From ffa15296413243350ff4755fd34ed4372c7b9924 Mon Sep 17 00:00:00 2001
From: fox <1466778434@qq.com>
Date: Mon, 26 May 2025 15:55:43 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8E=A5=E5=8F=A3=E5=AF=B9=E6=8E=A5;?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
api/model/product.js | 9 +++-
components/couponList/couponList.vue | 7 ++-
pages/index/center.vue | 25 ++++++++---
pages_order/components/voucher/voucherCard.vue | 21 +++++----
pages_order/mine/verifyVoucher.vue | 44 ++++++++++++-------
pages_order/mine/voucher.vue | 2 +
pages_order/order/orderDetail.vue | 4 +-
pages_order/order/verifyOrder.vue | 59 +++++++++++++++-----------
8 files changed, 109 insertions(+), 62 deletions(-)
diff --git a/api/model/product.js b/api/model/product.js
index f0b8752..ec60c3d 100644
--- a/api/model/product.js
+++ b/api/model/product.js
@@ -31,12 +31,19 @@ const api = {
method: 'GET',
},
/**
- * 获取优惠券信息
+ * 优惠券-可使用门店列表
*/
queryVoucherShopList: {
url: '/vouchers/queryShopList',
method: 'GET',
},
+ /**
+ * 代金券-根据id查看代金券详情
+ */
+ queryVouchersById: {
+ url: '/vouchers/queryVouchersById',
+ method: 'GET',
+ },
}
export default api
\ No newline at end of file
diff --git a/components/couponList/couponList.vue b/components/couponList/couponList.vue
index 47d2204..2b3200a 100644
--- a/components/couponList/couponList.vue
+++ b/components/couponList/couponList.vue
@@ -17,8 +17,8 @@
- {{ item.money }}
- {{ `有效期至${item.endTime}` }}
+ {{ item.discountAmount }}
+ {{ `有效期至${item.validTime ? $dayjs(item.validTime).format('YYYY-MM-DD') : '-'}` }}
@@ -49,8 +49,7 @@
}
},
watch: {
- status: function(newValue) {
- console.log('--watch--status', newValue)
+ status: function() {
this.getCouponList()
}
},
diff --git a/pages/index/center.vue b/pages/index/center.vue
index 1bb64c8..6402d22 100644
--- a/pages/index/center.vue
+++ b/pages/index/center.vue
@@ -71,17 +71,15 @@
我的余额
-
{{ userCenterData.score || 0 }}
我的积分
- {{ riceInfo.canWithdraw || 0 }}元
+ {{ userInfo.recommendAmount || 0 }}元
推广佣金
-
- {{ riceInfo.balance || 0 }}张
+ {{ couponCount || 0 }}张
优惠券
@@ -178,6 +176,7 @@
},
data() {
return {
+ couponCount: 0,
}
},
onShow() {
@@ -185,6 +184,7 @@
this.$store.commit('getUserInfo')
this.$store.commit('getUserCenterInfo')
this.$store.commit('getRiceInfo')
+ this.fetchCouponData()
}
},
methods: {
@@ -214,10 +214,16 @@
console.log(res);
if (res.result) {
// 处理扫码结果
+ const [id, type] = res.result.split(',')
console.log('扫码结果:', res.result);
+ console.log('--overOrder', {
+ orderId : id,
+ type, // type区分,0-订单核销 1-代金券核销
+ })
this.$fetch('overOrder', {
- orderId : res.result
+ orderId : id,
+ type, // type区分,0-订单核销 1-代金券核销
}).then(() => {
uni.showToast({
title: '核销成功',
@@ -236,6 +242,15 @@
}
});
},
+ async fetchCouponData() {
+ try {
+ const { total } = await this.$fetch('queryVouchersList', { type: 0 })
+
+ this.couponCount = total
+ } catch (err) {
+
+ }
+ },
}
}
diff --git a/pages_order/components/voucher/voucherCard.vue b/pages_order/components/voucher/voucherCard.vue
index 9b5046c..8c52db2 100644
--- a/pages_order/components/voucher/voucherCard.vue
+++ b/pages_order/components/voucher/voucherCard.vue
@@ -5,7 +5,7 @@
{{ data.vouchersId_dictText }}
- {{ `${data.startTime}-${data.endTime}` }}
+ {{ validRange }}
{{ data.desc ||'' }}
@@ -17,20 +17,13 @@
diff --git a/pages_order/mine/voucher.vue b/pages_order/mine/voucher.vue
index e71b885..c470820 100644
--- a/pages_order/mine/voucher.vue
+++ b/pages_order/mine/voucher.vue
@@ -105,6 +105,8 @@
}
}
+ this.list = []
+
this.getData()
}
},
diff --git a/pages_order/order/orderDetail.vue b/pages_order/order/orderDetail.vue
index 384fd94..35530e6 100644
--- a/pages_order/order/orderDetail.vue
+++ b/pages_order/order/orderDetail.vue
@@ -20,11 +20,11 @@
付款时间
- {{ orderDetail.payTime }}
+ {{ orderDetail.payTime || '-' }}
核销时间
- {{ orderDetail.validTime }}
+ {{ orderDetail.useTime || '-' }}
diff --git a/pages_order/order/verifyOrder.vue b/pages_order/order/verifyOrder.vue
index 7567493..f4aaa8a 100644
--- a/pages_order/order/verifyOrder.vue
+++ b/pages_order/order/verifyOrder.vue
@@ -23,22 +23,18 @@
-
-
-
-
+
{{ `订单号:${orderDetail.id}` }}
- {{ `有效时间:${orderDetail.startTime}至${orderDetail.endTime}` }}
+ {{ `有效时间:${validRange}` }}
-
@@ -58,6 +54,16 @@
orderDetail: {},
}
},
+ computed: {
+ validRange() {
+ const { createTime, validTime } = this.orderDetail || {}
+
+ let startTime = createTime ? this.$dayjs(createTime).format('YYYY-MM-DD') : '-'
+ let endTime = validTime ? this.$dayjs(validTime).format('YYYY-MM-DD') : '-'
+
+ return `${startTime}至${endTime}`
+ },
+ },
onLoad(args) {
this.id = args.id
this.fetchOrderDetail()
@@ -79,32 +85,35 @@
uni.stopPullDownRefresh()
},
-
- overOrder() {
- uni.showModal({
- title: '确认核销订单吗?',
- success: e => {
- if (e.confirm) {
- this.$api('overOrder', {
- orderId: this.orderDetail.id,
- }, res => {
- this.$emit('done')
- // 请求成功后返回上一个页面
- uni.navigateBack()
- })
- }
+ async fetchRefund() {
+ try {
+ const res = await this.$fetch('refundOrder', { orderId: this.orderDetail.id }, false)
+
+ if (res.code == 200) {
+ uni.showToast({
+ title: '退款成功',
+ icon: 'none'
+ })
+ setTimeout(uni.navigateBack, 800, -1)
+ } else {
+ uni.showToast({
+ title: res.data,
+ icon: 'none'
+ })
}
- })
+ } catch (err) {
+
+ }
},
onRefund() {
uni.showModal({
title: '确认申请订单退款嘛?',
success: e => {
if (e.confirm) {
- this.$api('refundOrder', {
- orderId: this.orderDetail.id,
- }, res => {
- this.$emit('done')
+ this.fetchRefund()
+ uni.showToast({
+ title: '已提交申请,请耐心等候',
+ icon: 'none'
})
}
}