// pages/mine/order/orderlist.js const app = getApp() Page({ /** * 页面的初始数据 */ data: { orderList: [], //订单列表 waitList: [], //待付款 marchList: [], //进行中 completeList: [], //已完成 tab: 0, //当前tab currentType: '', currentPage: 1, totalSize: 0, hasMore: true, isLoadMore: false, contentHeight: app.globalData.windowHeight - app.globalData.CustomBar, imgUrl: app.urls.baseImgUrl, tabList: [{ name: '待付款' }, { name: '待发货' }, { name: '待收货' }, { name: '全部' }] }, onChange(e) { this.setData({ tab: e.detail.index }) // var cur = e.currentTarget.dataset.tab // if (this.data.tab != cur) { // this.setData({ // tab: cur, // currentType: cur, // currentPage: 1, // orderList: [] // }) // this.getOrderList() // } }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { var state = options.status this.setData({ tab: Number.parseInt(state) }) // if (state == 5) { // this.setData({ // currentType: '', // tab: 4 // }) // } else { // this.setData({ // currentType: state, // tab: state // }) // } // this.getOrderList() }, //获取订单列表 getOrderList() { let _self = this wx.showLoading({ title: '加载中...', }) app.http.get(app.urls.getMineOrderList, { header: { token: app.globalData.token }, data: { page: _self.data.currentPage } }) .then(res => { wx.hideLoading({}) _self.setData({ isLoadMore: false }) if (res.data.rows.length > 0) { _self.data.orderList = _self.data.orderList.concat(res.data.rows) _self.setData({ orderList: _self.data.orderList }) } else { _self.setData({ hasMore: false }) } }) .catch(err => { wx.hideLoading({}) _self.setData({ hasMore: true, currentPage: --_self.data.currentPage, isLoadMore: false }) }) }, //加载更多 doLoadMore(e) { let _self = this if (_self.data.hasMore) { if (_self.data.isLoadMore) { return } _self.setData({ isLoadMore: true, currentPage: ++_self.data.currentPage }) _self.getOrderList() } else { wx.showToast({ title: '暂无更多数据', icon: 'none', duration: 500 }) } }, //显示订单详情 toDetail(e) { wx.navigateTo({ url: './orderdetail?orderId=' + e.currentTarget.dataset.item.orderId + '&shopId=' + e.currentTarget.dataset.item.shopId, }) } })