import { httpList } from "../../api/serverOrder"; import { statusType, status_options } from "../../utils/statusTypeOptions"; import { convertTime } from "../../utils/util" import { createStoreBindings } from 'mobx-miniprogram-bindings' import { store } from "../../store/index"; Page({ data: { hasData: true, logout: true, searchModel: { flow_stage: "", page: 1, size: 10 }, tabIndex: 0, statusType: statusType, status_options: status_options, orderList: [] }, onLoad() { this.storeBindings = createStoreBindings(this, { store, fields: ["token"], actions: ["setStore"], }); }, onUnload() { this.storeBindings.destroyStoreBindings(); }, onShow() { if (typeof this.getTabBar === 'function' && this.getTabBar()) { this.getTabBar().setData({ selected: 2 }) } this.orderList(); }, aa(e) { }, bindViewTap(e) { const type = e.currentTarget.dataset.type; wx.navigateTo({ url: '../../userOrder/pages/order-details/index?id=' + type }) }, bindViewTap1(e) { wx.navigateTo({ url: '../../userOrder/pages/continue/index' }) }, bindViewTap2(e) { wx.makePhoneCall({ phoneNumber: '400-9121-211' //仅为示例,并非真实的电话号码 }) }, //阶段筛选 statusTap: function (e) { const { searchModel } = this.data const index = e.detail.index const status = this.data.statusType[index].status this.setData({ searchModel: { ...searchModel, page: 1, flow_stage: status } }); this.orderList(); }, onReady: function () { // 生命周期函数--监听页面初次渲染完成 }, // onShow: function () {}, onPullDownRefresh: function () { // this.data.page = 1 this.orderList() // wx.stopPullDownRefresh() }, onReachBottom() { const { searchModel } = this.data this.setData({ searchModel: { ...searchModel, page: searchModel.page + 1, } }); this.orderList() }, async orderList() { const { searchModel, orderList, status_options, hasData } = this.data const { page, size } = searchModel if (page !== 1 && hasData === false) { this.setData({ searchModel: { ...searchModel, page: page - 1 } }) return } if (page === 1) { wx.pageScrollTo({ scrollTop: 0, duration: 500 }) } // if (page !== 0 && total > count) { // return // } let arr = [] const { code, data, msg } = await httpList(searchModel) const total = page * size if (code == 1) { const { list, count } = data arr = page == 1 ? list : orderList.concat(list) arr.map((s) => { return s.status_name = (status_options.find((item) => item.value == String(s.status)) || {}).label || '--', s.act_time_day = convertTime(s.act_time, 'MM.DD') }) this.setData({ orderList: arr, hasData: count > total }) } else { await this.setStore("", ""); } }, })