// pages/order/list.js Page({ data: { currentTab: 'all', // 当前选中的标签 orderList: [], // 订单列表 page: 1, pageSize: 10, loading: false, hasMore: true }, onLoad(options) { // 如果从个人中心跳转过来,设置对应的标签 if (options.type) { this.setData({ currentTab: options.type }) } this.getOrderList(true) }, // 切换标签 switchTab(e) { const type = e.currentTarget.dataset.type this.setData({ currentTab: type, orderList: [], page: 1, hasMore: true }) this.getOrderList(true) }, // 获取订单列表 getOrderList(refresh = false) { if (this.data.loading || (!this.data.hasMore && !refresh)) return this.setData({ loading: true }) // TODO: 调用后端API获取订单列表 // 这里先模拟数据 setTimeout(() => { const mockOrders = [{ id: '1', createTime: '2024-01-07 12:00:00', status: 'pending', statusText: '待结算', goods: { id: '1', image: '/static/images/goods-1.jpg', name: '商品名称商品名称商品名称商品名称商品名称', price: '99.00', count: 1 }, commission: '9.90', commissionRate: '10' }, { id: '2', createTime: '2024-01-06 15:30:00', status: 'settled', statusText: '已结算', goods: { id: '2', image: '/static/images/goods-2.jpg', name: '商品名称2', price: '199.00', count: 2 }, commission: '39.80', commissionRate: '10', settlementTime: '2024-01-07 10:00:00' }, { id: '3', createTime: '2024-01-05 09:30:00', status: 'invalid', statusText: '无效', goods: { id: '3', image: '/static/images/goods-3.jpg', name: '商品名称3', price: '299.00', count: 1 }, commission: '0.00', commissionRate: '10', invalidReason: '订单已取消' }] if (refresh) { this.setData({ orderList: mockOrders, loading: false, page: 2 }) } else { this.setData({ orderList: [...this.data.orderList, ...mockOrders], loading: false, page: this.data.page + 1, hasMore: this.data.page < 3 // 模拟只有3页数据 }) } }, 500) }, // 加载更多 loadMore() { this.getOrderList() }, // 下拉刷新 onPullDownRefresh() { this.getOrderList(true) wx.stopPullDownRefresh() } })