数据库分析和对应不同角色页面
This commit is contained in:
494
pages/mall/delivery/test/consumer-logistics-detail.uvue
Normal file
494
pages/mall/delivery/test/consumer-logistics-detail.uvue
Normal file
@@ -0,0 +1,494 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<!-- 头部状态栏 (沉浸式) -->
|
||||
<view class="status-header">
|
||||
<view class="status-main">
|
||||
<text class="status-icon">{{ getStatusIcon(order.status) }}</text>
|
||||
<view class="status-text-wrap">
|
||||
<text class="status-title">{{ getStatusText(order.status) }}</text>
|
||||
<view class="status-desc-row">
|
||||
<text v-for="(seg, i) in splitText(getLatestEventText())" :key="i" class="status-desc-text" :class="{ 'highlight': seg.isPhone }" @click="seg.isPhone ? makeCall(seg.raw as string) : null">{{ seg.text }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 承运信息卡片 -->
|
||||
<view class="card carrier-card">
|
||||
<view class="carrier-info">
|
||||
<image class="carrier-logo" src="/static/carrier-default.png" mode="aspectFit" />
|
||||
<view class="carrier-detail">
|
||||
<text class="carrier-name">{{ order.carrier }}快递</text>
|
||||
<text class="waybill-no">运单号: {{ order.tracking_no }}</text>
|
||||
</view>
|
||||
<button class="copy-btn" @click="copyTrackingNo">复制</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 物流轨迹时间线 -->
|
||||
<view class="card timeline-card">
|
||||
<view class="section-title">物流追踪</view>
|
||||
<view class="timeline-container">
|
||||
<view v-for="(event, index) in statusHistory" :key="index" class="timeline-item">
|
||||
<!-- 时间轴线 -->
|
||||
<view class="axis">
|
||||
<view class="dot" :class="{active: index === 0}"></view>
|
||||
<view class="line" v-if="index !== statusHistory.length - 1"></view>
|
||||
</view>
|
||||
|
||||
<!-- 内容区 -->
|
||||
<view class="content">
|
||||
<view class="event-header">
|
||||
<view class="status-time-row">
|
||||
<text v-if="shouldShowStatus(index)" class="status-label" :class="{active: index === 0}">{{ getStatusLabel(event.status_code) }}</text>
|
||||
<text class="event-time" :class="{active: index === 0}">{{ event.event_time }}</text>
|
||||
</view>
|
||||
<view class="event-title-row">
|
||||
<text v-for="(seg, i) in splitText(event.event_text)" :key="i" class="event-title-text" :class="{ 'highlight': seg.isPhone, 'active': index === 0 }" @click="seg.isPhone ? makeCall(seg.raw as string) : null">{{ seg.text }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="event.location" class="location-info">
|
||||
<text class="loc-icon">📍</text>
|
||||
<text class="loc-text">{{ event.location }}</text>
|
||||
</view>
|
||||
<!-- 证据/签收图片 (POD) -->
|
||||
<view v-if="event.evidence_urls.length > 0" class="evidence-grid">
|
||||
<image v-for="(img, idx) in event.evidence_urls" :key="idx" :src="img" class="evidence-img" mode="aspectFill" @click="previewImage(img, event.evidence_urls)" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="statusHistory.length === 0" class="empty-state">
|
||||
<text class="empty-text">暂无物流动态</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 订单交易信息 -->
|
||||
<view class="card order-info-card">
|
||||
<view class="section-title">订单信息</view>
|
||||
<view class="info-item">
|
||||
<text class="info-label">订单编号</text>
|
||||
<text class="info-value">{{ order.order_no }}</text>
|
||||
</view>
|
||||
<view class="info-item">
|
||||
<text class="info-label">下单时间</text>
|
||||
<text class="info-value">{{ order.created_at }}</text>
|
||||
</view>
|
||||
<view class="info-item">
|
||||
<text class="info-label">实付金额</text>
|
||||
<text class="info-value">¥{{ order.amount || '0.00' }}</text>
|
||||
</view>
|
||||
<view v-if="order.address" class="info-item">
|
||||
<text class="info-label">收货地址</text>
|
||||
<text class="info-value">{{ order.address }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 底部操作栏 -->
|
||||
<view class="bottom-actions">
|
||||
<button class="action-item" @click="refresh">🔄 刷新物流</button>
|
||||
<button class="action-item" @click="showSupport">💬 物流客服</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script uts>
|
||||
import { mockService, MockOrder, MockTrackingEvent } from './mock-service.uts'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
orderNo: 'ORD20260205002',
|
||||
order: {
|
||||
order_no: '',
|
||||
status: '',
|
||||
created_at: '',
|
||||
receiver_name: '',
|
||||
receiver_masked_phone: '',
|
||||
address: '',
|
||||
amount: '',
|
||||
carrier: '',
|
||||
tracking_no: ''
|
||||
} as MockOrder,
|
||||
statusHistory: [] as MockTrackingEvent[]
|
||||
}
|
||||
},
|
||||
onLoad(options: any) {
|
||||
if (options['order_no'] != null) {
|
||||
this.orderNo = options['order_no'] as string
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
this.loadData()
|
||||
},
|
||||
methods: {
|
||||
loadData() {
|
||||
const orders = mockService.getMockOrders()
|
||||
const found = orders.find((o: MockOrder): boolean => o.order_no === this.orderNo)
|
||||
if (found != null) {
|
||||
// 确保对象引用更新以触发响应式
|
||||
this.order = { ...found } as MockOrder
|
||||
}
|
||||
// 确保数组引用更新
|
||||
this.statusHistory = [...mockService.getMockTracking(this.orderNo)]
|
||||
},
|
||||
getStatusText(status: string): string {
|
||||
const maps = {
|
||||
'SHIPPED': '运输中',
|
||||
'DELIVERED': '已签收',
|
||||
'OUT_FOR_DELIVERY': '派送中',
|
||||
'PENDING': '待揽收',
|
||||
'EXCEPTION': '包裹异常'
|
||||
}
|
||||
return (maps[status] != null) ? maps[status] : status
|
||||
},
|
||||
getStatusIcon(status: string): string {
|
||||
const maps = { 'SHIPPED': '🚚', 'DELIVERED': '✅', 'OUT_FOR_DELIVERY': '🛵', 'PENDING': '📦', 'EXCEPTION': '❗' }
|
||||
return (maps[status] != null) ? maps[status] : '📦'
|
||||
},
|
||||
getLatestEventText(): string {
|
||||
if (this.statusHistory.length > 0) {
|
||||
return this.statusHistory[0].event_text
|
||||
}
|
||||
return '暂无物流信息'
|
||||
},
|
||||
shouldShowStatus(index: number): boolean {
|
||||
if (index == 0) return true
|
||||
const current = this.statusHistory[index].status_code
|
||||
const prev = this.statusHistory[index - 1].status_code
|
||||
// 如果当前状态与上一个状态不同,或者是状态变更点,则显示标签
|
||||
return current != '' && current != prev
|
||||
},
|
||||
copyTrackingNo() {
|
||||
uni.setClipboardData({
|
||||
data: this.order.tracking_no,
|
||||
success: () => uni.showToast({ title: '单号已复制' })
|
||||
})
|
||||
},
|
||||
callCourier() {
|
||||
uni.makePhoneCall({ phoneNumber: '13800138000' })
|
||||
},
|
||||
async refresh() {
|
||||
if (this.order.status === 'DELIVERED') {
|
||||
uni.showToast({ title: '已签收包裹无需刷新', icon: 'none' })
|
||||
return
|
||||
}
|
||||
uni.showLoading({ title: '同步中...' })
|
||||
const success = await mockService.syncFromCloud(this.orderNo)
|
||||
uni.hideLoading()
|
||||
if (success) {
|
||||
this.loadData()
|
||||
uni.showToast({ title: '已同步最新动态' })
|
||||
} else {
|
||||
uni.showToast({ title: '暂无更多更新', icon: 'none' })
|
||||
}
|
||||
},
|
||||
previewImage(url: string, urls: string[]) {
|
||||
uni.previewImage({ current: url, urls: urls })
|
||||
},
|
||||
showSupport() {
|
||||
uni.showToast({ title: '接入平台客服中...', icon: 'none' })
|
||||
},
|
||||
getStatusLabel(code: string): string {
|
||||
const maps = {
|
||||
'SHIPPED': '已发货',
|
||||
'IN_TRANSIT': '运输中',
|
||||
'ARRIVED_HUB': '中转中',
|
||||
'OUT_FOR_DELIVERY': '派送中',
|
||||
'DELIVERED': '已签收',
|
||||
'EXCEPTION': '异常'
|
||||
}
|
||||
return (maps[code] != null) ? maps[code] : code
|
||||
},
|
||||
splitText(text: string): UTSJSONObject[] {
|
||||
const res = [] as UTSJSONObject[]
|
||||
const regex = /(1[3-9]\d{9})/g
|
||||
const parts = text.split(regex)
|
||||
for (let i = 0; i < parts.length; i++) {
|
||||
const part = parts[i]
|
||||
if (i % 2 === 1) {
|
||||
// 消费者端:脱敏显示,但保持可点击
|
||||
const masked = part.substring(0, 3) + '****' + part.substring(7)
|
||||
res.push({ text: masked, raw: part, isPhone: true } as UTSJSONObject)
|
||||
} else if (part.length > 0) {
|
||||
res.push({ text: part, raw: '', isPhone: false } as UTSJSONObject)
|
||||
}
|
||||
}
|
||||
return res
|
||||
},
|
||||
makeCall(phone: string) {
|
||||
// 获取原始电话拨打
|
||||
uni.makePhoneCall({ phoneNumber: phone })
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.container {
|
||||
background-color: #f3f4f6;
|
||||
min-height: 100vh;
|
||||
padding-bottom: 160rpx;
|
||||
}
|
||||
.status-header {
|
||||
background: linear-gradient(135deg, #007AFF, #0056b3);
|
||||
padding: 60rpx 40rpx;
|
||||
color: #ffffff;
|
||||
}
|
||||
.status-main {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 30rpx;
|
||||
}
|
||||
.status-icon {
|
||||
font-size: 80rpx;
|
||||
}
|
||||
.status-title {
|
||||
font-size: 44rpx;
|
||||
font-weight: bold;
|
||||
display: block;
|
||||
}
|
||||
.status-desc-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
.status-desc-text {
|
||||
font-size: 26rpx;
|
||||
color: #ffffff;
|
||||
opacity: 0.9;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.status-desc-text.highlight {
|
||||
color: #FFD700;
|
||||
font-weight: bold;
|
||||
text-decoration: underline;
|
||||
opacity: 1;
|
||||
}
|
||||
.event-title-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.event-title-text {
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.event-title-text.active {
|
||||
color: #1a1a1a;
|
||||
font-weight: 500;
|
||||
}
|
||||
.event-title-text.highlight {
|
||||
color: #007AFF;
|
||||
font-weight: bold;
|
||||
text-decoration: underline;
|
||||
}
|
||||
.header-call-btn {
|
||||
/* Lines 258-267 omitted */
|
||||
}
|
||||
.card {
|
||||
background-color: #ffffff;
|
||||
margin: 20rpx;
|
||||
border-radius: 20rpx;
|
||||
padding: 30rpx;
|
||||
}
|
||||
.carrier-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20rpx;
|
||||
}
|
||||
.carrier-logo {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
background-color: #f0f0f0;
|
||||
border-radius: 50%;
|
||||
}
|
||||
.carrier-detail {
|
||||
flex: 1;
|
||||
}
|
||||
.carrier-name {
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
display: block;
|
||||
}
|
||||
.waybill-no {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
}
|
||||
.copy-btn {
|
||||
font-size: 22rpx;
|
||||
padding: 0 20rpx;
|
||||
height: 44rpx;
|
||||
line-height: 44rpx;
|
||||
border-radius: 22rpx;
|
||||
background-color: #eef2f7;
|
||||
color: #007AFF;
|
||||
}
|
||||
.courier-box {
|
||||
margin-top: 30rpx;
|
||||
padding-top: 30rpx;
|
||||
border-top: 1rpx solid #f0f0f0;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
.courier-tip {
|
||||
font-size: 26rpx;
|
||||
color: #27ae60;
|
||||
font-weight: bold;
|
||||
}
|
||||
.call-btn {
|
||||
font-size: 24rpx;
|
||||
background-color: #007AFF;
|
||||
color: #fff;
|
||||
margin: 0;
|
||||
}
|
||||
.section-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
.info-item {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
.info-label {
|
||||
width: 160rpx;
|
||||
font-size: 26rpx;
|
||||
color: #999;
|
||||
}
|
||||
.info-value {
|
||||
flex: 1;
|
||||
font-size: 26rpx;
|
||||
color: #333;
|
||||
text-align: left;
|
||||
word-break: break-all;
|
||||
}
|
||||
.empty-state {
|
||||
padding: 40rpx;
|
||||
text-align: center;
|
||||
}
|
||||
.empty-text {
|
||||
color: #999;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
.timeline-item {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
.axis {
|
||||
width: 30rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
margin-right: 15rpx;
|
||||
}
|
||||
.line {
|
||||
width: 2rpx;
|
||||
flex: 1;
|
||||
background-color: #eee;
|
||||
}
|
||||
.dot {
|
||||
width: 12rpx;
|
||||
height: 12rpx;
|
||||
background-color: #ddd;
|
||||
border-radius: 50%;
|
||||
z-index: 1;
|
||||
margin-top: 14rpx;
|
||||
}
|
||||
.dot.active {
|
||||
background-color: #007AFF;
|
||||
width: 16rpx;
|
||||
height: 16rpx;
|
||||
box-shadow: 0 0 8rpx rgba(0,122,255,0.3);
|
||||
margin-top: 12rpx;
|
||||
}
|
||||
.content {
|
||||
flex: 1;
|
||||
padding-bottom: 24rpx;
|
||||
}
|
||||
.event-header {
|
||||
margin-bottom: 4rpx;
|
||||
}
|
||||
.status-time-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
margin-bottom: 6rpx;
|
||||
}
|
||||
.status-label {
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
.status-label.active {
|
||||
color: #007AFF;
|
||||
}
|
||||
.event-title {
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
display: block;
|
||||
line-height: 1.6;
|
||||
text-align: left;
|
||||
}
|
||||
.event-title.active {
|
||||
color: #1a1a1a;
|
||||
font-weight: 500;
|
||||
}
|
||||
.event-time {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
text-align: left;
|
||||
}
|
||||
.event-time.active {
|
||||
color: #007AFF;
|
||||
}
|
||||
.event-time.active {
|
||||
color: #666;
|
||||
}
|
||||
.location-info {
|
||||
margin-top: 12rpx;
|
||||
background-color: #f9fafb;
|
||||
padding: 10rpx 16rpx;
|
||||
border-radius: 8rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8rpx;
|
||||
}
|
||||
.loc-icon { font-size: 20rpx; }
|
||||
.loc-text { font-size: 22rpx; color: #666; }
|
||||
.evidence-grid {
|
||||
display: flex;
|
||||
gap: 16rpx;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
.evidence-img {
|
||||
width: 140rpx;
|
||||
height: 140rpx;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
.bottom-actions {
|
||||
position: fixed;
|
||||
bottom: 0; left: 0; right: 0;
|
||||
background-color: #fff;
|
||||
padding: 20rpx 30rpx;
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
box-shadow: 0 -2rpx 10rpx rgba(0,0,0,0.05);
|
||||
}
|
||||
.action-item {
|
||||
font-size: 24rpx;
|
||||
background-color: #f8fafc;
|
||||
border: 1rpx solid #e2e8f0;
|
||||
margin: 0;
|
||||
padding: 0 30rpx;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user