integral.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. //index.js
  2. //获取应用实例
  3. const app = getApp()
  4. Page({
  5. data: {
  6. //直推积分
  7. integralList: [],
  8. //开卡量
  9. cardList: [],
  10. //卡单分红
  11. bonusList: [],
  12. },
  13. //事件处理函数
  14. bindViewTap: function () {
  15. wx.navigateTo({
  16. url: '../index/index'
  17. })
  18. },
  19. onLoad: function () {
  20. //处理直推积分
  21. var that = this;
  22. this.directRecord();
  23. //处理开卡量
  24. let cardList = [
  25. {
  26. id: 1,
  27. status: '已结算',
  28. name: '宋某某',
  29. money: '100.00',
  30. grade: '一级',
  31. time: '2020-10-2',
  32. num: '11111111111',
  33. },
  34. ]
  35. for (let val of cardList) {
  36. val.name = val.name.substring(0, 1) + new Array(val.name.length).join('*');
  37. val.num = val.num.substring(0, 3) + new Array(5).join('*') + val.num.substring(7, 11);
  38. }
  39. that.setData({ cardList: cardList });
  40. //处理卡单分红
  41. this.bonusRecord()
  42. },
  43. /**
  44. * 查询直推开卡的积分记录
  45. */
  46. directRecord() {
  47. wx.request({
  48. url: `${app.globalData.publicUrl}/api/htyd/record?mobile=${app.globalData.userInfo.mobile}&opera=1`,
  49. method: 'get',
  50. success: res => {
  51. let { data } = res.data
  52. if (data.length <= 0) wx.showToast({
  53. title: '未查到相关直推积分数据',
  54. icon: "none"
  55. })
  56. data = data.map(i => {
  57. i.word = ` ${i.name.split('')[0]} `;
  58. i.mobile = `${i.mobile.substring(0, 3)}****${i.mobile.substring(7, 11)}`
  59. i.create_time = i.create_time.split(' ')[0]
  60. i.level = this.getLevel(i.params.level);
  61. return i;
  62. })
  63. this.setData({
  64. integralList: data,
  65. })
  66. }
  67. })
  68. },
  69. /**
  70. * 卡单分红
  71. */
  72. bonusRecord() {
  73. wx.request({
  74. url: `${app.globalData.publicUrl}/api/htyd/record?mobile=${app.globalData.userInfo.mobile}&opera=4`,
  75. method: 'get',
  76. success: res => {
  77. let { data } = res.data
  78. if (data.length <= 0) wx.showToast({
  79. title: '未查到相关卡单分红数据',
  80. icon: "none"
  81. })
  82. data = data.map(i => {
  83. i.word = ` ${i.name.split('')[0]} `;
  84. i.mobile = `${i.mobile.substring(0, 3)}****${i.mobile.substring(7, 11)}`
  85. i.create_time = i.create_time.split(' ')[0]
  86. i.level = this.getLevel(i.params.level);
  87. return i;
  88. })
  89. this.setData({
  90. bonusList: data,
  91. })
  92. }
  93. })
  94. },
  95. /**
  96. * 用户等级数字换取中文
  97. * @param {Number} level 用户等级
  98. */
  99. getLevel(level) {
  100. let res;
  101. if (level == 2) res = '经理'
  102. else if (level == 3) res = '一星经理'
  103. else if (level == 4) res = '二星经理'
  104. else if (level == 5) res = '三星经理'
  105. else if (level == 6) res = '四星经理'
  106. else res = '业务员'
  107. return res;
  108. }
  109. })