核销流程优化
This commit is contained in:
parent
b38847ada8
commit
0eb6237e41
|
|
@ -59,8 +59,9 @@
|
|||
</scroll-view>
|
||||
|
||||
<view class="bottom-btn-wrapper">
|
||||
<view class="confirm-btn" @tap="confirmVerify" :class="{ 'btn-disabled': isVerifying }">
|
||||
<text class="btn-text">{{ isVerifying ? '核销中...' : '确认核销' }}</text>
|
||||
<view class="confirm-btn" @tap="isVerified ? goHomePage() : confirmVerify()"
|
||||
:class="{ 'btn-disabled': isVerifying }">
|
||||
<text class="btn-text">{{ isVerified ? '核销成功,返回首页' : (isVerifying ? '核销中...' : '确认核销') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
|
@ -101,7 +102,9 @@ export default {
|
|||
payPrice: 0,
|
||||
settlePrice: 0
|
||||
},
|
||||
isVerifying: false
|
||||
isVerifying: false,
|
||||
isVerified: false, // 订单是否已被核销
|
||||
userInfo: {} // 用户信息,用于获取sjid
|
||||
};
|
||||
},
|
||||
onLoad(options) {
|
||||
|
|
@ -124,6 +127,23 @@ export default {
|
|||
console.log('未获取到订单信息');
|
||||
}
|
||||
},
|
||||
async onShow() {
|
||||
// 每次页面显示时刷新订单核销状态
|
||||
if (this.orderData.orderId) {
|
||||
// 获取用户信息(sjid)
|
||||
if (!this.userInfo.id) {
|
||||
try {
|
||||
const res = await request.post('/user/getuser', { type: 3 });
|
||||
if (res.data) {
|
||||
this.userInfo = res.data;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('获取用户信息失败', e);
|
||||
}
|
||||
}
|
||||
this.checkVerifyStatus();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 精准映射 /sj/poster/getOrderByCode 接口返回的 data 字段
|
||||
mapOrderData(data) {
|
||||
|
|
@ -152,6 +172,48 @@ export default {
|
|||
goBack() {
|
||||
uni.navigateBack();
|
||||
},
|
||||
// 检查订单核销状态
|
||||
checkVerifyStatus() {
|
||||
if (!this.orderData.orderId) return;
|
||||
// 根据订单类型选择对应的详情接口
|
||||
const orderType = this.orderData.orderType;
|
||||
let detailUrl = '';
|
||||
let params = { id: this.orderData.orderId };
|
||||
|
||||
if (orderType == 3) {
|
||||
// 工时订单
|
||||
detailUrl = '/syr/workHourOrder/details';
|
||||
} else if (orderType == 4) {
|
||||
// 工位订单
|
||||
detailUrl = '/sj/workSeatOrder/details';
|
||||
} else if (orderType == 6) {
|
||||
// 自营订单
|
||||
detailUrl = '/sj/orderSelf/details';
|
||||
params.sjid = this.userInfo.id || ''; // 自营订单需要sjid
|
||||
} else {
|
||||
// 普通订单 (orderType 1, 2, 5)
|
||||
detailUrl = '/sj/yhorderdetail';
|
||||
params.sjid = this.userInfo.id || '';
|
||||
}
|
||||
|
||||
request.post(detailUrl, params).then(res => {
|
||||
if (res.code === 200 && res.data) {
|
||||
const orderState = res.data.state;
|
||||
// 状态 1/2/3 为待核销,状态 4/5/6/7 为已核销
|
||||
if (orderState >= 4) {
|
||||
this.isVerified = true;
|
||||
}
|
||||
}
|
||||
}).catch(err => {
|
||||
console.error('检查核销状态失败', err);
|
||||
});
|
||||
},
|
||||
// 返回首页
|
||||
goHomePage() {
|
||||
uni.switchTab({
|
||||
url: '/pages/home/home'
|
||||
});
|
||||
},
|
||||
confirmVerify() {
|
||||
if (this.isVerifying) return;
|
||||
if (!this.orderData.orderId) {
|
||||
|
|
@ -182,6 +244,9 @@ export default {
|
|||
uni.hideLoading();
|
||||
if (res.code === 200) {
|
||||
uni.showToast({ title: '核销成功', icon: 'success' });
|
||||
this.isVerified = true;
|
||||
this.isVerifying = false;
|
||||
// 核销成功后跳转到订单详情
|
||||
const orderId = this.orderData.orderId;
|
||||
const orderType = this.orderData.orderType;
|
||||
let url = '';
|
||||
|
|
|
|||
Loading…
Reference in New Issue