问题修复

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

@@ -1,120 +1,138 @@
export default (params) => { export default (params) => {
let url = params.url; let url = params.url;
let method = params.method || "get"; let method = params.method || "get";
let data = params.data || {}; let data = params.data || {};
let type = params.type || 1; let type = params.type || 1;
let toast = params.toast || true; let toast = params.toast || true;
let token=uni.cache.get('token') || ''; let token = uni.cache.get("token") || "";
const shopId=uni.cache.get('shopId')*1; const shopId = uni.cache.get("shopId") * 1;
const userInfo=uni.cache.get('userInfo')||{}; const userInfo = uni.cache.get("userInfo") || {};
// #ifdef H5 // #ifdef H5
token="21f0a0b10e1d40ce9c6464037fedb792" token = "21f0a0b10e1d40ce9c6464037fedb792";
// #endif // #endif
let header = { let header = {
version: uni.conf.version, version: uni.conf.version,
type: uni.getSystemInfoSync().platform, type: uni.getSystemInfoSync().platform,
// #ifdef APP-PLUS // #ifdef APP-PLUS
platformType: 'APP', platformType: "APP",
// #endif // #endif
// #ifdef H5 // #ifdef H5
platformType: 'H5', platformType: "H5",
// #endif // #endif
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
platformType: 'WX', platformType: "WX",
// #endif // #endif
// #ifdef MP-ALIPAY // #ifdef MP-ALIPAY
platformType: 'ALI', platformType: "ALI",
// #endif // #endif
token, token,
id: userInfo.id || '', id: userInfo.id || "",
shopId:shopId || '', shopId: shopId || "",
userId: userInfo.id || '', userId: userInfo.id || "",
} };
if (toast) { if (toast) {
uni.showLoading({ uni.showLoading({
title: '加载中', title: "加载中",
mask: true mask: true,
}) });
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const timeoutDuration = params.timeout || 10000; // 可以通过 params 传入超时时间,默认 10 秒 const timeoutDuration = params.timeout || 10000; // 可以通过 params 传入超时时间,默认 10 秒
uni.request({ uni.request({
url: uni.conf.baseUrl + url, url: uni.conf.baseUrl + url,
method: method, method: method,
header: header, header: header,
data: data, data: data,
timeout: timeoutDuration, timeout: timeoutDuration,
success(response) { success(response) {
const res = response.data const res = response.data;
// 根据返回的状态码做出对应的操作 // 根据返回的状态码做出对应的操作
//获取成功 //获取成功
if (res.code == 200) { if (res.code == 200) {
uni.hideLoading(); uni.hideLoading();
uni.hideToast(); uni.hideToast();
resolve(res.data ? res.data : true); resolve(res.data ? res.data : true);
} else { } else {
switch (res.code) { switch (res.code) {
case '501': case "501":
uni.cache.remove('shopId') uni.cache.remove("shopId");
// uni.showToast({ // uni.showToast({
// title: '', // title: '',
// icon: "none", // icon: "none",
// success: () => { // success: () => {
// } // }
// }) // })
setTimeout(() => { setTimeout(() => {
uni.reLaunch({ uni.reLaunch({
url: "/pages/index/index", url: "/pages/index/index",
}) });
}, 1000); }, 1000);
break; break;
case 404: case 404:
uni.showToast({ uni.showToast({
title: '请求地址不存在...', title: "请求地址不存在...",
duration: 2000, duration: 2000,
}) });
break; break;
default: default:
// 是否提示 // 是否提示
if (toast) { if (toast) {
uni.showToast({ uni.showToast({
title: res.message || res.msg || res.error, title: (() => {
icon: "none", // 1. 获取原始提示文本(兜底空字符串避免报错)
success: () => { const originMsg = res.message || res.msg || res.error || "";
setTimeout(res => { // 2. 定义要匹配的前缀
reject(false); const exceptionPrefix = "Exception:";
}, 1000) // 3. 判断是否包含目标前缀
} if (originMsg.includes(exceptionPrefix)) {
}) // 截取前缀后的内容 → 去除首尾空格 → 限制最大20个字符
} return originMsg
break; .slice(
} originMsg.indexOf(exceptionPrefix) +
} exceptionPrefix.length
}, )
fail(err) { .trim()
if (err.errMsg.indexOf('request:fail') !== -1) { .slice(0, 20);
if (err.errMsg.indexOf('timeout') !== -1) { } else {
if (toast) { // 不包含则按原逻辑截取前20个字符
uni.showToast({ return originMsg.slice(0, 20);
title: `请求超时,请稍后重试`, }
icon: "error", })(),
duration: 2000 icon: "none",
}); success: () => {
} // 修复:去掉多余的 res 参数(避免覆盖外层 res
} setTimeout(() => {
} reject(false);
reject(err); }, 1000);
}, },
complete() { });
// 不管成功还是失败都会执行 }
setTimeout(res => { break;
uni.hideLoading(); }
uni.hideToast(); }
}, 10000) },
fail(err) {
} if (err.errMsg.indexOf("request:fail") !== -1) {
}); if (err.errMsg.indexOf("timeout") !== -1) {
}).catch((e) => { if (toast) {
}); uni.showToast({
}; title: `请求超时,请稍后重试`,
icon: "error",
duration: 2000,
});
}
}
}
reject(err);
},
complete() {
// 不管成功还是失败都会执行
setTimeout((res) => {
uni.hideLoading();
uni.hideToast();
}, 10000);
},
});
}).catch((e) => {});
};

View File

@@ -8,8 +8,12 @@
backgroundColor: btnColor, backgroundColor: btnColor,
width: `${btnSize}px`, width: `${btnSize}px`,
height: `${btnSize}px`, height: `${btnSize}px`,
transform: `translateX(${currentOffsetX}px) translateY(${currentOffsetY}px)`,
}" }"
:class="{ active: isPopupVisible }" :class="{ active: isPopupVisible }"
@touchstart="touchstart"
@touchmove="touchmove"
@touchend="touchend"
> >
<up-icon <up-icon
name="plus" name="plus"
@@ -20,7 +24,14 @@
</view> </view>
<!-- 操作弹窗 --> <!-- 操作弹窗 -->
<view class="popup" v-if="isPopupVisible" :class="{ show: isPopupVisible }"> <view
class="popup"
v-if="isPopupVisible"
:class="{ show: isPopupVisible }"
:style="{
transform: `translateX(${currentOffsetX}px) translateY(${currentOffsetY}px)`,
}"
>
<view class="popup-arrow"></view> <view class="popup-arrow"></view>
<view class="popup-content"> <view class="popup-content">
<view <view
@@ -40,14 +51,57 @@
</template> </template>
<script setup> <script setup>
import { ref, defineProps, defineEmits,computed } from "vue"; import { ref, defineProps, defineEmits, computed } from "vue";
const show=computed(()=>{ const show = computed(() => {
const sysInfo=uni.getAccountInfoSync(); // trial
if(sysInfo&&sysInfo.miniProgram && (sysInfo.miniProgram.envVersion == 'release'||sysInfo.miniProgram.envVersion == 'develop')) { const sysInfo = uni.getAccountInfoSync();
return true; if (
} sysInfo &&
return false sysInfo.miniProgram &&
}) (
sysInfo.miniProgram.envVersion == "develop")
) {
return true;
}
return false;
});
// 核心修改1新增“历史累积偏移量”变量保存上一次拖拽后的最终位置
const lastOffsetX = ref(0); // 历史X偏移累积值
const lastOffsetY = ref(0); // 历史Y偏移累积值
const currentOffsetX = ref(0); // 当前拖拽的实时偏移(基于历史值)
const currentOffsetY = ref(0); // 当前拖拽的实时偏移(基于历史值)
const startX = ref(0);
const startY = ref(0);
// 核心修改2touchstart - 基于历史偏移量初始化当前拖拽起点
function touchstart(e) {
const touch = e.touches[0];
startX.value = touch.clientX;
startY.value = touch.clientY;
// 关键:当前拖拽的起点 = 上一次拖拽的终点(历史累积偏移量)
currentOffsetX.value = lastOffsetX.value;
currentOffsetY.value = lastOffsetY.value;
}
// 核心修改3touchmove - 实时计算“历史偏移量 + 当前拖拽距离”
function touchmove(e) {
const touch = e.touches[0];
// 当前拖拽的相对距离 = 现在触摸点 - 拖拽起点
const moveX = touch.clientX - startX.value;
const moveY = touch.clientY - startY.value;
// 实时偏移 = 历史累积偏移 + 当前相对移动距离(位置连续)
currentOffsetX.value = lastOffsetX.value + moveX;
currentOffsetY.value = lastOffsetY.value + moveY;
}
// 核心修改4touchend - 保存当前拖拽终点为历史偏移量(供下次使用)
function touchend() {
// 关键:将本次拖拽的最终位置保存为历史值
lastOffsetX.value = currentOffsetX.value;
lastOffsetY.value = currentOffsetY.value;
}
// 定义组件属性 // 定义组件属性
const props = defineProps({ const props = defineProps({
@@ -133,45 +187,43 @@ const closePopup = () => {
} }
}; };
async function getWxloginCode() {
async function getWxloginCode(){ return new Promise((resolve, reject) => {
return new Promise((resolve, reject) => { uni.login({
uni.login({ success: (res) => {
success: (res) => { if (res.code) {
if (res.code) { resolve(res.code);
resolve(res.code); } else {
} else { console.log("获取登录凭证code失败" + res.errMsg);
console.log("获取登录凭证code失败" + res.errMsg); reject(res.errMsg);
reject(res.errMsg); }
} },
},
});
}); });
});
} }
// 处理操作选择 // 处理操作选择
const handleOperation = async (action) => { const handleOperation = async (action) => {
let data=''; let data = "";
if (action == "token") { if (action == "token") {
data=uni.cache.get("token"); data = uni.cache.get("token");
} }
if (action == "userInfo") { if (action == "userInfo") {
data=JSON.stringify(uni.cache.get("userInfo")); data = JSON.stringify(uni.cache.get("userInfo"));
} }
if(action == "getLoginCode"){ if (action == "getLoginCode") {
data=await getWxloginCode(); data = await getWxloginCode();
} }
if(action == "copyStoreInfo"){ if (action == "copyStoreInfo") {
data=JSON.stringify(uni.cache.get("shopInfo")); data = JSON.stringify(uni.cache.get("shopInfo"));
} }
if(action == "copyStoreUserInfo"){ if (action == "copyStoreUserInfo") {
data=JSON.stringify(uni.cache.get("shopUserInfo")); data = JSON.stringify(uni.cache.get("shopUserInfo"));
} }
console.log('data',data) console.log("data", data);
uni.setClipboardData({ uni.setClipboardData({
data: data, data: data,
success: function () {}, success: function () {},
}); });
emit("onOperation", action); emit("onOperation", action);
closePopup(); closePopup();
}; };
@@ -198,7 +250,7 @@ const handleOperation = async (action) => {
linear-gradient(259deg, #fe6d11 50.14%, #ffd1b4 114.93%); linear-gradient(259deg, #fe6d11 50.14%, #ffd1b4 114.93%);
box-shadow: 0 0.4375rem 0.95rem 0 #fe8b435e; box-shadow: 0 0.4375rem 0.95rem 0 #fe8b435e;
cursor: pointer; cursor: pointer;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); /*transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); */
z-index: 1001; z-index: 1001;
} }

View File

@@ -1,5 +1,5 @@
// const debug = process.env.NODE_ENV == 'development' ? true : false; // const debug = process.env.NODE_ENV == 'development' ? true : false;
const debug = true const debug = false
// #ifdef H5 // #ifdef H5
const proxyApi = "/api" const proxyApi = "/api"
// #endif // #endif
@@ -7,9 +7,6 @@ const proxyApi = "/api"
// #ifdef MP-WEIXIN || APP || MP-ALIPAY // #ifdef MP-WEIXIN || APP || MP-ALIPAY
const proxyApi = 'http://192.168.1.42' // 调试地址 const proxyApi = 'http://192.168.1.42' // 调试地址
const proxyApiwws = 'ws://192.168.1.42:2348' // 调试地址 const proxyApiwws = 'ws://192.168.1.42:2348' // 调试地址
// 测试
// const proxyApi = "https://fv901fw8033.vicp.fun"
// const proxyApiwws = 'wss://sockets.sxczgkj.com/wss'
// #endif // #endif
// #ifdef H5 // #ifdef H5
@@ -23,10 +20,6 @@ const baseUrlwws = debug ? proxyApiwws : 'wss://czgeatws.sxczgkj.com/wss' // 线
// #endif // #endif
// import VConsole from "./vConsole.js"
// if (debug) {
// new VConsole()
// }
const version = '100' const version = '100'
const autoRemoveCache = { const autoRemoveCache = {
count: 100000, count: 100000,

View File

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

View File

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

View File

@@ -288,11 +288,15 @@ export const useCartsStore = defineStore("cart", () => {
//购物车商品信息补全初始化 //购物车商品信息补全初始化
function cartsGoodsInfoInit(arr) { function cartsGoodsInfoInit(arr) {
carts.value = arr console.log('cartsGoodsInfoInit',arr)
if(arr&&Array.isArray(arr)){
carts.value = arr
.map((v) => { .map((v) => {
return getProductDetails(v); return getProductDetails(v);
}) })
.filter((v) => v); .filter((v) => v);
}
} }
//收到socket消息时对购物车进行处理 //收到socket消息时对购物车进行处理
@@ -395,6 +399,7 @@ export const useCartsStore = defineStore("cart", () => {
}); });
function setOldOrder(data) { function setOldOrder(data) {
console.log("setOldOrder", data);
oldOrder.value = data; oldOrder.value = data;
allGoods.value = getAllGoodsList(); allGoods.value = getAllGoodsList();
} }

View File

@@ -27,6 +27,10 @@
<view class="color-333 font-bold small-title">优惠券</view> <view class="color-333 font-bold small-title">优惠券</view>
<text class="color-666 u-m-l-38">{{data.couponInfoList.map(item=>item.title+'*'+item.num).join('、')}}</text> <text class="color-666 u-m-l-38">{{data.couponInfoList.map(item=>item.title+'*'+item.num).join('、')}}</text>
</view> </view>
<view class="u-m-t-32 u-flex u-col-center" v-if="data.amount">
<view class="color-333 font-bold small-title">金额</view>
<text class="color-666 u-m-l-38">{{data.amount}}</text>
</view>
<view class="u-m-t-32 u-flex u-col-center" style="gap: 54rpx"> <view class="u-m-t-32 u-flex u-col-center" style="gap: 54rpx">
<view class="cancel" @click="close">取消</view> <view class="cancel" @click="close">取消</view>
<view class="confirm" @click="confirm">确认</view> <view class="confirm" @click="confirm">确认</view>

View File

@@ -1316,7 +1316,7 @@ function calcVipDiscountAmount(
return truncateToTwoDecimals( return truncateToTwoDecimals(
new BigNumber(goodsRealAmount) new BigNumber(goodsRealAmount)
.times((100 - (shopUserInfo.discount || 0)) / 100) .times((100 - (shopUserInfo.discount || 0)) / 100)
.decimalPlaces(2, BigNumber.ROUND_UP) .decimalPlaces(2, BigNumber.ROUND_DOWN)
.toNumber() .toNumber()
); );
} }
@@ -1584,7 +1584,8 @@ export function calculateOrderCostSummary(
.minus(fullReductionAmount) .minus(fullReductionAmount)
.toNumber(), .toNumber(),
shopUserInfo shopUserInfo
); // 会员折扣减免金额 );
console.log("vipDiscountAmount", vipDiscountAmount);
// ------------------------------ 6. 最终实付金额计算 ------------------------------ // ------------------------------ 6. 最终实付金额计算 ------------------------------
const finalPayAmountBn = new BigNumber(goodsRealAmount) const finalPayAmountBn = new BigNumber(goodsRealAmount)
.minus(newUserDiscount) .minus(newUserDiscount)

View File

@@ -59,6 +59,7 @@ export function returnPrice(args) {
shopUserInfo, shopUserInfo,
idKey = "product_id", idKey = "product_id",
} = args; } = args;
limitTimeDiscountRes=limitTimeDiscountRes||{foods:'',foodType:2}
const canUseFoods = (limitTimeDiscountRes.foods || "").split(","); const canUseFoods = (limitTimeDiscountRes.foods || "").split(",");
const includesGoods = const includesGoods =
limitTimeDiscountRes.foodType == 1 || limitTimeDiscountRes.foodType == 1 ||