index.ts 3.6 KB

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