index.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. namespace hangyezhanbi {
  2. const { line, upLine } = require("./F2");
  3. const { line1, upLine1 } = require("./F21");
  4. const { line2, upLine2 } = require("./F22");
  5. const { line3, upLine3 } = 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. /**
  33. * 组件的初始数据
  34. */
  35. data: {
  36. onInitChart: undefined,
  37. onInitChart1: undefined,
  38. onInitChart2: undefined,
  39. onInitChart3: undefined,
  40. DayList: {},
  41. select_act: 0,
  42. select: [
  43. {
  44. text: "时长",
  45. proportionType: "timeSize",
  46. type: 2,
  47. unit: "分",
  48. },
  49. {
  50. text: "频次",
  51. proportionType: "pinci",
  52. type: 1,
  53. unit: "次",
  54. },
  55. {
  56. text: "客户数",
  57. proportionType: "feiyong",
  58. type: 4,
  59. unit: "元",
  60. },
  61. ],
  62. },
  63. /**
  64. * 组件的方法列表
  65. */
  66. methods: {
  67. init() {
  68. let channelItem = this.data.channel;
  69. Promise.all([
  70. getMSIndustryProportion({
  71. type: this.data.select[this.data.select_act].type,
  72. industryId: channelItem.channelId,
  73. dataType: this.data.array.index
  74. }),
  75. ]).then((res: any[]) => {
  76. let li = (res[0] || []);
  77. this.setData({
  78. DayList: li,
  79. onInitChart: line.bind(this),
  80. onInitChart1: line1.bind(this),
  81. onInitChart2: line2.bind(this),
  82. onInitChart3: line3.bind(this),
  83. })
  84. })
  85. },
  86. upData() {
  87. let channelItem = this.data.channel;
  88. Promise.all([
  89. getMSIndustryProportion({
  90. type: this.data.select[this.data.select_act].type,
  91. industryId: channelItem.channelId,
  92. dataType: this.data.array.index
  93. }),
  94. ]).then((res: any[]) => {
  95. this.setData({
  96. DayList: res[0] || [],
  97. },()=>{
  98. upLine.bind(this)()
  99. upLine1.bind(this)()
  100. upLine2.bind(this)()
  101. upLine3.bind(this)()
  102. })
  103. })
  104. },
  105. channelChange(event: wxPicker) {
  106. this.setData({
  107. select_act: Number(event.detail.value)
  108. }, () => this.upData())
  109. },
  110. }
  111. })
  112. }