index.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. * 获取用户详情
  58. */
  59. getUserInfo:function(){
  60. let that = this;
  61. getUserInfo().then(res=>{
  62. that.setData({
  63. userInfo: res.data,
  64. recharge_switch: res.data.recharge_switch
  65. });
  66. });
  67. },
  68. /**
  69. * 获取活动可参与否
  70. */
  71. get_activity:function(){
  72. var that=this;
  73. userActivity().then(res=>{
  74. that.setData({ activity: res.data });
  75. })
  76. },
  77. /**
  78. * 获取我的推荐
  79. */
  80. get_host_product:function(){
  81. var that=this;
  82. getProductHot().then(res=>{
  83. that.setData({ host_product: res.data });
  84. })
  85. },
  86. /**
  87. * 生命周期函数--监听页面显示
  88. */
  89. onShow: function () {
  90. if (app.globalData.isLog && this.data.isClose) {
  91. this.getUserInfo();
  92. this.get_host_product();
  93. // this.get_activity();
  94. this.setData({
  95. iShidden: true
  96. });
  97. }
  98. },
  99. /**
  100. * 生命周期函数--监听页面隐藏
  101. */
  102. onHide: function () {
  103. this.setData({ isClose: true });
  104. },
  105. })