import { mapMutations } from 'vuex'
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
}
|
|
},
|
|
computed: {
|
|
},
|
|
methods: {
|
|
...mapMutations(['clearCouponData']),
|
|
// 支付接口
|
|
handlePay(orderParams) {
|
|
uni.showLoading({
|
|
title: '支付处理中...'
|
|
})
|
|
if (!orderParams.userCouponId) {
|
|
// 没有优惠卷 则不传
|
|
delete orderParams.userCouponId
|
|
}
|
|
if (orderParams.remark == '') {
|
|
delete orderParams.remark
|
|
}
|
|
this.$api('createOrder', {
|
|
...orderParams
|
|
}, res => {
|
|
uni.hideLoading()
|
|
if (res.code === 200) {
|
|
if (orderParams.payType == '0') {
|
|
uni.requestPaymentWxPay(res)
|
|
.then(n => {
|
|
setTimeout(uni.redirectTo, 700, {
|
|
url: '/pages/index/order?tabIndex=1'
|
|
})
|
|
})
|
|
.catch(err => {
|
|
uni.showToast({
|
|
title: '支付失败',
|
|
icon: 'error'
|
|
})
|
|
setTimeout(uni.redirectTo, 700, {
|
|
url: '/pages/index/order?tabIndex=0'
|
|
})
|
|
})
|
|
} else {
|
|
uni.showToast({
|
|
title: '下单成功',
|
|
icon: 'success'
|
|
})
|
|
setTimeout(uni.redirectTo, 700, {
|
|
url: '/pages/index/order?tabIndex=1'
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
|
|
|
|
// 立即支付
|
|
// toPayOrder(item){
|
|
// let api = ''
|
|
|
|
// // if([0, 1].includes(item.shopState)){
|
|
// // api = 'createOrderTwo'
|
|
// // }else{
|
|
// api = 'createSumOrderAgain'
|
|
// // }
|
|
|
|
// this.$api(api, {
|
|
// orderId : item.id,
|
|
// addressId : item.addressId
|
|
// }, res => {
|
|
// if(res.code == 200){
|
|
// uni.requestPaymentWxPay(res)
|
|
// .then(res => {
|
|
// uni.showToast({
|
|
// title: '支付成功',
|
|
// icon: 'none'
|
|
// })
|
|
// this.getData()
|
|
// }).catch(n => {
|
|
// this.getData()
|
|
// })
|
|
// }
|
|
// })
|
|
// },
|
|
// 确认收货
|
|
// confirmOrder(item){
|
|
// uni.showModal({
|
|
// title: '您收到货了吗?',
|
|
// success : e => {
|
|
// if(e.confirm){
|
|
// this.$api('confirmOrder', {
|
|
// orderId : item.id,
|
|
// }, res => {
|
|
// this.getData()
|
|
// })
|
|
// }
|
|
// }
|
|
// })
|
|
// },
|
|
// // 取消订单
|
|
// cancelOrder(item){
|
|
// uni.showModal({
|
|
// title: '确认取消订单吗?',
|
|
// success : e => {
|
|
// if(e.confirm){
|
|
// this.$api('cancelOrder', {
|
|
// orderId : item.id,
|
|
// }, res => {
|
|
// this.getData()
|
|
// })
|
|
// }
|
|
// }
|
|
// })
|
|
// },
|
|
},
|
|
beforeDestroy() {
|
|
this.clearCouponData();
|
|
}
|
|
}
|