This commit is contained in:
2024-11-20 16:48:33 +08:00
9 changed files with 351 additions and 146 deletions

View File

@@ -21,6 +21,9 @@ export function canTuiKuan(orderInfo, item) {
return orderInfo.status == 'closed' && item.status != 'return' && item.status != 'refund' && item.status !=
'refunding' && !item.userCouponId
}
export function isTuiCai(item) {
return item.status == 'return'
}
export function isTui(item) {
return item.status == 'return' || item.status == 'refund' || item.status == 'refunding'
}

View File

@@ -6,8 +6,8 @@
充值设置
</view>
<view class="boxconstantbox_tow">
<text>用户消费结账时成功充值成功</text>
<input class="text" v-model="form.rechargeTimes"></input>
<text>用户消费结账时成功充值</text>
<input class="number" v-model="form.rechargeTimes"></input>
<text>倍的金额本单即可享受免单</text>
</view>
</view>
@@ -17,7 +17,7 @@
</view>
<view class="boxconstantbox_tow">
<text>订单支付金额需满</text>
<input class="text" v-model="form.rechargeThreshold"></input>
<input class="number" v-model="form.rechargeThreshold"></input>
<text> 才能使用</text>
</view>
</view>

View File

@@ -17,15 +17,17 @@
<!-- <view class="headeimg">
<image class="img" :src="user.headImg" mode=""></image>
</view> -->
<view class="u-m-l-20">{{user.nickName}}</view>
<view class="color-main u-m-l-10 u-font-24">{{user.isVip?'会员':'' }}</view>
<view class="u-font-24 u-m-l-30"><text>余额</text><text
<view class="u-m-l-20">
<!-- <view class="color-main u-font-24 no-wrap">{{user.isVip?'会员':'' }}</view> -->
<view class="">{{user.nickName}}</view>
</view>
<view class="u-font-24 u-m-l-30 u-text-center"><text>余额</text><text
class="color-main">{{user.amount}}</text>
</view>
<view class="u-font-24 u-m-l-30"><text>积分</text><text
<view class="u-font-24 u-m-l-30 u-text-center"><text>积分</text><text
class="color-main">{{user.accountPoints}}</text></view>
</view>
<uni-icons type="right" color="#999" size="16"></uni-icons>
<uni-icons type="right" color="#999" size="20" bold></uni-icons>
</view>
</view>
<view class=" ">
@@ -168,7 +170,7 @@
</view>
</template>
<template v-else>
<template v-if="isVip&&item.memberPrice&&item.memberPrice!=item.salePrice">
<template v-if="isVip&&item.memberPrice&&item.memberPrice*1!=item.salePrice*1">
<text
class="line-th color-999">{{formatPrice(item.salePrice*item.number) }}</text>
<view class="u-absolute" style="right: 0;bottom: 100%;">
@@ -239,10 +241,17 @@
<view class="u-flex u-row-right u-m-t-38">
<view class="u-flex u-row-between u-m-t-38">
<!-- <template v-if="$shop.registerType=='munchies'">
<view class="color-main" @tap="showModel('editMoney')">修改</view>
</template> -->
<view class="u-flex">
<view class="u-flex price" v-if="youhui*1>0">
<view class="">优惠金额</view>
<view class="font-bold u-font-32">{{formatPrice(youhui) }}</view>
</view>
</view>
<view class="u-flex price u-m-l-32">
<view class="">实收金额</view>
<view class="font-bold u-font-32">{{formatPrice(allPrice) }}</view>
@@ -512,7 +521,7 @@
totalAmount: 0,
})
const isVip=computed(()=>{
return $shop.isMemberPrice&& user.value&&user.value.id&&user.value.isVip
return $shop.value.isMemberPrice&& user.value&&user.value.id&&user.value.isVip
})
const goodsPrice = computed(() => {
const goodsTotalPrice = goods.list.reduce((prve, cur) => {
@@ -532,6 +541,19 @@
// }, 0)
// return (goodsTotalPrice + ($seatFee.totalAmount || 0)).toFixed(2)
})
const youhui=computed(()=>{
if(user.value&&user.value.id&&user.value.isVip){
const goodsTotalPrice = goods.list.reduce((prve, cur) => {
const tPrice = cur.salePrice * cur.number
const tpackFee = cur.isPack ? cur.packFee * 1 : 0
return prve + tPrice + tpackFee
}, 0)
return goodsTotalPrice-allPrice.value
}else{
return 0
}
return goodsTotalPrice
})
function setGoodsItem(key, val) {
item[key] = val

View File

@@ -53,12 +53,7 @@
returnCanComputedGoodsArr,canComputedPackFee,
returnPackFee
} from '@/commons/utils/goodsUtil.js'
function extraCanTuicai(orderInfo,data){
return orderInfo.status=='unpaid'&&data.status!='return'&&data.priceAmount*1>0
}
function extraCanTuiKuan(orderInfo,data){
return orderInfo.status=='closed'&&data.status!='return'&&data.priceAmount*1>0
}
const props = defineProps({
data: {
type: Object,
@@ -77,6 +72,12 @@
default: () => {}
}
})
function extraCanTuicai(orderInfo,data){
return orderInfo.status=='unpaid'&&data.status!='return'&&data.priceAmount*1>0
}
function extraCanTuiKuan(orderInfo,data){
return orderInfo.status=='closed'&&data.status!='refund'&&data.priceAmount*1>0
}
const packeNumbber = computed(() => {
if (!props.orderInfo.detailList) {
return 0

View File

@@ -58,7 +58,7 @@
<view class="u-text-right u-m-t-28">
<template v-if="isTui(item)">
<view>0.00</view>
<view class="line-th color-666 ">{{returnTotalMoney(item)}}
<view class="line-th color-666 " >{{returnTotalMoney(item)}}
</view>
</template>
<template v-else-if="isGift(item)||item.userCouponId">
@@ -67,7 +67,8 @@
</view>
</template>
<template v-else>
<template v-if="user.isVip&&item.isMember&&returnVipMoney(item)>0&&returnVipMoney(item)!=returnTotalMoney(item)">
<template
v-if="user.isVip&&item.isMember&&returnVipMoney(item)>0&&returnVipMoney(item)!=returnTotalMoney(item)">
<view>{{returnVipMoney(item)}}</view>
<view class=" color-666 line-th">
{{returnTotalMoney(item)}}</view>
@@ -120,21 +121,21 @@
<view class="u-flex">
<view class="u-flex u-m-r-24" v-if="youhuiAllPrice>0">
<view class="color-red u-m-r-6 " >
<view class="color-red u-m-r-6 ">
已优惠{{youhuiAllPrice}}
</view>
<up-icon name="info-circle" color="#999" :size="14" @click="youhuiDetailShow"></up-icon>
</view>
<view>
<text>小计</text>
<text class="font-bold u-font-32">{{allPrice}}</text>
</view>
</view>
</view>
<template v-if="orderInfo.status=='refund'">
<template v-if="orderInfo.refundAmount">
<view class="u-flex u-row-between u-m-t-32">
<view>退款金额</view>
<view class="color-999">
@@ -165,40 +166,47 @@
<my-button @tap="printOrder" type="cancel" :color="color.ColorMain">重新打印</my-button>
</view>
</view>
<up-popup :round="10" :show="pop.youhui" mode="center" closeOnClickOverlay @close="youhuiDetailHide" >
<up-popup :round="10" :show="pop.youhui" mode="center" closeOnClickOverlay @close="youhuiDetailHide">
<view class="u-p-30" style="width: 80vw;">
<view class="font-bold u-text-center">优惠详情</view>
<view class="u-m-t-32">
<!-- <view class="u-flex u-row-between u-m-b-18">
<view class="u-flex u-row-between u-m-b-18">
<view>会员优惠</view>
<view class="color-red">
<text></text>
<text>{{vipDiscountPrice}}</text>
</view>
</view> -->
<view class="u-flex u-row-between ">
</view>
<view class="u-flex u-row-between u-m-b-18" v-if="orderInfo.discountAmount*1>0">
<view>打折</view>
<view class="color-red">
<text></text>
<text>{{to2(orderInfo.discountAmount) }}</text>
</view>
</view>
<view class="u-flex u-row-between " v-if="orderInfo.fullCouponDiscountAmount*1>0">
<view>满减券抵扣</view>
<view class="color-red">
<text></text>
<text>{{orderInfo.fullCouponDiscountAmount}}</text>
<text>{{to2(orderInfo.fullCouponDiscountAmount) }}</text>
</view>
</view>
<view class="u-flex u-row-between u-m-t-18">
<view class="u-flex u-row-between u-m-t-18"
v-if="orderInfo.productCouponDiscountAmount||productCoupPrice*1>0">
<view>商品券抵扣</view>
<view class="color-red">
<text></text>
<text>{{orderInfo.productCouponDiscountAmount||productCoupPrice}}</text>
<text> {{to2(orderInfo.productCouponDiscountAmount||productCoupPrice) }}</text>
</view>
</view>
<view class="u-flex u-row-between u-m-t-18">
<view class="u-flex u-row-between u-m-t-18" v-if="orderInfo.pointsDiscountAmount">
<view>积分抵扣</view>
<view class="color-red">
<text></text>
<text>{{orderInfo.pointsDiscountAmount}}</text>
<text>{{to2(orderInfo.pointsDiscountAmount) }}</text>
</view>
</view>
</view>
</view>
</up-popup>
@@ -207,26 +215,31 @@
<script setup>
import {
computed, reactive
computed,
reactive
} from 'vue';
import color from '@/commons/color.js'
import {
hasPermission
} from '@/commons/utils/hasPermission.js'
import {
isTui,isGift,
isTui,
isTuiCai,
isGift,
canTuiKuan,
canTuicai,
numSum
} from '@/commons/utils/goodsUtil.js'
const pop=reactive({
youhui:false
const pop = reactive({
youhui: false
})
function youhuiDetailShow(){
pop.youhui=true
function youhuiDetailShow() {
pop.youhui = true
}
function youhuiDetailHide(){
pop.youhui=false
function youhuiDetailHide() {
pop.youhui = false
}
const props = defineProps({
orderInfo: {
@@ -292,7 +305,7 @@
if (!props.seatFee.priceAmount) {
return 0
}
const n = props.seatFee.priceAmount * (props.seatFee.status == 'return' ? 0 : 1)
const n = props.seatFee.priceAmount * (isTui(props.seatFee) ? 0 : 1)
return n.toFixed(2)
})
const goodsOriginAllPrice = computed(() => {
@@ -305,12 +318,13 @@
}, 0)
return goodsPrice.toFixed(2)
})
const freePrice = computed(() => {
const goodsPrice = props.data.reduce((prve, cur) => {
const curTotal = cur.info.filter(v => v.gift == true || isTui(v)).reduce((a,
const curTotal = cur.info.filter(v => v.gift == true || isGift(v)).reduce((a,
b) => {
return a + (b.num * b.price)
const price = (b.isMember && b.memberPrice) ? b.memberPrice : b.price
return a + (b.num * price)
}, 0)
return prve + curTotal
}, 0)
@@ -321,35 +335,43 @@
return 0
}
const goodsPrice = props.data.reduce((prve, cur) => {
const curTotal = cur.info.filter(v => v.gift != true && v.status !== "return" &&!v.userCouponId&&(v.isMember&&v.memberPrice)&&(v.memberPrice!=v.price)).reduce((a,
const curTotal = cur.info.filter(v => v.gift != true && v.status !== "return" && !v
.userCouponId && (v.isMember && v.memberPrice) && (v.memberPrice != v.price)).reduce((
a,
b) => {
return a + (b.num * (b.price-b.memberPrice))
return a + (b.num * (b.price - b.memberPrice))
}, 0)
return prve + curTotal
}, 0)
return goodsPrice.toFixed(2)
})
const productCoupPrice=computed(()=>{
if(props.orderInfo.status=='closed'){
const productCoupPrice = computed(() => {
if (props.orderInfo.status == 'closed') {
return props.orderInfo.productCouponDiscountAmount
}
const goodsPrice = props.data.reduce((a, b) => {
const curTotal = b.info.filter(v => v.gift != true&& v.userCouponId).reduce((prve,
const curTotal = b.info.filter(v => v.gift != true && v.userCouponId).reduce((prve,
cur) => {
const isVip=props.user.isVip&&cur.isMember
const memberPrice=cur.memberPrice?cur.memberPrice:cur.price
const price=isVip?memberPrice:cur.price
const curTotal=price*cur.num
return prve+curTotal
const isVip = props.user.isVip && cur.isMember
const memberPrice = cur.memberPrice ? cur.memberPrice : cur.price
const price = isVip ? memberPrice : cur.price
const curTotal = price * cur.num
return prve + curTotal
}, 0)
return a + curTotal
}, 0)
return goodsPrice.toFixed(2)
})
const youhuiAllPrice=computed(()=>{
return (freePrice.value*1+vipDiscountPrice.value*1+props.orderInfo.fullCouponDiscountAmount+props.orderInfo.pointsDiscountAmount+productCoupPrice.value*1).toFixed(2)
const youhuiAllPrice = computed(() => {
console.log(freePrice.value * 1 , vipDiscountPrice.value * 1 , props.orderInfo.fullCouponDiscountAmount ,props
.orderInfo.pointsDiscountAmount , productCoupPrice.value * 1 , props.orderInfo.discountAmount);
return (freePrice.value * 1 + vipDiscountPrice.value * 1 + props.orderInfo.fullCouponDiscountAmount + props
.orderInfo.pointsDiscountAmount + productCoupPrice.value * 1 + (props.orderInfo.discountAmount ||
0)).toFixed(2)
})
const packFee = computed(() => {
const goodsPrice = props.data.reduce((prve, cur) => {
@@ -363,8 +385,8 @@
})
const allPrice = computed(() => {
const n=goodsOriginAllPrice.value-youhuiAllPrice.value
return (n<0?0:n).toFixed(2)
const n = goodsOriginAllPrice.value - youhuiAllPrice.value
return (n < 0 ? 0 : n).toFixed(2)
})
const goodsNumber = computed(() => {

View File

@@ -48,7 +48,7 @@
</view>
</view>
</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()">
<text class="line-th">{{goodsPriceAmount(item)}}</text>
<view class="u-absolute" style="bottom: 100%;right: 0;">
@@ -164,7 +164,7 @@
}
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)
}
// const packeFee=computed(()=>{

View File

@@ -46,15 +46,22 @@
<view class="u-m-l-18">{{item.name}}</view>
<view class="u-m-l-18 color-999">x{{item.num}}</view>
</view>
<view class="color-red">
-{{item.discountAmount}}
<view class="u-flex">
<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 class="border-bottom u-p-b-30" v-if="discount.price||accountPoints.sel">
<view class="border-bottom u-p-b-30" v-if="(discount.price&&discount.currentPrice!=order.amount)||accountPoints.sel">
<view class="u-flex u-p-l-24 u-p-r-24 u-row-between u-p-t-30 "
v-if="discount.price&&discount.currentPrice!=order.amount">
<view>服务员改价</view>
@@ -77,7 +84,7 @@
<my-tabs :list="pays.list" v-model="pays.selIndex"></my-tabs>
<template v-if="pays.selIndex==0">
<view class="list">
<view class="item" @click="changePayType(index,item)"
<view class="item" @click="changePayType(index,item)" :class="{disabled:item.disabled}"
v-for="(item,index) in pays.payTypes.list" :key="index">
<view class="u-flex u-row-between u-p-t-30 u-p-b-30 border-bottom">
<view class="u-flex">
@@ -99,16 +106,18 @@
<text>{{user.accountPoints||'0'}}</text>
</view> -->
</view>
<my-radio @click="changePayType(index,item)"
:modelValue="index==pays.payTypes.selIndex">
</my-radio>
<view :class="{op3:item.disabled}">
<my-radio @click="changePayType(index,item)"
:modelValue="index==pays.payTypes.selIndex">
</my-radio>
</view>
</view>
</view>
</view>
</view>
<view class="border-bottom-dashed "></view>
<view class="u-flex u-row-between u-p-t-24" v-if="user.id&&user.accountPoints"
@click="changeAccountPoints">
<view class="u-flex u-row-between u-p-t-24" v-if="user.id" @click="changeAccountPoints">
<view class="u-flex ">
<view class="">积分抵扣</view>
<view class="color-999 u-m-l-10">
@@ -120,9 +129,9 @@
</view>
<view class="u-flex">
<view class="u-flex" @click.stop="refPointsOpen">
<view class="u-flex">
<view><text>{{accountPoints.num}}</text></view>
<view v-if="accountPoints.calcRes.usable">
<view v-if="accountPoints.calcRes.usable" @click.stop="refPointsOpen">
<up-icon name="edit-pen" size="16" color="#999"></up-icon>
</view>
</view>
@@ -196,7 +205,12 @@
<edit-discount @confirm="editDiscountConfirm" title="优惠金额" :ref="setModel" name="editMoney"
:price="order.amount"></edit-discount>
<edit-accountPoints @confirm="pointsConfirm" :price="accountPoints.num" :accountPoints="accountPoints" ref="refPoints"></edit-accountPoints>
<up-modal :title="modal.title" :content="modal.content" :show="modal.show" :confirmText="modal.confirmText"
:cancelText="modal.cancelText" showCancelButton closeOnClickOverlay @confirm="confirmModelConfirm"
@cancel="confirmModelCancel" @close="confirmModelCancel" width="300px" />
<edit-accountPoints @confirm="pointsConfirm" :price="accountPoints.num" :accountPoints="accountPoints"
ref="refPoints"></edit-accountPoints>
</view>
</template>
@@ -227,13 +241,49 @@
import editDiscount from '@/components/my-components/edit-discount.vue'
import editAccountPoints from './components/edit-accountPoints.vue'
import {
returnGoodsPayPriceMap,returnProCoupStartIndex ,returnProductCoupAllPrice
returnGoodsPayPriceMap,
returnProCoupStartIndex,
returnProductCoupAllPrice,
returnProductCanUseNum
} from '../quan_util.js'
const modal = reactive({
title: '提示',
cancelText: '取消',
confirmText: '确认',
content: '',
key: 'cash',
show: false,
data: ''
})
function confirmModelCancel() {
modal.show=false
modal.key=''
modal.data=''
}
function cashConfirmShow() {
modal.content = '是否确认已现金收款' + payPrice.value
modal.key='cash'
modal.show=true
}
async function confirmModelConfirm() {
if (modal.key == 'cash') {
await pay()
confirmModelCancel()
}
}
//商品数量从0到n每一个对应的价格
let $goodsPayPriceMap={}
let $goodsPayPriceMap = {}
const refPoints = ref(null)
function delQuan(i) {
pays.quan.splice(i, 1)
}
function refPointsOpen() {
if (!accountPoints.calcRes.usable && accountPoints.sel) {
return
@@ -251,8 +301,9 @@
},
price: 0
})
function pointsConfirm(e){
accountPoints.num=e
function pointsConfirm(e) {
accountPoints.num = e
}
async function calcUsablePoints() {
if (!order.memberId) {
@@ -308,7 +359,7 @@
go.to('PAGES_ORDER_QUAN', {
orderId: order.id,
memberId: order.memberId,
orderPrice: payPrice.value*1+coupAllPrice.value*1
orderPrice: payPrice.value * 1 + coupAllPrice.value * 1
})
}
async function discountShow() {
@@ -395,29 +446,35 @@
uni.$off('choose-quan')
uni.$on('choose-quan', (arr) => {
console.log(arr);
const manjianCoup = arr.filter(v => v.type == 1&&v.num>=1)
let productCoup = arr.filter(v => v.type == 2&&v.num>=1)
const manjianCoup = arr.filter(v => v.type == 1 && v.num >= 1)
let productCoup = arr.filter(v => v.type == 2)
console.log(productCoup);
//商品券分组
let coupMap={}
for(let i in productCoup){
const coup=productCoup[i]
if(coupMap.hasOwnProperty(coup.proId)){
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]
} else {
coupMap[coup.proId] = [coup]
}
}
for(let key in coupMap){
const arr=coupMap[key]
for(let i in arr){
const coup=arr[i]
const proCoupStartIndex=returnProCoupStartIndex(arr,i)
const num=Math.min($goodsPayPriceMap[coup.proId].length,coup.num)
coup.num=num
coup.discountAmount=returnProductCoupAllPrice($goodsPayPriceMap[coup.proId],proCoupStartIndex,num).toFixed(2)
console.log(coupMap);
for (let key in coupMap) {
const arr = coupMap[key]
for (let i in arr) {
const coup = arr[i]
const proCoupStartIndex = returnProCoupStartIndex(arr, i)
console.log(proCoupStartIndex);
const coupUseNum = returnProductCanUseNum($goodsPayPriceMap[coup.proId], proCoupStartIndex,
coup.num)
const num = Math.min($goodsPayPriceMap[coup.proId].length, coupUseNum)
coup.num = num
coup.discountAmount = returnProductCoupAllPrice($goodsPayPriceMap[coup.proId],
proCoupStartIndex, num).toFixed(2)
}
}
productCoup = productCoup.filter(v => v.num >= 1)
console.log(productCoup);
pays.quan = [...manjianCoup, ...productCoup]
})
@@ -459,7 +516,7 @@
//打折相关数据
const discount = reactive({
discount: 100
})
function editDiscountConfirm(form) {
@@ -470,10 +527,18 @@
async function getPayType() {
const payTypeList = await Api.$getPayType()
pays.payTypes.list = payTypeList
pays.payTypes.list = payTypeList.map(v => {
return {
...v,
disabled: false
}
})
}
function changePayType(i, item) {
if (item.disabled) {
return infoBox.showToast(item.payName + '不可用')
}
pays.payTypes.selIndex = i
if (item.payType == 'vipPay') {
chooseUser()
@@ -501,6 +566,9 @@
if (payType == 'scanCode' || payType == 'deposit') {
return saomaPay()
}
if (payType == 'cash' && payPrice.value * 1 > 0) {
return cashConfirmShow()
}
payOrder()
}
const tipsMap = {
@@ -513,33 +581,39 @@
infoBox.showToast('余额不足')
return
}
if (payStatus) {
return infoBox.showToast(tipsMap[payStatus])
}
try {
payStatus = 'paying'
await Api.$payOrder({
tableId: order.tableId,
masterId: order.masterId,
orderId: order.id || order.orderId,
payType,
vipUserId: order.memberId,
discount: 1,
code: '',
pointsNum: accountPoints.sel ? accountPoints.num : 0,
userCouponInfos: pays.quan.map(v => {
return {
userCouponId: v.id,
num: v.num
}
})
})
paySuccess()
pay()
} catch (e) {
//TODO handle the exception
payStatus = ''
}
}
async function pay(par) {
const payType = pays.payTypes.list[pays.payTypes.selIndex].payType
payStatus = 'paying'
await Api.$payOrder({
tableId: order.tableId,
masterId: order.masterId,
orderId: order.id || order.orderId,
payType,
vipUserId: order.memberId,
discount: discount.discount / 100,
code: '',
pointsNum: accountPoints.sel ? accountPoints.num : 0,
userCouponInfos: pays.quan.map(v => {
return {
userCouponId: v.id,
num: v.num
}
}),
...par
})
paySuccess()
}
const order = reactive({
amount: 0
@@ -554,15 +628,7 @@
success: function(res) {
console.log('条码类型:' + res.scanType);
console.log('条码内容:' + res.result);
Api.$payOrder({
"orderId": order.orderId, // 订单id
"payType": item.payType, //
"discount": order.discount,
"code": res.result
}).then(res => {
console.log(res);
paySuccess()
})
pay({code: res.result})
}
});
}
@@ -584,7 +650,7 @@
async function init() {
const orderRes = await orderApi.tbOrderInfoDetail(order.orderId)
Object.assign(order, orderRes)
$goodsPayPriceMap=returnGoodsPayPriceMap(order.detailList)
$goodsPayPriceMap = returnGoodsPayPriceMap(order.detailList)
console.log($goodsPayPriceMap);
if (orderRes.memberId) {
calcUsablePoints()
@@ -616,8 +682,24 @@
const calcPrice = discountPrice - coupAllPrice.value - accountPoints.price * (accountPoints.sel ? 1 : 0)
return (calcPrice <= 0 ? 0 : calcPrice).toFixed(2)
})
watch(() => payPrice.value, () => {
watch(() => payPrice.value, (newval) => {
getPayUrl()
if (newval <= 0) {
const arr = ['cash', 'vipPay']
pays.payTypes.list.map(v => {
if (arr.includes(v.payType)) {
v.disabled = false
} else {
v.disabled = true
}
})
const index = pays.payTypes.list.findIndex(v => !v.disabled)
pays.payTypes.selIndex = index
} else {
pays.payTypes.list.map(v => {
v.disabled = false
})
}
})
const pointCanDicountPrice = computed(() => {
const discountPrice = discount.currentPrice ? discount.currentPrice : order.amount
@@ -645,6 +727,10 @@
<style lang="scss" scoped>
$quan-color: #318AFE;
.op3 {
opacity: .3;
}
.hui {
// background-color: $quan-color;
background-image: linear-gradient(to right bottom, rgb(254, 103, 4), rgb(241, 50, 42));
@@ -676,6 +762,12 @@
}
.list {
.item {
&.disabled {
color: #999;
}
}
.item:last-child {
.border-bottom {
border-bottom: none;

View File

@@ -21,7 +21,8 @@
</view>
<view class=" u-m-t-20 u-flex">
<view>有效期:</view>
<view class="u-font-24 u-m-l-6"> {{dayjs(item.endTime).format('YYYY-MM-DD HH:mm:ss') }}</view>
<view class="u-font-24 u-m-l-6"> {{dayjs(item.endTime).format('YYYY-MM-DD HH:mm:ss') }}
</view>
</view>
<view class="u-m-t-10 color-999 u-font-24">
{{ formatStr(item.useRestrictions)}}
@@ -65,7 +66,8 @@
</view>
<view class=" u-m-t-14 u-flex">
<view>有效期:</view>
<view class="u-font-24 u-m-l-6"> {{dayjs(item.endTime).format('YYYY-MM-DD HH:mm:ss') }}</view>
<view class="u-font-24 u-m-l-6"> {{dayjs(item.endTime).format('YYYY-MM-DD HH:mm:ss') }}
</view>
</view>
<view class="u-m-t-10 color-999 u-font-24">
{{ formatStr(item.useRestrictions)}}
@@ -92,7 +94,7 @@
<view :style="{height:safebottomHeight+'px'}"></view>
<view class="fixed-b bottom safe-bottom border-top">
<view class="u-m-b-32 u-flex u-row-between u-p-t-10">
<view class="u-flex">
<text>抵扣金额</text>
@@ -103,7 +105,8 @@
<text>支付金额</text>
<text class="color-red"></text>
<text class="color-red">{{payPrice }}</text>
<view class="u-absolute u-flex u-row-between" style="bottom: 100%;right: 0;" v-if="payPrice*1!=option.orderPrice*1">
<view class="u-absolute u-flex u-row-between" style="bottom: 100%;right: 0;"
v-if="payPrice*1!=option.orderPrice*1">
<view class="u-flex line-th color-999">
<text class=""></text>
<text class="">{{option.orderPrice}}</text>
@@ -229,13 +232,18 @@
if (!item.use) {
return
}
console.log();
if (myQuan.fullReductionCouponSel.id && !item.checked) {
const goodsQuan = myQuan.res.productCoupon.filter(v => v.checked)
const fullReductionCoupon = myQuan.fullReductionCouponSel.id ? [myQuan.fullReductionCouponSel] : []
let coupArr = [...goodsQuan, item]
const payPrice = option.orderPrice - returnCouponAllPrice(coupArr, canDikouGoodsArr, user.value)
console.log(payPrice);
if (payPrice<=0) {
modal.content = '选择该商品券后支付金额将为0继续选择将取消选择的满减券'
modal.cancelText = '取消'
modal.confirmText = '继续选择'
setModalShow('clear', true, item)
return
}
if (myQuan.fullReductionCouponSel.fullAmount > payPrice) {
modal.content = '选择该商品券后将不满足选择抵扣券的最低满减需求,继续选择将取消选择的满减券'
modal.cancelText = '取消'
@@ -247,11 +255,18 @@
item.checked = !item.checked
const CheckedArr = myQuan.res.productCoupon.filter(v => v.checked)
if (CheckedArr.length <= 0) {
return myQuan.res.productCoupon.map(v => {
v.use = true
})
}
const noCheckedArr = myQuan.res.productCoupon.filter(v => !v.checked)
noCheckedArr.map(v => {
console.log(returnCoupCanUse(canDikouGoodsArr, v, CheckedArr));
v.use = returnCoupCanUse(canDikouGoodsArr, v, CheckedArr)
})
}
function changeFullReductionCouponSel(item) {
@@ -263,10 +278,11 @@
myQuan.fullReductionCouponSel = {
id: ''
}
}else{
} else {
myQuan.fullReductionCouponSel = item
}
myQuan.res.fullReductionCoupon=returnCanUseFullReductionCoupon($fullReductionCoupon, payPrice.value, myQuan.fullReductionCouponSel)
myQuan.res.fullReductionCoupon = returnCanUseFullReductionCoupon($fullReductionCoupon, payPrice.value, myQuan
.fullReductionCouponSel)
}
function formatStr(str) {
@@ -299,13 +315,21 @@
memberId: option.memberId
})
canDikouGoodsArr = returnNewGoodsList(order.value.detailList || [])
res.fullReductionCoupon = res.fullReductionCoupon.filter((v) => v.use && option.orderPrice * 1 >= v
.fullAmount * 1)
res.fullReductionCoupon = res.fullReductionCoupon.filter((v) => {
if(option.orderPrice<=0){
return false
}else{
return v.use && option.orderPrice * 1 >= v
.fullAmount * 1
}
})
res.productCoupon = res.productCoupon.map(v => {
const calcCoup = returnProductCoupon(v, canDikouGoodsArr, user.value)
return {
...calcCoup,
checked: false
checked: false,
use:option.orderPrice<=0?false:v.use
}
}).filter((v) => v.use);
$fullReductionCoupon = res.fullReductionCoupon
@@ -316,7 +340,7 @@
const option = reactive({
orderId: '',
memberId: '',
orderPrice:0
orderPrice: 0
})
function toEmitChooseQuan(item) {
@@ -339,13 +363,14 @@
let coupArr = [...fullReductionCoupon, ...goodsQuan]
return returnCouponAllPrice(coupArr, canDikouGoodsArr, user.value)
})
const payPrice=computed(()=>{
const pay= option.orderPrice-discountAmount.value
return (pay<0?0:pay).toFixed(2)
const payPrice = computed(() => {
const pay = option.orderPrice - discountAmount.value
return (pay < 0 ? 0 : pay).toFixed(2)
})
watch(() => myQuan.types.sel, (newval) => {
if (newval == 0) {
myQuan.res.fullReductionCoupon = returnCanUseFullReductionCoupon($fullReductionCoupon, payPrice.value, myQuan.fullReductionCouponSel)
myQuan.res.fullReductionCoupon = returnCanUseFullReductionCoupon($fullReductionCoupon, payPrice.value,
myQuan.fullReductionCouponSel)
}
if (newval == 1) {

View File

@@ -40,7 +40,8 @@ export function returnCoupCanUse(goodsArr = [], coup, selCoupArr = []) {
if (selCoupNumber >= findGoodsTotalNumber) {
return false
}
return findGoodsTotalNumber < (coup.num + selCoupNumber) ? false : true
console.log(selCoupNumber,findGoodsTotalNumber);
return findGoodsTotalNumber < selCoupNumber ? false : true
}
//查找购物车商品根据购物车商品数据返回商品券信息(抵扣价格以及是否满足可用需求)
export function returnProductCoupon(coup, goodsArr, vipUser, selCoupArr = []) {
@@ -101,6 +102,23 @@ export function returnProductCoupAllPrice(productPriceArr,startIndex,num){
return prve+curPrice
},0)
}
//返回商品券可抵扣的商品数量
export function returnProductCanUseNum(productPriceArr,startIndex,num){
console.log(productPriceArr);
console.log(num);
let n=0;
for(let i=0;i<num;i++){
if(productPriceArr[startIndex*1+i]){
n+=1
console.log(n);
}else{
break
}
}
return n
}
//返回同类商品券在同类商品价格数组里的开始位置
export function returnProCoupStartIndex(coupArr,index){
return coupArr.slice(0,index).reduce((prve,cur)=>{
@@ -201,9 +219,31 @@ export function returnCanUseFullReductionCoupon(coupArr, payPrice, selCoup) {
return v
}
const isfullAmount = payPrice >= v.fullAmount * 1
if(payPrice<=0){
return {
...v,
use: false
}
}
return {
...v,
use: v.use && isfullAmount
}
})
}
//根据商品数量还有商品券数量返回优惠券可以使用的数量数组
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
}