index.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. namespace hangyezhanbi {
  2. const { line, upLine,clearchart } = require("./F2");
  3. const { line1, upLine1,clearchart1 } = require("./F21");
  4. const { line2, upLine2,clearchart2 } = require("./F22");
  5. const { line3, upLine3,clearchart3 } = require("./F23");
  6. let { getMSIndustryProportion } = require('../../../../utils/api')
  7. let first = true;
  8. Component({
  9. /**
  10. * 组件的属性列表
  11. */
  12. properties: {
  13. array: {
  14. type: Object
  15. },
  16. channel: {
  17. type: Object
  18. },
  19. },
  20. observers: {
  21. 'array': function () {
  22. !first && this.upData()
  23. },
  24. 'channel': function () {
  25. !first && this.upData()
  26. },
  27. },
  28. ready() {
  29. this.init();
  30. first = false;
  31. },
  32. detached: function() {
  33. // 在组件实例被从页面节点树移除时执行
  34. clearchart()
  35. clearchart1()
  36. clearchart2()
  37. clearchart3()
  38. },
  39. /**
  40. * 组件的初始数据
  41. */
  42. data: {
  43. onInitChart: undefined,
  44. onInitChart1: undefined,
  45. onInitChart2: undefined,
  46. onInitChart3: undefined,
  47. DayList: {},
  48. select_act: 0,
  49. select: [
  50. {
  51. text: "时长",
  52. proportionType: "timeSize",
  53. type: 2,
  54. unit: "分",
  55. },
  56. {
  57. text: "频次",
  58. proportionType: "pinci",
  59. type: 1,
  60. unit: "次",
  61. },
  62. {
  63. text: "客户数",
  64. proportionType: "feiyong",
  65. type: 4,
  66. unit: "元",
  67. },
  68. ],
  69. },
  70. /**
  71. * 组件的方法列表
  72. */
  73. methods: {
  74. init() {
  75. let channelItem = this.data.channel;
  76. Promise.all([
  77. getMSIndustryProportion({
  78. type: this.data.select[this.data.select_act].type,
  79. industryId: channelItem.channelId,
  80. dataType: this.data.array.index
  81. }),
  82. ]).then((res: any[]) => {
  83. let li = (res[0] || []);
  84. this.setData({
  85. DayList: li,
  86. onInitChart: line.bind(this),
  87. onInitChart1: line1.bind(this),
  88. onInitChart2: line2.bind(this),
  89. onInitChart3: line3.bind(this),
  90. })
  91. })
  92. },
  93. upData() {
  94. let channelItem = this.data.channel;
  95. Promise.all([
  96. getMSIndustryProportion({
  97. type: this.data.select[this.data.select_act].type,
  98. industryId: channelItem.channelId,
  99. dataType: this.data.array.index
  100. }),
  101. ]).then((res: any[]) => {
  102. this.setData({
  103. DayList: res[0] || [],
  104. },()=>{
  105. upLine.bind(this)()
  106. upLine1.bind(this)()
  107. upLine2.bind(this)()
  108. upLine3.bind(this)()
  109. })
  110. })
  111. },
  112. channelChange(event: wxPicker) {
  113. this.setData({
  114. select_act: Number(event.detail.value)
  115. }, () => this.upData())
  116. },
  117. }
  118. })
  119. }