index.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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.updateUnread(res.data.notice.toString());
  70. });
  71. },
  72. /**
  73. * 获取活动可参与否
  74. */
  75. get_activity:function(){
  76. var that=this;
  77. userActivity().then(res=>{
  78. that.setData({ activity: res.data });
  79. })
  80. },
  81. /**
  82. * 获取我的推荐
  83. */
  84. get_host_product:function(){
  85. var that=this;
  86. getProductHot().then(res=>{
  87. that.setData({ host_product: res.data });
  88. })
  89. },
  90. /**
  91. * 生命周期函数--监听页面显示
  92. */
  93. onShow: function () {
  94. if (app.globalData.isLog && this.data.isClose) {
  95. this.getUserInfo();
  96. this.get_host_product();
  97. // this.get_activity();
  98. this.setData({
  99. iShidden: true
  100. });
  101. }
  102. },
  103. /**
  104. * 生命周期函数--监听页面隐藏
  105. */
  106. onHide: function () {
  107. this.setData({ isClose: true });
  108. },
  109. })