publisherPage.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. // miniprogram/pages/publisherPage/publisherPage.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. pubInfo: [],
  9. hasPubInfo: false,
  10. pubName: [],
  11. pubIndex: 0
  12. },
  13. previewAvatar: function () {
  14. if (this.data.hasPubInfo) {
  15. wx.previewImage({
  16. urls: [this.data.pubInfo[this.data.pubIndex].publisher.avatar]
  17. })
  18. }
  19. },
  20. publisherHome: function () {
  21. wx.navigateTo({
  22. url: '/pages/publisher/publisher',
  23. }).then(res => {
  24. res.eventChannel.emit('loadCommonData', {
  25. data: this.data.pubInfo[this.data.pubIndex].publisher
  26. })
  27. })
  28. },
  29. activityPublish: function () {
  30. wx.navigateTo({
  31. url: "/pages/activityPublish/activityPublish?id=" + this.data.pubInfo[this.data.pubIndex].pub_id,
  32. })
  33. },
  34. publisherQuestion: function () {
  35. wx.navigateTo({
  36. url: "/pages/publisherQuestion/publisherQuestion?id=" + this.data.pubInfo[this.data.pubIndex].pub_id
  37. })
  38. },
  39. administratorSetting: function () {
  40. wx.navigateTo({
  41. url: "/pages/administratorSetting/administratorSetting?id=" + this.data.pubInfo[this.data.pubIndex].pub_id
  42. })
  43. },
  44. publisherInfoChange: function () {
  45. wx.navigateTo({
  46. url: "/pages/publisherInfoChange/publisherInfoChange?id=" + this.data.pubInfo[this.data.pubIndex].pub_id
  47. })
  48. },
  49. publisherLogin: function () {
  50. wx.navigateTo({
  51. url: "/pages/publisherLogin/publisherLogin",
  52. })
  53. },
  54. /**
  55. * 生命周期函数--监听页面加载
  56. */
  57. onLoad: function (options) {
  58. if (app.globalData.hasUserInfo) {
  59. const pubName = []
  60. for (let i = 0; i < app.globalData.pubInfo.length; i++) {
  61. pubName.push(app.globalData.pubInfo[i].publisher.name)
  62. }
  63. this.setData({
  64. pubInfo: app.globalData.pubInfo,
  65. hasPubInfo: true,
  66. pubName: pubName,
  67. pubIndex: app.globalData.pubIndex
  68. })
  69. } else {
  70. wx.showToast({
  71. title: '请先登录',
  72. icon: 'none'
  73. })
  74. }
  75. },
  76. /**
  77. * 生命周期函数--监听页面初次渲染完成
  78. */
  79. onReady: function () {
  80. },
  81. /**
  82. * 生命周期函数--监听页面显示
  83. */
  84. onShow: function () {
  85. },
  86. /**
  87. * 生命周期函数--监听页面隐藏
  88. */
  89. onHide: function () {
  90. },
  91. /**
  92. * 生命周期函数--监听页面卸载
  93. */
  94. onUnload: function () {
  95. app.globalData.pubIndex = this.data.pubIndex
  96. },
  97. /**
  98. * 页面相关事件处理函数--监听用户下拉动作
  99. */
  100. onPullDownRefresh: function () {
  101. },
  102. /**
  103. * 页面上拉触底事件的处理函数
  104. */
  105. onReachBottom: function () {
  106. },
  107. /**
  108. * 用户点击右上角分享
  109. */
  110. onShareAppMessage: function () {
  111. }
  112. })