From e6ca187e5ac042e89bc6f337e850cf38cb1c87a8 Mon Sep 17 00:00:00 2001
From: wwz <1144797966@qq.com>
Date: Thu, 13 Mar 2025 09:15:51 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=AE=A2=E5=8D=95=E8=AF=A6?=
=?UTF-8?q?=E6=83=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
App.vue | 50 +-----------
common/api/api.js | 18 +++++
common/js/websocket.js | 8 +-
components/payPassword.vue | 3 +-
components/paymentMethod.vue | 13 ++--
pages/index/index.vue | 74 +++++++++++++++---
pages/order/components/IntegralInput.vue | 4 +-
pages/order/components/orderInfoAfter.vue | 32 ++++----
pages/order/detail.vue | 94 +++++++++++++----------
pages/product/components/confirmorder.vue | 16 ++--
pages/product/index.vue | 6 +-
pages/user/member/index.vue | 45 +++++------
stores/order.js | 6 +-
stores/pay.js | 26 ++++---
14 files changed, 219 insertions(+), 176 deletions(-)
diff --git a/App.vue b/App.vue
index b929757..0f606f6 100644
--- a/App.vue
+++ b/App.vue
@@ -26,58 +26,12 @@
try {
const storelogin = Storelogin();
await storelogin.actionslogin()
+ proxy.$isResolve()
} catch (error) {
+ proxy.$isResolve()
console.log(error)
}
// #endif
- try {
- uni.getLocation({
- type: 'wgs84',
- success: async (res) => {
- let successres = await APIgeocodelocation({
- lng: res.longitude,
- lat: res.latitude,
- })
- if (successres) {
- let datastorage = {
- country: successres.addressComponent.country, // "中国"
- province: successres.addressComponent
- .province, //province: "陕西省"
- address: successres.addressComponent.city, //district: "西安市"
- district: successres.addressComponent.district, //district: "未央区"
- lng: res.longitude,
- lat: res.latitude,
- }
- uni.cache.set('getLocationstorage', datastorage);
- // 登录
- proxy.$isResolve()
- }
- },
-
- });
- } catch (error) {
- try {
- let successres = await APIgeocodelocation({
- lng: '',
- lat: '',
- })
- if (successres) {
- let datastorage = {
- country: successres.addressComponent.country, // "中国"
- province: successres.addressComponent
- .province, //province: "陕西省"
- address: successres.addressComponent.city, //district: "西安市"
- district: successres.addressComponent.district, //district: "未央区"
- lng: res.longitude,
- lat: res.latitude,
- }
- uni.cache.set('getLocationstorage', datastorage);
- proxy.$isResolve()
- }
- } catch (error) {
- proxy.$isResolve()
- }
- }
});
// export default {
diff --git a/common/api/api.js b/common/api/api.js
index 18f86bf..25abaa5 100644
--- a/common/api/api.js
+++ b/common/api/api.js
@@ -47,4 +47,22 @@ export const APIuserupload = (data) => {
method: 'post',
data: data
})
+}
+
+//用户密码修改
+export const APIuserpwd = (data) => {
+ return request({
+ url: url + '/user/pwd',
+ method: 'put',
+ data: data
+ })
+}
+
+//验证码获取
+export const APIusercode = (data) => {
+ return request({
+ url: url + '/user/code',
+ method: 'get',
+ data: data
+ })
}
\ No newline at end of file
diff --git a/common/js/websocket.js b/common/js/websocket.js
index a3fd63f..95c5676 100644
--- a/common/js/websocket.js
+++ b/common/js/websocket.js
@@ -56,14 +56,13 @@ const useWebSocket = (options = {}) => {
// 连接 WebSocket
const connect = () => {
-
if (!isNetworkConnected.value) {
uni.showToast({
title: '网络未连接...',
icon: 'none'
})
setTimeout(() => {
- uni.navigateBack()
+ uni.pro.switchTab('index/index')
}, 1000)
console.log('网络未连接,暂不尝试连接 WebSocket');
return;
@@ -112,7 +111,6 @@ const useWebSocket = (options = {}) => {
clearTimeout(reconnectTimer.value); // 清除重连定时器
if (res.code == '1006') {
console.log('服务器正常关闭,停止重连');
- uni.navigateBack()
autoReconnect.value = false;
return false;
}
@@ -143,7 +141,7 @@ const useWebSocket = (options = {}) => {
icon: 'none'
})
setTimeout(() => {
- uni.navigateBack()
+ uni.pro.switchTab('index/index')
}, 1000)
return;
}
@@ -184,7 +182,6 @@ const useWebSocket = (options = {}) => {
// 手动关闭连接
const closeSocket = () => {
isManuallyClosed.value = true;
- uni.navigateBack()
closeExistingConnection();
};
@@ -230,7 +227,6 @@ const useWebSocket = (options = {}) => {
title: '重连次数达到上限,停止重连',
icon: 'none'
});
- uni.navigateBack()
}
};
diff --git a/components/payPassword.vue b/components/payPassword.vue
index db71cc5..0bde54c 100644
--- a/components/payPassword.vue
+++ b/components/payPassword.vue
@@ -49,13 +49,14 @@
}
if (password.value.length === 6) {
emits('inputComplete', password.value);
+ password.value = ''
}
};
// 关闭模态框
const closeModal = () => {
emits('close');
- password.value = '';
+ password = '';
};
// 将方法暴露给父组件
defineExpose({
diff --git a/components/paymentMethod.vue b/components/paymentMethod.vue
index 3e3ef54..82f7003 100644
--- a/components/paymentMethod.vue
+++ b/components/paymentMethod.vue
@@ -13,8 +13,10 @@
{{ item.name }}
- 会员卡余额 ¥{{orderVIP?orderVIP.amount:0}}
- 去充值
+
+ 会员卡余额¥{{orderVIP?orderVIP.amount:0}}
+ {{orderVIP.isVip == 0?'注册会员':'去充值'}}
@@ -60,14 +62,15 @@
}
});
-
+
const emits = defineEmits(['customevent', 'groupChange']);
+
const paymentMethodList = ref([{
name: "余额支付",
type: 1,
url: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/drder/wechat.png",
- payType: ''
+ payType: 'accountPay'
},
// #ifdef MP-WEIXIN
{
@@ -92,7 +95,7 @@
name: "余额支付",
type: 1,
url: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/drder/wechat.png",
- payType: ''
+ payType: 'accountPay'
},
{
name: "微信支付",
diff --git a/pages/index/index.vue b/pages/index/index.vue
index 2125d22..f4df936 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -10,7 +10,7 @@
-
+
@@ -25,10 +25,10 @@
-
-
+
@@ -164,6 +164,9 @@
APIhomehomePageUp,
APIhome
} from "@/common/api/index/index.js"
+ import {
+ APIgeocodelocation
+ } from "@/common/api/api.js"
import {
useNavbarStore
} from '@/stores/navbarStore';
@@ -203,16 +206,16 @@
const refbannervo = ref(null);
//数据
const hometoplist = reactive({
-
+
})
// 首页上面数据
const hometop = async () => {
try {
let res = await APIhomehomePageUp()
Object.assign(hometoplist, res)
- hometoplist.freeBannerList.forEach((item, index) => {
- advertisementStyle.value.push(getStyle(index))
- })
+ hometoplist.freeBannerList.forEach((item, index) => {
+ advertisementStyle.value.push(getStyle(index))
+ })
// 数据加载完后获取dom 高度
setTimeout(() => {
const query = uni.createSelectorQuery().select('#fourcontent');
@@ -231,7 +234,7 @@
page: 1, //页数
size: 10, //页容量
status: 'loadmore',
- name:'1'
+ name: '1'
})
// 使用 reactive 创建响应式对象
const timeData = ref({});
@@ -334,10 +337,9 @@
isSticky.value = res.scrollTop > elementTop.value ? true : false
uni.$u.debounce(store.scrollTop = res.scrollTop, 500)
});
- onShow(() => {})
- onMounted(async () => {
+ onShow(async () => {
await proxy.$onLaunched;
- if (uni.cache.get('shopId') && uni.cache.get('token')) {
+ if (uni.cache.get('shopId')) {
showindex.value = 'shopIndex'
await storeuser.actionsAPIuser()
} else {
@@ -346,6 +348,56 @@
showindex.value = 'index'
// 获取初始定位高度
}
+ })
+ onMounted(async () => {
+ try {
+ uni.getLocation({
+ type: 'wgs84',
+ success: async (res) => {
+ let successres = await APIgeocodelocation({
+ lng: res.longitude,
+ lat: res.latitude,
+ })
+ if (successres) {
+ let datastorage = {
+ country: successres.addressComponent.country, // "中国"
+ province: successres.addressComponent
+ .province, //province: "陕西省"
+ address: successres.addressComponent.city, //district: "西安市"
+ district: successres.addressComponent.district, //district: "未央区"
+ lng: res.longitude,
+ lat: res.latitude,
+ }
+ uni.cache.set('getLocationstorage', datastorage);
+ // 登录
+ proxy.$isResolve()
+ }
+ },
+
+ });
+ } catch (error) {
+ try {
+ let successres = await APIgeocodelocation({
+ lng: '',
+ lat: '',
+ })
+ if (successres) {
+ let datastorage = {
+ country: successres.addressComponent.country, // "中国"
+ province: successres.addressComponent
+ .province, //province: "陕西省"
+ address: successres.addressComponent.city, //district: "西安市"
+ district: successres.addressComponent.district, //district: "未央区"
+ lng: res.longitude,
+ lat: res.latitude,
+ }
+ uni.cache.set('getLocationstorage', datastorage);
+ proxy.$isResolve()
+ }
+ } catch (error) {
+ proxy.$isResolve()
+ }
+ }
});
onReachBottom(() => {
diff --git a/pages/order/components/IntegralInput.vue b/pages/order/components/IntegralInput.vue
index 6e5856a..5422441 100644
--- a/pages/order/components/IntegralInput.vue
+++ b/pages/order/components/IntegralInput.vue
@@ -4,9 +4,9 @@
+ :placeholder="instructions" />
- {{ instructions }}
+
diff --git a/pages/order/components/orderInfoAfter.vue b/pages/order/components/orderInfoAfter.vue
index 54dc009..c651a71 100644
--- a/pages/order/components/orderInfoAfter.vue
+++ b/pages/order/components/orderInfoAfter.vue
@@ -162,23 +162,13 @@
-
-
- 优惠券
-
-
- -¥
- {{item.discountAmount}}
-
-
-
-
- 商品券
+
+ 优惠折扣
-
+
{{item.name}}
- X{{item.finalUseNum}}
- -¥{{item.finalDiscountAmount}}
+
+ {{item.amount}}元
@@ -258,7 +248,7 @@
} from '@/common/api/shop/index.js'
// 定义自定义事件
- const emits = defineEmits(['customevent', 'istype']);
+ const emits = defineEmits(['customevent', 'istype', 'learcoupons']);
// teb 切换送餐和打包
const tebtypeList = reactive([{
@@ -344,6 +334,8 @@
case 'coupon':
// 清空积分
IntegralInputclose()
+ favorablelist[1].value = ''
+ emits('learcoupons', 'coupon')
uni.pro.navigateTo('/pages/order/coupon', {
type: "confirm_order_coupon",
shopId: uni.cache.get('orderVIP').shopId,
@@ -356,8 +348,9 @@
// 清空积分
IntegralInputclose()
// 清空优惠卷
- props.listinfo.coupondiscountAmount = 0
favorablelist[1].value = ''
+ favorablelist[0].value = ''
+ emits('learcoupons', 'product')
uni.pro.navigateTo('/pages/order/coupon', {
type: "confirm_order_product",
shopId: uni.cache.get('orderVIP').shopId,
@@ -369,7 +362,8 @@
case 'points':
if (calcUsablePointsData.usable == 0) {
uni.showToast({
- title: '此次订单不可用积分!'
+ title: calcUsablePointsData.unusableReason,
+ icon: 'none'
})
return false;
}
@@ -672,7 +666,7 @@
.head {
display: flex;
justify-content: space-between;
- padding: 32rpx 0;
+ // padding: 32rpx 0;
.head_left {
display: flex;
diff --git a/pages/order/detail.vue b/pages/order/detail.vue
index 448d996..2ee1370 100644
--- a/pages/order/detail.vue
+++ b/pages/order/detail.vue
@@ -33,10 +33,10 @@
-
+
+ @clickPointsamount='clickPointsamount' @learcoupons="learcoupons">
@@ -85,8 +85,7 @@
-
+
@@ -159,7 +158,10 @@
Productroll: 0,
coupondiscountAmount: 0,
couponInfoList: '',
- pointsDiscountAmount: 0
+ pointsDiscountAmount: 0,
+ packFee: 0,
+ totalPrices: 0,
+ Seatcharge: 0
})
// 会员信息
@@ -195,24 +197,40 @@
// }
}
- // 历史订单
- if (listinfo.detailMap) {
- let combinedArray = [];
- for (const key in listinfo.detailMap) {
- if (listinfo.detailMap.hasOwnProperty(key)) {
- let subArray = listinfo.detailMap[key];
- combinedArray = [...combinedArray, ...subArray]
+ try {
+ // 历史订单
+ if (listinfo.detailMap) {
+ let combinedArray = [];
+ for (const key in listinfo.detailMap) {
+ if (listinfo.detailMap.hasOwnProperty(key)) {
+ let subArray = listinfo.detailMap[key];
+ combinedArray = [...combinedArray, ...subArray]
+ }
}
- }
- listinfo.combinedArray = combinedArray
- setTimeout(async () => {
+ listinfo.combinedArray = combinedArray
listinfo.packFee = await cartStore.getTotalPackFee(listinfo.combinedArray)
// 计算购物车商品费用
- listinfo.totalPrices = await cartStore.getTotalTotalPrices(listinfo.combinedArray)
+ listinfo.totalPrices = await cartStore.getTotalTotalPrices(listinfo
+ .combinedArray)
// 餐位费listinfo.seatNum
listinfo.Seatcharge = await cartStore.getTotalSeatcharge(listinfo.seatNum)
- })
+ }
+ if (listinfo.discountInfo) {
+ const discountObj = JSON.parse(listinfo.discountInfo);
+ const tempArray = [];
+ for (const [key, value] of Object.entries(discountObj)) {
+ tempArray.push({
+ name: key,
+ amount: value
+ });
+ }
+ listinfo.discountInfo = tempArray;
+ console.log(tempArray)
+ }
+ } catch (e) {
+
}
+
}
}
@@ -220,8 +238,8 @@
watchEffect(async () => {
if (listinfo.combinedArray.length > 0) {
//总价格
- console.log(listinfo.combinedArray, listinfo.packFee, listinfo.totalPrices, listinfo.Seatcharge,
- listinfo.Productroll, listinfo.coupondiscountAmount)
+ // console.log(listinfo.combinedArray, listinfo.packFee, listinfo.totalPrices, listinfo.Seatcharge,
+ // listinfo.Productroll, listinfo.coupondiscountAmount)
// 打包费packFee 计算购物车商品费用totalPrices 餐位费Seatcharge
let sum = (is_type.value != 0 ? listinfo.packFee : 0) + listinfo.totalPrices + (is_type.value ==
0 ? listinfo.Seatcharge : 0);
@@ -234,7 +252,8 @@
listinfo.totalCost = Math.round(sums * 100) / 100;
// 积分
if (listinfo.totalCost && listinfo.status == 'unpaid') {
- await memberPointscalcUsablePoints()
+ uni.$u.debounce(await memberPointscalcUsablePoints(), 500)
+
}
}
});
@@ -286,15 +305,6 @@
listinfo.coupondiscountAmount = data.item.discountAmount
uniqueIds.value.push(data.item.id)
orderInfoAfterRef.value.dataprocessing(data)
- } else {
- if (listinfo.coupondiscountAmount > 0) {
- listinfo.coupondiscountAmount = 0
- uniqueIds.value.pop()
- orderInfoAfterRef.value.dataprocessing({
- typeOrder: 1,
- item: ''
- })
- }
}
} else {
// 筛选出商品卷的id
@@ -310,7 +320,17 @@
};
- const payPasswordPassword = ref('')
+ const learcoupons = (data) => {
+ console.log('qing')
+ if (data == 'product') {
+ uniqueIds.value = [] // 筛选出商品卷的id
+ listinfo.coupondiscountAmount = 0 // 优惠卷减去的金额
+ listinfo.Productroll = 0 // 商品卷总价价格
+ } else {
+ uniqueIds.value = [] // 筛选出商品卷的id
+ listinfo.coupondiscountAmount = 0 // 优惠卷减去的金额
+ }
+ }
// * 去支付
const goToPay = async () => {
@@ -333,7 +353,6 @@
})
} else {
- payPasswordPassword.value = ''
ispws.value = true
}
return false
@@ -362,9 +381,7 @@
buyerRemark: '',
returnUrl: ''
})
- if (res) {
- await orderorderInfo()
- }
+ await orderorderInfo()
}
//002-获取订单可用积分及抵扣金额(支付页面使用)
@@ -414,11 +431,10 @@
buyerRemark: '',
returnUrl: ''
})
- await orderorderInfo()
} catch (error) {
//TODO handle the exception
}
- payPasswordPassword.value = ''
+ orderorderInfo()
}
onUnmounted(() => {
@@ -447,7 +463,7 @@
orderVIP.value = res
ordershopUserInfo.value = res.shopInfo
}
- await orderorderInfo()
+ orderorderInfo()
})
@@ -549,7 +565,7 @@
.head {
display: flex;
justify-content: space-between;
- padding: 50rpx 34rpx 32rpx 34rpx;
+ padding: 50rpx 0 32rpx 0;
border-bottom: 2rpx dashed #E3E3E3;
.head_left {
@@ -653,7 +669,7 @@
}
.item {
- margin-bottom: 32rpx;
+ padding: 32rpx 0 !important;
display: flex;
.cover {}
diff --git a/pages/product/components/confirmorder.vue b/pages/product/components/confirmorder.vue
index d7c1ab5..25dc0aa 100644
--- a/pages/product/components/confirmorder.vue
+++ b/pages/product/components/confirmorder.vue
@@ -203,10 +203,12 @@
// 计算购物车商品费用
const totalPrices = computed(() => {
+
let combinedArray = [];
for (const key in props.orderinfo.detailMap) {
if (props.orderinfo.detailMap.hasOwnProperty(key)) {
- combinedArray = props.orderinfo.detailMap[key];
+ let subArray = props.orderinfo .detailMap[key];
+ combinedArray = [...combinedArray, ...subArray]
}
}
// 购物车总数价格
@@ -214,13 +216,12 @@
// 是否启用会员价 0否1是
if (shopInfo.isVip == 1 && shopInfo.isMemberPrice == 1) {
// memberPrice会员价
- return total + parseFloat(item.memberPrice) * parseFloat(item.num);
+ return total + (parseFloat(item.memberPrice) * parseFloat(item.num - item.returnNum));
} else {
// salePrice销售价
- return total + parseFloat(item.price) * parseFloat(item.num);
+ return total + (parseFloat(item.price) * parseFloat(item.num - item.returnNum));
}
}, 0);
- console.log(cartone)
// 购物车总数价格
let cart = props.cartList.reduce((total, item) => {
// 是否启用会员价 0否1是
@@ -246,7 +247,6 @@
tableFeeTotals = Math.ceil(parseFloat(dinersNum) * parseFloat(tableFee) *
100) / 100;
}
- console.log(tableFeeTotals)
return Math.floor(tableFeeTotals * 100) / 100 ? Math.floor(tableFeeTotals * 100) / 100 : 0;
});
@@ -266,7 +266,6 @@
// 监听送餐/打包切换
const tabClick = (item, index) => {
is_type.value = index
- console.log(props.cartList)
// this.getchoseEatModel('tabClick', index, item);
}
@@ -295,10 +294,9 @@
remark: remark.value, //备注
placeNum: props.orderinfo.placeNum + 1, //当前订单下单次数
waitCall: '', //是否等叫 0 否 1 等叫
- orderId: props.orderinfo.id
-
+ orderId: props.orderinfo.id,
+ userId: uni.cache.get('userInfo').id || '' //
})
- console.log(res)
// 清空购物车
emits('customevent', {
type: 'shopping',
diff --git a/pages/product/index.vue b/pages/product/index.vue
index 7c5c6d5..46c56d0 100644
--- a/pages/product/index.vue
+++ b/pages/product/index.vue
@@ -723,7 +723,7 @@
//获取多规格数据
const clickspecifications = async (item, index, indexs, type) => {
- console.log(item, index, indexs, type)
+ // console.log(item, index, indexs, type)
// 数量清零
shopCartNumber.value = 0
// 初始化
@@ -883,7 +883,7 @@
// 购物车数据更新从新请求
if (Message.type == 'product') {
isDataLoaded.value = false;
- await productqueryProduct()
+ uni.$u.debounce(productqueryProduct(), 500)
// 数据可以更新
}
@@ -1110,6 +1110,7 @@
})
onMounted(async () => {
+ await proxy.$onLaunched;
// 获取当前页面栈
const pages = getCurrentPages();
// 获取当前页面实例
@@ -1119,6 +1120,7 @@
// #ifdef MP-WEIXIN
if (options.q) {
+ console.log(options.q)
const store = productStore();
await store.scanCodeactions(options.q)
}
diff --git a/pages/user/member/index.vue b/pages/user/member/index.vue
index c3e397a..5f44e0f 100644
--- a/pages/user/member/index.vue
+++ b/pages/user/member/index.vue
@@ -94,7 +94,7 @@
立即充值
-
+
@@ -320,6 +320,7 @@
});
return false;
}
+ console.log(infoForn, 111)
console.log({
shopId: infoForn.shopId,
activateId: infoForn.id,
@@ -347,11 +348,12 @@
uni.cache.set('orderVIP', res)
uni.cache.set('ordershopUserInfo', res.shopInfo)
infoForn.show = res.isVip == 1 ? false : true
-
+ infoForn.userInfo = res
}
-
+
const detailtype = ref('')
-
+
+
onMounted(async () => {
// 获取当前页面栈
const pages = getCurrentPages();
@@ -359,28 +361,27 @@
const currentPage = pages[pages.length - 1];
// 获取页面参数
const options = currentPage.options;
- // // #ifdef MP-WEIXIN
- // if (options.q) {
- // infoForn.shopId = this.getQueryString(decodeURIComponent(options.q), 'shopId')
- // uni.cache.set('shopId', infoForn.shopId)
- // this.tokenShow = false;
- // }
- // // #endif
- // // #ifdef MP-ALIPAY
- // if (getApp().globalData.shopId) {
- // infoForn.shopId = getApp().globalData.shopId
- // }
- // uni.cache.set('shopId', infoForn.shopId)
- // // #endif
+ // #ifdef MP-WEIXIN
+ if (options.q) {
+ infoForn.shopId = await getQueryString(decodeURIComponent(options.q), 'shopId')
+ }
+ // #endif
+ // #ifdef MP-ALIPAY
+ if (getApp().globalData.shopId) {
+ infoForn.shopId = getApp().globalData.shopId
+ }
+ // #endif
+
if (options.shopId) {
uni.cache.set('shopId', options.shopId, 30)
infoForn.shopId = options.shopId ? options.shopId : uni.cache.get('shopId')
- let resone = await APIusershopInfodetail({
- shopId: options.shopId
- })
- infoForn.shopUserInfo = resone.shopInfo
- asyncshopUserInfo()
}
+
+ let resone = await APIusershopInfodetail({
+ shopId: infoForn.shopId
+ })
+ infoForn.shopUserInfo = resone.shopInfo
+ asyncshopUserInfo()
if (options.type == 'detail') {
detailtype.value = 'detail'
}
diff --git a/stores/order.js b/stores/order.js
index ab706ce..5f9140e 100644
--- a/stores/order.js
+++ b/stores/order.js
@@ -44,10 +44,10 @@ export const useCartStore = defineStore('cart', () => {
if (uni.cache.get('orderVIP').isVip == 1 && uni.cache.get('ordershopUserInfo')
.isMemberPrice == 1) {
// memberPrice会员价
- return total + parseFloat(item.memberPrice) * parseFloat(item.num);
+ return total + (parseFloat(item.memberPrice) * parseFloat(item.num - item.returnNum));
} else {
// salePrice销售价
- return total + parseFloat(item.price) * parseFloat(item.num);
+ return total + (parseFloat(item.price) * parseFloat(item.num - item.returnNum));
}
}, 0);
// 向上取整并保留两位小数
@@ -94,7 +94,7 @@ export const useCartStore = defineStore('cart', () => {
// 计算购物车总打包费用(向下取整并保留两位小数)
const getTotalPackFee = (cartList) => computed(() => {
const total = cartList.reduce((sum, item) => {
- return sum + item.packAmount * (item.packNumber || (item.num - item.returnNum));
+ return sum + (item.packAmount * (item.packNumber || (item.num - item.returnNum)));
}, 0);
return Math.floor(total * 100) / 100;
});
diff --git a/stores/pay.js b/stores/pay.js
index 86fdc6e..7f9ab33 100644
--- a/stores/pay.js
+++ b/stores/pay.js
@@ -26,6 +26,7 @@ export const Memberpay = defineStore('memberpay', {
shopId: data.shopId,
shopUserId: data.shopUserId,
amount: data.amount,
+ activateId: data.activateId,
// #ifdef MP-WEIXIN
payType: 'wechatPay',
openId: uni.cache.get('userInfo').wechatOpenId,
@@ -110,7 +111,12 @@ export const Memberpay = defineStore('memberpay', {
try {
let res = await APIpayltPayOrder({
shopId: uni.cache.get('shopId'),
- checkOrderPay: data.checkOrderPay,
+ checkOrderPay: {
+ ...data.checkOrderPay,
+ ...{
+ userId: uni.cache.get('userInfo').id
+ }
+ },
// #ifdef MP-WEIXIN
payType: 'wechatPay',
openId: uni.cache.get('userInfo').wechatOpenId,
@@ -121,6 +127,7 @@ export const Memberpay = defineStore('memberpay', {
// #endif
returnUrl: data.returnUrl,
buyerRemark: data.buyerRemark,
+ userId: uni.cache.get('userInfo').id || ''
})
if (res) {
uni.showLoading({
@@ -189,19 +196,20 @@ export const Memberpay = defineStore('memberpay', {
try {
let res = await APIrefundVip({
shopId: uni.cache.get('shopId'),
- checkOrderPay: data.checkOrderPay,
+ checkOrderPay: {
+ ...data.checkOrderPay,
+ ...{
+ userId: uni.cache.get('userInfo').id
+ }
+ },
pwd: data.pwd,
- payType: 'accountPay',
+ payType: data.payType,
returnUrl: data.returnUrl,
buyerRemark: data.buyerRemark,
shopUserId: data.shopUserId,
+ userId: uni.cache.get('userInfo').id || '' //
})
- if (res) {
- uni.showLoading({
- title: '加载中...',
- mask: true
- })
- }
+ resolve(true)
} catch (e) {
uni.showToast({
title: "支付失败"