index.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. namespace zhongdiankehu {
  2. let { getImportantCustomer } = require('../../../../utils/api')
  3. let first = true;
  4. Component({
  5. /**
  6. * 组件的属性列表
  7. */
  8. properties: {
  9. array: {
  10. type: Object
  11. },
  12. channel: {
  13. type: Object
  14. },
  15. },
  16. observers: {
  17. 'array': function () {
  18. !first && this.upData()
  19. },
  20. 'channel': function () {
  21. !first && this.upData()
  22. },
  23. },
  24. ready() {
  25. this.init();
  26. first = false;
  27. },
  28. /**
  29. * 组件的初始数据
  30. */
  31. data: {
  32. onInitChart: undefined,
  33. onInitChart1: undefined,
  34. DayList: [],
  35. DayList1: [],
  36. select_act: 0,
  37. select: [
  38. {
  39. text: "时长",
  40. proportionType: "timeSize",
  41. type: 2,
  42. unit: "分",
  43. },
  44. {
  45. text: "频次",
  46. proportionType: "pinci",
  47. type: 1,
  48. unit: "次",
  49. },
  50. ],
  51. },
  52. /**
  53. * 组件的方法列表
  54. */
  55. methods: {
  56. init() {
  57. let channelItem = this.data.channel, key = this.data.select[this.data.select_act].proportionType;
  58. Promise.all([
  59. getImportantCustomer({
  60. type: this.data.select[this.data.select_act].type,
  61. industryId: channelItem.channelId,
  62. dataType: this.data.array.index
  63. }),
  64. ]).then((res: any[]) => {
  65. let hard = (res[0] || []).harddata;
  66. let soft= (res[0] || []).softdata;
  67. this.setData({
  68. DayList: hard.splice(0,10).map((v:any, i:number)=>{
  69. v[key] = Number(v[key] || 0)
  70. v.feiyong = Number(v.feiyong|| 0)
  71. v.huanbi = Number(v.huanbi|| 0)
  72. return v
  73. }),
  74. DayList1: soft.splice(0,10).map((v:any, i:number)=>{
  75. v[key] = Number(v[key])
  76. v.huanbi = Number(v.huanbi|| 0)
  77. return v
  78. }),
  79. })
  80. })
  81. },
  82. upData() {
  83. let channelItem = this.data.channel,key = this.data.select[this.data.select_act].proportionType;;
  84. Promise.all([
  85. getImportantCustomer({
  86. type: this.data.select[this.data.select_act].type,
  87. industryId: channelItem.channelId,
  88. dataType: this.data.array.index
  89. }),
  90. ]).then((res: any[]) => {
  91. let hard = (res[0] || []).harddata;
  92. let soft= (res[0] || []).softdata;
  93. this.setData({
  94. DayList: hard.splice(0,10).map((v:any, i:number)=>{
  95. v[key] = Number(v[key] || 0)
  96. v.feiyong = Number(v.feiyong|| 0)
  97. v.huanbi = Number(v.huanbi|| 0)
  98. return v
  99. }),
  100. DayList1: soft.splice(0,10).map((v:any, i:number)=>{
  101. v[key] = Number(v[key])
  102. v.huanbi = Number(v.huanbi|| 0)
  103. return v
  104. }),
  105. })
  106. })
  107. },
  108. channelChange(event: wxPicker) {
  109. this.setData({
  110. select_act: Number(event.detail.value)
  111. }, () => this.upData())
  112. },
  113. }
  114. })
  115. }