index.js 2.2 KB

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