问题修复,下单修复

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,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">
-¥{{cartStore.orderCostSummary.pointDeductionAmount}}
</text>
<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 maxMoney = cartStore.orderCostSummary.goodsRealAmount - cartStore.orderCostSummary
const maxPointDiscount = ref(0)
//积分可抵扣最大金额
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
// })
cartStore.setUserPoints(maxUsablePoints)
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
}
}
getConsumeDiscount()
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
})