确认订单更新

This commit is contained in:
2025-09-28 13:57:18 +08:00
parent 53dcd1f788
commit a8c2096096
7 changed files with 49 additions and 20 deletions

View File

@@ -7,6 +7,6 @@
"lodash": "^4.17.21", "lodash": "^4.17.21",
"pinia": "^2.3.1", "pinia": "^2.3.1",
"pinia-plugin-unistorage": "^0.1.2", "pinia-plugin-unistorage": "^0.1.2",
"ysk-utils": "^1.0.28" "ysk-utils": "^1.0.35"
} }
} }

View File

@@ -72,7 +72,6 @@
isShow.value = res.isOrder isShow.value = res.isOrder
list.value = res.rechargeDetailList.filter(v=>v.amount>cartStore.orderCostSummary.finalPayAmount) list.value = res.rechargeDetailList.filter(v=>v.amount>cartStore.orderCostSummary.finalPayAmount)
if(list.value.length){ if(list.value.length){
sel.value=0
updateSel() updateSel()
} }
} }
@@ -80,7 +79,6 @@
watch(()=>cartStore.orderCostSummary.finalPayAmount,(newval)=>{ watch(()=>cartStore.orderCostSummary.finalPayAmount,(newval)=>{
list.value=$riginList.filter(v=>v.amount>newval) list.value=$riginList.filter(v=>v.amount>newval)
if(list.value.length){ if(list.value.length){
sel.value=0
updateSel() updateSel()
} }
}) })

View File

@@ -365,6 +365,7 @@
cartStore.setDinnerType(item.val) cartStore.setDinnerType(item.val)
// this.getchoseEatModel('tabClick', index, item); // this.getchoseEatModel('tabClick', index, item);
} }
cartStore.setDinnerType(tebtypeList[is_type.value].val)
// 操作优惠卷 // 操作优惠卷
const dataprocessing = (data) => { const dataprocessing = (data) => {

View File

@@ -169,7 +169,7 @@
//充值相关 //充值相关
const rechargeItem=ref(null) const rechargeItem=ref({id:''})
const rechargeId=ref(null) const rechargeId=ref(null)
function updateRechargeId(e){ function updateRechargeId(e){
@@ -192,6 +192,11 @@
let res = await APIgetOrderById({ let res = await APIgetOrderById({
orderId: listinfo.id orderId: listinfo.id
}) })
console.log('onMessage:APIgetOrderById',res);
if(res){
// cartStore.carts=[];
// cartStore.setOldOrder(res)
}
if (noPayStatus[res.status]) { if (noPayStatus[res.status]) {
uni.showToast({ uni.showToast({
title: noPayStatus[res.status], title: noPayStatus[res.status],
@@ -582,7 +587,10 @@
// 清空购物车 // 清空购物车
if (res) { if (res) {
Object.assign(listinfo, res) Object.assign(listinfo, res)
// cartStore.carts=[];
// cartStore.setOldOrder(res)
getOrderInfoAfterCalcInit(res) getOrderInfoAfterCalcInit(res)
cartsSocket.sendMessage({ cartsSocket.sendMessage({
type: 'shopping', type: 'shopping',
table_code: uni.cache.get('tableCode'), table_code: uni.cache.get('tableCode'),
@@ -638,7 +646,13 @@
// 购物车有数据 // 购物车有数据
if (!cartStore.isEmpty) { if (!cartStore.isEmpty) {
const res = await createOrder() const res = await createOrder()
//历史订单数据
const res1= await APIgetOrderById({
orderId: res.id
})
cartStore.setOldOrder(res1)
} }
goToPay() goToPay()
} else { } else {
@@ -794,6 +808,7 @@
}) })
pay(payRes) pay(payRes)
}else{ }else{
console.log('微信支付');
await storeMemberpay.actionsltPayOrder({ await storeMemberpay.actionsltPayOrder({
checkOrderPay, checkOrderPay,
payType: paymentmethod.payType, payType: paymentmethod.payType,
@@ -803,6 +818,7 @@
} }
} catch (error) { } catch (error) {
console.log('error',error);
pay_unlock() pay_unlock()
//TODO handle the exception //TODO handle the exception
} }
@@ -918,10 +934,13 @@
url: '/pages/product/index' url: '/pages/product/index'
}) })
} }
const packfee=computed(()=>{
return cartStore.orderCostSummary.packFee
})
//不计算各种折扣前的实付金额 //不计算各种折扣前的实付金额
const shifu = computed(() => { const shifu = computed(() => {
const payAmount = listinfo.payAmount ? listinfo.payAmount * 1 : 0 const payAmount = listinfo.payAmount ? listinfo.payAmount * 1 : 0
return payAmount + cartStore.totalPrice * 1 + 0; return payAmount + cartStore.totalPrice * 1 + packfee.value * 1
}) })
//减去各种折扣后的金额 //减去各种折扣后的金额
const lastPayMoney = computed(() => { const lastPayMoney = computed(() => {
@@ -963,6 +982,7 @@
if (shopInfoRes) { if (shopInfoRes) {
cartStore.shopInfo = shopInfoRes.shopInfo; cartStore.shopInfo = shopInfoRes.shopInfo;
} }
await cartStore.goodsInit()
// * 获取会员信息 // * 获取会员信息
await storeuser.actionsproductqueryProduct() await storeuser.actionsproductqueryProduct()
await nextTick() await nextTick()

10
pnpm-lock.yaml generated
View File

@@ -30,8 +30,8 @@ importers:
specifier: ^0.1.2 specifier: ^0.1.2
version: 0.1.2 version: 0.1.2
ysk-utils: ysk-utils:
specifier: ^1.0.28 specifier: ^1.0.35
version: 1.0.28 version: 1.0.35
packages: packages:
@@ -173,8 +173,8 @@ packages:
typescript: typescript:
optional: true optional: true
ysk-utils@1.0.28: ysk-utils@1.0.35:
resolution: {integrity: sha512-VpEYjK5ldWgZXY+rxcwef8DB9/K9K13BPZEL3l3NXybofLsh1089sMJF4B4rVpqYszcTF13ZLL6WJWCkhCPOkg==} resolution: {integrity: sha512-kxPtEk5zs0HjdazbH2l2x1Tm5BUpmj1MBiOnb9Xquuj2hW2NtICtq+JB6RWFO7tzAAnOC5MRw366VOKceyeK5Q==}
snapshots: snapshots:
@@ -314,6 +314,6 @@ snapshots:
'@vue/server-renderer': 3.5.22(vue@3.5.22) '@vue/server-renderer': 3.5.22(vue@3.5.22)
'@vue/shared': 3.5.22 '@vue/shared': 3.5.22
ysk-utils@1.0.28: ysk-utils@1.0.35:
dependencies: dependencies:
bignumber.js: 9.3.1 bignumber.js: 9.3.1

View File

@@ -24,6 +24,7 @@ import {
productminiApphotsquery, productminiApphotsquery,
APIgroupquery, APIgroupquery,
} from "@/common/api/product/product.js"; } from "@/common/api/product/product.js";
export const useCartsStore = defineStore('cart', export const useCartsStore = defineStore('cart',
() => { () => {
@@ -42,11 +43,15 @@ export const useCartsStore = defineStore('cart',
} : } :
undefined; undefined;
const goods = getProductDetails({
...item,
product_id: item.product_id || item.productId,
sku_id:item.skuId||item.sku_id
})
return { return {
...item, ...item,
id: item.id, id: item.id,
sku_id:item.skuId||item.sku_id,
product_id: item.product_id || item.productId, product_id: item.product_id || item.productId,
salePrice: item.salePrice || item.price, salePrice: item.salePrice || item.price,
number: item.number || item.num || 0, number: item.number || item.num || 0,
@@ -56,7 +61,7 @@ export const useCartsStore = defineStore('cart',
returnNum: item.returnNum || 0, returnNum: item.returnNum || 0,
memberPrice: item.memberPrice || 0, memberPrice: item.memberPrice || 0,
discountSaleAmount: item.discount_sale_amount || item.discountSaleAmount || 0, discountSaleAmount: item.discount_sale_amount || item.discountSaleAmount || 0,
packFee: item.packFee || 0, packFee: item.packFee || (goods?goods.packFee:0) || 0,
packNumber: item.pack_number || item.packNumber || 0, packNumber: item.pack_number || item.packNumber || 0,
activityInfo: item.activityInfo ? { activityInfo: item.activityInfo ? {
type: item.activityInfo.type, type: item.activityInfo.type,
@@ -68,7 +73,9 @@ export const useCartsStore = defineStore('cart',
}; };
// 合并所有商品列表 // 合并所有商品列表
const allGoods = computed(() => { const allGoods = ref([])
function getAllGoodsList() {
const currentGoods = (carts.value).map(convertToBaseCartItem); const currentGoods = (carts.value).map(convertToBaseCartItem);
const giftGoods = [].map(convertToBaseCartItem); const giftGoods = [].map(convertToBaseCartItem);
// 扁平化历史订单商品 // 扁平化历史订单商品
@@ -76,7 +83,7 @@ export const useCartsStore = defineStore('cart',
.flat() .flat()
.map(convertToBaseCartItem); .map(convertToBaseCartItem);
return [...currentGoods, ...giftGoods, ...oldOrderGoods]; return [...currentGoods, ...giftGoods, ...oldOrderGoods];
}) }
// 就餐类型 'dine-in' | 'take-out' // 就餐类型 'dine-in' | 'take-out'
@@ -162,6 +169,8 @@ export const useCartsStore = defineStore('cart',
const cartOrder = ref({}); const cartOrder = ref({});
// 订单费用汇总 // 订单费用汇总
const orderCostSummary = computed(() => { const orderCostSummary = computed(() => {
allGoods.value = getAllGoodsList()
console.log('orderCostSummary:allGoods.value',allGoods.value );
const costSummary = OrderPriceCalculator.calculateOrderCostSummary( const costSummary = OrderPriceCalculator.calculateOrderCostSummary(
allGoods.value, allGoods.value,
dinnerType.value, dinnerType.value,
@@ -193,6 +202,8 @@ export const useCartsStore = defineStore('cart',
setGoodsMap(product.id, product) setGoodsMap(product.id, product)
} }
} }
allGoods.value = getAllGoodsList()
console.log('allGoods.value ',allGoods.value );
goodsIsloading.value = false goodsIsloading.value = false
} }
@@ -214,9 +225,7 @@ export const useCartsStore = defineStore('cart',
} }
let skuData = undefined; let skuData = undefined;
skuData = goods?.skuList.find((sku) => sku.id == v.sku_id); skuData = goods?.skuList.find((sku) => sku.id == v.sku_id);
skuData = goods?.skuList.find((sku) => sku.id == v.sku_id);
if (skuData) { if (skuData) {
return { return {
...v, ...v,
@@ -576,7 +585,8 @@ export const useCartsStore = defineStore('cart',
seatFeeConfig, seatFeeConfig,
shopInfo, shopInfo,
//新客立减金额 //新客立减金额
newUserDiscount newUserDiscount,
getAllGoodsList
}; };
} }
); );

View File

@@ -4,7 +4,7 @@
<view class="top" style=" background-image: url(/static/czzx_header_bg.png);"> <view class="top" style=" background-image: url(/static/czzx_header_bg.png);">
<view> <view>
<view class="u-flex"> <view class="u-flex">
<up-avatar size="136rpx" shape="square" round="20rpx" :src="shopInfo.coverImg"></up-avatar> <up-avatar size="136rpx" shape="square" round="20rpx" :src="shopInfo.logo"></up-avatar>
<view class="u-p-l-20"> <view class="u-p-l-20">
<view class="shop-name u-line-1">{{shopInfo.shopName||'店铺名称' }}</view> <view class="shop-name u-line-1">{{shopInfo.shopName||'店铺名称' }}</view>
<view class="u-flex"> <view class="u-flex">