index.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. import { httpList } from "../../api/serverOrder";
  2. import {
  3. statusType,
  4. status_options
  5. } from "../../utils/statusTypeOptions";
  6. import { convertTime } from "../../utils/util"
  7. import {
  8. createStoreBindings
  9. } from 'mobx-miniprogram-bindings'
  10. import {
  11. store
  12. } from "../../store/index";
  13. Page({
  14. data: {
  15. hasData: true,
  16. logout: true,
  17. searchModel: {
  18. flow_stage: "",
  19. page: 1,
  20. size: 10
  21. },
  22. tabIndex: 0,
  23. statusType: statusType,
  24. status_options: status_options,
  25. orderList: []
  26. },
  27. onLoad() {
  28. this.storeBindings = createStoreBindings(this, {
  29. store,
  30. fields: ["token"],
  31. actions: ["setStore"],
  32. });
  33. },
  34. onUnload() {
  35. this.storeBindings.destroyStoreBindings();
  36. },
  37. onShow() {
  38. if (typeof this.getTabBar === 'function' &&
  39. this.getTabBar()) {
  40. this.getTabBar().setData({
  41. selected: 2
  42. })
  43. }
  44. this.orderList();
  45. },
  46. aa(e) {
  47. },
  48. bindViewTap(e) {
  49. const type = e.currentTarget.dataset.type;
  50. wx.navigateTo({
  51. url: '../../userOrder/pages/order-details/index?id=' + type
  52. })
  53. },
  54. bindViewTap1(e) {
  55. wx.navigateTo({
  56. url: '../../userOrder/pages/continue/index'
  57. })
  58. },
  59. bindViewTap2(e) {
  60. wx.makePhoneCall({
  61. phoneNumber: '400-9121-211' //仅为示例,并非真实的电话号码
  62. })
  63. },
  64. //阶段筛选
  65. statusTap: function (e) {
  66. const {
  67. searchModel
  68. } = this.data
  69. const index = e.detail.index
  70. const status = this.data.statusType[index].status
  71. this.setData({
  72. searchModel: {
  73. ...searchModel,
  74. page: 1,
  75. flow_stage: status
  76. }
  77. });
  78. this.orderList();
  79. },
  80. onReady: function () {
  81. // 生命周期函数--监听页面初次渲染完成
  82. },
  83. // onShow: function () {},
  84. onPullDownRefresh: function () {
  85. // this.data.page = 1
  86. this.orderList()
  87. // wx.stopPullDownRefresh()
  88. },
  89. onReachBottom() {
  90. const {
  91. searchModel
  92. } = this.data
  93. this.setData({
  94. searchModel: {
  95. ...searchModel,
  96. page: searchModel.page + 1,
  97. }
  98. });
  99. this.orderList()
  100. },
  101. async orderList() {
  102. const {
  103. searchModel,
  104. orderList,
  105. status_options,
  106. hasData
  107. } = this.data
  108. const {
  109. page,
  110. size
  111. } = searchModel
  112. if (page !== 1 && hasData === false) {
  113. this.setData({
  114. searchModel: {
  115. ...searchModel,
  116. page: page - 1
  117. }
  118. })
  119. return
  120. }
  121. if (page === 1) {
  122. wx.pageScrollTo({
  123. scrollTop: 0,
  124. duration: 500
  125. })
  126. }
  127. // if (page !== 0 && total > count) {
  128. // return
  129. // }
  130. let arr = []
  131. const {
  132. code,
  133. data,
  134. msg
  135. } = await httpList(searchModel)
  136. const total = page * size
  137. if (code == 1) {
  138. const {
  139. list,
  140. count
  141. } = data
  142. arr = page == 1 ? list : orderList.concat(list)
  143. arr.map((s) => {
  144. return s.status_name = (status_options.find((item) => item.value == String(s.status)) || {}).label ||
  145. '--',
  146. s.act_time_day = convertTime(s.act_time, 'MM.DD')
  147. })
  148. this.setData({
  149. orderList: arr,
  150. hasData: count > total
  151. })
  152. } else {
  153. await this.setStore("", "");
  154. }
  155. },
  156. })