积分商城修改

This commit is contained in:
2025-12-11 11:34:06 +08:00
parent 87f2ee8c3d
commit bb2830730d
6 changed files with 372 additions and 170 deletions

View File

@@ -46,14 +46,17 @@
<view class="title">商品详情</view>
</view>
<view class="u-m-t-32">
<image class="w-full" v-for="(item,index) in item.goodsDescription" :key="index" mode="widthFix" :src="item">
<image class="w-full" v-for="(item,index) in item.goodsDescription" :key="index" mode="widthFix"
:src="item">
</image>
</view>
</view>
<view style="height: 100px"></view>
<view class="fixed-bottom u-flex u-row-center">
<view class="btn" @click="exchangeClick" :class="isCanExchange">立即兑换</view>
<view class="btn" @click="exchangeClick" :class="[isCanExchange?'':'gray']">
{{returnBtmText}}
</view>
</view>
<!-- 兑换确认弹窗start -->
@@ -76,27 +79,27 @@
</view>
<view class="goods-info">
<view class="u-flex">
<image class="cover"></image>
<image class="cover" :src="item.goodsImageUrl"></image>
<view class="u-flex u-flex-1 u-row-between u-p-l-16 u-col-center">
<view>
<view class="u-font-32 font-bold">这里是商品名称</view>
<view class="u-m-t-54 color-666">8000积分+9.99</view>
<view class="u-font-32 font-bold">{{item.goodsName}}</view>
<view class="u-m-t-54 color-666">{{item.requiredPoints}}积分+{{item.extraPrice}}</view>
</view>
<text class="color-666">X1</text>
</view>
</view>
<view class="u-m-t-20 waring u-flex u-col-center">
<view class="u-m-t-20 waring u-flex u-col-center" v-if="item.goodsCategory=='优惠券'">
<up-icon name="info-circle" size="16" color="#FF9900"></up-icon>
<view class="u-m-l-16">优惠券为虚拟发放一旦兑换不支持退款请悉知</view>
</view>
</view>
<view class="bottom font-bold text-right">
<text>合计 8000积分 + ¥9.99</text>
<text>合计 {{item.requiredPoints}}积分 + ¥{{item.extraPrice}}</text>
</view>
<view class="u-m-t-42 u-flex u-row-center">
<view class="btn">确认兑换</view>
<view class="btn" @click="payExchange">确认兑换</view>
</view>
</view>
</up-popup>
@@ -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;