feat: 订单下单支付跳转

pull/2/head
TianYu 2023-05-29 14:43:03 +08:00
parent 49c9611182
commit eab653230d
2 changed files with 57 additions and 17 deletions

View File

@ -8,8 +8,8 @@
</view> </view>
<view class="count-down"> <view class="count-down">
支付剩余时间 支付剩余时间
<countDown :is-day="false" :is-show-hour='false' :tip-text="''" :day-text="''" :hour-text="''" :minute-text="' : '" <countDown :is-day="false" :is-show-hour='false' :tip-text="''" :day-text="''" :hour-text="''"
:second-text="' '" :datatime="invalidTime"></countDown> :minute-text="' : '" :second-text="' '" :datatime="invalidTime"></countDown>
</view> </view>
</view> </view>
<view class="payment"> <view class="payment">
@ -33,15 +33,15 @@
</view> </view>
<view class="btn"> <view class="btn">
<view class="button acea-row row-center-wrapper pay-button" @click='goPay'>确认支付</view> <view class="button acea-row row-center-wrapper pay-button" @click='goPay'>确认支付</view>
<view class="wait-pay" @click="waitPay"></view> <view class="wait-pay" @click="cancelPayModalShow = true">暂不支</view>
</view> </view>
<view v-show="false" v-html="formContent"></view> <view v-show="false" v-html="formContent"></view>
<u-modal :show="cancelPayModalShow" width="519rpx"> <u-modal :show="cancelPayModalShow" width="519rpx">
<view class="modal-wrap"> <view class="modal-wrap">
<view class="count-down"> <view class="count-down">
支付剩余时间 支付剩余时间
<countDown :is-day="false" :is-show-hour='false' :tip-text="''" :day-text="''" :hour-text="''" :minute-text="' : '" <countDown :is-day="false" :is-show-hour='false' :tip-text="''" :day-text="''" :hour-text="''"
:second-text="' '" :datatime="invalidTime"></countDown> :minute-text="' : '" :second-text="' '" :datatime="invalidTime"></countDown>
</view> </view>
<view class="model-content">确认要放弃付款吗</view> <view class="model-content">确认要放弃付款吗</view>
</view> </view>
@ -53,7 +53,7 @@
</view> </view>
</u-modal> </u-modal>
<!-- 支付宝支付链接复制组件 --> <!-- 支付宝支付链接复制组件 -->
<alipay-link-copy :show.sync="alipayShow" :alipayLink="alipayLink"/> <alipay-link-copy :show.sync="alipayShow" :alipayLink="alipayLink" @confirm="onConfirm" />
</view> </view>
</template> </template>
@ -76,9 +76,11 @@
data() { data() {
return { return {
cancelPayModalShow: false, cancelPayModalShow: false,
backPayModalShow: true,
alipayShow: false, alipayShow: false,
alipayLink: '', alipayLink: '',
checked: false, checked: false,
isClickGiveUpBtn: true,
// //
cartArr: [{ cartArr: [{
"name": '微信支付', "name": '微信支付',
@ -95,6 +97,7 @@
payStatus: 1, payStatus: 1,
} }
], ],
paytype: 'WXPAY',
orderId: 0, orderId: 0,
active: 0, active: 0,
payPrice: 10.00, payPrice: 10.00,
@ -113,7 +116,8 @@
}, },
onShow() { onShow() {
let options = wx.getEnterOptionsSync(); let options = wx.getEnterOptionsSync();
console.log(options) window.history.pushState(null, null, document.url)
window.addEventListener('popstate', this.backShowPayModal)
/* /*
if (options.scene == '1038' && options.referrerInfo.appId == 'wxef277996acc166c3' && this.initIn) { if (options.scene == '1038' && options.referrerInfo.appId == 'wxef277996acc166c3' && this.initIn) {
// //
@ -153,10 +157,25 @@
} }
}*/ }*/
}, },
onHide() {
window.removeEventListener('popstate', this.backShowPayModal)
},
onUnload() {
window.removeEventListener('popstate', this.backShowPayModal)
},
methods: { methods: {
backShowPayModal() {
this.isClickGiveUpBtn = false
this.cancelPayModalShow = this.backPayModalShow
},
onGiveUpPay() { onGiveUpPay() {
if (this.isClickGiveUpBtn) {
window.history.back()
}
this.cancelPayModalShow = false this.cancelPayModalShow = false
// uni.navigateBack() uni.navigateBack({
delta: 1
})
}, },
getCashierOrder() { getCashierOrder() {
uni.showLoading({ uni.showLoading({
@ -164,6 +183,7 @@
}); });
getOrderDetail(this.orderId).then(res => { getOrderDetail(this.orderId).then(res => {
const orderInfo = res.data const orderInfo = res.data
this.invalidTime = new Date(res.data.endTime).getTime()
this.payPrice = parseFloat(orderInfo.proTotalPrice).toFixed(2) this.payPrice = parseFloat(orderInfo.proTotalPrice).toFixed(2)
this.payPriceShow = parseFloat(orderInfo.proTotalPrice).toFixed(2) this.payPriceShow = parseFloat(orderInfo.proTotalPrice).toFixed(2)
}).catch(err => { }).catch(err => {
@ -176,12 +196,28 @@
this.active = index; this.active = index;
this.paytype = paytype; this.paytype = paytype;
}, },
waitPay() { onConfirm() {
this.cancelPayModalShow = true let that = this
// uni.reLaunch({ uni.showModal({
// url: '/pages/goods/order_pay_status/index?order_id=' + this.orderId + '&msg=&type=3' + title: '提示',
// '&status=2&totalPrice=' + this.payPriceShow content: '您是否已支付?',
// }) cancelText: '未支付',
confirmText: '已支付',
success: function(res) {
if (res.confirm) {
// popstate
that.backPayModalShow = false
window.history.back()
setTimeout(()=>{
uni.redirectTo({
url: '/pages/users/order_list/index'
})
}, 200)
} else if (res.cancel) {
}
}
});
}, },
goPay() { goPay() {
let that = this; let that = this;
@ -205,6 +241,9 @@
}, },
wxPaySuccess: () => { wxPaySuccess: () => {
// window.location.reload() // window.location.reload()
uni.redirectTo({
url: '/pages/users/order_list/index'
})
}, },
aliPaySuccess: (link) => { aliPaySuccess: (link) => {
that.alipayLink = link that.alipayLink = link
@ -224,6 +263,7 @@
.count-down .time { .count-down .time {
margin-left: 10rpx; margin-left: 10rpx;
} }
.modal-btn-wrap { .modal-btn-wrap {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;

View File

@ -293,7 +293,7 @@
preOrderNo: '' // preOrderNo: '' //
}; };
}, },
computed: mapGetters(['isLogin', 'systemPlatform', 'productType']), computed: mapGetters(['isLogin', 'systemPlatform', 'productType', 'tenantId']),
watch: { watch: {
isLogin: { isLogin: {
handler: function(newV, oldV) { handler: function(newV, oldV) {
@ -628,7 +628,7 @@
}, },
getOrderPay: function(orderNo, message) { getOrderPay: function(orderNo, message) {
let that = this; let that = this;
uni.navigateTo({ uni.redirectTo({
url: '/pages/goods_cashier/index?order_id=' + orderNo url: '/pages/goods_cashier/index?order_id=' + orderNo
}) })
// wechatOrderPay({ // wechatOrderPay({