From bb2830730df1b10f92030bd24bb16db3df296860 Mon Sep 17 00:00:00 2001 From: YeMingfei666 <1619116647@qq.com> Date: Thu, 11 Dec 2025 11:34:06 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=AF=E5=88=86=E5=95=86=E5=9F=8E=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/api/order/pointGoods.js | 8 + scoreShop/detail/index.vue | 92 ++++- scoreShop/index/components/goods-list.vue | 6 +- scoreShop/order/components/order-list.vue | 17 +- scoreShop/order/detail.vue | 417 ++++++++++++++-------- scoreShop/order/index.vue | 2 +- 6 files changed, 372 insertions(+), 170 deletions(-) diff --git a/common/api/order/pointGoods.js b/common/api/order/pointGoods.js index d480e46..f5d9a5e 100644 --- a/common/api/order/pointGoods.js +++ b/common/api/order/pointGoods.js @@ -55,4 +55,12 @@ export const recordPage = (data) => { method: 'get', data: data }) +} + +export const recordOne = (data) => { + return request({ + url: url + '/user/pointGoods/record/one', + method: 'get', + data: data + }) } \ No newline at end of file diff --git a/scoreShop/detail/index.vue b/scoreShop/detail/index.vue index 3d680a4..5c95d37 100644 --- a/scoreShop/detail/index.vue +++ b/scoreShop/detail/index.vue @@ -46,14 +46,17 @@ 商品详情 - + - 立即兑换 + + {{returnBtmText}} + @@ -76,27 +79,27 @@ - + - 这里是商品名称 - 8000积分+9.99元 + {{item.goodsName}} + {{item.requiredPoints}}积分+{{item.extraPrice}}元 X1 - + 优惠券为虚拟发放,一旦兑换不支持退款,请悉知 - 合计 8000积分 + ¥9.99 + 合计 {{item.requiredPoints}}积分 + ¥{{item.extraPrice}} - 确认兑换 + 确认兑换 @@ -113,6 +116,9 @@ } from '@/utils/uniapp.js' import modal from "@/scoreShop/components/modal.vue"; import * as pointGoodsApi from "@/common/api/order/pointGoods.js"; + import { + pay + } from '@/utils/pay.js' const imgs = { bg: "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/2/9fd6a3ad2b384f6cb4e88ed6b77bd334.png", }; @@ -125,6 +131,10 @@ }); function exchangeClick() { + if (item.extraPrice > 0) { + popupData.show = true + return + } modalData.show = true; } @@ -132,7 +142,45 @@ // modalData.show = false; exchange() } + async function payExchange() { + uni.showLoading({ + title: '兑换中……' + }) + const openId = await getOpenId() + uni.hideLoading() + if (openId) { + pointGoodsApi.exchange({ + pointsGoodsId: item.id, + shopId: item.shopId, + number: 1, + price: item.extraPrice, + openId + }).then(orderRes => { + popupData.show = false; + pay(orderRes.payInfo).then(res => { + console.log(res) + if (res) { + uni.setStorageSync('exchange_goods_success', orderRes.goodsRecord) + uni.redirectTo({ + url: '/scoreShop/success/index' + }) + } else { + uni.showToast({ + title: '兑换失败', + icon: 'none' + }) + } + }) + + }) + } else { + uni.showToast({ + title: '鉴权失败,兑换失败', + icon: 'none' + }) + } + } async function exchange() { uni.showLoading({ title: '兑换中……' @@ -148,12 +196,12 @@ openId }).then(res => { modalData.show = false; - if(res){ - uni.setStorageSync('exchange_goods_success',res) + if (res) { + uni.setStorageSync('exchange_goods_success', res) uni.redirectTo({ - url:'/scoreShop/success/index' + url: '/scoreShop/success/index' }) - }else{ + } else { uni.showToast({ title: '兑换失败', icon: 'none' @@ -219,11 +267,27 @@ if (item.quantity <= 0) { return false } - if(item.limitQuota&&item.boughtCount>=item.limitQuota){ + if (item.limitQuota && item.boughtCount >= item.limitQuota) { return false } return true }) + + const returnBtmText = computed(() => { + if (isCanExchange.value) { + return '立即兑换' + } + if (pointsUser.pointBalance < item.requiredPoints) { + const num = item.requiredPoints - pointsUser.pointBalance + return `积分不足,还差${num}积分` + } + if (item.quantity <= 0) { + return `库存不足` + } + if (item.limitQuota && item.boughtCount >= item.limitQuota) { + return `单人兑换已达上限` + } + }) onLoad((opt) => { const exchange_goods = uni.getStorageSync('exchange_goods') if (exchange_goods.goodsDescription) { @@ -342,7 +406,7 @@ background-color: #fff; bottom: 0; z-index: 10; - + .btn { padding: 16rpx 62rpx; diff --git a/scoreShop/index/components/goods-list.vue b/scoreShop/index/components/goods-list.vue index d85b8c7..660a54e 100644 --- a/scoreShop/index/components/goods-list.vue +++ b/scoreShop/index/components/goods-list.vue @@ -25,7 +25,7 @@