Dining_Hall/pages/work/details.vue

313 lines
8.0 KiB
Vue
Raw Normal View History

2025-01-10 17:39:14 +08:00
<template>
<view class="page">
2025-02-19 09:34:34 +08:00
<h3 v-if="detailData.orderState==1">已下单</h3>
<h3 v-if="detailData.orderState==2">已完成</h3>
<h3 v-if="detailData.orderState==3">已取消</h3>
2025-01-10 17:39:14 +08:00
<div class="appraise">
<div>您对本单满意吗?</div>
2025-02-19 09:34:34 +08:00
<div class="flex appraise-right" @click="goEvaluate">
2025-01-10 17:39:14 +08:00
去评价
<u-icon name="arrow-right" size="12" />
</div>
</div>
<div class="cont">
2025-02-19 09:34:34 +08:00
<div class="top-source m-8">订单来源: 双屏消费机</div>
<!-- <div class="top-source m-8">订单来源: {{ detailData.sourceTypeStr }}</div> -->
2025-01-10 17:39:14 +08:00
<div class="flex justify-between m-8">
<div class="flex align-center">
2025-02-19 09:34:34 +08:00
<!-- <div>{{ detailData.canteenName }}/{{detailData.stallName}}</div> -->
2025-01-10 17:39:14 +08:00
<div>{{ detailData.canteenName }}</div>
2025-02-19 09:34:34 +08:00
<div class="tag">{{ detailData.mealtimeName }}</div>
2025-01-10 17:39:14 +08:00
</div>
2025-02-19 09:34:34 +08:00
<div>就餐日期: {{ detailData.orderDate }}</div>
2025-01-10 17:39:14 +08:00
</div>
<div class="img-cont m-8">
2025-02-19 09:34:34 +08:00
<div class="img-list m-8" v-for="(item, index) in detailData.orderDetailList" :key="index">
2025-01-10 17:39:14 +08:00
<div class="flex align-center">
2025-02-19 09:34:34 +08:00
<u-image :src="item.goodsDishesImgUrl" width="80px" height="80px" />
2025-01-10 17:39:14 +08:00
<div class="name-num">
2025-02-19 09:34:34 +08:00
<div style="margin-bottom: 10px">{{ item.goodsDishesName }}</div>
<div>x{{ item.quantity }}</div>
2025-01-10 17:39:14 +08:00
</div>
</div>
2025-02-19 09:34:34 +08:00
<div>{{ (item.realPrice/100).toFixed(2) }}</div>
2025-01-10 17:39:14 +08:00
</div>
</div>
<div class="flex justify-between m-8 bt">
配送费
2025-02-19 09:34:34 +08:00
<div>{{ detailData.deliveryAmount>0? (detailData.deliveryAmount/100).toFixed(2):"免配送费" }}</div>
2025-01-10 17:39:14 +08:00
</div>
<div class="flex justify-between m-8 bt">
包装费
2025-02-19 09:34:34 +08:00
<div>{{ detailData.packingAmount>0?(detailData.packingAmount/100).toFixed(2):"免包装费" }}</div>
2025-01-10 17:39:14 +08:00
</div>
<div class="flex justify-between m-8 bt">
餐券金额
2025-02-19 09:34:34 +08:00
<div>{{ (detailData.couponAmount/100).toFixed(2) }}</div>
2025-01-10 17:39:14 +08:00
</div>
<div class="flex justify-between m-8 bt">
优惠金额
2025-02-19 09:34:34 +08:00
<div>{{ (detailData.discountsAmount/100).toFixed(2) }}</div>
2025-01-10 17:39:14 +08:00
</div>
<u-line />
<div class="flex justify-between m-8 realAmount">
实付金额
2025-02-19 09:34:34 +08:00
<div>{{ (detailData.realAmount/100).toFixed(2) }}</div>
2025-01-10 17:39:14 +08:00
</div>
</div>
<div class="order">
<div class="m-8">订单二维码</div>
<div class="qrcode">
<canvas id="qrcode" canvas-id="qrcode" style="width: 175px; height: 175px"/>
</div>
<template >
</template>
2025-02-19 09:34:34 +08:00
<div class="flex justify-center">流水号: {{ detailData.mealCode }}</div>
2025-01-10 17:39:14 +08:00
<u-line style="margin: 20px 0;" />
<div class="flex justify-between m-8 bt">
订单编号
2025-02-19 09:34:34 +08:00
<div>{{ detailData.orderId }}</div>
2025-01-10 17:39:14 +08:00
</div>
<div class="flex justify-between m-8 bt">
创建时间
2025-02-19 09:34:34 +08:00
<div>{{ detailData.orderTime }}</div>
2025-01-10 17:39:14 +08:00
</div>
<div class="flex justify-between m-8 bt">
支付时间
<div>{{ detailData.payTime }}</div>
</div>
<div class="flex justify-between m-8">
支付方式
2025-02-19 09:34:34 +08:00
<div>{{ detailData.payTypeStr }}</div>
2025-01-10 17:39:14 +08:00
</div>
</div>
</view>
</template>
<script>
import uqrCode from '@/utils/uqrcode'
2025-02-19 09:34:34 +08:00
import { getOrderInfoAPI,getOrderPayTypeListAPI,getOrderSourceTypeListAPI } from '../../api/order/index'
2025-01-10 17:39:14 +08:00
export default {
2025-02-19 09:34:34 +08:00
data() {
return {
orderId:"",
payTypeList:[],//支付类型
sourceTypeList:[],//订单来源
// 详情页数据
detailData: {
sourceType:0,
// 订单状态
orderState: '订单已完成',
// 订单来源
orderSource: '设备下线消费',
// 餐厅名称
canteenName: '宏远工业园/本周菜谱',
// 餐次
intervalName: '午餐',
// 就餐时间
diningTime: '2024-08-12',
// 菜品
dishes: [
{
name: '苹果',
imgUrl: 'https://img.yzcdn.cn/vant/apple-1.jpg',
price: 10,
num: 1
},
{
name: '香蕉',
imgUrl: 'https://img.yzcdn.cn/vant/banana.jpg',
price: 5,
num: 2
},
{
name: '橘子',
imgUrl: 'https://img.yzcdn.cn/vant/orange.jpg',
price: 8,
num: 1
}
],
// 配送费
deliveryFee: '免配送费',
// 包装费
packingFee: '免包装费',
// 餐券金额
mealTicketAmount: '27',
// 优惠金额
discountAmount: '0.7',
// 实付金额
realAmount: '9.3',
// 订单二维码
qrCode: '',
// 流水号
serialNumber: '361',
// 订单号
orderNumber: '397944984700981249',
// 创建时间
createTime: '2025-01-05 06:57:08',
// 支付时间
payTime: '2025-01-03 22:56:23',
// 支付方式
payType: '小程序二维码支付'
}
}
},
onLoad(options) {
options = JSON.parse(options.params)
console.log(options)
this.orderId = options.orderId;
this.getPayTypeList()
// this.getSourceTypeList()
this.getOrderDetail()
this.generate('1223321312')
},
methods: {
//评价按钮
goEvaluate() {
console.log('跳转订单详情', this.detailData)
uni.navigateTo({
url: `/pages/work/evaluate?params=${JSON.stringify(this.detailData)}`
})
},
async getPayTypeList() {
try {
const res = await getOrderPayTypeListAPI({})
// console.log('🚀 ~ getList ~ res:', res)
this.payTypeList=res
} catch (error) {
console.log(error)
}
},
async getSourceTypeList() {
try {
const res = await getOrderSourceTypeListAPI({})
// console.log('🚀 ~ getList ~ res:', res)
this.sourceTypeList=res
} catch (error) {
console.log(error)
}
},
async getOrderDetail() {
try {
let param = {
"orderId":this.orderId
}
const res = await getOrderInfoAPI(param)
console.log('🚀 ~ getList ~ res:', res)
this.detailData = res.data;
this.generate(res.data.macOrderId)
this.payTypeList.forEach((item=>{
if(item.key==this.detailData.payType){
this.detailData.payTypeStr = item.value
}
}))
// this.sourceTypeList.forEach((item=>{
// if(item.key==this.detailData.sourceType){
// this.detailData.sourceTypeStr = item.value
// }
// }))
} catch (error) {
console.log(error)
}
},
// 生成二维码
generate(e) {
console.log('🚀 ~ generate ~ e:', e)
uqrCode.make({
canvasId: 'qrcode',
componentInstance: this,
text: e, // 想生成二维码到内容
size: 175,
margin: 0,
backgroundColor: '#ffffff',
foregroundColor: '#000000',
fileType: 'jpg',
errorCorrectLevel: uqrCode.errorCorrectLevel.H,
success: res => {
// this.imgCode = res // base64的图片格式
// console.log('🚀 ~ generate ~ res:', res)
}
})
}
}
2025-01-10 17:39:14 +08:00
}
</script>
<style lang="scss" scoped>
.page {
background: #f9fbff;
padding: 16px;
min-height: 100vh;
color: #0f274b;
}
.appraise {
display: flex;
justify-content: space-between;
font-size: 13px;
margin: 8px 0 20px;
.appraise-right {
color: #ff6816;
}
}
.m-8 {
margin: 0 8px;
}
.bt {
margin-bottom: 16px;
}
.cont {
background: #fff;
border-radius: 8px;
padding: 8px 0;
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1);
.top-source {
font-weight: 800;
margin-bottom: 12px;
}
.tag {
margin-left: 5px;
width: 32px;
border-radius: 1px 1px 1px 1px;
border: 1px solid #ff6816;
color: #ff6816;
2025-02-19 09:34:34 +08:00
font-size: 12px;
2025-01-10 17:39:14 +08:00
display: flex;
justify-content: center;
align-items: center;
}
.img-cont {
margin: 20px 0;
.img-list {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
.name-num {
margin-left: 10px;
}
}
}
.realAmount {
margin-top: 16px;
font-size: 16px;
font-weight: 800;
}
}
.order {
margin-top: 16px;
padding: 8px 0;
background: #fff;
border-radius: 8px;
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1);
.qrcode{
display: flex;
justify-content: center;
align-items: center;
margin: 28px 0 12px;
}
}
</style>