更新订单管理模块

This commit is contained in:
2024-09-28 15:08:21 +08:00
parent 5a7aaad0a4
commit 90eb77d891
9 changed files with 409 additions and 125 deletions

View File

@@ -49,51 +49,54 @@
<text>余额</text>
<text>0.00</text>
</view> -->
<my-radio @click="changePayType(index)" :modelValue="index==pays.payTypes.selIndex">
<my-radio @click="changePayType(index)"
:modelValue="index==pays.payTypes.selIndex">
</my-radio>
</view>
</view>
</view>
</view>
<view class="u-m-t-60 u-p-b-30">
<my-button @click="payOrder">确认付款</my-button>
<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="uview-plus"></up-qrcode>
<up-qrcode :size="140" :val="payCodeUrl"></up-qrcode>
</view>
</view>
</template>
</view>
<!-- 二维码支付扫码 -->
<template v-if="pays.selIndex==1">
<template v-if="pays.selIndex==1">
<view class="card border-bottom top u-m-t-32">
</view>
<view class="bg-fff card bottom border-r-12 u-p-32">
<view class="font-bold u-font-32 u-text-center">
{{discount.currentPrice?discount.currentPrice: order.amount}}</view>
<view class="u-flex u-row-center u-m-t-24">
<up-loading-icon size="14" text="等待支付"></up-loading-icon>
<view class="u-flex pay-success">
<up-icon color="#5CBB6F" name="checkmark-circle-fill"></up-icon>
<view class="u-m-l-6">支付成功</view>
</view>
<template v-if="order.status=='unpaid'">
<up-loading-icon size="14" text="等待支付"></up-loading-icon>
</template>
<template v-if="order.status=='closed'">
<view class="u-flex pay-success">
<up-icon color="#5CBB6F" name="checkmark-circle-fill"></up-icon>
<view class="u-m-l-6">支付成功</view>
</view>
</template>
</view>
</view>
</template>
</view>
</view>
@@ -107,7 +110,8 @@
reactive,
onMounted,
watch,
ref
ref,
onBeforeUnmount
} from 'vue';
import {
onLoad
@@ -119,6 +123,12 @@
let payStatus = ref(null) //loading success
let timer = null
function clear() {
clearInterval(timer)
timer = null
}
const pays = reactive({
list: ['扫码收款', '二维码收款'],
@@ -129,6 +139,22 @@
}
})
watch(() => pays.selIndex, (newval) => {
clearInterval(timer)
if (newval) {
timer = setInterval(() => {
orderApi.tbOrderInfoDetail(order.orderId).then(res => {
order.status=res.status
if(res.status=='closed'){
paySuccess()
}
})
}, 2000)
} else {
}
})
const models = new Map();
function setModel(el) {
@@ -169,6 +195,15 @@
})
}, 500)
}
function payOrderClick(){
const payType = pays.payTypes.list[pays.payTypes.selIndex].payType
console.log(payType);
if(payType=='scanCode'||payType=='deposit'){
return saomaPay()
}
payOrder()
}
async function payOrder() {
const payType = pays.payTypes.list[pays.payTypes.selIndex].payType
await Api.$payOrder({
@@ -190,6 +225,8 @@
amount: 0
})
function saomaPay() {
const item = pays.payTypes.list[pays.payTypes.selIndex]
uni.scanCode({
@@ -223,14 +260,26 @@
return saomaPay('scanCode')
}
})
let payCodeUrl = ref('')
async function init() {
const res = await orderApi.tbOrderInfoDetail(order.orderId)
Object.assign(order, res)
}
onLoad((opt) => {
orderApi.$getOrderPayUrl({
orderId: opt.orderId
}).then(res => {
payCodeUrl.value = res
})
console.log(opt);
Object.assign(order, opt)
init()
})
onBeforeUnmount(() => {
clear()
})
</script>
<style lang="scss" scoped>