index.js 2.3 KB

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