问题修复,下单修复

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

@@ -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>