- Add request.js for unified API calls with loading/error handling - Add service page (service type listing) - Fix hospital list to load from API with proper image URL construction - Add service types dynamic loading on index page - Various mini program improvements (order, care, wallet pages) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
136 lines
3.2 KiB
JavaScript
136 lines
3.2 KiB
JavaScript
var app = getApp();
|
|
const { request } = require('../../utils/request')
|
|
|
|
Page({
|
|
data: {
|
|
order_list: [],
|
|
nav_type: 1,
|
|
all: true,
|
|
height: '',
|
|
url: app.globalData.url,
|
|
statusType: ["全部", "待接单", "已接单", "服务中", "待支付", "已完成","已取消"],
|
|
status: ["", "0", "1", "2", "3","4","-2"],
|
|
currentType: 0,
|
|
tabClass: ["", "", "", "", "", "", ""],
|
|
pageNum: 1,
|
|
hasMore: true,
|
|
firstLoad: true,
|
|
loading: false
|
|
},
|
|
|
|
statusTap: function (e) {
|
|
var curType = e.currentTarget.dataset.index;
|
|
this.setData({
|
|
currentType: curType,
|
|
pageNum: 1,
|
|
order_list: []
|
|
});
|
|
this.getOrderList();
|
|
},
|
|
|
|
onClickLeft() {
|
|
wx.navigateBack()
|
|
},
|
|
|
|
onLoad: function (options) {
|
|
var statusBarHeight = wx.getSystemInfoSync().statusBarHeight;
|
|
this.setData({
|
|
statusBarHeight: statusBarHeight,
|
|
height: 46 + statusBarHeight,
|
|
});
|
|
},
|
|
|
|
itemclick(e) {
|
|
if (e.currentTarget.dataset.item != 0) {
|
|
let item = JSON.stringify(e.currentTarget.dataset.item);
|
|
wx.navigateTo({
|
|
url: "/pages/orderdetail/orderdetail?item=" + item,
|
|
});
|
|
}
|
|
},
|
|
|
|
go_pay(e) {
|
|
if (e.currentTarget.dataset.item != 0) {
|
|
let item = JSON.stringify(e.currentTarget.dataset.item);
|
|
wx.navigateTo({
|
|
url: "/pages/orderdetail/orderdetail?item=" + item,
|
|
});
|
|
}
|
|
},
|
|
|
|
onShow: function () {
|
|
// 首次加载或从其他页返回刷新
|
|
if (this.data.firstLoad) {
|
|
this.setData({ firstLoad: false })
|
|
this.getOrderList()
|
|
}
|
|
},
|
|
|
|
onPullDownRefresh: function () {
|
|
this.setData({ pageNum: 1 })
|
|
this.refreshList().finally(() => wx.stopPullDownRefresh())
|
|
},
|
|
|
|
onReachBottom: function () {
|
|
if (this.data.hasMore && !this.data.loading) {
|
|
this.getOrderList()
|
|
}
|
|
},
|
|
|
|
async refreshList() {
|
|
this.setData({ loading: true })
|
|
try {
|
|
var res = await request({
|
|
url: '/system/view/list',
|
|
method: 'GET',
|
|
loading: false,
|
|
data: {
|
|
pageNum: 1,
|
|
pageSize: 30,
|
|
status: this.data.status[this.data.currentType],
|
|
usercId: wx.getStorageSync('uid')
|
|
}
|
|
})
|
|
var list = res.rows || res.data || []
|
|
this.setData({
|
|
order_list: list,
|
|
pageNum: 2,
|
|
hasMore: list.length >= 30
|
|
})
|
|
} catch (e) {}
|
|
this.setData({ loading: false })
|
|
},
|
|
|
|
async getOrderList() {
|
|
if (this.data.loading) return
|
|
this.setData({ loading: true })
|
|
try {
|
|
var res = await request({
|
|
url: '/system/view/list',
|
|
method: 'GET',
|
|
loading: this.data.pageNum === 1,
|
|
data: {
|
|
pageNum: this.data.pageNum,
|
|
pageSize: 30,
|
|
status: this.data.status[this.data.currentType],
|
|
usercId: wx.getStorageSync('uid')
|
|
}
|
|
})
|
|
var newList = res.rows || res.data || []
|
|
if (this.data.pageNum === 1) {
|
|
this.setData({
|
|
order_list: newList,
|
|
pageNum: 2,
|
|
hasMore: newList.length >= 30
|
|
})
|
|
} else {
|
|
this.setData({
|
|
order_list: this.data.order_list.concat(newList),
|
|
pageNum: this.data.pageNum + 1,
|
|
hasMore: newList.length >= 30
|
|
})
|
|
}
|
|
} catch (e) {}
|
|
this.setData({ loading: false })
|
|
},
|
|
}) |