问题修复

This commit is contained in:
2025-11-06 10:42:42 +08:00
parent 0f6c87efc7
commit ab350ccc14
9 changed files with 332 additions and 217 deletions

View File

@@ -220,7 +220,7 @@
ref="payPasswordref"
:isShow="ispws"
@inputComplete="(e) => accountPayevent(e)"
@close="ispws = false"
@close="pwdClose"
/>
<!-- 私域引流配置 -->
<OrderFinshModal v-model="showDrainage"></OrderFinshModal>
@@ -228,7 +228,7 @@
</template>
<script setup>
import { back } from "@/utils/uniapp.js";
import { onLoad } from "@dcloudio/uni-app";
import { onLoad ,onUnload} from "@dcloudio/uni-app";
import ChargeVue from "./components/charge.vue";
import { pay } from "@/utils/pay.js";
import OrderFinshModal from "@/components/order-finish-modal.vue";
@@ -263,6 +263,19 @@ import {
import { useCartsStore } from "@/stores/carts.js";
import { useWebSocket } from "@/stores/carts-websocket.js";
function pwdClose() {
ispws.value = false;
pay_unlock();
}
onUnload(()=> {
console.log("onUnload");
closeSocket();
})
onBackPress(()=> {
console.log("返回拦截");
closeSocket();
})
function onback() {
closeSocket();
console.log("返回");
@@ -306,18 +319,24 @@ async function onMessage(Message) {
youhuiReset();
}
if (Message.operate_type == "cleanup") {
listinfo.totalCost = 0;
console.log("onMessage:cleanup", Message);
console.log("onMessage:options", options);
console.log("onMessage:listinfo", listinfo);
youhuiReset();
if (listinfo.id) {
let res = await APIgetOrderById({
orderId: listinfo.id,
});
if (listinfo.id || options.tableCode) {
let res = listinfo.id
? await APIgetOrderById({
orderId: listinfo.id,
})
: await APIhistoryOrder({
tableCode: options.tableCode || "",
});
console.log("onMessage:APIgetOrderById", res);
Object.assign(listinfo, res);
if (res) {
orderRemarker.value = res.remark;
// cartStore.carts=[];
// cartStore.setOldOrder(res)
cartStore.setOldOrder(res);
}
if (noPayStatus[res.status]) {
uni.showToast({
@@ -437,14 +456,18 @@ const freeCheck = ref(false);
let backtimer = null;
let historyTotalPrices = 0;
// * 获取订单详情接口
const orderorderInfo = async () => {
const orderorderInfo = async (isNpwGetOrderDetail = false) => {
console.log("listinfo.id", listinfo.id);
if (!listinfo.id && !options.tableCode) {
return;
}
if (isPayBefor() && !listinfo.id) {
return;
if (!isNpwGetOrderDetail) {
if (isPayBefor() && !listinfo.id) {
return;
}
}
let res = listinfo.id
? await APIgetOrderById({
orderId: listinfo.id,
@@ -838,10 +861,36 @@ const istoricalorders = async () => {
}
};
//开始锁单
function start_lock_order() {
clearInterval(payStatusTimer);
pay_lock();
payStatusTimer = setInterval(() => {
pay_lock();
}, 1000);
}
// * 去支付
const goToPay = async (payParams) => {
console.log("goToPay:payParams", payParams);
const canPayRes = await search_pay_lock();
const canPay = canPayRes.status == 1 ? true : false;
if (!canPay) {
uni.showToast({
title: "有人正在付款中!",
icon: "none",
});
const shopUserInfo = uni.cache.get("shopUserInfo");
console.log("shopUserInfo", shopUserInfo);
console.log("listinfo", listinfo);
if (shopUserInfo) {
if (shopUserInfo.userId == listinfo.userId) {
pay_unlock();
}
}
return;
}
// 余额支付
if (payParams.payType == "accountPay") {
if (orderVIP.value.payPwd == "") {
@@ -861,6 +910,7 @@ const goToPay = async (payParams) => {
});
return;
}
start_lock_order();
if (userInfo.usePayPwd) {
ispws.value = true;
return;
@@ -868,30 +918,10 @@ const goToPay = async (payParams) => {
accountPayevent();
return;
}
const canPayRes = await search_pay_lock();
const canPay = canPayRes.status == 1 ? true : false;
if (!canPay) {
uni.showToast({
title: "有人正在付款中!",
icon: "none",
});
const shopUserInfo = uni.cache.get("shopUserInfo");
console.log("shopUserInfo", shopUserInfo);
console.log("listinfo", listinfo);
if (shopUserInfo) {
if (shopUserInfo.userId == listinfo.userId) {
pay_unlock();
}
}
return;
}
console.log("canPay:goToPay:payParams", payParams);
pay_lock();
payStatusTimer = setInterval(() => {
pay_lock();
}, 1000);
start_lock_order();
console.log("霸王餐前payParams", payParams);
if (payParams.isBwc) {
payParams.checkOrderPay.orderId = listinfo.id;
@@ -968,7 +998,7 @@ const accountPayevent = async (pwd) => {
ispws.value = false;
payParams.checkOrderPay.userId = uni.cache.get("userInfo").id;
payParams.checkOrderPay.orderId = listinfo.id;
payParams.pwd = pwd;
try {
const isPaySuccess = await storeMemberpay.balancePayOrder(payParams);
if (isPaySuccess) {
@@ -976,10 +1006,13 @@ const accountPayevent = async (pwd) => {
title: "支付成功",
icon: "none",
});
pay_unlock();
paySucessCallback();
}
} catch (error) {
//TODO handle the exception
pay_unlock();
}
orderorderInfo();
};
@@ -1028,10 +1061,6 @@ let options = {};
function toJiacai() {
console.log("跳转到加菜页面");
back();
return;
uni.navigateTo({
url: "/pages/product/index",
});
}
const packfee = computed(() => {
return cartStore.orderCostSummary.packFee;
@@ -1067,6 +1096,7 @@ const navTitle = computed(() => {
//支付成功后的处理
function paySucessCallback() {
console.log("paySucessCallback");
cartsSocket.closeSocket();
showDrainage.value = true;
}

View File

@@ -847,6 +847,7 @@ import {
onReady,
onShow,
onHide,
onUnload,
onPageScroll,
} from "@dcloudio/uni-app";
@@ -989,8 +990,6 @@ const imageLoaded = (item, index, index1) => {
// 计算左侧位置
const leftIndex = ref(0);
//元素最低端的距离
const lastbottom = ref("");
@@ -1428,7 +1427,7 @@ const submitSelection = async () => {
} else {
selectedGroupSnap.value = [];
}
console.log('specifications.item', specifications.item);
websocketsendMessage({
id: res ? res.cartListId : "",
type: "shopping",
@@ -1446,8 +1445,7 @@ const submitSelection = async () => {
memberPrice: specifications.item.memberPrice,
is_print: 1,
product_type: specifications.item.type,
is_time_discount:specifications.item.is_time_discount
is_time_discount: specifications.item.is_time_discount,
});
// 清空套餐选中
selectedGroupSnap.value = [];
@@ -1487,7 +1485,7 @@ const clickspecifications = async (item, index, indexs, type) => {
// skuBtnText.value = '请选择规格'
// single-单规格商品 sku-多规格商品 package-套餐商品 weight-称重商品 coupon-团购券
let res = await APIminiAppinfo(item.id);
specifications.item = res;
specifications.item = {...res,is_time_discount:item.is_time_discount};
if (specifications.item.type == "package") {
selectedOptions.value = [];
specifications.product_id = res.id;
@@ -1595,7 +1593,7 @@ const singleclick = async (item, i) => {
number: await calculateValue(item.cartNumber, i, suitNum),
is_print: 1,
product_type: item.type,
is_time_discount:item.is_time_discount
is_time_discount: item.is_time_discount,
});
};
@@ -2122,7 +2120,7 @@ const productqueryProduct = async () => {
product.startTime,
product.endTime
);
product.is_time_discount = showLimitDiscount(product)?1:0;
product.is_time_discount = showLimitDiscount(product) ? 1 : 0;
product.limitSalePrice = returnLimitPrice(product);
cartStore.setGoodsMap(product.id, product);
@@ -2135,11 +2133,11 @@ const productqueryProduct = async () => {
i.startTime,
i.endTime
);
i.is_time_discount = showLimitDiscount(i)?1:0;
i.is_time_discount = showLimitDiscount(i) ? 1 : 0;
i.limitSalePrice = returnLimitPrice(i);
cartStore.setGoodsMap(i.id, i);
});
console.log("shopProductList", shopProductList);
cartStore.goodsIsloading = true;
scrollTopSize.value = 0;
topArr.value = [];
@@ -2167,6 +2165,11 @@ provide("shopUserInfo", shopUserInfo);
provide("shopInfo", shopInfo);
onLoad(async (e) => {
console.log("onLoad:e", e);
cartStore.setOldOrder({
detailMap: {},
originAmount: 0,
});
await proxy.$onLaunched;
});
@@ -2215,7 +2218,16 @@ onShow(async () => {
}
});
onHide(() => {});
onHide(() => {
console.log("product index onHide");
useSocket.closeSocket();
useSocket.setOnMessage(()=>{});
});
onUnload(() => {
console.log("product index onUnload");
useSocket.closeSocket();
useSocket.setOnMessage(()=>{});
});
onMounted(async () => {
await proxy.$onLaunched;
@@ -2252,7 +2264,6 @@ onMounted(async () => {
operate_type: "time_discount_save",
data: null,
});
}
await productqueryProduct();