index.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // components/toufang/index.ts
  2. namespace hangyezhanbi{
  3. let { getQianzai } = require('../../../../utils/api')
  4. let first = true;
  5. Component({
  6. /**
  7. * 组件的属性列表
  8. */
  9. properties: {
  10. array: {
  11. type: Object
  12. },
  13. channel: {
  14. type: Object
  15. },
  16. },
  17. observers: {
  18. 'array': function () {
  19. !first && this.upData()
  20. },
  21. 'channel': function () {
  22. !first && this.upData()
  23. }
  24. },
  25. ready() {
  26. this.init();
  27. first = false;
  28. },
  29. /**
  30. * 组件的初始数据
  31. */
  32. data: {
  33. DayList: [],
  34. select_act: 0,
  35. select: [
  36. {
  37. text: "费用",
  38. proportionType: "fee",
  39. type: 3,
  40. unit: "万元",
  41. },
  42. {
  43. text: "时长",
  44. proportionType: "timeSize",
  45. type: 2,
  46. unit: "分",
  47. },
  48. {
  49. text: "频次",
  50. proportionType: "pinci",
  51. type: 1,
  52. unit: "次",
  53. },
  54. ]
  55. },
  56. /**
  57. * 组件的方法列表
  58. */
  59. methods: {
  60. init() {
  61. let channelItem = this.data.channel;
  62. let arrayItem = this.data.array;
  63. Promise.all([
  64. getQianzai({
  65. channelId: channelItem.channelId,
  66. order: this.data.select[this.data.select_act].type,
  67. end: arrayItem.endDate,
  68. start: arrayItem.startDate
  69. }),
  70. ]).then((res: adDay[]) => {
  71. this.setData({
  72. DayList: res[0],
  73. })
  74. })
  75. },
  76. upData() {
  77. let channelItem = this.data.channel;
  78. let arrayItem = this.data.array;
  79. Promise.all([
  80. getQianzai({
  81. channelId: channelItem.channelId,
  82. order: this.data.select[this.data.select_act].type,
  83. end: arrayItem.endDate,
  84. start: arrayItem.startDate
  85. }),
  86. ]).then((res: adDay[]) => {
  87. this.setData({
  88. DayList: res[0],
  89. })
  90. })
  91. },
  92. channelChange(event:wxPicker){
  93. this.setData({
  94. select_act: Number(event.detail.value)
  95. },()=>this.upData())
  96. }
  97. }
  98. })
  99. }