feat: 添加退款相关功能和状态显示

- 新增退款状态显示,包括“已退款”和“退款中”
- 添加退款目的地页面,支持查看订单退款信息
- 更新订单列表和订单详情页,支持退款操作
- 更新依赖edu-core至v1.0.13以支持新功能
This commit is contained in:
2026-05-09 11:09:14 +08:00
parent 708804cbbf
commit 5f4a4d4ae4
12 changed files with 221 additions and 35 deletions

View File

@@ -88,6 +88,16 @@
v-if="orderContet.orderStatus == 5"
>已超时</text
>
<text
class="orderState orderState6"
v-if="orderContet.orderStatus == 6"
>已退款</text
>
<text
class="orderState orderState7"
v-if="orderContet.orderStatus == 7"
>退款中</text
>
</view>
<view
class="orderContent"
@@ -1105,14 +1115,15 @@ export default {
text: "继续付款",
});
}
if (this.orderContet.orderStatus == 0) {
this.customButton.push({
width: "160rpx",
text: "取消订单",
color: "#333",
backgroundColor: "#f0f0f0",
});
}
// sociology注释取消订单按钮
// if (this.orderContet.orderStatus == 0) {
// this.customButton.push({
// width: "160rpx",
// text: "取消订单",
// color: "#333",
// backgroundColor: "#f0f0f0",
// });
// }
// var seconds = res.result.timestamp + 30 * 60 + 2 // 过期时间
// var nowSeconds = Math.floor(new Date().getTime() / 1000);
@@ -1131,6 +1142,10 @@ export default {
this.titleStat = "待收到";
} else if (this.orderContet.orderStatus == 3) {
this.titleStat = "已完成";
} else if (this.orderContet.orderStatus == 6) {
this.titleStat = "已退款";
} else if (this.orderContet.orderStatus == 7) {
this.titleStat = "退款中";
}
if (
this.orderContet.orderStatus >= 2 &&
@@ -1173,10 +1188,28 @@ export default {
},
});
},
checkPayTimeout(payItem) {
const createTime = payItem && payItem.createTime;
if (!createTime) return true;
const createdAt = new Date(String(createTime).replace(/-/g, "/")).getTime();
if (!createdAt) return true;
const expired = Date.now() - createdAt > 10 * 60 * 1000;
if (expired) {
uni.showModal({
title: "提示",
content: "订单已超时,不能继续支付,请重新下单",
confirmText: "知道了",
showCancel: false,
});
return false;
}
return true;
},
// 支付
goPay(payItem) {
console.log(payItem, "订单数据");
if (!this.checkPayTimeout(payItem)) return;
if (payItem.paymentMethod == 2) {
console.log("阿里支付");
setPay(
@@ -1320,6 +1353,12 @@ uni-view {
.orderState5 {
background-color: #787878;
}
.orderState6 {
background-color: #f56c6c;
}
.orderState7 {
background-color: #f56c6c;
}
.guoqi {
font-size: 28rpx;
align-items: center;

View File

@@ -24,7 +24,7 @@
<view class="cateList flexbox">
<common-sticky
itemStyle="width:20%; height: 68rpx;font-size:24rpx;"
itemStyle="height: 68rpx;font-size:24rpx; padding: 0 20rpx;"
:list="ordersTabs"
label="name"
:currentCateIndex="currentCateIndex"
@@ -120,6 +120,16 @@
v-show="slotProps.row.orderStatus == 5"
>已过期</text
>
<text
class="orderstatus"
v-show="slotProps.row.orderStatus == 6"
>已退款</text
>
<text
class="orderstatus"
v-show="slotProps.row.orderStatus == 7"
>退款中</text
>
</view>
</view>
<view
@@ -380,11 +390,12 @@
class="operation_box boxShadow"
v-if="slotProps.row.isShowMore == true"
>
<view
<!-- sociology注释取消订单入口 -->
<!-- <view
v-if="slotProps.row.orderStatus == 0"
@click.native.stop="canceOrder(slotProps.row)"
>取消订单</view
>
> -->
</view>
<view class="btns flexbox" style="margin-top: 10rpx">
<view
@@ -421,8 +432,18 @@
>
<view
class="orderstatusbtn"
v-if="slotProps.row.orderStatus == 3"
>申请售后</view
v-if="
slotProps.row.orderStatus == 6 ||
slotProps.row.orderStatus == 7
"
@click.stop="goRefundDestination(slotProps.row)"
>钱款去向</view
>
<view
class="orderstatusbtn"
v-if="slotProps.row.refundableStatus === true"
@click.stop="confirmApplyRefund(slotProps.row)"
>申请退款</view
>
<!-- <view
class="orderstatusbtn"
@@ -615,12 +636,14 @@ export default {
come: "1",
isShowTab: false,
isLoadingHide: false,
moreList: [
{
name: "取消订单",
key: "false",
},
],
// sociology注释取消订单菜单
// moreList: [
// {
// name: "取消订单",
// key: "false",
// },
// ],
moreList: [],
currentCateIndex: 0,
pagination: {
// 请求参数
@@ -671,6 +694,16 @@ export default {
value: 3,
badge: {},
},
{
name: "已退款",
value: 6,
badge: {},
},
{
name: "退款中",
value: 7,
badge: {},
},
],
selectOrderInfo: {},
ordersListTab: 1,
@@ -790,7 +823,8 @@ export default {
console.log("index at line 609:", index);
if (index.key == "false") {
this.isShowMore = false;
this.canceOrder(this.selectOrderInfo);
// sociology注释取消订单触发
// this.canceOrder(this.selectOrderInfo);
}
},
openMore(row, index) {
@@ -856,6 +890,51 @@ export default {
val.orderSn,
});
},
goRefundDestination(row) {
uni.navigateTo({
url: `/pages/bookShop/refundDestination?orderId=${row.orderId}`,
});
},
confirmApplyRefund(row) {
uni.showModal({
title: "申请退款",
content: "请确认是否提交退款申请?",
confirmText: "确认提交",
cancelText: "取消",
success: (res) => {
if (res.confirm) {
this.submitOrderRefund(row);
}
},
});
},
submitOrderRefund(orderRow) {
this.$http
.request({
url: "book/buyOrder/refundOrder",
method: "POST",
data: {
orderId: orderRow.orderId,
},
header: {
"Content-Type": "application/json",
},
})
.then((res) => {
if (res.code === 0) {
this.$commonJS.showToast("申请退款成功");
this.newestpage = 1;
this.pagination.page = 1;
this.newList = [];
this.getBookList(this.ordersListTab, false);
return;
}
this.$commonJS.showToast(res.errMsg || "申请退款失败");
})
.catch(() => {
this.$commonJS.showToast("申请退款失败");
});
},
getBookList(flag, refreshflag) {
this.isLoadingHide = false;
var that = this;
@@ -882,6 +961,8 @@ export default {
// * 3已完成
// * 4: 交易失败
// * 5: 已过期
// * 6: 已退款
// * 7: 退款中
console.log("res at line 757:", res);
that.map = res.data;
@@ -909,7 +990,7 @@ export default {
var params = {
userId: this.userInfo.id,
come: this.come,
orderStatus: flag == -1 ? "" : flag, //传null为全部订单状态 0-待付款 1-待发出 2-待收到 3-已完成 4-交易失败 5-已过期
orderStatus: flag == -1 ? "" : flag, //传null为全部订单状态 0-待付款 1-待发出 2-待收到 3-已完成 4-交易失败 5-已过期 6-已退款 7-退款中
...this.pagination,
// limit: 10,
// page: this.newestpage,
@@ -949,9 +1030,27 @@ export default {
this.axiosStatus = 1;
},
checkPayTimeout(payItem) {
const createTime = payItem && payItem.createTime;
if (!createTime) return true;
const createdAt = new Date(String(createTime).replace(/-/g, "/")).getTime();
if (!createdAt) return true;
const expired = Date.now() - createdAt > 10 * 60 * 1000;
if (expired) {
uni.showModal({
title: "提示",
content: "订单已超时,不能继续支付,请重新下单",
confirmText: "知道了",
showCancel: false,
});
return false;
}
return true;
},
// 支付
goPay(payItem) {
console.log(payItem, "订单数据");
if (!this.checkPayTimeout(payItem)) return;
if (payItem.paymentMethod == 2) {
console.log("阿里支付");
setPay(
@@ -1629,9 +1728,9 @@ export default {
z-index: 970;
}
/deep/.u-tabs__wrapper__nav__item {
padding: 0 !important;
}
// /deep/.u-tabs__wrapper__nav__item {
// padding: 0 !important;
// }
.commonDetailPage {
background-color: #f5f5f5;

View File

@@ -0,0 +1,27 @@
<template>
<view class="page-wrap">
<public-module></public-module>
<common-refund-destination :order-id="orderId" :http="$http" />
</view>
</template>
<script>
export default {
data() {
return {
orderId: "",
};
},
onLoad(options) {
if (options && options.orderId != null) {
this.orderId = options.orderId;
}
},
};
</script>
<style scoped>
.page-wrap {
min-height: 100vh;
}
</style>

View File

@@ -445,4 +445,8 @@ export default {
font-weight: 700;
}
}
.title_list {
margin-bottom: 20rpx;
}
</style>

View File

@@ -1,6 +1,6 @@
<template>
<!-- <scroll-view class="scroll-view_H cateList" scroll-x="true" scroll-left="0"> -->
<view class="" style="background-color: #fff; width: 100%">
<view class="" style="background-color: #fff; width: 100%; padding: 0 20rpx;">
<u-tabs
lineWidth="30"
lineColor="#3AB3AE"