first commit
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
<template>
|
||||
<view class="">
|
||||
<web-view ref="webviewRef" v-if="isshow" :src="url" @message="handleMessage" @logData = "logData"></web-view>
|
||||
|
||||
<!-- ✅ 新增:一个绝对定位的遮罩层,用于在刷新时覆盖 web-view -->
|
||||
<view v-else class="reloading-mask">
|
||||
<up-loading-icon text="正在获取订单状态..." v-if="orderOver" textSize="16"></up-loading-icon>
|
||||
|
||||
<up-loading-icon text="订单已完成" v-else textSize="16"></up-loading-icon>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import { Service } from "@/Service/Service";
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { CNRiderOrderService } from '@/Service/CN/CNRiderOrderService'
|
||||
|
||||
let orderId = ref<string>('')
|
||||
let url = ref<string>('')
|
||||
let isshow = ref<false>(false)
|
||||
|
||||
let orderInfo = ref<any>({
|
||||
isFood: 0
|
||||
})
|
||||
|
||||
let riderOrder = ref<any>({
|
||||
status:0
|
||||
})
|
||||
|
||||
let orderOver = ref<true>(false)
|
||||
|
||||
onLoad((data) => {
|
||||
if (data.orderId) {
|
||||
orderId.value = data.orderId
|
||||
getData()
|
||||
} else {
|
||||
Service.Msg('为获取到订单ID')
|
||||
}
|
||||
});
|
||||
|
||||
// 初始化url
|
||||
const getUrl = () => {
|
||||
isshow.value = false
|
||||
url.value = 'https://hmjz.327gzs.top?orderId=' + orderId.value + '&isFood=' + riderOrder.value.status
|
||||
isshow.value = true
|
||||
}
|
||||
|
||||
|
||||
const getData = () => {
|
||||
CNRiderOrderService.GetUnitOrderInfo(orderId.value).then(res => {
|
||||
if (res.code==0) {
|
||||
orderInfo.value = res.data.orderInfo
|
||||
riderOrder.value = res.data.riderOrder
|
||||
getUrl()
|
||||
|
||||
}else{
|
||||
Service.Msg(res.mgs)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 点击完成送餐取餐调用
|
||||
const handleMessage = (data) => {
|
||||
|
||||
let preat = data.detail.data[0]
|
||||
if(preat.action =='message'){
|
||||
if (riderOrder.value.status == 0) {
|
||||
// 去商家、取餐
|
||||
pickFood(1)
|
||||
} else {
|
||||
// 去用户,送餐
|
||||
pickFood(2)
|
||||
}
|
||||
}else if(preat.action =='logData'){
|
||||
CNRiderOrderService.UpdateRiderLocation(preat.data[0],preat.data[1]).then(res=>{
|
||||
if(res.code==0){
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
// 骑手定位
|
||||
const logData = (data) =>{
|
||||
console.log(data,'骑手定位')
|
||||
}
|
||||
|
||||
// 取餐
|
||||
const pickFood = ( type:number) => {
|
||||
CNRiderOrderService.UpdateRiderOrderTake(orderId.value, type).then(res => {
|
||||
if (res.data) {
|
||||
Service.Msg(type==1?'取餐成功':'订单完成')
|
||||
if(type==2){
|
||||
setTimeout(()=>{Service.GoPageTab('/pages/index/index')},500)
|
||||
}
|
||||
getData()
|
||||
} else {
|
||||
Service.Msg(res.msg)
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.reloading-mask {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: #f7f7f7; // 使用页面底色
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 10;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user