待客下单更新:
先付款模式下必须完成支付才能离开支付页面
This commit is contained in:
@@ -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 cid="code" :size="140" :val="payCodeUrl"></up-qrcode>
|
||||||
<up-qrcode :size="140" :val="payCodeUrl"></up-qrcode>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
</view>
|
</view>
|
||||||
@@ -114,26 +112,40 @@
|
|||||||
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){
|
|
||||||
if(!n){
|
function to2(n) {
|
||||||
|
if (!n) {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
return n.toFixed(2)
|
return n.toFixed(2)
|
||||||
@@ -152,8 +164,8 @@
|
|||||||
if (newval) {
|
if (newval) {
|
||||||
timer = setInterval(() => {
|
timer = setInterval(() => {
|
||||||
orderApi.tbOrderInfoDetail(order.orderId).then(res => {
|
orderApi.tbOrderInfoDetail(order.orderId).then(res => {
|
||||||
order.status=res.status
|
order.status = res.status
|
||||||
if(res.status=='closed'){
|
if (res.status == 'closed') {
|
||||||
paySuccess()
|
paySuccess()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -191,8 +203,8 @@
|
|||||||
pays.payTypes.list = payTypeList
|
pays.payTypes.list = payTypeList
|
||||||
}
|
}
|
||||||
|
|
||||||
function changePayType(i,item) {
|
function changePayType(i, item) {
|
||||||
if(item.payType=='vipPay'&&user.value.amount*1<order.amount*1){
|
if (item.payType == 'vipPay' && user.value.amount * 1 < order.amount * 1) {
|
||||||
return infoBox.showToast('余额不足')
|
return infoBox.showToast('余额不足')
|
||||||
}
|
}
|
||||||
pays.payTypes.selIndex = i
|
pays.payTypes.selIndex = i
|
||||||
@@ -202,17 +214,18 @@
|
|||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
function payOrderClick(){
|
function payOrderClick() {
|
||||||
const payType = pays.payTypes.list[pays.payTypes.selIndex].payType
|
const payType = pays.payTypes.list[pays.payTypes.selIndex].payType
|
||||||
console.log(payType);
|
console.log(payType);
|
||||||
if(payType=='scanCode'||payType=='deposit'){
|
if (payType == 'scanCode' || payType == 'deposit') {
|
||||||
return saomaPay()
|
return saomaPay()
|
||||||
}
|
}
|
||||||
payOrder()
|
payOrder()
|
||||||
@@ -277,27 +290,31 @@
|
|||||||
async function init() {
|
async function init() {
|
||||||
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({
|
||||||
user.value=res.content[0]||opt
|
id: order.userId
|
||||||
|
}).then(res => {
|
||||||
|
user.value = res.content[0] || opt
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
getPayUrl()
|
getPayUrl()
|
||||||
}
|
}
|
||||||
function getPayUrl(){
|
|
||||||
|
function getPayUrl() {
|
||||||
orderApi.$getOrderPayUrl({
|
orderApi.$getOrderPayUrl({
|
||||||
orderId: order.id,
|
orderId: order.id,
|
||||||
payAmount:discount.currentPrice?discount.currentPrice:order.amount
|
payAmount: discount.currentPrice ? discount.currentPrice : order.amount
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
payCodeUrl.value = res
|
payCodeUrl.value = res
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
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
|
||||||
|
|
||||||
init()
|
init()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user