aircraft-pilot/aircraft/server/order/order.vue

281 lines
7.2 KiB
Vue
Raw Permalink Normal View History

2025-07-14 18:41:30 +08:00
<template>
<view class="aircraft-order">
2025-07-23 00:15:17 +08:00
<u-image width="100%" :src="fileUrl+banner" mode="widthFix" />
<view class="order-list">
<view class="order-item" v-for="(item,index) in orders" :key="index" @click="showDetail(item)">
2025-07-23 16:02:02 +08:00
<view class="item-first">
<view class="item-status">{{ orderStatus[item.mainOrderStatus] }}</view>
<view class="item-type">订单类型<text>{{ orderTypes[item.orderType] }}</text></view>
2025-07-23 16:02:02 +08:00
</view>
<view class="item-second">
<view class="item-spot">
<view class="item-dot"/>景区{{ scenics[item.attractionId] }}
2025-07-23 16:02:02 +08:00
</view>
<view class="item-route">
<view class="item-dot"/>路线{{ item.routeName }}
</view>
</view>
<view class="item-third">
<view class="item-identity">
<u-image class="item-avatar" width="80rpx" height="80rpx"
2025-08-03 01:01:22 +08:00
:src="fileUrl+(!isPilot?pilotIcon:(customers[item.customerId].gender === '男' ? boyIcon : girlIcon))" />
2025-07-23 16:02:02 +08:00
<view class="item-self">
2025-08-03 16:43:06 +08:00
<text class="item-name">{{ customers[item[isPilot?'customerId':'orderInitiatorId']].name }}</text>
<text class="item-phone">{{ isPilot?item.customerPhone:customers[item.orderInitiatorId].phone }}</text>
2025-07-23 16:02:02 +08:00
</view>
</view>
<view class="item-active">
<u-button type="warning" :custom-style="customStyle"
2025-08-03 01:01:22 +08:00
:hair-line="false" @click.stop="handleDoAction(item)">{{isPilot?'执行任务':'查看详情'}}</u-button>
2025-07-23 16:02:02 +08:00
</view>
</view>
</view>
<u-loadmore v-if="orders.length>0" @loadmore="getMore" :status="form.isFinish" color="#333333" marginTop="30" marginBottom="20" />
<view class="order-empty" v-else>
2025-07-23 16:02:02 +08:00
<u-empty text="订单为空" mode="list"
src="/static/empty.png" icon-size="300" font-size="40"
margin-top="250"></u-empty>
2025-07-23 00:15:17 +08:00
</view>
</view>
2025-07-14 18:41:30 +08:00
<u-toast ref="uToast"></u-toast>
</view>
2025-07-14 18:41:30 +08:00
</template>
<script>
2025-07-23 00:15:17 +08:00
import configService from '@/common/config.service.js';
2025-07-14 18:41:30 +08:00
export default {
2025-07-23 00:15:17 +08:00
// #ifdef MP
options: {
styleIsolation: 'shared'
},
// #endif
2025-08-03 01:01:22 +08:00
props: {
isPilot:{
type: Boolean,
default: true
},
},
2025-07-14 18:41:30 +08:00
data(){
return {
2025-07-23 00:15:17 +08:00
fileUrl: configService.fileUrl + 'aerocraft/order/',//订单页图标基础路径
// 轮播图
banner: 'banner.png',
2025-07-23 16:02:02 +08:00
// 女生头像
girlIcon: 'girl.png',
// 男生头像
boyIcon: 'boy.png',
2025-08-03 01:01:22 +08:00
// 飞行员默认头像
pilotIcon: 'pilot-avatar.png',
// 订单状态
orderStatus: {
0:'未进行',
1:'进行中',
2:'已完成',
2025-08-03 01:01:22 +08:00
3:'已取消',
4:'待确认',
},
// 订单类型
orderTypes: {
1: '载物',
2: '载人'
},
2025-07-23 16:02:02 +08:00
// 订单列表
orders: [],
2025-07-23 16:02:02 +08:00
// 执行任务按钮样式
customStyle: {
backgroundColor: '#FEE547',
color: '#333333',
fontSize: '30rpx',
fontWeight: 'bold',
fontFamily: 'Source Han Sans SC',
width: '180rpx',
height: '72rpx',
borderRadius: '12rpx',
border: 'none'
},
// 用户信息
userMessage: this.$store.state.vuex_token === ''?{}:JSON.parse(this.$store.state.user_message),
// 翻页参数
form:{
current: 1,
size: 10,
// 是否结束——loadmore加载更多loading加载中nomore无更多
isFinish: 'nomore',
2025-08-03 01:01:22 +08:00
mainOrderStatusList: '0,1',
},
// 用户列表
customers: {},
// 景区列表
scenics: {}
2025-07-14 18:41:30 +08:00
}
},
methods:{
// 初始化
async init(){
2025-08-03 01:01:22 +08:00
this.form = {size: 10,current: 1,isFinish: 'nomore',mainOrderStatusList: this.isPilot?'0,1':'0,1,4'};
// 查询订单列表
await this.getOrderList();
// 查询全部客户
2025-08-03 01:01:22 +08:00
let cusRes = this.isPilot ? await this.$api.allCustomers() : await this.$api.allEmployees();
if(!cusRes){
this.$refs.uToast.show({type: 'error',title: "客户获取失败!"});
}else this.customers = await cusRes.reduce((obj, item) => ({...obj,[item.id]: item}), {})||{};
// 查询全部景区
let scenRes = await this.$api.allScenic();
if(!scenRes)
this.$refs.uToast.show({type: 'error',title: "景区列表获取失败!"});
else this.scenics = await scenRes.reduce((obj, item) => ({...obj,[item.id]: item.name}), {})||{};
},
// 查询订单列表
async getOrderList(){
this.form.isFinish = 'loading';
let ordRes = await this.$api.getOrders(this.form);
if(ordRes){
const { records, size, total, current } = ordRes;
if(current == 1) this.orders = records || [];
else this.orders.push(...records);
this.form.isFinish = size*current >= total ? 'nomore' : 'loadmore';
}else{
this.$refs.uToast.show({type:'error',title: "订单列表获取失败!"});
this.form.isFinish = 'loadmore';
}
},
// 加载更多
getMore(){
if(this.form.isFinish === 'nomore') return;
this.form.current++;
this.getOrderList();
2025-07-14 18:41:30 +08:00
},
// 执行任务
handleDoAction(item){
uni.navigateTo({
url: `/aircraft/server/order/detail?id=${item.id}`
})
},
// 查看详情
showDetail(item){
2025-08-03 01:01:22 +08:00
if(this.isPilot)
uni.navigateTo({
url: `/aircraft/server/order/add?id=${item.id}`
})
},
2025-07-14 18:41:30 +08:00
}
}
</script>
<style scoped lang="scss">
.aircraft-order{
2025-07-23 00:15:17 +08:00
height: 100%;
display: flex;
flex-direction: column;
.order-list{
flex: 1;
z-index: 1;
margin-top: -30rpx;
width: 100%;
background-color: #F5F5F5;
border-radius: 24rpx 16rpx 16rpx 16rpx;
.order-item{
border-radius: 24rpx 16rpx 16rpx 16rpx;
2025-07-23 16:02:02 +08:00
display: flex;
flex-direction: column;
padding: 0rpx 0rpx 38rpx;
background: #FFFFFF;
margin-bottom: 26rpx;
.item-first{
display: flex;
align-items: center;
.item-status{
width: 120rpx;
height: 60rpx;
background: linear-gradient(0deg, #666666, #333333);
border-radius: 24rpx 0rpx 30rpx 0rpx;
margin-right: 30rpx;
font-family: Source Han Sans SC;
font-weight: 500;
font-size: 28rpx;
color: #FFFEFE;
display: flex;
align-items: center;
justify-content: center;
}
.item-type{
margin-top: 20rpx;
font-family: Source Han Sans SC;
font-weight: 400;
font-size: 28rpx;
color: #333333;
text{
font-weight: bold;
font-size: 30rpx;
}
}
}
.item-second{
margin: 38rpx 30rpx 0;
border-bottom: 2rpx solid #E6E6E6;
.item-spot,.item-route{
font-family: Source Han Sans SC;
font-weight: 400;
font-size: 30rpx;
color: #333333;
display: flex;
align-items: center;
.item-dot{
background-color: #FCCF16;
border-radius: 50%;
width: 12rpx;
height: 12rpx;
margin-right: 12rpx;
}
}
.item-spot{
margin-bottom: 30rpx;
}
.item-route{
margin-bottom: 36rpx;
}
}
.item-third{
margin: 28rpx 30rpx 0;
display: flex;
align-items: center;
justify-content: space-between;
.item-identity{
display: flex;
align-items: center;
.item-avatar{
margin-right: 14rpx;
}
.item-self{
display: flex;
flex-direction: column;
justify-content: space-between;
font-family: Source Han Sans SC;
font-weight: 500;
font-size: 28rpx;
color: #333333;
.item-name{
margin-top: 6rpx;
}
.item-phone{
margin-bottom: 6rpx;
font-family: Arial;
}
}
}
.item-active{
}
}
}
}
.order-empty{
&::v-deep .u-icon__label{
margin-top: 24rpx !important;
font-weight: 500;
font-family: Source Han Sans SC;
2025-07-23 00:15:17 +08:00
}
}
2025-07-14 18:41:30 +08:00
}
</style>