index.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. namespace hangyejiegou {
  2. const { line, upLine } = require("./F2");
  3. const { line1, upLine1 } = 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. /**
  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. text: "客户数",
  55. proportionType: "custom",
  56. type: 4,
  57. unit: "个",
  58. },
  59. ],
  60. },
  61. /**
  62. * 组件的方法列表
  63. */
  64. methods: {
  65. init() {
  66. Promise.all([
  67. getMarket({
  68. dataType: this.data.select[this.data.select_act].type,
  69. indexTime: this.data.array.index,
  70. tableType: 3
  71. }),
  72. getMarket({
  73. dataType: this.data.select[this.data.select_act].type,
  74. indexTime: this.data.array.index,
  75. tableType: 4
  76. }),
  77. ]).then((res: any[]) => {
  78. let li = res[0] || [],li1 = res[1] || [], key = this.data.select[this.data.select_act].proportionType
  79. this.setData({
  80. DayList: li.map((v:any)=>{
  81. v.type = '0';
  82. v[key] = Number(v[key] || 0)
  83. return v
  84. }),
  85. DayList1: li1.map((v:any)=>{
  86. v.type = '0';
  87. v[key] = Number(v[key] || 0)
  88. return v
  89. }),
  90. onInitChart: line.bind(this),
  91. onInitChart1: line1.bind(this)
  92. })
  93. })
  94. },
  95. upData() {
  96. Promise.all([
  97. getMarket({
  98. dataType: this.data.select[this.data.select_act].type,
  99. indexTime: this.data.array.index,
  100. tableType: 3
  101. }),
  102. getMarket({
  103. dataType: this.data.select[this.data.select_act].type,
  104. indexTime: this.data.array.index,
  105. tableType: 4
  106. }),
  107. ]).then((res: any[]) => {
  108. let li = res[0] || [],li1 = res[1] || [], key = this.data.select[this.data.select_act].proportionType;
  109. this.setData({
  110. DayList: li.map((v:any)=>{
  111. v.type = '0';
  112. v[key] = Number(v[key] || 0)
  113. return v
  114. }),
  115. DayList1: li1.map((v:any)=>{
  116. v.type = '0';
  117. v[key] = Number(v[key] || 0)
  118. return v
  119. }),
  120. },()=>{
  121. upLine.bind(this)()
  122. upLine1.bind(this)()
  123. })
  124. })
  125. },
  126. channelChange(event: wxPicker) {
  127. this.setData({
  128. select_act: Number(event.detail.value)
  129. }, () => this.upData())
  130. },
  131. }
  132. })
  133. }