This commit is contained in:
魏啾 2024-11-22 10:03:22 +08:00
commit 433479fee7
17 changed files with 481 additions and 232 deletions

View File

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

View File

@ -17,10 +17,10 @@ import infoBox from "@/commons/utils/infoBox.js"
import go from '@/commons/utils/go.js'; import go from '@/commons/utils/go.js';
import { reject } from 'lodash'; import { reject } from 'lodash';
// 测试服 // 测试服
let baseUrl = 'https://admintestpapi.sxczgkj.cn' // let baseUrl = 'https://admintestpapi.sxczgkj.cn'
//预发布 //预发布
// let baseUrl = 'https://pre-cashieradmin.sxczgkj.cn' let baseUrl = 'https://pre-cashieradmin.sxczgkj.cn'
//正式 //正式
// let baseUrl = 'https://cashieradmin.sxczgkj.cn' // let baseUrl = 'https://cashieradmin.sxczgkj.cn'

View File

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

View File

@ -8,9 +8,9 @@
</view> </view>
</view> </view>
<view class="item"> <view class="item">
<view class="lable">使用门槛</view> <view class="lable">使用门槛2</view>
<view class="value"> <view class="value">
<view></view><input v-model="formData.fullAmount" placeholder="填写金额" border="none"></input><view>元</view><view>减</view><input v-model="formData.discountAmount" placeholder="填写金额" border="none"></input><view></view> <view></view><input v-model="formData.fullAmount" type="number" placeholder="填写金额" border="none"></input><view>元</view><view>减</view><input v-model="formData.discountAmount" type="number" placeholder="填写金额" border="none"></input><view></view>
</view> </view>
</view> </view>
</view> </view>
@ -35,13 +35,15 @@
<view class="item"> <view class="item">
<view class="lable">有效期</view> <view class="lable">有效期</view>
<view class="value"> <view class="value">
<up-input v-model="formData.validDays" placeholder="填写天数" border="none"></up-input> <up-input v-model="formData.validDays" type="number" placeholder="填写天数" border="none"></up-input>
</view> </view>
</view> </view>
<view class="item"> <view class="item">
<view class="lable">隔天生效<up-icon @click="modalShow(1)" name="question-circle" color="#999" size="20" style="margin-left: 10rpx;"></up-icon></view> <view class="lable">隔天生效
<!-- <up-icon @click="modalShow(1)" name="question-circle" color="#999" size="20" style="margin-left: 10rpx;"></up-icon> -->
</view>
<view class="value"> <view class="value">
<view></view><input v-model="formData.daysToTakeEffect" placeholder="填写天数" border="none" ></input><view>天生效</view> <view></view><input v-model="formData.daysToTakeEffect" type="number" placeholder="填写天数" border="none" ></input><view>天生效</view>
</view> </view>
</view> </view>
<view class="item"> <view class="item">
@ -79,7 +81,7 @@
<view class="card"> <view class="card">
<view class="item"> <view class="item">
<view class="lable">总发放数量 <view class="lable">总发放数量
<up-icon @click="modalShow(2)" name="question-circle" color="#999" size="20" style="margin-left: 10rpx;"></up-icon> <!-- <up-icon @click="modalShow(2)" name="question-circle" color="#999" size="20" style="margin-left: 10rpx;"></up-icon> -->
</view> </view>
<view class="value"> <view class="value">
<up-input v-model="formData.number" placeholder="填写数量" border="none" clearable ></up-input> <up-input v-model="formData.number" placeholder="填写数量" border="none" clearable ></up-input>
@ -311,6 +313,7 @@
height: 150rpx; height: 150rpx;
width: 100%; width: 100%;
background-color: #fff; background-color: #fff;
z-index: 9;
>button { >button {
width: 530rpx; width: 530rpx;
margin: 30rpx 0; margin: 30rpx 0;

View File

@ -10,13 +10,13 @@
<view class="item"> <view class="item">
<view class="lable">使用门槛</view> <view class="lable">使用门槛</view>
<view class="value"> <view class="value">
<view></view><input v-model="formData.fullAmount" placeholder="填写金额" border="none"></input><view>可用</view> <view></view><input v-model="formData.fullAmount" type="number" placeholder="填写金额" border="none"></input><view>可用</view>
</view> </view>
</view> </view>
<view class="item"> <view class="item">
<view class="lable">总发放数量</view> <view class="lable">总发放数量</view>
<view class="value"> <view class="value">
<up-input v-model="formData.number" placeholder="填写数量" border="none" clearable ></up-input> <up-input v-model="formData.number" type="number" placeholder="填写数量" border="none" clearable ></up-input>
</view> </view>
</view> </view>
</view> </view>

View File

@ -36,10 +36,10 @@
<view v-if="item.type == 1"> {{ item.fullAmount }} 元减 {{ item.discountAmount }} </view> <view v-if="item.type == 1"> {{ item.fullAmount }} 元减 {{ item.discountAmount }} </view>
<view v-if="item.type == 2"> {{ item.fullAmount }} 元可用 </view> <view v-if="item.type == 2"> {{ item.fullAmount }} 元可用 </view>
</view> </view>
<view> <!-- <view>
<view> 领取方式 </view> <view> 领取方式 </view>
<view> 用户不可自行领取 </view> <view> 用户不可自行领取 </view>
</view> </view> -->
<view v-if="item.type == 1"> <view v-if="item.type == 1">
<view> 有效期 </view> <view> 有效期 </view>
<view> 领券后{{ item.validDays }}天过期 </view> <view> 领券后{{ item.validDays }}天过期 </view>
@ -197,7 +197,7 @@
padding: 32rpx 28rpx; padding: 32rpx 28rpx;
background-color: #fff; background-color: #fff;
position: fixed; position: fixed;
top: 79rpx; top: 0rpx;
z-index: 999; z-index: 999;
.tag-item { .tag-item {
display: inline-block; display: inline-block;
@ -253,7 +253,7 @@
/* height: 544rpx; */ /* height: 544rpx; */
margin: 32rpx auto 0; margin: 32rpx auto 0;
margin-bottom: 32rpx; margin-bottom: 32rpx;
padding: 122rpx 28rpx 182rpx 28rpx; padding: 70rpx 28rpx 182rpx 28rpx;
} }
.couponContent { .couponContent {
/* background-color: #f9f9f9; */ /* background-color: #f9f9f9; */

View File

@ -164,11 +164,11 @@
icon: '/static/indexImg/icon-line-up.svg', icon: '/static/indexImg/icon-line-up.svg',
pageUrl: 'PAGES_LINE_UP' pageUrl: 'PAGES_LINE_UP'
}, },
// { {
// title: '', title: '霸王餐',
// icon: '/static/indexImg/icon-bwc.svg', icon: '/static/indexImg/icon-bwc.svg',
// pageUrl: 'PAGES_BWC' pageUrl: 'PAGES_BWC'
// }, },
// { // {
// title: '', // title: '',
// icon: '/static/indexImg/icon-staff.svg', // icon: '/static/indexImg/icon-staff.svg',
@ -184,11 +184,11 @@
// icon: '/static/indexImg/icon-cashier.svg', // icon: '/static/indexImg/icon-cashier.svg',
// pageUrl: 'PAGES_SHOP_SETUP', // pageUrl: 'PAGES_SHOP_SETUP',
// }, // },
// { {
// title: '', title: '优惠券',
// icon: '/static/coupon/icon_coupon.svg', icon: '/static/coupon/icon_coupon.svg',
// pageUrl: 'PAGES_COUPON_INDEX', pageUrl: 'PAGES_COUPON_INDEX',
// }, },
{ {
title: '订阅通知', title: '订阅通知',
icon: '/static/indexImg/icon-notification.svg', icon: '/static/indexImg/icon-notification.svg',

View File

@ -17,15 +17,17 @@
<!-- <view class="headeimg"> <!-- <view class="headeimg">
<image class="img" :src="user.headImg" mode=""></image> <image class="img" :src="user.headImg" mode=""></image>
</view> --> </view> -->
<view class="u-m-l-20">{{user.nickName}}</view> <view class="u-m-l-20">
<view class="color-main u-m-l-10 u-font-24">{{user.isVip?'会员':'' }}</view> <!-- <view class="color-main u-font-24 no-wrap">{{user.isVip?'会员':'' }}</view> -->
<view class="u-font-24 u-m-l-30"><text>余额</text><text <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> class="color-main">{{user.amount}}</text>
</view> </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> class="color-main">{{user.accountPoints}}</text></view>
</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> </view>
<view class=" "> <view class=" ">
@ -88,8 +90,8 @@
<view class="color-333 u-m-l-10"> {{user.accountPoints}}</view> <view class="color-333 u-m-l-10"> {{user.accountPoints}}</view>
</view> </view>
<view class="u-flex"> <view class="u-flex">
<view>已消费</view> <view class="u-text-center">订单数量</view>
<view class="color-333 u-m-l-10"> 0.00</view> <view class="color-333 u-m-l-10">{{user.orderNumber||0}}</view>
</view> </view>
</view> </view>
</view> </view>
@ -168,7 +170,7 @@
</view> </view>
</template> </template>
<template v-else> <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 <text
class="line-th color-999">{{formatPrice(item.salePrice*item.number) }}</text> class="line-th color-999">{{formatPrice(item.salePrice*item.number) }}</text>
<view class="u-absolute" style="right: 0;bottom: 100%;"> <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'"> <!-- <template v-if="$shop.registerType=='munchies'">
<view class="color-main" @tap="showModel('editMoney')">修改</view> <view class="color-main" @tap="showModel('editMoney')">修改</view>
</template> --> </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="u-flex price u-m-l-32">
<view class="">实收金额</view> <view class="">实收金额</view>
<view class="font-bold u-font-32">{{formatPrice(allPrice) }}</view> <view class="font-bold u-font-32">{{formatPrice(allPrice) }}</view>
@ -512,13 +521,12 @@
totalAmount: 0, totalAmount: 0,
}) })
const isVip=computed(()=>{ const isVip=computed(()=>{
return user.value&&user.value.id&&user.value.isVip return $shop.value.isMemberPrice&& user.value&&user.value.id&&user.value.isVip
}) })
const goodsPrice = computed(() => { const goodsPrice = computed(() => {
const goodsTotalPrice = goods.list.reduce((prve, cur) => { const goodsTotalPrice = goods.list.reduce((prve, cur) => {
const memberPrice=cur.memberPrice?cur.memberPrice:cur.salePrice const memberPrice=cur.memberPrice?cur.memberPrice:cur.salePrice
const tPrice = (isVip.value? memberPrice:cur.salePrice) * cur.number const tPrice = (isVip.value? memberPrice:cur.salePrice) * cur.number
console.log(cur.isPack);
const tpackFee = cur.isPack ? cur.packFee * 1 : 0 const tpackFee = cur.isPack ? cur.packFee * 1 : 0
return prve + (cur.isGift ? 0 : tPrice) + tpackFee return prve + (cur.isGift ? 0 : tPrice) + tpackFee
}, 0) }, 0)
@ -533,6 +541,19 @@
// }, 0) // }, 0)
// return (goodsTotalPrice + ($seatFee.totalAmount || 0)).toFixed(2) // 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) { function setGoodsItem(key, val) {
item[key] = val item[key] = val
@ -552,12 +573,17 @@
records, records,
seatFee seatFee
} = await Api.getCart(par) } = await Api.getCart(par)
let useType=''
if (seatFee && seatFee.useType) { if (seatFee && seatFee.useType) {
$storageManage.useType(seatFee.useType) useType=seatFee.useType
// uni.setStorageSync('useType',seatFee.useType); $storageManage.useType(useType)
eatTypes.active = seatFee.useType == 'takeout' ? seatFee.useType : seatFee.useType.replace( }else{
/-after|-before/g, ''); useType=records[0].info[0].useType
$storageManage.useType(useType)
} }
console.log(useType);
eatTypes.active =useType == 'takeout' ? useType : useType.replace(
/-after|-before/g, '');
goods.list = getNowCart(records) goods.list = getNowCart(records)
if (seatFee && seatFee.totalNumber) { if (seatFee && seatFee.totalNumber) {
userNumbers.defaultCateIndex = seatFee.totalNumber - 1 || 0 userNumbers.defaultCateIndex = seatFee.totalNumber - 1 || 0

View File

@ -242,7 +242,7 @@
itemId: '', // scroll-viewid itemId: '', // scroll-viewid
tabbar: storageManage.cacheGoods() || [], tabbar: storageManage.cacheGoods() || [],
menuItemPos: [], menuItemPos: [],
arr: storageManage.cacheGoodsNode() || [], // arr: [], //
scrollRightTop: 0, // scroll-view scrollRightTop: 0, // scroll-view
timer: null, // timer: null, //
topZhanwei: 136 + 24, topZhanwei: 136 + 24,
@ -1110,7 +1110,6 @@
}) })
data.arr = arr data.arr = arr
console.log(data.arr); console.log(data.arr);
storageManage.cacheGoodsNode(data.arr)
resolve(); resolve();
}).exec() }).exec()
}) })

View File

@ -53,12 +53,7 @@
returnCanComputedGoodsArr,canComputedPackFee, returnCanComputedGoodsArr,canComputedPackFee,
returnPackFee returnPackFee
} from '@/commons/utils/goodsUtil.js' } 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({ const props = defineProps({
data: { data: {
type: Object, type: Object,
@ -77,6 +72,12 @@
default: () => {} 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(() => { const packeNumbber = computed(() => {
if (!props.orderInfo.detailList) { if (!props.orderInfo.detailList) {
return 0 return 0

View File

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

View File

@ -37,8 +37,8 @@
<view class="color-666 u-m-t-8 u-font-24">积分</view> <view class="color-666 u-m-t-8 u-font-24">积分</view>
</view> </view>
<view class=""> <view class="">
<view class="font-bold">0.00</view> <view class="font-bold u-text-center">{{user.orderNumber||0}}</view>
<view class="color-666 u-m-t-8 u-font-24">已消费</view> <view class="color-666 u-m-t-8 u-font-24">订单数量</view>
</view> </view>
</view> </view>
</view> </view>

View File

@ -48,7 +48,7 @@
</view> </view>
</view> </view>
</template> </template>
<template v-else-if="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.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

@ -1,18 +1,25 @@
<template> <template>
<my-model ref="model" :title="title" iconColor="#000" @close="resetForm"> <my-model ref="model" :title="title" iconColor="#000" @close="resetForm">
<template #desc> <template #desc>
<view class="u-text-left u-p-30 color-666"> <view class="u-text-left u-p-30 color-666 u-font-28">
<view class="u-m-t-32 u-flex "> <view class="u-m-t-32 u-flex ">
<view class="color-red">*</view> <view class="" v-if="accountPoints.calcRes.usable">
<view class="u-m-l-32"> <text class="color-red">*</text>
<text class=""
v-if="accountPoints.calcRes.equivalentPoints">100积分等于{{to2(accountPoints.calcRes.equivalentPoints*100)}},</text>
<text>
最大抵扣积分{{accountPoints.calcRes.maxUsablePoints}}
</text>
<text>,
最小抵扣积分0
</text>
</view> </view>
</view> </view>
<view class="u-m-t-40 u-flex "> <view class="u-m-t-40 u-flex ">
<view>积分</view> <view>积分</view>
<view class="u-m-l-32 border u-p-l-10 u-p-r-10 u-flex-1"> <view class="u-m-l-32 border u-p-l-10 u-p-r-10 u-flex-1">
<uni-easyinput type="number" @input="currentPriceInput" @change="currentPriceChange" paddingNone :inputBorder="false" <uni-easyinput type="number" @input="pointsInput" @change="pointsChange" paddingNone
v-model="form.currentPrice" :inputBorder="false" v-model="form.points" placeholder="输入积分抵扣数量"></uni-easyinput>
placeholder="输入实际金额"></uni-easyinput>
</view> </view>
</view> </view>
</view> </view>
@ -20,9 +27,9 @@
<template #btn> <template #btn>
<view class="u-p-30"> <view class="u-p-30">
<view class="u-m-t-10"> <view class="u-m-t-10">
<my-button @tap="confirm" shape="circle" fontWeight="700" >修改</my-button> <my-button @tap="confirm" shape="circle" fontWeight="700">修改</my-button>
<view class=""> <view class="">
<my-button @tap="close" type="cancel" bgColor="#fff" >取消</my-button> <my-button @tap="close" type="cancel" bgColor="#fff">取消</my-button>
</view> </view>
</view> </view>
</view> </view>
@ -34,7 +41,8 @@
import { import {
reactive, reactive,
nextTick, nextTick,
ref,watch ref,
watch
} from 'vue'; } from 'vue';
import myModel from '@/components/my-components/my-model.vue' import myModel from '@/components/my-components/my-model.vue'
import myButton from '@/components/my-components/my-button.vue' import myButton from '@/components/my-components/my-button.vue'
@ -45,76 +53,68 @@
type: String, type: String,
default: '积分抵扣' default: '积分抵扣'
}, },
data: { accountPoints:{
type: Array, type:Object,
default: [] default:()=>{
}, return {
discount:{ calcRes:{
type: [Number,String], usable: false,
default:100 unusableReason: '',
minDeductionPoints: 0,
maxUsablePoints: 0
}
}
}
}, },
price: { price: {
type: [Number,String], type: [Number, String],
default: 0 default: 0
} }
}) })
function currentPriceInput(newval){
form.discount=(newval*100/form.price).toFixed() function to2(n) {
} if (!n) {
function discountInput(newval){ return ''
form.currentPrice=(form.price*newval/100).toFixed(2)
}
function currentPriceChange(newval){
if(newval<0){
form.currentPrice=0
form.discount=100
return infoBox.showToast('实收金额不能小于0')
}
if(newval>props.price){
form.currentPrice=props.price
form.discount=0
return infoBox.showToast('实收金额不能大于应付金额')
} }
return n.toFixed(2)
} }
function discountChange(newval){
if(newval<0){ function pointsInput(e){
form.currentPrice=props.price setTimeout(()=>{
form.discount=0 form.points=Math.floor(e)
return infoBox.showToast('优惠折扣不能小于0') },100)
}
function pointsChange(newval) {
form.points=Math.floor(newval)
if (newval < 0) {
form.points = 0
return infoBox.showToast('积分抵扣不能小于0')
} }
if(newval>100){ if (newval > props.accountPoints.calcRes.maxUsablePoints) {
form.discount=100 form.points = props.price
form.currentPrice=0 return infoBox.showToast('积分抵扣不能大于'+props.accountPoints.calcRes.maxUsablePoints)
return infoBox.showToast('优惠折扣不能大于100')
} }
} }
const $form = {
price:props.price,
currentPrice: props.price,
discount: 100
}
const form = reactive({ const form = reactive({
...$form points: props.price,
}) })
watch(()=>props.price,(newval)=>{ watch(() => props.price, (newval) => {
console.log(newval); form.points = newval
form.price=newval
form.currentPrice=newval
}) })
function resetForm() { function resetForm() {
Object.assign(form, { form.points=0
...$form
})
} }
const model = ref(null) const model = ref(null)
function open() { function open() {
model.value.open() model.value.open()
form.price=props.price form.points = props.price
form.currentPrice=props.price
form.discount=props.discount
} }
function close() { function close() {
@ -123,8 +123,7 @@
const emits = defineEmits(['confirm']) const emits = defineEmits(['confirm'])
function confirm() { function confirm() {
console.log(form); emits('confirm',Math.floor(form.points) )
emits('confirm',{...form,currentPrice:Number(form.currentPrice).toFixed(2)})
close() close()
} }
defineExpose({ defineExpose({
@ -134,11 +133,12 @@
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.border{ .border {
border-radius: 8rpx; border-radius: 8rpx;
overflow: hidden; overflow: hidden;
border-color: #999; border-color: #999;
} }
.lh34 { .lh34 {
line-height: 34rpx; line-height: 34rpx;
} }

View File

@ -46,15 +46,22 @@
<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>
</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 " <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"> v-if="discount.price&&discount.currentPrice!=order.amount">
<view>服务员改价</view> <view>服务员改价</view>
@ -77,7 +84,7 @@
<my-tabs :list="pays.list" v-model="pays.selIndex"></my-tabs> <my-tabs :list="pays.list" v-model="pays.selIndex"></my-tabs>
<template v-if="pays.selIndex==0"> <template v-if="pays.selIndex==0">
<view class="list"> <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"> 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 u-row-between u-p-t-30 u-p-b-30 border-bottom">
<view class="u-flex"> <view class="u-flex">
@ -99,16 +106,18 @@
<text>{{user.accountPoints||'0'}}</text> <text>{{user.accountPoints||'0'}}</text>
</view> --> </view> -->
</view> </view>
<my-radio @click="changePayType(index,item)" <view :class="{op3:item.disabled}">
:modelValue="index==pays.payTypes.selIndex"> <my-radio @click="changePayType(index,item)"
</my-radio> :modelValue="index==pays.payTypes.selIndex">
</my-radio>
</view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
<view class="border-bottom-dashed "></view> <view class="border-bottom-dashed "></view>
<view class="u-flex u-row-between u-p-t-24" v-if="user.id&&user.accountPoints" <view class="u-flex u-row-between u-p-t-24" v-if="user.id" @click="changeAccountPoints">
@click="changeAccountPoints">
<view class="u-flex "> <view class="u-flex ">
<view class="">积分抵扣</view> <view class="">积分抵扣</view>
<view class="color-999 u-m-l-10"> <view class="color-999 u-m-l-10">
@ -120,9 +129,9 @@
</view> </view>
<view class="u-flex"> <view class="u-flex">
<view class="u-flex" @click.stop="refPointsOpen"> <view class="u-flex">
<view><text>{{accountPoints.num}}</text></view> <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> <up-icon name="edit-pen" size="16" color="#999"></up-icon>
</view> </view>
</view> </view>
@ -196,7 +205,12 @@
<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 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> </view>
</template> </template>
@ -227,13 +241,49 @@
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 returnGoodsPayPriceMap,
returnProCoupStartIndex,
returnProductCoupAllPrice,
returnProductCanUseNum
} from '../quan_util.js' } 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()
}
}
//0n //0n
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,6 +301,10 @@
}, },
price: 0 price: 0
}) })
function pointsConfirm(e) {
accountPoints.num = e
}
async function calcUsablePoints() { async function calcUsablePoints() {
if (!order.memberId) { if (!order.memberId) {
return return
@ -305,7 +359,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() {
@ -392,30 +446,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) 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]
} }
} }
for(let key in coupMap){ console.log(coupMap);
const arr=coupMap[key] for (let key in coupMap) {
for(let i in arr){ const arr = coupMap[key]
const coup=arr[i] for (let i in arr) {
const proCoupStartIndex=returnProCoupStartIndex(arr,i) const coup = arr[i]
const proCoupStartIndex = returnProCoupStartIndex(arr, i)
console.log(proCoupStartIndex); console.log(proCoupStartIndex);
console.log($goodsPayPriceMap[coup.proId]); const coupUseNum = returnProductCanUseNum($goodsPayPriceMap[coup.proId], proCoupStartIndex,
coup.discountAmount=returnProductCoupAllPrice($goodsPayPriceMap[coup.proId],proCoupStartIndex,coup.num) coup.num)
console.log(coup.discountAmount); 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); console.log(productCoup);
pays.quan = [...manjianCoup, ...productCoup] pays.quan = [...manjianCoup, ...productCoup]
}) })
@ -457,7 +516,7 @@
// //
const discount = reactive({ const discount = reactive({
discount: 100
}) })
function editDiscountConfirm(form) { function editDiscountConfirm(form) {
@ -468,10 +527,18 @@
async function getPayType() { async function getPayType() {
const payTypeList = await Api.$getPayType() const payTypeList = await Api.$getPayType()
pays.payTypes.list = payTypeList pays.payTypes.list = payTypeList.map(v => {
return {
...v,
disabled: false
}
})
} }
function changePayType(i, item) { function changePayType(i, item) {
if (item.disabled) {
return infoBox.showToast(item.payName + '不可用')
}
pays.payTypes.selIndex = i pays.payTypes.selIndex = i
if (item.payType == 'vipPay') { if (item.payType == 'vipPay') {
chooseUser() chooseUser()
@ -499,6 +566,9 @@
if (payType == 'scanCode' || payType == 'deposit') { if (payType == 'scanCode' || payType == 'deposit') {
return saomaPay() return saomaPay()
} }
if (payType == 'cash' && payPrice.value * 1 > 0) {
return cashConfirmShow()
}
payOrder() payOrder()
} }
const tipsMap = { const tipsMap = {
@ -511,33 +581,39 @@
infoBox.showToast('余额不足') infoBox.showToast('余额不足')
return return
} }
if (payStatus) { if (payStatus) {
return infoBox.showToast(tipsMap[payStatus]) return infoBox.showToast(tipsMap[payStatus])
} }
try { try {
payStatus = 'paying' pay()
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()
} catch (e) { } catch (e) {
//TODO handle the exception //TODO handle the exception
payStatus = '' 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({ const order = reactive({
amount: 0 amount: 0
@ -552,15 +628,7 @@
success: function(res) { success: function(res) {
console.log('条码类型:' + res.scanType); console.log('条码类型:' + res.scanType);
console.log('条码内容:' + res.result); console.log('条码内容:' + res.result);
Api.$payOrder({ pay({code: res.result})
"orderId": order.orderId, // id
"payType": item.payType, //
"discount": order.discount,
"code": res.result
}).then(res => {
console.log(res);
paySuccess()
})
} }
}); });
} }
@ -582,7 +650,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()
@ -614,8 +682,24 @@
const calcPrice = discountPrice - coupAllPrice.value - accountPoints.price * (accountPoints.sel ? 1 : 0) const calcPrice = discountPrice - coupAllPrice.value - accountPoints.price * (accountPoints.sel ? 1 : 0)
return (calcPrice <= 0 ? 0 : calcPrice).toFixed(2) return (calcPrice <= 0 ? 0 : calcPrice).toFixed(2)
}) })
watch(() => payPrice.value, () => { watch(() => payPrice.value, (newval) => {
getPayUrl() 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 pointCanDicountPrice = computed(() => {
const discountPrice = discount.currentPrice ? discount.currentPrice : order.amount const discountPrice = discount.currentPrice ? discount.currentPrice : order.amount
@ -643,6 +727,10 @@
<style lang="scss" scoped> <style lang="scss" scoped>
$quan-color: #318AFE; $quan-color: #318AFE;
.op3 {
opacity: .3;
}
.hui { .hui {
// background-color: $quan-color; // background-color: $quan-color;
background-image: linear-gradient(to right bottom, rgb(254, 103, 4), rgb(241, 50, 42)); background-image: linear-gradient(to right bottom, rgb(254, 103, 4), rgb(241, 50, 42));
@ -674,6 +762,12 @@
} }
.list { .list {
.item {
&.disabled {
color: #999;
}
}
.item:last-child { .item:last-child {
.border-bottom { .border-bottom {
border-bottom: none; border-bottom: none;

View File

@ -21,7 +21,8 @@
</view> </view>
<view class=" u-m-t-20 u-flex"> <view class=" u-m-t-20 u-flex">
<view>有效期:</view> <view>有效期:</view>
<view class="u-font-24 u-m-l-6"> {{item.endTime}}</view> <view class="u-font-24 u-m-l-6"> {{dayjs(item.endTime).format('YYYY-MM-DD HH:mm:ss') }}
</view>
</view> </view>
<view class="u-m-t-10 color-999 u-font-24"> <view class="u-m-t-10 color-999 u-font-24">
{{ formatStr(item.useRestrictions)}} {{ formatStr(item.useRestrictions)}}
@ -65,7 +66,8 @@
</view> </view>
<view class=" u-m-t-14 u-flex"> <view class=" u-m-t-14 u-flex">
<view>有效期:</view> <view>有效期:</view>
<view class="u-font-24 u-m-l-6"> {{item.endTime}}</view> <view class="u-font-24 u-m-l-6"> {{dayjs(item.endTime).format('YYYY-MM-DD HH:mm:ss') }}
</view>
</view> </view>
<view class="u-m-t-10 color-999 u-font-24"> <view class="u-m-t-10 color-999 u-font-24">
{{ formatStr(item.useRestrictions)}} {{ formatStr(item.useRestrictions)}}
@ -103,7 +105,8 @@
<text>支付金额</text> <text>支付金额</text>
<text class="color-red"></text> <text class="color-red"></text>
<text class="color-red">{{payPrice }}</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"> <view class="u-flex line-th color-999">
<text class=""></text> <text class=""></text>
<text class="">{{option.orderPrice}}</text> <text class="">{{option.orderPrice}}</text>
@ -138,6 +141,7 @@
onMounted onMounted
} from 'vue'; } from 'vue';
import color from '@/commons/color.js' import color from '@/commons/color.js'
import dayjs from 'dayjs';
import { import {
getSafeBottomHeight getSafeBottomHeight
} from '@/commons/utils/safe-bottom.js' } from '@/commons/utils/safe-bottom.js'
@ -228,13 +232,18 @@
if (!item.use) { if (!item.use) {
return return
} }
console.log();
if (myQuan.fullReductionCouponSel.id && !item.checked) { if (myQuan.fullReductionCouponSel.id && !item.checked) {
const goodsQuan = myQuan.res.productCoupon.filter(v => v.checked) const goodsQuan = myQuan.res.productCoupon.filter(v => v.checked)
const fullReductionCoupon = myQuan.fullReductionCouponSel.id ? [myQuan.fullReductionCouponSel] : [] const fullReductionCoupon = myQuan.fullReductionCouponSel.id ? [myQuan.fullReductionCouponSel] : []
let coupArr = [...goodsQuan, item] let coupArr = [...goodsQuan, item]
const payPrice = option.orderPrice - returnCouponAllPrice(coupArr, canDikouGoodsArr, user.value) 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) { if (myQuan.fullReductionCouponSel.fullAmount > payPrice) {
modal.content = '选择该商品券后将不满足选择抵扣券的最低满减需求,继续选择将取消选择的满减券' modal.content = '选择该商品券后将不满足选择抵扣券的最低满减需求,继续选择将取消选择的满减券'
modal.cancelText = '取消' modal.cancelText = '取消'
@ -246,11 +255,18 @@
item.checked = !item.checked item.checked = !item.checked
const CheckedArr = myQuan.res.productCoupon.filter(v => v.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) const noCheckedArr = myQuan.res.productCoupon.filter(v => !v.checked)
noCheckedArr.map(v => { noCheckedArr.map(v => {
console.log(returnCoupCanUse(canDikouGoodsArr, v, CheckedArr)); console.log(returnCoupCanUse(canDikouGoodsArr, v, CheckedArr));
v.use = returnCoupCanUse(canDikouGoodsArr, v, CheckedArr) v.use = returnCoupCanUse(canDikouGoodsArr, v, CheckedArr)
}) })
} }
function changeFullReductionCouponSel(item) { function changeFullReductionCouponSel(item) {
@ -262,10 +278,11 @@
myQuan.fullReductionCouponSel = { myQuan.fullReductionCouponSel = {
id: '' id: ''
} }
}else{ } else {
myQuan.fullReductionCouponSel = item myQuan.fullReductionCouponSel = item
} }
myQuan.res.fullReductionCoupon=returnCanUseFullReductionCoupon($fullReductionCoupon, payPrice.value, myQuan.fullReductionCouponSel) myQuan.res.fullReductionCoupon = returnCanUseFullReductionCoupon($fullReductionCoupon, payPrice.value, myQuan
.fullReductionCouponSel)
} }
function formatStr(str) { function formatStr(str) {
@ -298,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
@ -315,7 +340,7 @@
const option = reactive({ const option = reactive({
orderId: '', orderId: '',
memberId: '', memberId: '',
orderPrice:0 orderPrice: 0
}) })
function toEmitChooseQuan(item) { function toEmitChooseQuan(item) {
@ -338,13 +363,14 @@
let coupArr = [...fullReductionCoupon, ...goodsQuan] let coupArr = [...fullReductionCoupon, ...goodsQuan]
return returnCouponAllPrice(coupArr, canDikouGoodsArr, user.value) return returnCouponAllPrice(coupArr, canDikouGoodsArr, user.value)
}) })
const payPrice=computed(()=>{ const payPrice = computed(() => {
const pay= option.orderPrice-discountAmount.value const pay = option.orderPrice - discountAmount.value
return (pay<0?0:pay).toFixed(2) return (pay < 0 ? 0 : pay).toFixed(2)
}) })
watch(() => myQuan.types.sel, (newval) => { watch(() => myQuan.types.sel, (newval) => {
if (newval == 0) { if (newval == 0) {
myQuan.res.fullReductionCoupon = returnCanUseFullReductionCoupon($fullReductionCoupon, payPrice.value, myQuan.fullReductionCouponSel) myQuan.res.fullReductionCoupon = returnCanUseFullReductionCoupon($fullReductionCoupon, payPrice.value,
myQuan.fullReductionCouponSel)
} }
if (newval == 1) { if (newval == 1) {

View File

@ -1,6 +1,10 @@
export function isTui(item) { export function isTui(item) {
return item.status == 'return' || item.status == 'refund' || item.status == 'refunding' return item.status == 'return' || item.status == 'refund' || item.status == 'refunding'
} }
//是否使用会员价
export function isUseVipPrice(vipUser,goods){
return vipUser.id&&vipUser.isVip&&goods.isMember
}
//计算商品券优惠价格 //计算商品券优惠价格
export function returnProductCouponPrice(coup, goodsArr, vipUser) { export function returnProductCouponPrice(coup, goodsArr, vipUser) {
@ -9,7 +13,7 @@ export function returnProductCouponPrice(coup, goodsArr, vipUser) {
return 0 return 0
} }
const memberPrice = item.memberPrice ? item.memberPrice : item.price; const memberPrice = item.memberPrice ? item.memberPrice : item.price;
const price = item ? (vipUser.isVip ? memberPrice : item.price) : 0; const price = item ? (isUseVipPrice(vipUser,item) ? memberPrice : item.price) : 0;
return price * coup.num return price * coup.num
} }
@ -36,7 +40,8 @@ export function returnCoupCanUse(goodsArr = [], coup, selCoupArr = []) {
if (selCoupNumber >= findGoodsTotalNumber) { if (selCoupNumber >= findGoodsTotalNumber) {
return false 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 = []) { export function returnProductCoupon(coup, goodsArr, vipUser, selCoupArr = []) {
@ -50,12 +55,13 @@ export function returnProductCoupon(coup, goodsArr, vipUser, selCoupArr = []) {
} }
} }
const memberPrice = item.memberPrice ? item.memberPrice : item.price; const memberPrice = item.memberPrice ? item.memberPrice : item.price;
const price = item ? (vipUser.isVip ? memberPrice : item.price) : 0; const price = item ? (isUseVipPrice(vipUser,item) ? memberPrice : item.price) : 0;
const discountAmount = (price * coup.num).toFixed(2) const discountAmount = (price * coup.num).toFixed(2)
console.log(discountAmount); console.log(discountAmount);
const canUse = !coup.use ? false : (discountAmount > 0 && returnCoupCanUse(goodsArr, coup, selCoupArr)) // const canUse = !coup.use ? false : (discountAmount > 0 && returnCoupCanUse(goodsArr, coup, selCoupArr))
// const canUse=discountAmount>0 // const canUse=discountAmount>0
const canUse=coup.use
return { return {
...coup, ...coup,
discountAmount: discountAmount, discountAmount: discountAmount,
@ -81,7 +87,7 @@ export function returnProductAllCoup(coupArr, goodsArr, vipUser) {
//返回商品实际支付价格 //返回商品实际支付价格
export function returnProductPayPrice(goods,vipUser){ export function returnProductPayPrice(goods,vipUser){
const memberPrice = goods.memberPrice ? goods.memberPrice : goods.price; const memberPrice = goods.memberPrice ? goods.memberPrice : goods.price;
const price = vipUser.isVip ? memberPrice : item.price; const price = isUseVipPrice(vipUser,goods) ? memberPrice : goods.price;
return price return price
} }
//返回商品券抵扣的商品价格 //返回商品券抵扣的商品价格
@ -96,6 +102,23 @@ export function returnProductCoupAllPrice(productPriceArr,startIndex,num){
return prve+curPrice return prve+curPrice
},0) },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){ export function returnProCoupStartIndex(coupArr,index){
return coupArr.slice(0,index).reduce((prve,cur)=>{ return coupArr.slice(0,index).reduce((prve,cur)=>{
@ -162,7 +185,9 @@ export function returnProductCouponAllPrice(coupArr, goodsArr, vipUser) {
} }
const proCoupStartIndex=returnProCoupStartIndex(arr,i) const proCoupStartIndex=returnProCoupStartIndex(arr,i)
console.log(proCoupStartIndex); console.log(proCoupStartIndex);
total+=returnProductCoupAllPrice(goodsPayPriceMap[coup.proId],proCoupStartIndex,coup.num) const coupNum=Math.min(goodsPayPriceMap[coup.proId].length,coup.num)
console.log(coupNum);
total+=returnProductCoupAllPrice(goodsPayPriceMap[coup.proId],proCoupStartIndex,coupNum)
} }
} }
@ -194,9 +219,31 @@ export function returnCanUseFullReductionCoupon(coupArr, payPrice, selCoup) {
return v return v
} }
const isfullAmount = payPrice >= v.fullAmount * 1 const isfullAmount = payPrice >= v.fullAmount * 1
if(payPrice<=0){
return {
...v,
use: false
}
}
return { return {
...v, ...v,
use: v.use && isfullAmount 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
}