index.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // pages/my-account/index.js
  2. import { getProductHot } from '../../api/store.js';
  3. import { openRechargeSubscribe } from '../../utils/SubscribeMessage.js';
  4. import { getUserInfo, userActivity } from '../../api/user.js';
  5. const app=getApp();
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. parameter: {
  12. 'navbar': '1',
  13. 'return': '1',
  14. 'title': '钱包',
  15. 'color': false,
  16. },
  17. iShidden: false,
  18. userInfo:{},
  19. host_product:[],
  20. isClose:false,
  21. recharge_switch:0,
  22. activity: {
  23. is_pink: false,
  24. is_seckill: false,
  25. is_bargin: false
  26. }
  27. },
  28. /**
  29. * 登录回调
  30. */
  31. onLoadFun:function(){
  32. this.getUserInfo();
  33. this.get_host_product();
  34. // this.get_activity();
  35. },
  36. /**
  37. * 生命周期函数--监听页面加载
  38. */
  39. onLoad: function (options) {
  40. if (app.globalData.token) this.setData({ iShidden:true});
  41. },
  42. openSubscribe:function(e){
  43. let page = e.currentTarget.dataset.url;
  44. wx.showLoading({
  45. title: '正在加载',
  46. })
  47. openRechargeSubscribe().then(res => {
  48. wx.hideLoading();
  49. wx.navigateTo({
  50. url: page,
  51. });
  52. }).catch(() => {
  53. wx.hideLoading();
  54. });
  55. },
  56. // 点击币
  57. onTapCoinItem: function() {
  58. },
  59. /**
  60. * 获取用户详情
  61. */
  62. getUserInfo:function(){
  63. let that = this;
  64. getUserInfo().then(res=>{
  65. that.setData({
  66. userInfo: res.data,
  67. recharge_switch: res.data.recharge_switch
  68. });
  69. // app.globalData.unread = res.data.notice
  70. app.setUnread(res.data.notice)
  71. });
  72. },
  73. /**
  74. * 获取活动可参与否
  75. */
  76. get_activity:function(){
  77. var that=this;
  78. userActivity().then(res=>{
  79. that.setData({ activity: res.data });
  80. })
  81. },
  82. /**
  83. * 获取我的推荐
  84. */
  85. get_host_product:function(){
  86. var that=this;
  87. getProductHot().then(res=>{
  88. that.setData({ host_product: res.data });
  89. })
  90. },
  91. /**
  92. * 生命周期函数--监听页面显示
  93. */
  94. onShow: function () {
  95. if (app.globalData.isLog && this.data.isClose) {
  96. this.getUserInfo();
  97. this.get_host_product();
  98. // this.get_activity();
  99. this.setData({
  100. iShidden: true
  101. });
  102. }
  103. },
  104. /**
  105. * 生命周期函数--监听页面隐藏
  106. */
  107. onHide: function () {
  108. this.setData({ isClose: true });
  109. },
  110. })