问题修复,下单修复

This commit is contained in:
2025-09-29 16:54:35 +08:00
parent 719a513371
commit afa769579a
16 changed files with 417 additions and 167 deletions

View File

@@ -21,7 +21,7 @@
</view>
<view class="icon icon3" v-if="props.item.couponType == 3">
<view class="top">
<text class="num">{{ props.item.discountRate }}</text>
<text class="num">{{ props.item.discountRate/10 }}</text>
</view>
<view class="intro">
<text class="t">{{ props.item.fullAmount }}可用</text>

View File

@@ -12,7 +12,7 @@
<scroll-view scroll-y="true" class="u-m-t-42" style="max-height: 50vh;">
<view class="list">
<view class="item u-flex u-m-b-32 u-col-center" v-for="(item,index) in list" :key="index">
<view class="left">
<view class="left" style="min-width: 162rpx;">
<couponIcon :item="item.coupon" />
<!-- <view class="red font-16 font-700" style="width: 122rpx;">第二件半价券</view> -->
<view></view>

View File

@@ -6,7 +6,7 @@
<up-radio-group v-model="radiovalue" iconPlacement="right" @change="groupChanges" :size="28"
placement="column">
<block v-for="(item,index) in paymentMethodList" :key="index">
<view class="method_list" @click="groupChanges(item.type)"
<view class="method_list" @click="groupChanges(item.type)" :class="{disabled:returnDisabled(item)}"
v-if="(index+1) == radiovalue?!changeFreeenable:true">
<view class="method_list_top">
<view class="method_list_top_left">
@@ -14,10 +14,9 @@
<view class="method_list_top_cen">
<view class="name"> {{ item.name }} </view>
<view class="method_list_bom" v-if="item.type == 1">
<text class="balance" v-if="orderVIP.isVip == 1">
会员卡余额{{orderVIP?orderVIP.amount:0}}</text>
<text class="topUpNow"
@click="goRecharge">{{orderVIP.isVip == 0?'注册会员':'去充值'}}</text>
<text class="balance">
当前余额{{orderVIP?orderVIP.amount:0}}</text>
<text class="topUpNow" @click="goRecharge">去充值</text>
</view>
</view>
</view>
@@ -59,11 +58,24 @@
changeFreeenable: {
type: Boolean,
default: false
},
disablePayType: {
type: Array,
default: () => {
return []
}
}
});
function returnDisabled(item) {
if (props.disablePayType.includes(item.name)) {
return true
}else{
return false
}
}
const orderVIP = ref(null)
const emits = defineEmits(['customevent', 'groupChange']);
watchEffect(() => {
@@ -131,6 +143,13 @@
if (props.freeCheck && type == 1) {
return;
}
const item=paymentMethodList.value.find(v=>v.type==type)
if(item&&returnDisabled(item)){
return uni.showToast({
title:"当前支付方式不可用",
icon:'none'
})
}
// if (props.payAmount <= 0 && type != 1) {
// return;
// }
@@ -142,14 +161,14 @@
// 去充值
const goRecharge = () => {
if(orderVIP.value.isVip){
if (orderVIP.value.isVip) {
uni.navigateTo({
url:'/pages/user/member/czzx?shopId='+orderVIP.value.shopId
url: '/pages/user/member/czzx?shopId=' + orderVIP.value.shopId
})
return
}
uni.navigateTo({
url:'/user/vip/buy-vip?shopId='+orderVIP.value.shopId
url: '/user/vip/buy-vip?shopId=' + orderVIP.value.shopId
})
// uni.pro.navigateTo('user/member/index', {
@@ -185,7 +204,9 @@
.method_list {
padding: 40rpx 0;
box-sizing: border-box;
&.disabled{
opacity: .6;
}
.method_list_top {
display: flex;
justify-content: space-between;

View File

@@ -327,6 +327,7 @@ onShow(async () => {
uni.getLocation({
type: 'wgs84',
success: async (res) => {
console.log('getLocation',res);
let successres = await APIgeocodelocation({
lng: res.longitude,
lat: res.latitude
@@ -344,29 +345,15 @@ onShow(async () => {
// 登录
proxy.$isResolve();
}
},
fail(error) {
console.error('获取经纬度失败',error);
}
});
indexsRef.value.getVipConfig();
} catch (error) {
try {
let successres = await APIgeocodelocation({
lng: '',
lat: ''
});
if (successres) {
let datastorage = {
country: successres.addressComponent.country, // "中国"
province: successres.addressComponent.province, //province: "陕西省"
address: successres.addressComponent.city, //district: "西安市"
district: successres.addressComponent.district, //district: "未央区"
lng: res.longitude,
lat: res.latitude
};
uni.cache.set('getLocationstorage', datastorage);
proxy.$isResolve();
}
} catch (error) {}
}
await proxy.$onLaunched;
if (uni.cache.get('shopId')) {

View File

@@ -21,8 +21,8 @@
</view>
<view class="font-12" v-if="item.rewardPoints">
<text></text>
<text></text>
<text class="font-14">{{item.rewardPoints}}</text>
<text>积分</text>
</view>
<view class="font-12 color-666" v-if="item.couponInfoList.length">
<text></text>

View File

@@ -117,7 +117,8 @@
v-if="item.icon" :src="item.icon" mode=""></u-image>
</view>
<text class="name u-m-l-16 no-wrap"> {{ item.name }} </text>
<text class="font-12 u-p-l-6" style="color: #666;margin-right: 16rpx;max-width: 360rpx;" v-if="item.type=='points'">
<text class=" u-p-l-6" style="color: #666;max-width: 400rpx;font-size: 10px;"
v-if="item.type=='points'">
可用积分{{pointsRes.accountPoints}}最大可抵扣{{maxPointDiscount}}
</text>
@@ -126,8 +127,17 @@
<!-- 优惠卷 -->
<view class="favorable_right" v-if="item.type=='coupon'">
<text class="favorable_right_text red"
v-if="returnCouponDiscount>0">-{{returnCouponDiscount}}</text>
<template v-if="cartStore.orderCostSummary.couponDeductionAmount>0">
<text
class="favorable_right_text red">-{{cartStore.orderCostSummary.couponDeductionAmount}}</text>
</template>
<template v-else>
<text class="favorable_right_text red" v-if="hasCouponCanUse">有可用优惠券</text>
<text class=" favorable_right_text " v-else>暂无可用优惠券</text>
</template>
<up-icon name="arrow-right" color="#575B66" size="16"
v-if="listinfo.status == 'unpaid' || listinfo.status == 'paying'||!listinfo.id"></up-icon>
@@ -142,14 +152,17 @@
<!-- 积分 -->
<view class="favorable_right u-flex u-col-center" v-if="item.type=='points'">
<up-icon name="checkmark-circle-fill" size="24rpx" v-if="usePoints"
color="#FE7E00"></up-icon>
<text v-if="usePoints" class="red">
<template v-if="usePoints&&cartStore.orderCostSummary.pointDeductionAmount">
<up-icon name="checkmark-circle-fill" size="24rpx" color="#FE7E00"></up-icon>
<text class="red">
-¥{{cartStore.orderCostSummary.pointDeductionAmount}}
</text>
</template>
<view v-else class="u-flex u-col-center">
<view class="round"></view>
<text class="color-333 font-12 no-wrap">使用抵扣</text>
<text class="color-333 font-12 no-wrap u-m-l-4">使用抵扣</text>
</view>
</view>
<!-- <view class="favorable_right" v-if="item.type=='points'">
@@ -218,21 +231,6 @@
</view>
</view>
<view class="orderInfo">
<view class="">
<view class="t">
订单备注
</view>
<view class="u-m-t-18 ">
<up-textarea border="none" placeholder="请填写口味、偏好等要求" :type="'textarea'" v-model="listinfo.remark"
:clearable="true" />
</view>
</view>
</view>
<IntegralInput :visible="calcUsablePointsData.showModal" :minValue="calcUsablePointsData.minIntegral"
:maxValue="calcUsablePointsData.maxIntegral" :instructions="calcUsablePointsData.instructionText"
@@ -260,8 +258,15 @@
watch,
watchEffect,
defineExpose,
toRaw,
onMounted
} from 'vue'
import {
returnHasCouponCanUse
} from '@/utils/coupon.js'
let hasCouponCanUse = ref(false)
const usePoints = ref(false)
@@ -300,7 +305,7 @@
},
])
const favorablelist = reactive([{
const favorablelist = ref([{
name: "新客立减",
type: "newUser",
width: '40rpx',
@@ -390,15 +395,15 @@
// 操作优惠卷
const dataprocessing = (data) => {
favorablelist[1].value = data
favorablelist.value[1].value = data
}
const returnCouponDiscount = computed(() => {
if (!favorablelist[1].value) {
if (!favorablelist.value[1].value) {
return 0
}
return favorablelist[1].value.reduce((prve, cur) => {
return favorablelist.value[1].value.reduce((prve, cur) => {
return prve + (cur.discountAmount || 0)
}, 0)
})
@@ -407,8 +412,8 @@
const bwcclear = () => {
IntegralInputclose()
// 清空优惠卷
favorablelist[1].value = ''
favorablelist[1].value = ''
favorablelist.value[1].value = ''
favorablelist.value[1].value = ''
}
const dinnerType = computed(() => {
return is_type.value ? 'take-out' : 'dine-ine'
@@ -418,10 +423,7 @@
const canDikouGoodsArr = props.nowCarts
const goodsOrderPrice = props.listinfo.totalPrices
// const user=uni.cache.get('shopUserInfo')
uni.setStorageSync('canDikouGoodsArr', canDikouGoodsArr)
uni.setStorageSync('goodsOrderPrice', goodsOrderPrice)
uni.setStorageSync('dinnerType', dinnerType.value)
if (props.isBwc) {
uni.showToast({
@@ -432,36 +434,13 @@
}
switch (item.type) {
case 'coupon':
// 清空积分
IntegralInputclose()
favorablelist[1].value = ''
emits('learcoupons', 'coupon')
console.log('payAmount', props.listinfo.totalPrices, props.listinfo
.Productroll);
uni.pro.navigateTo('/pages/order/coupon', {
type: "confirm_order_coupon",
shopId: uni.cache.get('orderVIP').shopId,
shopUserId: props.orderVIP.id,
payAmount: (parseFloat(props.listinfo.totalPrices) - parseFloat(props.listinfo
.Productroll)).toFixed(2),
shoppingCart: JSON.stringify([...props.nowCarts, ...props.listinfo.combinedArray]),
})
uni.pro.navigateTo('/pages/order/coupon', {})
break;
case 'points':
chnageIsUsePoints()
return
IntegralInputclose()
if (calcUsablePointsData.usable == 0) {
uni.showToast({
title: calcUsablePointsData.unusableReason,
icon: 'none'
})
return false;
}
console.log('calcUsablePointsData:', calcUsablePointsData)
calcUsablePointsData.showModal = true
break;
}
}
@@ -479,27 +458,35 @@
const pointsRes = reactive({
accountPoints: 0
})
getMaxPointsDiscount()
const maxPointDiscount=ref(0)
async function getMaxPointsDiscount() {
const maxPointDiscount = ref(0)
//积分可抵扣最大金额
const maxMoney = cartStore.orderCostSummary.goodsRealAmount - cartStore.orderCostSummary
const maxMoney = computed(() => {
return cartStore.orderCostSummary.goodsRealAmount - cartStore.orderCostSummary
.couponDeductionAmount
})
async function getMaxPointsDiscount() {
let res = await APImemberPointscalcUsablePoints({
shopUserId: props.orderVIP.id,
orderAmount: maxMoney
orderAmount: maxMoney.value
})
console.log(res);
Object.assign(pointsRes, res)
const maxUsablePoints = res.maxUsablePoints
maxPointDiscount.value=res.maxDeductionAmount
maxPointDiscount.value = res.maxDeductionAmount
// props.listinfo.pointsDiscountAmount = await APImemberPointscalcDeductionAmount({
// points: maxUsablePoints,
// shopUserId: props.orderVIP.id,
// orderAmount: maxMoney
// })
if (usePoints.value) {
cartStore.setUserPoints(maxUsablePoints)
}
}
watch(() => maxMoney.value, (newval) => {
console.log('maxMoney.value', newval);
getMaxPointsDiscount()
})
watch(() => usePoints.value, (newval) => {
if (newval) {
getMaxPointsDiscount()
@@ -571,21 +558,47 @@
});
watch(() => props.listinfo.seatNum, (newval) => {
cartStore.setSeatFeeConfig('personCount', newval || 1)
cartStore.setSeatFeeConfig('personCount', newval || 0)
})
const newUserDiscount = ref(0)
const back_favorablelist = toRaw(favorablelist.value)
async function getConsumeDiscount() {
const consumeDiscountRes = await consumeDiscount({
shopId: uni.cache.get('shopId'),
})
if (consumeDiscountRes&&consumeDiscountRes.isUse) {
if (!consumeDiscountRes.isUse) {
favorablelist.value = back_favorablelist.filter(v => v.name != '新客立减')
}
if (consumeDiscountRes && consumeDiscountRes.isUse) {
newUserDiscount.value = consumeDiscountRes.amount
cartStore.newUserDiscount = consumeDiscountRes.amount || 0
cartStore.consumeDiscount=consumeDiscountRes
cartStore.consumeDiscount = consumeDiscountRes
}
}
onMounted(async () => {
getConsumeDiscount()
//积分可抵扣最大金额
const goodsOrderPrice = cartStore.orderCostSummary.goodsRealAmount - cartStore.orderCostSummary
const dinnerType = cartStore.dinnerType
const shopInfo = cartStore.shopInfo
const shopId = cartStore.shopInfo.shopId
const user = uni.cache.get('shopUserInfo')
const shopUserId = user.id
const allGoods = cartStore.allGoods
hasCouponCanUse.value = await returnHasCouponCanUse({
goodsOrderPrice,
dinnerType,
shopId,
shopInfo,
shopUserId,
allGoods,
user
})
console.log('hasCouponCanUse', hasCouponCanUse.value);
})
</script>
<style lang="scss" scoped>

View File

@@ -44,6 +44,18 @@
:ordershopUserInfo='ordershopUserInfo' @istype="istype" @clickPointsamount='clickPointsamount'
@learcoupons="learcoupons" :isBwc='isBwc'>
</orderInfo>
<!-- 订单备注 -->
<view class="orderInfo">
<view class="">
<view class="t">
订单备注
</view>
<view class="u-m-t-18 ">
<up-textarea border="none" placeholder="请填写口味、偏好等要求" :type="'textarea'" v-model="listinfo.remark"
:clearable="true" />
</view>
</view>
</view>
<!-- 霸王餐 -->
<rechargeFree :freeDineConfig="orderVIP.freeDineConfig" :payAmount="listinfo.totalPrices"
v-if="(listinfo.status == 'unpaid'||!listinfo.id) && orderVIP.freeDineConfig.enable"
@@ -51,17 +63,21 @@
</rechargeFree>
<!-- 充值享优惠 -->
<view v-else>
<ChargeVue @updateChargeSel="updateChargeSel" @updateRechargeId="updateRechargeId" v-if="(listinfo.status == 'unpaid'||!listinfo.id)"></ChargeVue>
<ChargeVue @updateChargeSel="updateChargeSel" @updateRechargeId="updateRechargeId"
v-if="(listinfo.status == 'unpaid'||!listinfo.id)"></ChargeVue>
</view>
<!-- 支付方式 -->
<paymentMethodes ref="paymentMethodref" :orderVIP="orderVIP" @groupChange="groupChange"
:changeFreeenable="isBwc" v-if="listinfo.status == 'unpaid'||!listinfo.id">
:disablePayType="disablePayType" :changeFreeenable="isBwc" v-if="listinfo.status == 'unpaid'||!listinfo.id">
</paymentMethodes>
<view class="fixedview">
<view class="flex-between" v-if="listinfo.status == 'unpaid'||!listinfo.id">
<view class="fixedview_one flex-start">
<view class="fixedview_oneone"> 实付金额 </view>
<view class="fixedview_onetow">
<view class="fixedview_onetow" v-if="rechargeItem.id">
<text>¥</text>{{rechargeItem.amount}}
</view>
<view class="fixedview_onetow" v-else>
<text>¥</text>{{cartStore.orderCostSummary.finalPayAmount}}
</view>
</view>
@@ -77,6 +93,12 @@
<text class="u-font-32 color-main u-m-l-16">加菜</text>
</view>
</up-button>
<up-button shape="circle" v-if="listinfo.id&&listinfo.status=='unpaid'" plain
@tap="cancelOrder" :custom-style="customStyle">
<view class="u-flex u-flex-y-center">
<text class="u-font-32 color-main u-m-l-16">取消订单</text>
</view>
</up-button>
</template>
<template v-else>
<up-button v-if="!cartStore.isEmpty" shape="circle" @click="onlyCreateOrder" plain
@@ -123,6 +145,10 @@
import {
pay
} from '@/utils/pay.js'
import * as UTILS from '@/utils/goods-utils.js'
import {
findCoupon
} from '@/common/api/market/coupon.js';
function onback() {
closeSocket()
@@ -155,7 +181,8 @@
APIgetOrderById,
APIputuserorder,
APIhistoryOrder,
rechargePayOrder
rechargePayOrder,
APIcancelOrder
} from '@/common/api/order/index.js'
import {
APIusershopInfodetail,
@@ -171,9 +198,12 @@
import {
useWebSocket
} from '@/stores/carts-websocket.js';
const cartStore = useCartsStore()
const disablePayType = ref([])
//充值相关
const rechargeItem = ref({
id: ''
@@ -187,6 +217,15 @@
function updateChargeSel(e) {
rechargeItem.value = e
}
watch(() => rechargeItem.value.id, (newval) => {
//充值并付款时只能微信支付
if (newval) {
disablePayType.value = ['余额支付']
paymentMethodref.value.groupChanges(2)
} else {
disablePayType.value = []
}
})
async function onMessage(Message) {
cartStore.onMessage(Message, cartsSocket)
@@ -566,6 +605,31 @@
}
}
//取消订单
const cancelOrder = async () => {
uni.showModal({
title: '取消订单',
content: '是否取消订单?',
showCancel: true,
success: async (res) => {
if (res.confirm) {
await APIcancelOrder({
shopId: listinfo.shopId,
orderId: listinfo.id
})
uni.showToast({
title: '取消订单成功',
icon: 'none'
})
setTimeout(() => {
uni.pro.switchTab('order/index')
}, 1000)
}
}
})
}
// 删除订单
const APIputuserorderclick = async () => {
await APIputuserorder(listinfo.id)
@@ -581,6 +645,7 @@
}
// 生成订单
const createOrder = async () => {
cartStore.carts = [];
const res = await storeMemberpay.actionscreateOrder({
dineMode: is_type.value == 0 ? 'dine-in' : 'take-out', //堂食 dine-in 外带 take-out 外卖 take-away
seatNum: uni.cache.get('dinersNum') ? uni.cache.get('dinersNum') : '', //用餐人数
@@ -591,12 +656,12 @@
placeNum: listinfo.id ? (listinfo.placeNum * 1 + 1) : 1, //当前订单下单次数
waitCall: '', //是否等叫 0 否 1 等叫
orderId: listinfo.id || '',
tableCode: options.tableCode,
userId: uni.cache.get('userInfo').id || '' //
})
// 清空购物车
if (res) {
Object.assign(listinfo, res)
// cartStore.carts=[];
// cartStore.setOldOrder(res)
getOrderInfoAfterCalcInit(res)
@@ -651,7 +716,8 @@
//先付
if (isPayBefor()) {
console.log('isPayBefor');
console.log(cartStore.isEmpty);
console.log('cartStore.isEmpty', cartStore.isEmpty);
console.log('cartStore.carts', cartStore.carts);
// 购物车有数据
if (!cartStore.isEmpty) {
const res = await createOrder()
@@ -661,8 +727,9 @@
})
cartStore.setOldOrder(res1)
}
nextTick(goToPay)
goToPay()
// goToPay()
} else {
//后付
@@ -806,14 +873,18 @@
newCustomerDiscountAmount: cartStore.orderCostSummary.newUserDiscount, //新客立减
newCustomerDiscountId: cartStore.orderCostSummary.newUserDiscount > 0 ? cartStore
.consumeDiscount.id : '',
remark: '', //用户备注
remark: listinfo.remark, //用户备注
}
console.log('topay checkOrderPay', checkOrderPay);
try {
if (rechargeItem.value.id && rechargeId.value) {
//充值支付
const payRes = await rechargePayOrder({
checkOrderPay,
checkOrderPay: {
...checkOrderPay,
userId: uni.cache.get('shopUserInfo').userId || ''
},
payType: paymentmethod.payType,
buyerRemark: '',
returnUrl: '',
@@ -832,7 +903,6 @@
buyerRemark: '',
returnUrl: ''
})
pay_unlock()
}
} catch (error) {
@@ -886,7 +956,7 @@
newCustomerDiscountAmount: cartStore.orderCostSummary.newUserDiscount, //新客立减
newCustomerDiscountId: cartStore.orderCostSummary.newUserDiscount > 0 ? cartStore.consumeDiscount
.id : '',
remark: '', //用户备注
remark: listinfo.remark, //用户备注
}
try {
await storeMemberpay.balancePayOrder({
@@ -989,6 +1059,7 @@
})
async function init(opt) {
cartStore.clearOrderConfig()
Object.assign(options, opt)
listinfo.id = options.orderId;
console.log('options', options);
@@ -997,6 +1068,19 @@
uni.cache.set('shopId', options.shopId, 30)
uni.$on('returnData', handleReturnData);
}
//如果已经生成订单,根据历史订信息设置相关配置
if (options.orderId) {
let res = await APIgetOrderById({
orderId: listinfo.id
})
if (res) {
uni.cache.set('tableCode', res.tableCode)
uni.cache.set('tableCode', res.seatNum)
options.tableCode = res.tableCode
cartStore.setSeatFeeConfig('personCount', res.seatNum)
cartStore.setDinnerType(res.dineMode || 'dine-in')
}
}
//获取店铺信息
const shopInfoRes = await APIusershopInfodetail({
shopId: options.shopId
@@ -1492,4 +1576,25 @@
}
}
.orderInfo {
background: #FFFFFF;
border-radius: 18rpx 18rpx 18rpx 18rpx;
margin-top: 32rpx;
padding: 32rpx 34rpx;
.t {
font-weight: bold;
font-size: 28rpx;
color: #333333;
flex-shrink: 0;
}
.info {
font-weight: 400;
font-size: 28rpx;
color: #666666;
}
}
</style>

View File

@@ -323,13 +323,12 @@
let noUseGoodsCoupon = []
let noUseDiscountCoupon = []
const user = uni.cache.get('shopUserInfo')
let shopInfo = uni.cache.get('shopInfo')||{}
if(!shopInfo.isMemberPrice){
shopInfo={}
let shopInfo = uni.cache.get('shopInfo') || {}
if (!shopInfo.isMemberPrice) {
shopInfo = {}
}
const goodsOrderPrice = uni.getStorageSync('goodsOrderPrice') || 0
const goodsList = uni.getStorageSync('canDikouGoodsArr') || []
const dinnerType = uni.getStorageSync('dinnerType')
const dinnerType = cartStore.dinnerType
const canDikouGoodsArr = UTILS.returnCanDikouGoods(cartStore.allGoods, [], user);
const shopId = uni.cache.get('shopId')
for (let i = 0; i < res.length; i++) {
@@ -339,7 +338,7 @@
coupon,
goodsOrderPrice,
user,
selCoupon: [],
selCoupon: quansSelArr.value,
shopInfo
})
const {
@@ -347,7 +346,7 @@
reason
} = canuseResult
if (coupon.type == 2) {
if (canUse) {
if (canUse || goodsCouponSel.value.id == coupon.id) {
canUseGoodsCoupon.push(coupon)
} else {
noUseGoodsCoupon.push({
@@ -356,7 +355,7 @@
})
}
} else {
if (canUse) {
if (canUse || couponSel.value.id == coupon.id) {
canUseDiscountCoupon.push(coupon)
} else {
noUseDiscountCoupon.push({
@@ -373,7 +372,7 @@
v,
user,
goodsOrderPrice,
[],
quansSelArr.value,
shopInfo
);
return {
@@ -505,15 +504,64 @@
}
onShow(() => {
const couponArr = cartStore.backendCoupons.filter(v => v.type != 2)
const goodsCouponArr = cartStore.backendCoupons.filter(v => v.type == 2)
if (couponArr.length) {
couponSel.value = couponArr[0]
}
if (goodsCouponArr.length) {
goodsCouponSel.value = goodsCouponArr[0]
}
getCouponList();
});
onLoad(() => {
getCouponShopsAjax();
});
watch(() => quansSelArr.value, (newval) => {
uni.$emit('selCoupon', newval)
const user = uni.cache.get('shopUserInfo')
let shopInfo = uni.cache.get('shopInfo') || {}
if (!shopInfo.isMemberPrice) {
shopInfo = {}
}
const goodsOrderPrice = uni.getStorageSync('goodsOrderPrice') || 0
const dinnerType = cartStore.dinnerType
const canDikouGoodsArr = UTILS.returnCanDikouGoods(cartStore.allGoods, [], user);
const shopId = uni.cache.get('shopId')
let goodsCoupon = newval.filter(v => v.type == 2)
let otherCoupon = newval.filter(v => v.type != 2)
goodsCoupon = goodsCoupon.map(v => {
const discount = UTILS.returnCouponDiscount(
canDikouGoodsArr,
v,
user,
goodsOrderPrice,
[],
shopInfo
);
return {
...v,
discount,
discountAmount: discount ? discount.discountPrice : v.discountAmount,
}
})
otherCoupon = otherCoupon.map(v => {
const discount = UTILS.returnCouponDiscount(
canDikouGoodsArr,
v,
user,
goodsOrderPrice,
goodsCoupon,
shopInfo
);
return {
...v,
discount,
discountAmount: discount ? discount.discountPrice : v.discountAmount,
}
})
uni.$emit('selCoupon', [...goodsCoupon, ...otherCoupon])
}, {
deep: true
})

View File

@@ -244,7 +244,7 @@
</view>
<view class="flex-end" v-if="item1.type == 'sku' || (item1.type == 'package' && item1.groupType == '1')">
<view class="sku-wrap flex-center" @click.stop="clickspecifications(item1, index, index1)">
<text class="t" v-if="item1.groupType == '1'">选择套餐</text>
<text class="t no-wrap" v-if="item1.groupType == '1'">选择套餐</text>
<text class="t" v-else>选规格</text>
<text class="dot num" v-if="item1.cartNumber > 0">{{ ifcartNumber(item1) < 99 ? ifcartNumber(item1) : '99+' }}</text>
</view>
@@ -1914,7 +1914,7 @@ function toHistory() {
border-radius: 32rpx;
position: relative;
align-items: center;
white-space: nowrap;
.t {
font-size: 28rpx;
color: #fff;

View File

@@ -21,7 +21,7 @@
</view>
<view class="icon icon3" v-if="props.item.type == 3">
<view class="top">
<text class="num">{{ props.item.discountRate }}</text>
<text class="num">{{ props.item.discountRate/10 }}</text>
</view>
<view class="intro">
<text class="t">{{ props.item.fullAmount }}可用</text>

View File

@@ -28,7 +28,7 @@ import {
export const useCartsStore = defineStore('cart',
() => {
// 商品订单会员
// 店铺信息
const shopInfo = ref(uni.cache.get('shopInfo') || {
isMemberPrice: 0,
isTableFee: 1
@@ -97,10 +97,10 @@ export const useCartsStore = defineStore('cart',
}
//餐位费配置
const dinersNum = uni.cache.set('dinersNum') || 1
const dinersNum = uni.cache.get('dinersNum') || 0
const seatFeeConfig = ref({
pricePerPerson: shopInfo.value.tableFee || 1,
personCount: dinersNum,
pricePerPerson: shopInfo.value.tableFee || 0,
personCount: dinersNum||0,
isEnabled: !shopInfo.value.isTableFee
})
watch(() => shopInfo.value.isTableFee, (newval) => {
@@ -556,6 +556,13 @@ export const useCartsStore = defineStore('cart',
});
function clearOrderConfig(){
backendCoupons.value=[];
seatFeeConfig.value.personCount=uni.cache.get('dinersNum') || 0;
dinnerType.value='dine-in';
userPoints.value=0
}
return {
getTotalPackFee,
@@ -582,6 +589,8 @@ export const useCartsStore = defineStore('cart',
//优惠券列表
backendCoupons,
allGoods,
//就餐类型
dinnerType,
setDinnerType,
setSeatFeeConfig,
seatFeeConfig,
@@ -591,6 +600,8 @@ export const useCartsStore = defineStore('cart',
//新客立减金额
newUserDiscount,
getAllGoodsList,
//清空配置
clearOrderConfig
};
}

View File

@@ -132,6 +132,10 @@ export const Memberpay = defineStore('memberpay', {
buyerRemark: data.buyerRemark,
userId: uni.cache.get('userInfo').id || ''
})
if(!res){
console.log('支付失败');
reject(false)
}
if (res) {
uni.showLoading({
title: '加载中...',
@@ -235,7 +239,7 @@ export const Memberpay = defineStore('memberpay', {
seatNum: data.seatNum, //用餐人数
packFee: data.packFee, //打包费
originAmount: data.originAmount, //订单原金额(包含打包费) 不含折扣价格 不含餐位费
tableCode: uni.cache.get('tableCode'), //台桌编码
tableCode:data.tableCode|| uni.cache.get('tableCode'), //台桌编码
dineMode: 'dine-in', //堂食 dine-in 外带 take-out 外卖 take-away
remark: data.remark, //备注
placeNum: data.placeNum, //当前订单下单次数

View File

@@ -31,7 +31,7 @@
<text class="color-000 font-14 font-700">会员专属权益</text>
<view class="u-flex">
<text class="color-666 u-m-r-4 font-12">会员说明</text>
<up-icon name="question-circle" size="12" @click="modelShow"></up-icon>
<up-icon name="question-circle" size="12" @click="modelShow('会员说明')"></up-icon>
</view>
</view>
<view class="u-m-t-32">
@@ -190,15 +190,7 @@
}
model.show = true;
}
const modelContent = ref(`
1、可适用门店全部门店<br>
2、可适用商品部分商品<br>
3、可使用类型堂食<br>
4、可用时间段全时段可用<br>
5、限量规则每人限领3张每日可最多使用3张<br>
6、同享规则与限时折扣同享、与会员价同享<br>
7、其它说明这里是后台配置内容
`)
const modelContent = ref(``)
const state = reactive({
openType: 'CONDITION'
})

View File

@@ -12,7 +12,7 @@
<view class="lv">{{memberLevel?memberLevel.name:''}}</view>
<view class="time">
<text>{{memberLevel?memberLevel.endTime:''}}到期 </text>
<text>月度会员</text>
<text>{{memberLevel?memberLevel.memberName:''}}</text>
</view>
<view class="rule u-m-t-40 u-flex u-flex-between u-flex-y-center">
<text class="color-one ">
@@ -249,7 +249,7 @@
}
}
if (v.name == '会员折扣') {
v.desc = '全店折扣'+res.memberLevel.discount+'折'
v.desc = '全店折扣'+(res.memberLevel.discount/10)+'折'
}
return v
})
@@ -262,7 +262,7 @@
}
}
if (v.name == '会员折扣') {
v.desc = '全店折扣'+res.memberLevel.discount+'折'
v.desc = '全店折扣'+(res.memberLevel.discount/10)+'折'
}
return v
})
@@ -279,6 +279,7 @@
memberLevel.value = {
...res1.memberLevel,
endTime: res1.endTime,
memberName:res1.memberName,
experience: res1.experience,
nextExperienceValue: res1.nextExperienceValue
}
@@ -298,8 +299,7 @@
}
const index=memberLevelList.value.findIndex(v=>v.id==memberLevel.value.id)
console.log(index);
if(index!=-1||index>=memberLevelList.value.length-1){
if(index==-1||index>=memberLevelList.value.length-1){
return null
}
const next=memberLevelList.value[index+1]

45
utils/coupon.js Normal file
View File

@@ -0,0 +1,45 @@
import {
findCoupon
} from '@/common/api/market/coupon.js';
import * as UTILS from '@/utils/goods-utils.js'
export async function returnHasCouponCanUse(args) {
const {
goodsOrderPrice,
dinnerType,
shopId,
shopInfo,
shopUserId,
allGoods,
user
} = args
const res = await findCoupon({
shopUserId,
});
if(!res||res.length<=0){
return false
}
const canDikouGoodsArr = UTILS.returnCanDikouGoods(allGoods, [], user);
for (let i = 0; i < res.length; i++) {
const coupon = res[i]
const canuseResult = UTILS.returnCouponCanUse({
canDikouGoodsArr,
coupon,
goodsOrderPrice,
user,
selCoupon: [],
shopInfo
})
const {
canUse,
reason
} = canuseResult
if (canUse) {
return true
}
}
return false
}

View File

@@ -12,6 +12,9 @@ import _ from "lodash";
* @param {Object} shopInfo
*/
export function returnGoodsPrice(goods, user, shopInfo) {
if(!goods){
return 0
}
if (goods.discount_sale_amount * 1 > 0) {
return goods.discount_sale_amount;
}
@@ -65,21 +68,37 @@ export function returnCoupType(coupon) {
* @param user 用户信息
*/
export function returnCanDikouGoodsArr(canDikouGoodsArr, selCoupon, user) {
const types = [2, 4, 6];
// 收集已抵扣商品并关联对应的优惠券类型
const goodsCouponGoods = selCoupon
.filter((v) => v.type == 2)
.reduce((prve, cur) => {
prve.push(...cur.discount.hasDiscountGoodsArr);
return prve;
.filter((v) => types.includes(v.type))
.reduce((prev, cur) => {
// 给每个抵扣商品添加所属优惠券类型
const goodsWithType = cur.discount.hasDiscountGoodsArr.map(goods => ({
...goods,
couponType: cur.type // 记录该商品是被哪种类型的优惠券抵扣的
}));
prev.push(...goodsWithType);
return prev;
}, []);
const arr = _.cloneDeep(canDikouGoodsArr)
.map((v) => {
const findCart = goodsCouponGoods.find((carts) => carts.id == v.id);
if (findCart) {
// 根据优惠券类型判断扣减数量
if ([4, 6].includes(findCart.couponType)) {
// 类型4第二件半价或6买一送一数量减2
v.num -= 2;
} else {
// 其他类型如类型2商品券按原逻辑扣减对应数量
v.num -= findCart.num;
}
}
return v;
})
.filter((v) => v.num > 0);
.filter((v) => v.num > 0); // 过滤掉数量<=0的商品
return arr;
}
@@ -151,7 +170,13 @@ export function returnCouponCanUse(args) {
// 商品券特殊验证
if (coupon.type === 2) {
if (!(isDikouAll || canCalcGoodsArr.length > 0)) {
if (!(isDikouAll || canCalcGoodsArr.length === 0)) {
return {
canUse: false,
reason: "没有符合条件的商品可抵扣"
};
}
if(canDikouGoodsArr.length<=0){
return {
canUse: false,
reason: "没有符合条件的商品可抵扣"
@@ -241,7 +266,6 @@ export function calcDiscountGoodsArrPrice(discountGoodsArr, discountNum, user,sh
* @param selCoupon 已选择的优惠券列表
*/
export function returnCouponDiscount(arr, coupon, user, goodsOrderPrice, selCoupon) {
console.log('arr', arr);
const canDikouGoodsArr = returnCanDikouGoodsArr(arr, selCoupon, user);
console.log('canDikouGoodsArr', canDikouGoodsArr);
if (coupon.type == 2) {
@@ -291,7 +315,7 @@ export function returnCouponZhekouDiscount(
// 2. 计算优惠比例1 - 折扣率例如8折的优惠比例是 1 - 0.8 = 0.2
const discountAmountRatio = new BigNumber(1).minus(discountRatio);
// 3. 计算折扣金额:商品订单金额 × 优惠比例
let discountPrice = new BigNumber(goodsOrderPrice).times(discountAmountRatio).toNumber();
let discountPrice = new BigNumber(goodsOrderPrice).times(discountAmountRatio).decimalPlaces(2, BigNumber.ROUND_FLOOR).toNumber();
if (maxDiscountAmount != 0) {
discountPrice = discountPrice >= maxDiscountAmount ? maxDiscountAmount : discountPrice;
}