修复当支付金额为0时,抵扣券选中后会变不可用

This commit is contained in:
2024-11-20 10:12:49 +08:00
parent 0069b7c6fd
commit 61938a6947
4 changed files with 74 additions and 33 deletions

View File

@@ -48,7 +48,7 @@
</view> </view>
</view> </view>
</template> </template>
<template v-else-if="data.isMember&&data.memberId&&item.memberPrice&&item.memberPrice!=item.price"> <template v-else-if="item.isMember&&data.memberId&&item.memberPrice&&item.memberPrice!=item.price">
<view class="u-text-right u-relative" :style="computedPriceStyle()"> <view class="u-text-right u-relative" :style="computedPriceStyle()">
<text class="line-th">{{goodsPriceAmount(item)}}</text> <text class="line-th">{{goodsPriceAmount(item)}}</text>
<view class="u-absolute" style="bottom: 100%;right: 0;"> <view class="u-absolute" style="bottom: 100%;right: 0;">
@@ -164,7 +164,7 @@
} }
function goodsVipPriceAmount(item) { function goodsVipPriceAmount(item) {
const price = (props.data.memberId&&item.isMember) ? item.memberPrice : item.price const price = item.memberPrice ? item.memberPrice : item.price
return (price * item.num).toFixed(2) return (price * item.num).toFixed(2)
} }
// const packeFee=computed(()=>{ // const packeFee=computed(()=>{

View File

@@ -46,9 +46,16 @@
<view class="u-m-l-18">{{item.name}}</view> <view class="u-m-l-18">{{item.name}}</view>
<view class="u-m-l-18 color-999">x{{item.num}}</view> <view class="u-m-l-18 color-999">x{{item.num}}</view>
</view> </view>
<view class="color-red"> <view class="u-flex">
-{{item.discountAmount}} <view class="color-red">
-{{item.discountAmount}}
</view>
<view class="u-m-l-12" @click="delQuan(index)">
<up-icon :size="16" name="minus-circle-fill" color="rgb(255, 0, 0)"></up-icon>
</view>
</view> </view>
</view> </view>
</view> </view>
@@ -196,7 +203,8 @@
<edit-discount @confirm="editDiscountConfirm" title="优惠金额" :ref="setModel" name="editMoney" <edit-discount @confirm="editDiscountConfirm" title="优惠金额" :ref="setModel" name="editMoney"
:price="order.amount"></edit-discount> :price="order.amount"></edit-discount>
<edit-accountPoints @confirm="pointsConfirm" :price="accountPoints.num" :accountPoints="accountPoints" ref="refPoints"></edit-accountPoints> <edit-accountPoints @confirm="pointsConfirm" :price="accountPoints.num" :accountPoints="accountPoints"
ref="refPoints"></edit-accountPoints>
</view> </view>
</template> </template>
@@ -227,13 +235,19 @@
import editDiscount from '@/components/my-components/edit-discount.vue' import editDiscount from '@/components/my-components/edit-discount.vue'
import editAccountPoints from './components/edit-accountPoints.vue' import editAccountPoints from './components/edit-accountPoints.vue'
import { import {
returnGoodsPayPriceMap,returnProCoupStartIndex ,returnProductCoupAllPrice,returnProductCanUseNum returnGoodsPayPriceMap,
returnProCoupStartIndex,
returnProductCoupAllPrice,
returnProductCanUseNum
} from '../quan_util.js' } from '../quan_util.js'
//商品数量从0到n每一个对应的价格 //商品数量从0到n每一个对应的价格
let $goodsPayPriceMap={} let $goodsPayPriceMap = {}
const refPoints = ref(null) const refPoints = ref(null)
function delQuan(i){
pays.quan.splice(i,1)
}
function refPointsOpen() { function refPointsOpen() {
if (!accountPoints.calcRes.usable && accountPoints.sel) { if (!accountPoints.calcRes.usable && accountPoints.sel) {
return return
@@ -251,8 +265,9 @@
}, },
price: 0 price: 0
}) })
function pointsConfirm(e){
accountPoints.num=e function pointsConfirm(e) {
accountPoints.num = e
} }
async function calcUsablePoints() { async function calcUsablePoints() {
if (!order.memberId) { if (!order.memberId) {
@@ -308,7 +323,7 @@
go.to('PAGES_ORDER_QUAN', { go.to('PAGES_ORDER_QUAN', {
orderId: order.id, orderId: order.id,
memberId: order.memberId, memberId: order.memberId,
orderPrice: payPrice.value*1+coupAllPrice.value*1 orderPrice: payPrice.value * 1 + coupAllPrice.value * 1
}) })
} }
async function discountShow() { async function discountShow() {
@@ -395,33 +410,35 @@
uni.$off('choose-quan') uni.$off('choose-quan')
uni.$on('choose-quan', (arr) => { uni.$on('choose-quan', (arr) => {
console.log(arr); console.log(arr);
const manjianCoup = arr.filter(v => v.type == 1&&v.num>=1) const manjianCoup = arr.filter(v => v.type == 1 && v.num >= 1)
let productCoup = arr.filter(v => v.type == 2) let productCoup = arr.filter(v => v.type == 2)
console.log(productCoup); console.log(productCoup);
//商品券分组 //商品券分组
let coupMap={} let coupMap = {}
for(let i in productCoup){ for (let i in productCoup) {
const coup=productCoup[i] const coup = productCoup[i]
if(coupMap.hasOwnProperty(coup.proId)){ if (coupMap.hasOwnProperty(coup.proId)) {
coupMap[coup.proId].push(coup) coupMap[coup.proId].push(coup)
}else{ } else {
coupMap[coup.proId]=[coup] coupMap[coup.proId] = [coup]
} }
} }
console.log(coupMap); console.log(coupMap);
for(let key in coupMap){ for (let key in coupMap) {
const arr=coupMap[key] const arr = coupMap[key]
for(let i in arr){ for (let i in arr) {
const coup=arr[i] const coup = arr[i]
const proCoupStartIndex=returnProCoupStartIndex(arr,i) const proCoupStartIndex = returnProCoupStartIndex(arr, i)
console.log(proCoupStartIndex); console.log(proCoupStartIndex);
const coupUseNum=returnProductCanUseNum($goodsPayPriceMap[coup.proId],proCoupStartIndex,coup.num) const coupUseNum = returnProductCanUseNum($goodsPayPriceMap[coup.proId], proCoupStartIndex,
const num=Math.min($goodsPayPriceMap[coup.proId].length,coupUseNum) coup.num)
coup.num=num const num = Math.min($goodsPayPriceMap[coup.proId].length, coupUseNum)
coup.discountAmount=returnProductCoupAllPrice($goodsPayPriceMap[coup.proId],proCoupStartIndex,num).toFixed(2) coup.num = num
coup.discountAmount = returnProductCoupAllPrice($goodsPayPriceMap[coup.proId],
proCoupStartIndex, num).toFixed(2)
} }
} }
productCoup=productCoup.filter(v=>v.num>=1) productCoup = productCoup.filter(v => v.num >= 1)
console.log(productCoup); console.log(productCoup);
pays.quan = [...manjianCoup, ...productCoup] pays.quan = [...manjianCoup, ...productCoup]
}) })
@@ -588,7 +605,7 @@
async function init() { async function init() {
const orderRes = await orderApi.tbOrderInfoDetail(order.orderId) const orderRes = await orderApi.tbOrderInfoDetail(order.orderId)
Object.assign(order, orderRes) Object.assign(order, orderRes)
$goodsPayPriceMap=returnGoodsPayPriceMap(order.detailList) $goodsPayPriceMap = returnGoodsPayPriceMap(order.detailList)
console.log($goodsPayPriceMap); console.log($goodsPayPriceMap);
if (orderRes.memberId) { if (orderRes.memberId) {
calcUsablePoints() calcUsablePoints()

View File

@@ -315,13 +315,21 @@
memberId: option.memberId memberId: option.memberId
}) })
canDikouGoodsArr = returnNewGoodsList(order.value.detailList || []) canDikouGoodsArr = returnNewGoodsList(order.value.detailList || [])
res.fullReductionCoupon = res.fullReductionCoupon.filter((v) => v.use && option.orderPrice * 1 >= v res.fullReductionCoupon = res.fullReductionCoupon.filter((v) => {
.fullAmount * 1) if(option.orderPrice<=0){
return false
}else{
return v.use && option.orderPrice * 1 >= v
.fullAmount * 1
}
})
res.productCoupon = res.productCoupon.map(v => { res.productCoupon = res.productCoupon.map(v => {
const calcCoup = returnProductCoupon(v, canDikouGoodsArr, user.value) const calcCoup = returnProductCoupon(v, canDikouGoodsArr, user.value)
return { return {
...calcCoup, ...calcCoup,
checked: false checked: false,
use:option.orderPrice<=0?false:v.use
} }
}).filter((v) => v.use); }).filter((v) => v.use);
$fullReductionCoupon = res.fullReductionCoupon $fullReductionCoupon = res.fullReductionCoupon

View File

@@ -231,3 +231,19 @@ export function returnCanUseFullReductionCoupon(coupArr, payPrice, selCoup) {
} }
}) })
} }
//根据商品数量还有商品券数量返回优惠券可以使用的数量数组
export function returnCanUseNumProductCoup(coupArr,){
let productCoup = coupArr.filter(v => v.type == 2)
//商品券分组
let coupMap={}
for(let i in productCoup){
const coup=productCoup[i]
if(coupMap.hasOwnProperty(coup.proId)){
coupMap[coup.proId].push(coup)
}else{
coupMap[coup.proId]=[coup]
}
}
return arr
}