integral.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. data = data.map(i => {
  53. i.word = ` ${i.name.split('')[0]} `;
  54. i.mobile = `${i.mobile.substring(0, 3)}****${i.mobile.substring(7, 11)}`
  55. i.create_time = i.create_time.split(' ')[0]
  56. i.level = this.getLevel(i.params.level);
  57. return i;
  58. })
  59. this.setData({
  60. integralList: data,
  61. })
  62. }
  63. })
  64. },
  65. /**
  66. * 卡单分红
  67. */
  68. bonusRecord() {
  69. wx.request({
  70. url: `${app.globalData.publicUrl}/api/htyd/record?mobile=${app.globalData.userInfo.mobile}&opera=4`,
  71. method: 'get',
  72. success: res => {
  73. let { data } = res.data
  74. data = data.map(i => {
  75. i.word = ` ${i.name.split('')[0]} `;
  76. i.mobile = `${i.mobile.substring(0, 3)}****${i.mobile.substring(7, 11)}`
  77. i.create_time = i.create_time.split(' ')[0]
  78. i.level = this.getLevel(i.params.level);
  79. return i;
  80. })
  81. this.setData({
  82. bonusList: data,
  83. })
  84. }
  85. })
  86. },
  87. /**
  88. * 用户等级数字换取中文
  89. * @param {Number} level 用户等级
  90. */
  91. getLevel(level) {
  92. let res;
  93. if (level == 2) res = '经理'
  94. else if (level == 3) res = '一星经理'
  95. else if (level == 4) res = '二星经理'
  96. else if (level == 5) res = '三星经理'
  97. else if (level == 6) res = '四星经理'
  98. else res = '业务员'
  99. return res;
  100. }
  101. })