index.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // components/toufang/index.ts
  2. namespace shiduan {
  3. const { line, upLine } = require("./F2");
  4. let { getHour } = 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. first && this.init()
  28. first = false
  29. },
  30. /**
  31. * 组件的初始数据
  32. */
  33. data: {
  34. onInitChart: undefined,
  35. DayList: {},
  36. select_act: 0,
  37. select: [
  38. {
  39. text: "费用",
  40. proportionType: "fee",
  41. type: 3,
  42. unit: "元",
  43. },
  44. {
  45. text: "时长",
  46. proportionType: "timeSize",
  47. type: 2,
  48. unit: "分",
  49. },
  50. {
  51. text: "频次",
  52. proportionType: "pinci",
  53. type: 1,
  54. unit: "次",
  55. },
  56. {
  57. text: "客户量",
  58. proportionType: "customer",
  59. type: 4,
  60. unit: "个",
  61. },
  62. ]
  63. },
  64. /**
  65. * 组件的方法列表
  66. */
  67. methods: {
  68. init() {
  69. let channelItem = this.data.channel;
  70. let arrayItem = this.data.array;
  71. Promise.all([
  72. getHour({
  73. channelId: channelItem.channelId,
  74. order: this.data.select[this.data.select_act].type,
  75. end: arrayItem.endDate,
  76. start: arrayItem.startDate
  77. }),
  78. ]).then((res: adDay[]) => {
  79. this.data.DayList = res[0];
  80. this.setData({
  81. onInitChart: line.bind(this)
  82. })
  83. })
  84. },
  85. upData() {
  86. let channelItem = this.data.channel;
  87. let arrayItem = this.data.array;
  88. Promise.all([
  89. getHour({
  90. channelId: channelItem.channelId,
  91. order: this.data.select[this.data.select_act].type,
  92. end: arrayItem.endDate,
  93. start: arrayItem.startDate
  94. }),
  95. ]).then((res: adDay[]) => {
  96. this.data.DayList = res[0];
  97. upLine.bind(this)()
  98. })
  99. },
  100. channelChange(event:wxPicker){
  101. this.setData({
  102. select_act: Number(event.detail.value)
  103. },()=>this.upData())
  104. }
  105. }
  106. })
  107. }