227 lines
5.3 KiB
Plaintext
227 lines
5.3 KiB
Plaintext
<template>
|
|
<view class="container">
|
|
<view class="header">
|
|
<text class="title">我的快递</text>
|
|
<text class="count">共 {{ orders.length }} 个包裹</text>
|
|
</view>
|
|
|
|
<view class="tabs">
|
|
<view class="tab-item" :class="{active: currentTab === 'all'}" @click="currentTab = 'all'">全部</view>
|
|
<view class="tab-item" :class="{active: currentTab === 'active'}" @click="currentTab = 'active'">进行中</view>
|
|
<view class="tab-item" :class="{active: currentTab === 'completed'}" @click="currentTab = 'completed'">已签收</view>
|
|
</view>
|
|
|
|
<scroll-view class="order-list" scroll-y="true">
|
|
<view v-for="(order, index) in filteredOrders" :key="order.order_no" class="order-card" @click="goDetail(order.order_no)">
|
|
<view class="card-header">
|
|
<view class="carrier-tag">{{ order.carrier }}</view>
|
|
<text class="status-text" :class="order.status">{{ getStatusText(order.status) }}</text>
|
|
</view>
|
|
|
|
<view class="card-body">
|
|
<view class="pkg-icon">📦</view>
|
|
<view class="pkg-info">
|
|
<text class="latest-msg">{{ getLatestMsg(order.order_no) }}</text>
|
|
<text class="order-meta">订单号: {{ order.order_no }}</text>
|
|
</view>
|
|
<text class="arrow">></text>
|
|
</view>
|
|
|
|
<view class="card-footer">
|
|
<text class="time">下单时间: {{ order.created_at }}</text>
|
|
</view>
|
|
</view>
|
|
|
|
<view v-if="filteredOrders.length === 0" class="empty-state">
|
|
<text class="empty-icon">📂</text>
|
|
<text class="empty-text">暂无相关包裹信息</text>
|
|
</view>
|
|
</scroll-view>
|
|
</view>
|
|
</template>
|
|
|
|
<script uts>
|
|
import { mockService, MockOrder } from './mock-service.uts'
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
currentTab: 'all',
|
|
orders: [] as MockOrder[]
|
|
}
|
|
},
|
|
onShow() {
|
|
this.loadData()
|
|
},
|
|
computed: {
|
|
filteredOrders(): MockOrder[] {
|
|
if (this.currentTab === 'all') {
|
|
return this.orders
|
|
}
|
|
if (this.currentTab === 'completed') {
|
|
return this.orders.filter((o: MockOrder): boolean => o.status === 'DELIVERED')
|
|
} else {
|
|
return this.orders.filter((o: MockOrder): boolean => o.status !== 'DELIVERED')
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
loadData() {
|
|
this.orders = [...mockService.getMockOrders()]
|
|
},
|
|
getStatusText(status: string): string {
|
|
const maps = {
|
|
'SHIPPED': '已发货',
|
|
'IN_TRANSIT': '运输中',
|
|
'DELIVERED': '已签收',
|
|
'OUT_FOR_DELIVERY': '派送中',
|
|
'PENDING': '待揽收',
|
|
'EXCEPTION': '包裹异常'
|
|
}
|
|
return (maps[status] != null) ? maps[status] : '处理中'
|
|
},
|
|
getLatestMsg(orderNo: string): string {
|
|
const history = mockService.getMockTracking(orderNo)
|
|
if (history.length > 0) {
|
|
const text = history[0].event_text
|
|
// 消费者端列表页:脱敏处理手机号
|
|
return text.replace(/(1[3-9]\d{9})/g, (m : string) : string => {
|
|
return m.substring(0, 3) + '****' + m.substring(7)
|
|
})
|
|
}
|
|
return '包裹准备中'
|
|
},
|
|
goDetail(orderNo: string) {
|
|
uni.navigateTo({
|
|
url: `/pages/mall/delivery/test/consumer-logistics-detail?order_no=${orderNo}`
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.container {
|
|
background-color: #f7f8fa;
|
|
min-height: 100vh;
|
|
padding: 30rpx;
|
|
}
|
|
.header {
|
|
margin-bottom: 30rpx;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: flex-end;
|
|
}
|
|
.title {
|
|
font-size: 40rpx;
|
|
font-weight: bold;
|
|
color: #1a1a1a;
|
|
}
|
|
.count {
|
|
font-size: 24rpx;
|
|
color: #999;
|
|
}
|
|
.tabs {
|
|
display: flex;
|
|
margin-bottom: 30rpx;
|
|
gap: 40rpx;
|
|
}
|
|
.tab-item {
|
|
font-size: 30rpx;
|
|
color: #666;
|
|
padding-bottom: 10rpx;
|
|
}
|
|
.tab-item.active {
|
|
color: #007AFF;
|
|
font-weight: bold;
|
|
border-bottom: 4rpx solid #007AFF;
|
|
}
|
|
.order-card {
|
|
background-color: #fff;
|
|
border-radius: 20rpx;
|
|
padding: 24rpx;
|
|
margin-bottom: 24rpx;
|
|
box-shadow: 0 2rpx 10rpx rgba(0,0,0,0.02);
|
|
}
|
|
.card-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
margin-bottom: 20rpx;
|
|
}
|
|
.carrier-tag {
|
|
background-color: #f0f7ff;
|
|
color: #007AFF;
|
|
font-size: 20rpx;
|
|
padding: 4rpx 12rpx;
|
|
border-radius: 6rpx;
|
|
}
|
|
.status-text.DELIVERED { color: #52c41a; }
|
|
.status-text.SHIPPED { color: #007AFF; }
|
|
.status-text.OUT_FOR_DELIVERY { color: #faad14; }
|
|
.status-text.EXCEPTION { color: #ff4d4f; }
|
|
.status-text.PENDING { color: #999; }
|
|
.status-text.DELIVERED { color: #999; }
|
|
.status-text.OUT_FOR_DELIVERY { color: #27ae60; }
|
|
.status-text.SHIPPED { color: #007AFF; }
|
|
|
|
.card-body {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 20rpx;
|
|
padding: 10rpx 0;
|
|
}
|
|
.pkg-icon {
|
|
font-size: 50rpx;
|
|
background-color: #f9f9f9;
|
|
width: 90rpx;
|
|
height: 90rpx;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
border-radius: 16rpx;
|
|
}
|
|
.pkg-info {
|
|
flex: 1;
|
|
}
|
|
.latest-msg {
|
|
font-size: 26rpx;
|
|
color: #333;
|
|
line-height: 1.4;
|
|
display: -webkit-box;
|
|
-webkit-line-clamp: 1;
|
|
-webkit-box-orient: vertical;
|
|
overflow: hidden;
|
|
margin-bottom: 8rpx;
|
|
}
|
|
.order-meta {
|
|
font-size: 22rpx;
|
|
color: #999;
|
|
}
|
|
.arrow {
|
|
color: #ccc;
|
|
font-size: 30rpx;
|
|
}
|
|
.card-footer {
|
|
margin-top: 20rpx;
|
|
padding-top: 20rpx;
|
|
border-top: 1rpx solid #f2f2f2;
|
|
}
|
|
.time {
|
|
font-size: 22rpx;
|
|
color: #bbb;
|
|
}
|
|
.empty-state {
|
|
padding-top: 200rpx;
|
|
text-align: center;
|
|
}
|
|
.empty-icon {
|
|
font-size: 100rpx;
|
|
display: block;
|
|
margin-bottom: 20rpx;
|
|
}
|
|
.empty-text {
|
|
color: #999;
|
|
font-size: 28rpx;
|
|
}
|
|
</style>
|