index.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // pages/my-account/index.js
  2. const app=getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. parameter: {
  9. 'navbar': '1',
  10. 'return': '1',
  11. 'title': '我的账户',
  12. 'color': false,
  13. },
  14. userInfo:{},
  15. host_product:[],
  16. isClose:false,
  17. recharge_switch:0,
  18. },
  19. /**
  20. * 登录回调
  21. */
  22. onLoadFun:function(){
  23. this.getUserInfo();
  24. this.get_host_product();
  25. this.get_activity();
  26. this.getSystemConfig();
  27. },
  28. /**
  29. * 生命周期函数--监听页面加载
  30. */
  31. onLoad: function (options) {
  32. },
  33. /**
  34. * 获取系统配置信息
  35. */
  36. getSystemConfig:function(){
  37. var that = this;
  38. app.baseGet(app.U({ c: 'public_api', a: 'get_system_config_value', q: { name:'recharge_switch'} }), function (res) {
  39. that.setData({ recharge_switch: parseInt(res.data.recharge_switch) });
  40. });
  41. },
  42. /**
  43. * 获取用户详情
  44. */
  45. getUserInfo:function(){
  46. var that=this;
  47. app.baseGet(app.U({ c: 'user_api', a:'my'}),function(res){
  48. that.setData({userInfo:res.data});
  49. });
  50. },
  51. /**
  52. * 获取活动可参与否
  53. */
  54. get_activity:function(){
  55. var that=this;
  56. app.baseGet(app.U({c:'user_api',a:'get_activity'}),function(res){
  57. that.setData({activity:res.data});
  58. });
  59. },
  60. /**
  61. * 获取我的推荐
  62. */
  63. get_host_product:function(){
  64. var that=this;
  65. app.baseGet(app.U({ c: 'public_api', a: "get_hot_product", q: { offset:1,limit:4}}),function(res){
  66. that.setData({ host_product:res.data});
  67. });
  68. },
  69. /**
  70. * 生命周期函数--监听页面显示
  71. */
  72. onShow: function () {
  73. if (app.globalData.isLog && this.data.isClose) {
  74. this.getUserInfo();
  75. this.get_host_product();
  76. this.get_activity();
  77. }
  78. },
  79. /**
  80. * 生命周期函数--监听页面隐藏
  81. */
  82. onHide: function () {
  83. this.setData({ isClose: true });
  84. },
  85. })