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

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

View File

@ -23,19 +23,19 @@ const useUserStore = defineStore("user", () => {
uni.setStorageSync('token', data)
}
// #ifdef H5
token.value = "31f74a72e2d05673ec14d2a6408718ef"
userInfo.value = {
avatar: "https://lihaiim.oss-cn-chengdu.aliyuncs.com/image/admin/default_avatar.png",
id: 9,
is_disable: 0,
is_new_user: 1,
mobile: "19330904744",
nickname: "用户1714964250",
supplier: null,
token: "31f74a72e2d05673ec14d2a6408718ef"
}
// #endif
// #ifdef H5
token.value = "31f74a72e2d05673ec14d2a6408718ef"
userInfo.value = {
avatar: "https://lihaiim.oss-cn-chengdu.aliyuncs.com/image/admin/default_avatar.png",
id: 9,
is_disable: 0,
is_new_user: 1,
mobile: "19330904744",
nickname: "用户1714964250",
supplier: null,
token: "33bb1ca5e6c98a6f948ad56b75471fb8"
}
// #endif
return {
userInfo,