待客下单更新:

先付款模式下必须完成支付才能离开支付页面
This commit is contained in:
2024-10-11 15:44:10 +08:00
parent 6ef7ce8d89
commit f0b3a35d87

View File

@@ -37,8 +37,8 @@
<my-tabs :list="pays.list" v-model="pays.selIndex"></my-tabs> <my-tabs :list="pays.list" v-model="pays.selIndex"></my-tabs>
<template v-if="pays.selIndex==0"> <template v-if="pays.selIndex==0">
<view class="list"> <view class="list">
<view class="item" @click="changePayType(index,item)" v-for="(item,index) in pays.payTypes.list" <view class="item" @click="changePayType(index,item)"
:key="index"> v-for="(item,index) in pays.payTypes.list" :key="index">
<view class="u-flex u-row-between u-p-t-30 u-p-b-30 border-bottom"> <view class="u-flex u-row-between u-p-t-30 u-p-b-30 border-bottom">
<view class="u-flex"> <view class="u-flex">
<image class="icon" :src="item.icon" mode=""></image> <image class="icon" :src="item.icon" mode=""></image>
@@ -60,12 +60,10 @@
<my-button @click="payOrderClick">确认付款</my-button> <my-button @click="payOrderClick">确认付款</my-button>
</view> </view>
</template> </template>
<template v-else> <template v-if="pays.selIndex==1">
<view class=""> <view class="u-font-32 u-m-t-40 u-text-center">请让顾客使用微信/支付宝扫码</view>
<view class="u-font-32 u-m-t-40 u-text-center">请让顾客使用微信扫码</view>
<view class="u-flex u-row-center u-m-t-40"> <view class="u-flex u-row-center u-m-t-40">
<up-qrcode :size="140" :val="payCodeUrl"></up-qrcode> <up-qrcode cid="code" :size="140" :val="payCodeUrl"></up-qrcode>
</view>
</view> </view>
</template> </template>
</view> </view>
@@ -114,24 +112,38 @@
onBeforeUnmount onBeforeUnmount
} from 'vue'; } from 'vue';
import { import {
onLoad onLoad,
onBackPress
} from '@dcloudio/uni-app' } from '@dcloudio/uni-app'
import * as Api from '@/http/yskApi/Instead.js' import * as Api from '@/http/yskApi/Instead.js'
import {queryAllShopUser} from '@/http/yskApi/shop-user.js' import {
queryAllShopUser
} from '@/http/yskApi/shop-user.js'
import * as orderApi from '@/http/yskApi/order.js' import * as orderApi from '@/http/yskApi/order.js'
import infoBox from '@/commons/utils/infoBox.js' import infoBox from '@/commons/utils/infoBox.js'
import editDiscount from '@/components/my-components/edit-discount.vue' import editDiscount from '@/components/my-components/edit-discount.vue'
let option = {isNowPay:false}
let payFinish=ref(false)
onBackPress(() => {
if (option.isNowPay&&!payFinish.value) {
infoBox.showToast('先付费模式,请先结算订单')
return true
}
return false
})
let payStatus = ref(null) //loading success let payStatus = ref(null) //loading success
let timer = null let timer = null
let user=ref({amount:0}); let user = ref({
amount: 0
});
function clear() { function clear() {
clearInterval(timer) clearInterval(timer)
timer = null timer = null
} }
function to2(n) { function to2(n) {
if (!n) { if (!n) {
return '' return ''
@@ -202,9 +214,10 @@
infoBox.showToast('支付成功') infoBox.showToast('支付成功')
setTimeout(() => { setTimeout(() => {
// uni.$emit('orderDetail:update') // uni.$emit('orderDetail:update')
payFinish.value=true
uni.$emit('update:createOrderIndex') uni.$emit('update:createOrderIndex')
uni.navigateBack({ uni.navigateBack({
delta: 2 delta: 1
}) })
}, 500) }, 500)
} }
@@ -278,12 +291,15 @@
const res = await orderApi.tbOrderInfoDetail(order.orderId) const res = await orderApi.tbOrderInfoDetail(order.orderId)
Object.assign(order, res) Object.assign(order, res)
if (order.userId) { if (order.userId) {
queryAllShopUser({id:order.userId}).then(res=>{ queryAllShopUser({
id: order.userId
}).then(res => {
user.value = res.content[0] || opt user.value = res.content[0] || opt
}) })
} }
getPayUrl() getPayUrl()
} }
function getPayUrl() { function getPayUrl() {
orderApi.$getOrderPayUrl({ orderApi.$getOrderPayUrl({
orderId: order.id, orderId: order.id,
@@ -294,6 +310,7 @@
} }
onLoad(async (opt) => { onLoad(async (opt) => {
console.log(opt); console.log(opt);
option = opt
Object.assign(order, opt) Object.assign(order, opt)
const payTypeList = await Api.$getPayType() const payTypeList = await Api.$getPayType()
pays.payTypes.list = payTypeList pays.payTypes.list = payTypeList