index.ts 3.1 KB

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