add
This commit is contained in:
commit
8c03b3eafc
|
@ -262,80 +262,80 @@
|
||||||
submitOrder();
|
submitOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 提交订单
|
// 提交订单
|
||||||
const submitOrder = () => {
|
const submitOrder = () => {
|
||||||
if (!isAddress.value) return toastAddressShow.value = true;
|
if (!isAddress.value) return toastAddressShow.value = true;
|
||||||
createOrder();
|
createOrder();
|
||||||
}
|
}
|
||||||
// 订单相关
|
// 订单相关
|
||||||
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('用户取消支付')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 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();
|
||||||
// }
|
// }
|
||||||
// })
|
// })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
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>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|
|
@ -23,19 +23,19 @@ const useUserStore = defineStore("user", () => {
|
||||||
uni.setStorageSync('token', data)
|
uni.setStorageSync('token', data)
|
||||||
}
|
}
|
||||||
|
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
token.value = "31f74a72e2d05673ec14d2a6408718ef"
|
token.value = "31f74a72e2d05673ec14d2a6408718ef"
|
||||||
userInfo.value = {
|
userInfo.value = {
|
||||||
avatar: "https://lihaiim.oss-cn-chengdu.aliyuncs.com/image/admin/default_avatar.png",
|
avatar: "https://lihaiim.oss-cn-chengdu.aliyuncs.com/image/admin/default_avatar.png",
|
||||||
id: 9,
|
id: 9,
|
||||||
is_disable: 0,
|
is_disable: 0,
|
||||||
is_new_user: 1,
|
is_new_user: 1,
|
||||||
mobile: "19330904744",
|
mobile: "19330904744",
|
||||||
nickname: "用户1714964250",
|
nickname: "用户1714964250",
|
||||||
supplier: null,
|
supplier: null,
|
||||||
token: "31f74a72e2d05673ec14d2a6408718ef"
|
token: "33bb1ca5e6c98a6f948ad56b75471fb8"
|
||||||
}
|
}
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
return {
|
return {
|
||||||
userInfo,
|
userInfo,
|
||||||
|
|
Loading…
Reference in New Issue