publisherDetail.js 1015 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. const util = require('../../utils/util.js')
  2. Page({
  3. data: {
  4. publisherId: '',
  5. publisherInfo: {},
  6. },
  7. /**
  8. * 生命周期函数--监听页面加载
  9. */
  10. onLoad: function (options) {
  11. if (options.id) {
  12. this.setData({
  13. publisherId: options.id
  14. })
  15. wx.showLoading({
  16. title: "加载中"
  17. })
  18. wx.cloud.callFunction({
  19. name: 'getPublisher',
  20. data: {
  21. pub_id: this.data.publisherId
  22. }
  23. }).then(res => {
  24. wx.hideLoading()
  25. if (res.result.status !== 'OK') {
  26. wx.showToast({
  27. title: res.result.errMsg,
  28. icon: 'none'
  29. })
  30. return
  31. }
  32. this.setData({
  33. publisherInfo: res.result.data
  34. })
  35. })
  36. } else {
  37. const eventChannel = this.getOpenerEventChannel()
  38. eventChannel.on('loadCommonData', res => {
  39. this.setData({
  40. publisherId: res.data._id,
  41. publisherInfo: res.data
  42. })
  43. })
  44. }
  45. }
  46. })