index.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // pages/member-center/index.js
  2. const app=getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. parameter: {
  9. 'navbar': '1',
  10. 'return': '1',
  11. 'title': '会员中心',
  12. 'class':'1',
  13. 'color':true
  14. },
  15. VipList: [],
  16. indicatorDots: false,
  17. circular: true,
  18. autoplay: false,
  19. interval: 3000,
  20. duration: 500,
  21. swiperIndex: 0,
  22. growthValue: true,
  23. task:[],//任务列表
  24. illustrate:'',//任务说明
  25. level_id:0,//任务id,
  26. host_product:[],
  27. },
  28. /**
  29. * 授权回调
  30. */
  31. onLoadFun:function(){
  32. this.setLeveLComplete();
  33. this.get_host_product();
  34. },
  35. /**
  36. * 生命周期函数--监听页面加载
  37. */
  38. onLoad: function (options) {
  39. var that = this;
  40. setTimeout(function () {
  41. that.setData({
  42. loading: true
  43. })
  44. }, 500)
  45. },
  46. /**
  47. * 获取我的推荐
  48. */
  49. get_host_product: function () {
  50. var that = this;
  51. app.baseGet(app.U({ c: 'public_api', a: "get_hot_product", q: { offset: 1, limit: 4 } }), function (res) {
  52. that.setData({ host_product: res.data });
  53. });
  54. },
  55. /**
  56. * 会员切换
  57. *
  58. */
  59. bindchange(e) {
  60. var index = e.detail.current
  61. this.setData({swiperIndex: index,level_id: this.data.VipList[index].id || 0});
  62. this.getTask();
  63. },
  64. /**
  65. * 关闭说明
  66. */
  67. growthValue:function(){
  68. this.setData({growthValue: true})
  69. },
  70. /**
  71. * 打开说明
  72. */
  73. opHelp:function(e){
  74. var index = e.currentTarget.dataset.index;
  75. this.setData({ growthValue: false, illustrate: this.data.task[index].illustrate});
  76. },
  77. /**
  78. * 设置会员
  79. */
  80. setLeveLComplete:function(){
  81. app.baseGet(app.U({ c: "public_api", a:"set_level_complete"}),function(){
  82. this.getVipList();
  83. }.bind(this),null,true);
  84. },
  85. /**
  86. * 获取会员等级
  87. *
  88. */
  89. getVipList:function(){
  90. var that=this;
  91. app.baseGet(app.U({ c: 'public_api', a:'get_level_list'}),function(res){
  92. that.setData({
  93. VipList: res.data.list,
  94. task: res.data.task.task,
  95. reach_count: res.data.task.reach_count,
  96. level_id:res.data.list[0] ? res.data.list[0].id : 0
  97. });
  98. });
  99. },
  100. /**
  101. * 获取任务要求
  102. */
  103. getTask:function(){
  104. var that=this;
  105. app.baseGet(app.U({ c: 'public_api', a: 'get_task', q: { level_id: that.data.level_id}}),function(res){
  106. that.setData({ task: res.data.task, reach_count: res.data.reach_count});
  107. });
  108. },
  109. })