index.ts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. }),
  90. DayList1: li1.map((v:any)=>{
  91. v.type = '0';
  92. v[key] = Number(v[key] || 0)
  93. return v
  94. }),
  95. onInitChart: line.bind(this),
  96. onInitChart1: line1.bind(this)
  97. })
  98. })
  99. },
  100. upData() {
  101. Promise.all([
  102. getMarket({
  103. dataType: this.data.select[this.data.select_act].type,
  104. indexTime: this.data.array.index,
  105. tableType: 3
  106. }),
  107. getMarket({
  108. dataType: this.data.select[this.data.select_act].type,
  109. indexTime: this.data.array.index,
  110. tableType: 4
  111. }),
  112. ]).then((res: any[]) => {
  113. let li = res[0] || [],li1 = res[1] || [], key = this.data.select[this.data.select_act].proportionType;
  114. this.setData({
  115. DayList: li.map((v:any)=>{
  116. v.type = '0';
  117. v[key] = Number(v[key] || 0)
  118. return v
  119. }),
  120. DayList1: li1.map((v:any)=>{
  121. v.type = '0';
  122. v[key] = Number(v[key] || 0)
  123. return v
  124. }),
  125. },()=>{
  126. upLine.bind(this)()
  127. upLine1.bind(this)()
  128. })
  129. })
  130. },
  131. channelChange(event: wxPicker) {
  132. this.setData({
  133. select_act: Number(event.detail.value)
  134. }, () => this.upData())
  135. },
  136. }
  137. })
  138. }