index.ts 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. namespace quanpanqushi {
  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. !first && this.upData1()
  22. },
  23. 'channel': function () {
  24. !first && this.upData()
  25. !first && this.upData1()
  26. },
  27. },
  28. ready() {
  29. this.init();
  30. first = false;
  31. },
  32. /**
  33. * 组件的初始数据
  34. */
  35. data: {
  36. onInitChart: undefined,
  37. onInitChart1: undefined,
  38. DayList: {},
  39. DayList1: {},
  40. select_act: 0,
  41. select: [
  42. {
  43. text: "费用",
  44. proportionType: "fee",
  45. type: 3,
  46. unit: "元",
  47. },
  48. {
  49. text: "时长",
  50. proportionType: "timeSize",
  51. type: 2,
  52. unit: "分",
  53. },
  54. {
  55. text: "频次",
  56. proportionType: "pinci",
  57. type: 1,
  58. unit: "次",
  59. },
  60. ],
  61. select_act1: 0,
  62. select1: [
  63. {
  64. text: "时长",
  65. proportionType: "timeSize",
  66. type: 2,
  67. unit: "分",
  68. },
  69. {
  70. text: "频次",
  71. proportionType: "pinci",
  72. type: 1,
  73. unit: "次",
  74. },
  75. ]
  76. },
  77. /**
  78. * 组件的方法列表
  79. */
  80. methods: {
  81. init() {
  82. let channelItem = this.data.channel;
  83. Promise.all([
  84. getMarket({
  85. dataType: this.data.select[this.data.select_act].type,
  86. indexTime: this.data.array.index,
  87. tableType: 1
  88. }),
  89. getMarket({
  90. dataType: this.data.select[this.data.select_act].type,
  91. indexTime: this.data.array.index,
  92. tableType: 2
  93. }),
  94. ]).then((res: any[]) => {
  95. let li = res[0] || []
  96. let list: adDay = {
  97. before: [],
  98. now: []
  99. }, beforeKey = li[0].linkType, key = this.data.select[this.data.select_act].proportionType;
  100. for (let i = 0; i < li.length; i++) {
  101. const v = li[i];
  102. v[key] = Number(v[key] || 0)
  103. v.linkType === beforeKey ? list.before.push(v) : list.now.push(v)
  104. }
  105. let li1 = res[1] || []
  106. let list1: adDay = {
  107. before: [],
  108. now: []
  109. }, beforeKey1 = li1[0].linkType, key1 = this.data.select1[this.data.select_act1].proportionType;
  110. for (let i = 0; i < li1.length; i++) {
  111. const v = li1[i];
  112. v[key1] = Number(v[key1] || 0)
  113. v.linkType === beforeKey1 ? list1.before.push(v) : list1.now.push(v)
  114. }
  115. this.setData({
  116. DayList1: list1,
  117. DayList: list,
  118. onInitChart: line.bind(this),
  119. onInitChart1: line1.bind(this)
  120. })
  121. })
  122. },
  123. upData() {
  124. let channelItem = this.data.channel;
  125. Promise.all([
  126. getMarket({
  127. dataType: this.data.select[this.data.select_act].type,
  128. indexTime: this.data.array.index,
  129. tableType: 1
  130. }),
  131. ]).then((res: any[]) => {
  132. let li = res[0] || []
  133. let list: adDay = {
  134. before: [],
  135. now: []
  136. }, beforeKey = li[0].linkType, key = this.data.select[this.data.select_act].proportionType;
  137. for (let i = 0; i < li.length; i++) {
  138. const v = li[i];
  139. v[key] = Number(v[key] || 0)
  140. v.linkType === beforeKey ? list.before.push(v) : list.now.push(v)
  141. }
  142. this.setData({
  143. DayList: list,
  144. },()=>{
  145. upLine.bind(this)()
  146. })
  147. })
  148. },
  149. upData1() {
  150. Promise.all([
  151. getMarket({
  152. dataType: this.data.select[this.data.select_act].type,
  153. indexTime: this.data.array.index,
  154. tableType: 2
  155. }),
  156. ]).then((res: any[]) => {
  157. let li = res[0] || []
  158. let list: adDay = {
  159. before: [],
  160. now: []
  161. }, beforeKey = li[0].linkType, key = this.data.select1[this.data.select_act1].proportionType;
  162. for (let i = 0; i < li.length; i++) {
  163. const v = li[i];
  164. v[key] = Number(v[key] || 0)
  165. v.linkType === beforeKey ? list.before.push(v) : list.now.push(v)
  166. }
  167. this.setData({
  168. DayList1: list,
  169. },()=>{
  170. upLine1.bind(this)()
  171. })
  172. })
  173. },
  174. channelChange(event: wxPicker) {
  175. this.setData({
  176. select_act: Number(event.detail.value)
  177. }, () => this.upData())
  178. },
  179. channelChange1(event: wxPicker) {
  180. this.setData({
  181. select_act1: Number(event.detail.value)
  182. }, () => this.upData1())
  183. }
  184. }
  185. })
  186. }