待客下单更新:
先付款模式下必须完成支付才能离开支付页面
This commit is contained in:
@@ -37,8 +37,8 @@
|
||||
<my-tabs :list="pays.list" v-model="pays.selIndex"></my-tabs>
|
||||
<template v-if="pays.selIndex==0">
|
||||
<view class="list">
|
||||
<view class="item" @click="changePayType(index,item)" v-for="(item,index) in pays.payTypes.list"
|
||||
:key="index">
|
||||
<view class="item" @click="changePayType(index,item)"
|
||||
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">
|
||||
<image class="icon" :src="item.icon" mode=""></image>
|
||||
@@ -60,12 +60,10 @@
|
||||
<my-button @click="payOrderClick">确认付款</my-button>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view class="">
|
||||
<view class="u-font-32 u-m-t-40 u-text-center">请让顾客使用微信扫码</view>
|
||||
<view class="u-flex u-row-center u-m-t-40 ">
|
||||
<up-qrcode :size="140" :val="payCodeUrl"></up-qrcode>
|
||||
</view>
|
||||
<template v-if="pays.selIndex==1">
|
||||
<view class="u-font-32 u-m-t-40 u-text-center">请让顾客使用微信/支付宝扫码</view>
|
||||
<view class="u-flex u-row-center u-m-t-40">
|
||||
<up-qrcode cid="code" :size="140" :val="payCodeUrl"></up-qrcode>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
@@ -114,26 +112,40 @@
|
||||
onBeforeUnmount
|
||||
} from 'vue';
|
||||
import {
|
||||
onLoad
|
||||
onLoad,
|
||||
onBackPress
|
||||
} from '@dcloudio/uni-app'
|
||||
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 infoBox from '@/commons/utils/infoBox.js'
|
||||
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 timer = null
|
||||
|
||||
let user=ref({amount:0});
|
||||
|
||||
let user = ref({
|
||||
amount: 0
|
||||
});
|
||||
|
||||
function clear() {
|
||||
clearInterval(timer)
|
||||
timer = null
|
||||
}
|
||||
function to2(n){
|
||||
if(!n){
|
||||
|
||||
function to2(n) {
|
||||
if (!n) {
|
||||
return ''
|
||||
}
|
||||
return n.toFixed(2)
|
||||
@@ -152,8 +164,8 @@
|
||||
if (newval) {
|
||||
timer = setInterval(() => {
|
||||
orderApi.tbOrderInfoDetail(order.orderId).then(res => {
|
||||
order.status=res.status
|
||||
if(res.status=='closed'){
|
||||
order.status = res.status
|
||||
if (res.status == 'closed') {
|
||||
paySuccess()
|
||||
}
|
||||
})
|
||||
@@ -191,8 +203,8 @@
|
||||
pays.payTypes.list = payTypeList
|
||||
}
|
||||
|
||||
function changePayType(i,item) {
|
||||
if(item.payType=='vipPay'&&user.value.amount*1<order.amount*1){
|
||||
function changePayType(i, item) {
|
||||
if (item.payType == 'vipPay' && user.value.amount * 1 < order.amount * 1) {
|
||||
return infoBox.showToast('余额不足')
|
||||
}
|
||||
pays.payTypes.selIndex = i
|
||||
@@ -202,17 +214,18 @@
|
||||
infoBox.showToast('支付成功')
|
||||
setTimeout(() => {
|
||||
// uni.$emit('orderDetail:update')
|
||||
payFinish.value=true
|
||||
uni.$emit('update:createOrderIndex')
|
||||
uni.navigateBack({
|
||||
delta: 2
|
||||
delta: 1
|
||||
})
|
||||
}, 500)
|
||||
}
|
||||
|
||||
function payOrderClick(){
|
||||
|
||||
function payOrderClick() {
|
||||
const payType = pays.payTypes.list[pays.payTypes.selIndex].payType
|
||||
console.log(payType);
|
||||
if(payType=='scanCode'||payType=='deposit'){
|
||||
if (payType == 'scanCode' || payType == 'deposit') {
|
||||
return saomaPay()
|
||||
}
|
||||
payOrder()
|
||||
@@ -277,27 +290,31 @@
|
||||
async function init() {
|
||||
const res = await orderApi.tbOrderInfoDetail(order.orderId)
|
||||
Object.assign(order, res)
|
||||
if(order.userId){
|
||||
queryAllShopUser({id:order.userId}).then(res=>{
|
||||
user.value=res.content[0]||opt
|
||||
if (order.userId) {
|
||||
queryAllShopUser({
|
||||
id: order.userId
|
||||
}).then(res => {
|
||||
user.value = res.content[0] || opt
|
||||
})
|
||||
}
|
||||
getPayUrl()
|
||||
}
|
||||
function getPayUrl(){
|
||||
|
||||
function getPayUrl() {
|
||||
orderApi.$getOrderPayUrl({
|
||||
orderId: order.id,
|
||||
payAmount:discount.currentPrice?discount.currentPrice:order.amount
|
||||
payAmount: discount.currentPrice ? discount.currentPrice : order.amount
|
||||
}).then(res => {
|
||||
payCodeUrl.value = res
|
||||
})
|
||||
}
|
||||
onLoad(async(opt) => {
|
||||
onLoad(async (opt) => {
|
||||
console.log(opt);
|
||||
option = opt
|
||||
Object.assign(order, opt)
|
||||
const payTypeList = await Api.$getPayType()
|
||||
pays.payTypes.list = payTypeList
|
||||
|
||||
|
||||
init()
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user