index.ts 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. namespace hangyejiegou {
  2. const { line, upLine, clearchart } = require("./F2");
  3. const { line1, upLine1, clearchart1 } = require("./F21");
  4. let { getMarket } = require('../../../../utils/api')
  5. let first = true;
  6. Component({
  7. /**
  8. * 组件的属性列表
  9. */
  10. properties: {
  11. array: {
  12. type: Object
  13. },
  14. channel: {
  15. type: Object
  16. },
  17. },
  18. observers: {
  19. 'array': function () {
  20. !first && this.upData()
  21. },
  22. 'channel': function () {
  23. !first && this.upData()
  24. },
  25. },
  26. ready() {
  27. console.log(this.data.array.index)
  28. this.init();
  29. first = false;
  30. },
  31. detached: function() {
  32. // 在组件实例被从页面节点树移除时执行
  33. clearchart()
  34. clearchart1()
  35. },
  36. /**
  37. * 组件的初始数据
  38. */
  39. data: {
  40. onInitChart: undefined,
  41. onInitChart1: undefined,
  42. DayList: [],
  43. DayList1: [],
  44. select_act: 0,
  45. select: [
  46. {
  47. text: "时长",
  48. proportionType: "timeSize",
  49. type: 2,
  50. unit: "分",
  51. },
  52. {
  53. text: "频次",
  54. proportionType: "pinci",
  55. type: 1,
  56. unit: "次",
  57. },
  58. {
  59. text: "客户数",
  60. proportionType: "custom",
  61. type: 4,
  62. unit: "个",
  63. },
  64. ],
  65. },
  66. /**
  67. * 组件的方法列表
  68. */
  69. methods: {
  70. init() {
  71. Promise.all([
  72. getMarket({
  73. dataType: this.data.select[this.data.select_act].type,
  74. indexTime: this.data.array.index,
  75. tableType: 3
  76. }),
  77. getMarket({
  78. dataType: this.data.select[this.data.select_act].type,
  79. indexTime: this.data.array.index,
  80. tableType: 4
  81. }),
  82. ]).then((res: any[]) => {
  83. let li = res[0] || [],li1 = res[1] || [], key = this.data.select[this.data.select_act].proportionType
  84. this.setData({
  85. DayList: li.map((v:any)=>{
  86. v.type = '0';
  87. v[key] = Number(v[key] || 0)
  88. return v
  89. }).sort((a:any,b:any)=>{
  90. return b[key] - a[key]
  91. }),
  92. DayList1: li1.map((v:any)=>{
  93. v.type = '0';
  94. v[key] = Number(v[key] || 0)
  95. return v
  96. }).sort((a:any,b:any)=>{
  97. return b[key] - a[key]
  98. }),
  99. })
  100. })
  101. },
  102. upData() {
  103. Promise.all([
  104. getMarket({
  105. dataType: this.data.select[this.data.select_act].type,
  106. indexTime: this.data.array.index,
  107. tableType: 3
  108. }),
  109. getMarket({
  110. dataType: this.data.select[this.data.select_act].type,
  111. indexTime: this.data.array.index,
  112. tableType: 4
  113. }),
  114. ]).then((res: any[]) => {
  115. let li = res[0] || [],li1 = res[1] || [], key = this.data.select[this.data.select_act].proportionType;
  116. this.setData({
  117. DayList: li.map((v:any)=>{
  118. v.type = '0';
  119. v[key] = Number(v[key] || 0)
  120. return v
  121. }).sort((a:any,b:any)=>{
  122. return b[key] - a[key]
  123. }),
  124. DayList1: li1.map((v:any)=>{
  125. v.type = '0';
  126. v[key] = Number(v[key] || 0)
  127. return v
  128. }).sort((a:any,b:any)=>{
  129. return b[key] - a[key]
  130. }),
  131. },()=>{
  132. upLine.bind(this)()
  133. upLine1.bind(this)()
  134. })
  135. })
  136. },
  137. channelChange(event: wxPicker) {
  138. this.setData({
  139. select_act: Number(event.detail.value)
  140. }, () => this.upData())
  141. },
  142. }
  143. })
  144. }