Files
rlz/coupon/pages/order/order.js
renjianbo 97ad453e89 feat: implement serve-first-pay-later order flow
- Redesign order status: 0待接单→1已接单→2服务中→3待支付→4已完成
- Backend: startService now requires status=1, completeOrder sets status=3
- Backend: payment callback sets status=4, only status=3 can pay
- Backend: cancel only allowed at status 0/1 (not during service)
- Mini-program: update status labels and payment button to status=3
- Android: TobeSerFragment queries status=1, SerFragment queries status=2
- Update all status comments and UI mappings across three platforms

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-21 23:16:27 +08:00

179 lines
4.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//获取应用实例
var app = getApp();
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
},
statusTap: function (e) {
var curType = e.currentTarget.dataset.index;
this.setData({
currentType: curType,
pageNum: 1
});
this.getOrderList();
},
onClickLeft() {
wx.navigateBack()
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var statusBarHeight = wx.getSystemInfoSync().statusBarHeight;
this.setData({
statusBarHeight: statusBarHeight,
height: 46 + statusBarHeight,
});
},
//条目点击---订单状态:-2已取消 -1拒绝接单 0待接单 1已接单 2服务中 3待支付 4已完成 5申请退款 6退款中 7已退款 8已结算
itemclick(e) {
console.log("列表条目的index==" + e.currentTarget.dataset.index)
//去订单详情页
if (e.currentTarget.dataset.item != 0) {
let item = JSON.stringify(e.currentTarget.dataset.item);
//console.log("传递的item" + item);
wx.navigateTo({
url: "/pages/orderdetail/orderdetail?item=" + item,
});
}
},
//跳转订单详情(去付款)
go_pay(e) {
console.log(e.currentTarget.dataset.id)
// wx.navigateTo({
// url: '/pages/orderdetail/orderdetail?' + "type=" + '2' + '&id=' + e.currentTarget.dataset.id,
// })
if (e.currentTarget.dataset.item != 0) {
let item = JSON.stringify(e.currentTarget.dataset.item);
console.log("传递的item" + item);
wx.navigateTo({
url: "/pages/orderdetail/orderdetail?item=" + item,
});
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.setData({
order_list: [],
pageNum: 1
})
this.getOrderList();
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
//this.getOrderList();
var that = this;
wx.request({
url: app.globalData.url + '/system/view/list',
header: app.getRequestHeader(),
method: 'GET',
data: {
pageNum: 1,
pageSize: 30,
status: that.data.status[that.data.currentType],
usercId: wx.getStorageSync('uid')
},
success: (res) => {
var resp = res.data;
if (res.data.code == 200) {
that.setData({
pageNum: 1,
order_list: resp.rows || resp.data,
});
wx.stopPullDownRefresh({
success: (res) => {},
})
}
}
});
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
console.log("==页面上拉触底事件的处理函数==")
// this.getOrderList();
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
//订单状态:-2已取消 -1拒绝接单 0待接单 1已接单 2服务中 3待支付 4已完成 5申请退款 6退款中 7已退款 8已结算
getOrderList: function () {
var that = this;
wx.request({
url: app.globalData.url + '/system/view/list',
header: app.getRequestHeader(),
method: 'GET',
data: {
pageNum: this.data.pageNum,
pageSize: 30,
status: that.data.status[that.data.currentType],
usercId: wx.getStorageSync('uid')
},
success: (res) => {
var resp = res.data;
if (res.data.code == 200) {
if (this.data.pageNum == 1) {
that.setData({
order_list: resp.rows || resp.data,
pageNum: this.data.pageNum + 1
});
} else {
that.setData({
order_list: this.data.order_list.concat(resp.rows || resp.data),
pageNum: this.data.pageNum + 1
});
}
}
}
});
},
})