index.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // pages/my-promotion/index.js
  2. import { getUserInfo } from '../../api/user.js'
  3. import { openExtrctSubscribe } from '../../utils/SubscribeMessage.js'
  4. const app = getApp()
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. parameter: {
  11. navbar: '1',
  12. return: '1',
  13. title: '我的盈利',
  14. color: true,
  15. class: '0'
  16. },
  17. userInfo: [],
  18. yesterdayPrice: 0.0,
  19. isClone: false
  20. },
  21. onLoadFun: function () {
  22. this.getUserInfo()
  23. },
  24. /**
  25. * 生命周期函数--监听页面加载
  26. */
  27. onLoad: function (options) {},
  28. openSubscribe: function (e) {
  29. let page = e.currentTarget.dataset.url
  30. wx.showLoading({
  31. title: '正在加载'
  32. })
  33. openExtrctSubscribe()
  34. .then(res => {
  35. wx.hideLoading()
  36. wx.navigateTo({
  37. url: page
  38. })
  39. })
  40. .catch(() => {
  41. wx.hideLoading()
  42. })
  43. },
  44. /**
  45. * 生命周期函数--监听页面初次渲染完成
  46. */
  47. onReady: function () {},
  48. /**
  49. * 生命周期函数--监听页面显示
  50. */
  51. onShow: function () {
  52. if (app.globalData.isLog && this.data.isClone) {
  53. this.getUserInfo()
  54. }
  55. },
  56. /**
  57. * 获取个人用户信息
  58. */
  59. getUserInfo: function () {
  60. var that = this
  61. getUserInfo().then(res => {
  62. that.setData({
  63. userInfo: res.data
  64. })
  65. // app.globalData.unread = res.data.notice
  66. app.setUnread(res.data.notice)
  67. })
  68. },
  69. /**
  70. * 生命周期函数--监听页面隐藏
  71. */
  72. onHide: function () {
  73. this.setData({
  74. isClone: true
  75. })
  76. },
  77. /**
  78. * 生命周期函数--监听页面卸载
  79. */
  80. onUnload: function () {},
  81. /**
  82. * 页面相关事件处理函数--监听用户下拉动作
  83. */
  84. onPullDownRefresh: function () {},
  85. /**
  86. * 页面上拉触底事件的处理函数
  87. */
  88. onReachBottom: function () {},
  89. /**
  90. * 用户点击右上角分享
  91. */
  92. onShareAppMessage: function () {}
  93. })