完善订单页面

This commit is contained in:
wangxiaowei
2025-12-08 01:37:33 +08:00
parent becadb1d0c
commit 4a0d0c1114
6 changed files with 348 additions and 141 deletions

View File

@ -54,10 +54,10 @@
<!-- 使用余额支付优惠的折扣 -->
<view style="margin-top: 52rpx;" v-if="bill.dis">
<view class="title1 d-b-c">
<view style="color: #4C9F44;">优惠</view>
<view>折扣优惠</view>
<view>
<text style="margin-right: 6rpx;"> - </text>
<price-format color="#303133" :subscript-size="30" :first-size="30" :second-size="30" :price="bill.dis"></price-format>
<text style="margin-right: 6rpx;color: #FA2B21;"> - </text>
<price-format color="#FA2B21" :subscript-size="30" :first-size="30" :second-size="30" :price="bill.dis"></price-format>
</view>
</view>
</view>
@ -75,8 +75,9 @@
<view class="price2 bg-white" style="margin: 0; padding: 56rpx 22rpx 42rpx;">
<view class="d-b-c price-block" style="margin: 0;">
<view class="d-f d-c j-c-b">
<view class="">
<view>
合计: <price-format color="#FF5951" :subscript-size="26" :first-size="40" :second-size="40" :price="bill.total"></price-format>
<text style="margin-left: 10rpx;color: #FA2B21;font-size: 26rpx;">8折</text>
</view>
<view class="d-f j-c-c a-i-c" style="margin-top: 10rpx;" @click="closeBillPopup">
<view class="price-detail">费用明细</view>
@ -171,7 +172,7 @@
<view :class="payType == 'wxpay' ? 'item active' : 'item'" @tap="payTypeFunc('wxpay')" style="padding-bottom: 10rpx;">
<view class="d-s-c">
<view class="icon-box d-c-c mr10"><span class="icon iconfont icon-weixin"></span></view>
<text class="key">微信支付</text>
<text class="key">微信支付</text>
</view>
<view class="icon-box d-c-c"><span class="icon iconfont icon-xuanze"></span></view>
</view>
@ -244,6 +245,9 @@
payType: 'wxpay', // 支付方式 wxpay\balance
balance: 0,
order: {},
result: '',
loadding: true,
_submitting: false
};
},
@ -257,6 +261,17 @@
this.getData();
},
onUnload() {
switch(this.result) {
case 'success':
uni.$emit('payment', { result: true, order_id: this.orderId })
break;
case 'fail':
default: uni.$emit('payment', { result: false, order_id: this.orderId })
}
},
methods: {
getData() {
let self = this;
@ -264,12 +279,12 @@
title: '加载中'
});
const reserveDate = uni.getStorageSync('reserveDate') || null
self.date = reserveDate
self.countSelectedTime = reserveDate && reserveDate.duration ? reserveDate.duration : 0
if (self.typeId == 2) {
self.countSelectedTime = 4
}
// const reserveDate = uni.getStorageSync('reserveDate') || null
// self.date = reserveDate
// self.countSelectedTime = reserveDate && reserveDate.duration ? reserveDate.duration : 0
// if (self.typeId == 2) {
// self.countSelectedTime = 4
// }
// 获取余额
self._post(
@ -372,7 +387,6 @@
total: result.light_all_price
}
}
console.log("🚀 ~ self.bill:", self.bill)
self.loadding = false;
}
@ -401,32 +415,50 @@
// 去支付
toConfirm() {
if (this._submitting) return;
this._submitting = true;
if (this.countSelectedTime === 0) {
uni.showToast({title: '请选择时间后再预定', icon: 'none'});
this._submitting = false;
return;
}
const finish = () => { this._submitting = false; };
if (this.payType == 'wxpay') {
// 包装原有回调,确保无论成功失败都解锁
const oldWxPay = this.wxPay;
this.wxPay = (...args) => {
oldWxPay.apply(this, args);
this.wxPay = oldWxPay;
};
oldWxPay.call(this);
setTimeout(finish, 3000); // 兜底3秒自动解锁
} else if (this.payType == 'balance') {
const oldBalancePay = this.balancePay;
this.balancePay = (...args) => {
oldBalancePay.apply(this, args);
this.balancePay = oldBalancePay;
};
oldBalancePay.call(this);
setTimeout(finish, 3000);
} else {
finish();
}
},
// 微信支付
wxPay() {
let self = this;
uni.showLoading({
title: '加载中'
});
self._post(
'order.groundOrder/submitStoreOrder',
{
app_id: self.getAppId(),
ground_id: self.venueId,
room_id: self.roomId,
hours: 1,
day_time: self.date ? self.date.date : '',
start_time: self.date ? self.date.startTime : '',
end_time: self.date ? self.date.endTime : '',
},
function(res) {
console.log("🚀 ~ order res:", res)
try {
self._post(
'user.groundOrder/pay',
{
app_id: self.getAppId(),
order_id: res.data.lists.id
order_id: this.orderId
},
function(res) {
const data = res.data
@ -439,20 +471,102 @@
signType: 'MD5',
paySign: data.payment.paySign,
success: res => {
self.result = 'success'
console.log("🚀 ~ pay success res:", res)
uni.showToast({
title: '支付成功',
icon: 'none'
});
self.loadding = false;
setTimeout(() => {
uni.navigateBack({delta: 1})
}, 500);
},
fail: res => {
console.log("🚀 ~ pay fail res:", res)
uni.reLaunch({
url: '/pages/order/cg-my-order',
console.log("🚀 ~ pay error res:", res)
self.result = 'fail'
self.loadding = false;
uni.showToast({
title: '支付失败',
icon: 'none'
});
setTimeout(() => {
uni.navigateBack({delta: 1})
}, 500);
},
});
}
)
} catch (error) {
console.log("🚀 ~ pay error res:", res)
self.result = 'fail'
self.loadding = false;
uni.showToast({
title: '支付失败',
icon: 'none'
});
setTimeout(() => {
uni.navigateBack({delta: 1})
}, 500);
}
},
// 余额支付
balancePay() {
let self = this;
uni.showLoading({
title: '加载中'
});
try {
self._post(
'ground.ground/yuePay',
{
app_id: self.getAppId(),
order_id: this.orderId
},
function(res) {
if (res.code == 1) {
self.result = 'success'
uni.showToast({
title: '支付成功',
icon: 'none'
});
self.loadding = false;
setTimeout(() => {
uni.navigateBack({delta: 1})
}, 500);
} else {
self.result = 'fail'
self.loadding = false;
uni.showToast({
title: '支付失败',
icon: 'none'
});
setTimeout(() => {
uni.navigateBack({delta: 1})
}, 500);
}
}
)
} catch (error) {
self.result = 'fail'
self.loadding = false;
uni.showToast({
title: '支付失败',
icon: 'none'
});
setTimeout(() => {
uni.navigateBack({delta: 1})
}, 500);
}
}
}
};

View File

@ -280,7 +280,6 @@ export default {
selectedWeekDay: '',
selectedReserveTime: [],
countSelectedTime: 0,
submitting: false // 防止重复提交
};
},
@ -437,22 +436,14 @@ export default {
// 篮球场-立即预约
toReserve() {
let self = this
if (self.submitting) {
uni.showToast({
title: '正在提交,请勿重复操作',
icon: 'none'
});
return;
}
// 一进来就锁定,彻底防止高频点击
self.submitting = true;
if (self.typeId == 1) {
if (self.selectedReserveTime.length === 0) {
uni.showToast({
title: '请选择预约时间',
icon: 'none'
});
self.submitting = false;
return;
}
uni.showLoading({
@ -467,11 +458,32 @@ export default {
app_id: self.getAppId(),
ground_id: self.id,
room_list: JSON.stringify(self.selectedReserveTime),
type: this.typeId
},
function(res) {
self.loadding = false;
self.submitting = false;
if(res.code) {
uni.$on('payment', params => {
console.log("🚀 ~ params:", params)
uni.showLoading({
title: '加载中',
mask: true,
});
setTimeout(() => {
self.loadding = false
uni.$off("payment")
if (params.result) {
uni.redirectTo({
url: `/bundle/reserve/notice?order_id=${params.order_id}`
})
} else {
uni.redirectTo({
url: '/pages/order/cg-my-order'
})
}
}, 500)
})
uni.navigateTo({
url: `/bundle/reserve/confirm?venueId=${self.venue.id}&roomId=${self.id}&typeId=${self.typeId}&orderId=${res.data.lists.id}`
});
@ -479,7 +491,6 @@ export default {
}
)
} catch (error) {
self.submitting = false;
console.error('订单提交失败:', error);
uni.showToast({
title: '订单提交失败,请重试',
@ -493,13 +504,11 @@ export default {
title: '请选择预约时间',
icon: 'none'
});
self.submitting = false;
return;
}
uni.navigateTo({
url: `/bundle/reserve/confirm?venueId=${self.venue.id}&roomId=${self.id}&typeId=${self.typeId}`
});
self.submitting = false;
}
},
@ -616,13 +625,23 @@ export default {
getReserveTime() {
let self = this;
self._post(
'ground.ground/getSchedule',
{
let params = {}
if (self.selectedWeekTimes) {
params = {
app_id: self.getAppId(),
ground_id: self.id,
today: self.selectedWeekTimes
},
}
} else {
params = {
app_id: self.getAppId(),
ground_id: self.id,
}
}
self._post(
'ground.ground/getSchedule',params,
function (res) {
if (res.code) {
self.cdList = res.data.lists1

View File

@ -9,8 +9,8 @@
</view>
<view class="btn">
<view class="btn1">查看订单</view>
<view class="btn2">完成</view>
<view class="btn1" @click="seeOrder">查看订单</view>
<view class="btn2" @click="done">完成</view>
</view>
</view>
</template>
@ -19,18 +19,30 @@
export default {
data() {
return {
order_id: 0
};
},
onLoad(args) {
this.getData();
this.order_id = args.order_id || 0;
},
methods: {
getData() {
},
seeOrder() {
uni.navigateTo({
url: '/pages/order/cg-my-order'
});
},
done() {
uni.reLaunch({
url: '/pages/index/index'
});
}
}
};
</script>

View File

@ -5,7 +5,7 @@
<view class="search-wrap2 d-b-c" style="margin-left: 30rpx;">
<view class="index-search t-c flex-1" style="border: none;background-color: #fff;border-radius: 36rpx;">
<span class="icon iconfont icon-sousuo"></span>
<input type="text" v-model="form.keyWord" class="flex-1 ml10 f30 gray3" value="" placeholder-class="f32 gray7"
<input type="text" v-model="keyWord" class="flex-1 ml10 f30 gray3" value="" placeholder-class="f32 gray7"
placeholder="搜索场馆订单" confirm-type="search" @confirm="search()"/>
</view>
<!--<button class="btn ml10" @click="search()" type="default">搜索</button>-->
@ -14,12 +14,17 @@
</navbar>
<view class="top-tabbar">
<view :class="state_active == 0 ? 'tab-item active' : 'tab-item'" @click="stateFunc(0)">全部订单</view>
<view :class="state_active == 0 ? 'tab-item active' : 'tab-item'" @click="stateFunc('all')">全部订单</view>
<view :class="state_active == 1 ? 'tab-item active' : 'tab-item'" @click="stateFunc(1)">待付款</view>
<view :class="state_active == 2 ? 'tab-item active' : 'tab-item'" @click="stateFunc(2)">已预约</view>
<view :class="state_active == 3 ? 'tab-item active' : 'tab-item'" @click="stateFunc(3)">已完成</view>
<view :class="state_active == 4 ? 'tab-item active' : 'tab-item'" @click="stateFunc(4)">退订/退款</view>
</view>
<view class="d-f a-i-c ball-type-box">
<view class="ball" :class="ballType == 1 ? 'active' : ''" @click="changeBallType(1)">网球</view>
<view class="ball" :class="ballType == 2 ? 'active' : ''" @click="changeBallType(2)">篮球</view>
</view>
<!--列表-->
<scroll-view scroll-y="true" class="scroll-Y" :style="'height:' + scrollviewHigh + 'px;'" lower-threshold="50"
@scrolltolower="scrolltolowerFunc">
@ -31,19 +36,19 @@
<view class="order-head d-b-c">
<view class="d-f a-i-c">
<!-- <text class="state-text">{{ item.order_source_text }}</text> -->
<text class="cg-name flex-1 fb">场馆名称</text>
<text class="cg-name flex-1 fb" @click="toGround(item.ground_id)">{{ item.ground_name }}</text>
<image style="width: 48rpx;height: 48rpx;" src="@/static/icon/right.png" mode=""></image>
</view>
<view class="state cg-state">
<text class="red">{{ item.state_text }}</text>
<!-- <text style="color: #365A9A;">已预约</text>
<text style="color: #606266;">已完成</text>
<text style="color: #C9C9C9;">订单取消</text>
<text style="color: #606266;">退款成功</text> -->
<text class="red" v-if="item.order_status == 0">待付款</text>
<text style="color: #365A9A;" v-if="item.order_status == 1">已预约</text>
<text style="color: #606266;" v-if="item.order_status == 2">已完成</text>
<text style="color: #C9C9C9;" v-if="item.order_status == 3">订单取消</text>
<text style="color: #606266;" v-if="item.order_status == 4">退款成功</text>
</view>
</view>
<!--多个商品显示-->
<view class="product-list pr" v-if="item.product.length > 1" @click="gotoOrder(item.order_id)">
<!-- <view class="product-list pr" v-if="item.product.length > 1" @click="gotoOrder(item.order_id)">
<scroll-view scroll-x="true">
<view class="list d-s-c pr100">
<view class="cover mr10" v-for="(img, num) in item.product" :key="num" style="width: 200rpx; height: 200rxpx;">
@ -59,16 +64,13 @@
</view>
<view class="count">共{{ item.product.length }}件</view>
</view>
</view>
</view> -->
<!--一个商品显示-->
<view class="one-product d-s-c" v-else @click="gotoOrder(item.order_id)">
<view class="cover" v-for="(img, num) in item.product" :key="num" style="width: 200rpx; height: 200rxpx;">
<image :src="img.image.file_path" mode="aspectFill" style="width: 200rpx; height: 200rxpx;"></image>
</view>
<view class="one-product d-s-c" @click="gotoOrder(item.order_id)">
<image :src="item.image" mode="aspectFill" style="width: 200rpx; height: 200rpx; border-radius: 10rpx;"></image>
<view class="flex-1">
<view class="pro-info cg-info1">这个是场馆的分场名称</view>
<view class="pro-info cg-info2">预约时间03/18 08:00-12:00</view>
<view class="pro-info cg-info3">预约时长2小时</view>
<view class="pro-info cg-info2">订单号:{{ item.order_sn }}</view>
<view class="pro-info cg-info3">活动日期:{{ item.trade[0].day_title }}</view>
</view>
<!-- <view class="total-count">
@ -163,34 +165,17 @@
<view v-else class="count d-e-c ww100 redF11">取消申请中</view>
</view>
<view class="order-bts" v-else>
<block v-if="item.order_status.value ==10">
<block>
<!-- 未支付取消订单 -->
<button @click="showCancleOrderPopup(item.order_id)" class="theme-borderbtn cancel-btn"
v-if="item.pay_status.value == 10">取消订单</button>
<!-- 已支付取消订单 -->
<block v-if="item.pay_status.value == 20 && item.delivery_status.value == 10">
<button @click="cancelOrder(item.order_id)" class="theme-borderbtn pay-btn">申请取消</button>
</block>
<!-- 订单核销码 -->
<template
v-if="item.pay_status.value == 20 && item.delivery_type.value == 20 && item.delivery_status.value == 10">
<button v-if="item.order_source == 30 && item.assemble_status==20"
@click="onQRCode(item.order_id)" class="theme-borderbtn">核销码</button>
<button v-if="item.order_source != 30" @click="onQRCode(item.order_id)"
class="theme-borderbtn">核销码</button>
</template>
v-if="item.order_status == 0">取消订单</button>
<!-- 订单付款 -->
<block v-if="item.pay_status.value == 10"><button class="theme-btn pay-btn"
@click="onPayOrder(item.order_id)">去支付</button></block>
<block v-if="item.order_status == 0">
<button class="theme-btn pay-btn" @click="onPayOrder(item.order_id)">去支付</button>
</block>
<!-- todo 缺了一个删除订单的功能,需要跟后端确认 -->
<!-- <block v-if="item.pay_status.value == 10"><button class="theme-btn del-btn"
@click="onDelOrder(item.order_id)">删除订单</button></block> -->
<!-- 确认收货 -->
<block v-if="item.delivery_status.value == 20 && item.receipt_status.value == 10">
<button class="theme-btn" @click="orderReceipt(item.order_id)">确认收货</button>
<block v-if="item.order_status >= 2">
<button class="theme-btn del-btn" @click="onDelOrder(item.order_id)">删除订单</button>
</block>
</block>
<text v-if="item.order_status.value == 21" class="count">取消申请中</text>
@ -297,6 +282,9 @@
codeImg: '',
cancelOrderPopup: false,
delOrderPopup: false,
orderStatus: '',
keyWord: '',
ballType: 1, // 1网球 2篮球
};
},
computed: {
@ -317,15 +305,20 @@
if (typeof e.dataType != 'undefined') {
this.dataType = e.dataType;
}
if (this.dataType == 'payment') {
if (this.dataType == 'all') {
this.state_active = 0;
} else if (this.dataType == 0) {
this.state_active = 1;
} else if (this.dataType == 'received') {
this.state_active = 3;
} else if (this.dataType == 'comment') {
this.state_active = 4;
} else if (this.dataType == 'delivery') {
} else if (this.dataType == 1) {
this.state_active = 2;
} else if (this.dataType == 2) {
this.state_active = 3;
} else if (this.dataType == 4) {
this.state_active = 4;
}
console.log("🚀 ~ this.dataType:", this.dataType)
console.log("🚀 ~ this.dataType:", this.state_active)
},
mounted() {
this.init();
@ -353,33 +346,45 @@
});
},
// 切换球类
changeBallType(type) {
let self = this;
self.ballType = type;
self.listData = [];
self.getData();
},
/*状态切换*/
stateFunc(e) {
console.log("🚀 ~ e:", e)
let self = this;
console.log("🚀 ~ state_active:", self.state_active)
if (self.state_active != e) {
self.page = 1;
self.loading = true;
self.state_active = e;
switch (e) {
case 0:
case 'all':
self.listData = [];
self.dataType = 'all';
break;
case 1:
self.listData = [];
self.dataType = 'payment';
self.dataType = 0;
break;
case 2:
self.listData = [];
self.dataType = 'reserve';
self.dataType = 1;
break;
case 3:
self.listData = [];
self.dataType = 'completed';
self.dataType = 2;
break;
case 4:
self.listData = [];
self.dataType = 'comment';
self.dataType = 4;
break;
}
self.getData();
@ -402,20 +407,47 @@
/*获取数据*/
getData() {
// let self = this;
// self.loading = true;
// let dataType = self.dataType;
// self._get(
// 'user.order/lists', {
// dataType: dataType,
// page: self.page,
// list_rows: self.list_rows
// },
// function(res) {
// self.loading = false;
// self.listData = self.listData.concat(res.data.list.data);
// self.last_page = res.data.list.last_page;
// if (res.data.list.last_page <= 1) {
// self.no_more = true;
// } else {
// self.no_more = false;
// }
// }
// );
let self = this;
self.loading = true;
let dataType = self.dataType;
self._get(
'user.order/lists', {
dataType: dataType,
if (dataType == 'all') {
dataType = '';
}
self._post(
'order.groundOrder/orderGroundList', {
order_status: dataType,
search: self.keyWord,
page: self.page,
list_rows: self.list_rows
size: self.list_rows,
app_id: self.getAppId(),
type: self.ballType
},
function(res) {
self.loading = false;
self.listData = self.listData.concat(res.data.list.data);
self.last_page = res.data.list.last_page;
if (res.data.list.last_page <= 1) {
self.listData = self.listData.concat(res.data.lists.data);
console.log("🚀 ~ self.listData:", self.listData)
self.last_page = res.data.lists.last_page;
if (res.data.lists.last_page <= 1) {
self.no_more = true;
} else {
self.no_more = false;
@ -627,6 +659,13 @@
duration: 2000,
icon: 'none'
});
},
// 跳转场馆
toGround(ground_id) {
uni.navigateTo({
url: `/bundle/reserve/details?id=${id}&typeId=${this.ballType}`
});
}
}
};
@ -692,4 +731,27 @@
}
}
.ball-type-box {
margin-left: 40rpx;
margin-bottom: 24rpx;
.ball {
width: 108rpx;
height: 52rpx;
text-align: center;
line-height: 52rpx;
background: #FFFFFF;
border-radius: 8rpx;
font-size: 26rpx;
color: #606266;
margin-right: 10rpx;
}
.ball.active {
background: #365A9A;
color: #FFFFFF;
}
}
</style>

View File

@ -139,7 +139,7 @@ page {
height: 60rpx;
line-height: 60rpx;
margin-left: 20rpx;
font-size: 32rpx;
font-size: 28rpx;
border: 1px solid #F6220C;
border-radius: 8px;
background: #ffffff;
@ -238,7 +238,7 @@ page {
}
.cg-info2 {
margin-top: 34rpx;
white-space: nowrap;
font-weight: 400;
font-size: 26rpx;
color: #606266;

View File

@ -58,7 +58,7 @@
class="icon iconfont icon-jiantou"></text></view>
</view>
<view class="d-b-c w100">
<view class="item" @click="jumpPage('/pages/order/cg-my-order?dataType=payment')">
<view class="item" @click="jumpPage('/pages/order/cg-my-order?dataType=0')">
<view class="icon-box pr">
<image src="/static/icon/dfk.png" mode=""></image>
<text class="dot d-c-c"
@ -66,7 +66,7 @@
</view>
<text>待付款</text>
</view>
<view class="item" @click="jumpPage('/pages/order/cg-my-order?dataType=reserve')">
<view class="item" @click="jumpPage('/pages/order/cg-my-order?dataType=1')">
<view class="icon-box pr">
<image src="/static/icon/yyy.png" mode=""></image>
<text class="dot d-c-c"
@ -74,7 +74,7 @@
</view>
<text class="">已预约</text>
</view>
<view class="item" @click="jumpPage('/pages/order/cg-my-order?dataType=completed')">
<view class="item" @click="jumpPage('/pages/order/cg-my-order?dataType=2')">
<view class="icon-box pr">
<image src="/static/icon/ywc.png" mode=""></image>
<text class="dot d-c-c"
@ -82,7 +82,7 @@
</view>
<text>已完成</text>
</view>
<view class="item" @click="jumpPage('/pages/order/refund/index/index')">
<view class="item" @click="jumpPage('/pages/order/cg-my-order?dataType=4')">
<view class="icon-box pr">
<image src="/static/icon/tk.png" mode=""></image>
<text class="dot d-c-c"