This commit is contained in:
zmj 2024-05-07 13:38:27 +08:00
commit 8c03b3eafc
2 changed files with 87 additions and 87 deletions

View File

@ -270,42 +270,42 @@
// //
const cartList = ref([]); const cartList = ref([]);
const orderInfo = ref({}); const orderInfo = ref({});
const checkOrder = () => { const checkOrder = ()=>{
checkOrderApi({ checkOrderApi({
cart_id: cartStore.cartList cart_id: cartStore.cartList
}).then(res => { }).then(res=>{
cartList.value = res.data.cart_list; cartList.value = res.data.cart_list;
orderInfo.value = res.data.order; orderInfo.value = res.data.order;
}) })
} }
const createOrder = () => { const createOrder = ()=>{
createOrderApi({ createOrderApi({
cart_id: cartStore.cartList, cart_id: cartStore.cartList,
address_id: addressInfo.value.address_id, address_id: addressInfo.value.address_id,
mer_id: shopInfo.value.mer_id, mer_id: shopInfo.value.mer_id,
pay_type: 1 pay_type: 1
}).then(res => { }).then(res=>{
uni.requestPayment({ uni.requestPayment({
provider: 'wxpay', provider: 'wxpay',
timeStamp: res.data.config.timeStamp, timeStamp: res.data.timeStamp,
nonceStr: res.data.config.nonceStr, nonceStr: res.data.nonceStr,
package: res.data.config.package, package: res.data.package,
signType: res.data.config.signType, signType: res.data.signType,
paySign: res.data.config.paySign, paySign: res.data.paySign,
success: (e) => { success: (e) => {
if (e.errMsg == 'requestPayment:ok') { if(e.errMsg == 'requestPayment:ok'){
uni.showModal({ uni.showModal({
title: '订单支付成功', title: '订单支付成功',
confirmText: '查看订单', confirmText: '查看订单',
cancelText: '继续购买', cancelText: '继续购买',
success: (e) => { success: (e) => {
if (e.confirm) uni.navigateTo({ if(e.confirm) uni.navigateTo({
url: '/pagesOrder/order/order' url: '/pagesOrder/order/order'
}) })
else uni.navigateBack(); else uni.navigateBack();
} }
}) })
} else uni.$u.toast('支付失败') }else uni.$u.toast('支付失败')
}, },
fail: (e) => { fail: (e) => {
uni.$u.toast('用户取消支付') uni.$u.toast('用户取消支付')
@ -325,15 +325,15 @@
}) })
} }
const c_price = (price, index = 0) => { const c_price = (price, index=0)=>{
price = price + ''; price = price + '';
return price.split('.')[index] || (index ? '00' : '0'); return price.split('.')[index] || (index ? '00' : '0');
} }
onLoad(options => { onLoad(options=>{
checkOrder(); checkOrder();
}) })
onShow(() => { onShow(()=>{
getAddressList(); getAddressList();
}) })
</script> </script>

View File

@ -33,7 +33,7 @@ const useUserStore = defineStore("user", () => {
mobile: "19330904744", mobile: "19330904744",
nickname: "用户1714964250", nickname: "用户1714964250",
supplier: null, supplier: null,
token: "31f74a72e2d05673ec14d2a6408718ef" token: "33bb1ca5e6c98a6f948ad56b75471fb8"
} }
// #endif // #endif