feat: 变更物流查看方式
This commit is contained in:
@@ -5,50 +5,87 @@
|
||||
<view>
|
||||
<view class="express-popup__title">查看物流</view>
|
||||
<view class="express-popup__order-no">订单号:{{ orderNo || '-' }}</view>
|
||||
<view class="express-popup__tip">请选择要查看物流的商品</view>
|
||||
<view class="express-popup__tip">点击商品右侧按钮可展开/收起物流轨迹</view>
|
||||
</view>
|
||||
<view class="express-popup__close" @tap.stop="handleClose">×</view>
|
||||
</view>
|
||||
<scroll-view scroll-y class="express-popup__content">
|
||||
<view v-if="renderItems.length === 0" class="express-popup__empty">
|
||||
暂无物流信息
|
||||
</view>
|
||||
<view
|
||||
v-else
|
||||
class="express-popup__item"
|
||||
v-for="(item, index) in renderItems"
|
||||
:key="item.itemKey || index"
|
||||
<view class="express-popup__scroll-wrap">
|
||||
<scroll-view
|
||||
scroll-y
|
||||
scroll-with-animation
|
||||
enhanced
|
||||
:show-scrollbar="false"
|
||||
class="express-popup__content"
|
||||
>
|
||||
<image class="express-popup__item-image" :src="item.picUrl" mode="aspectFill" />
|
||||
<view class="express-popup__item-main">
|
||||
<view class="express-popup__item-name lineTwo">{{ item.spuName }}</view>
|
||||
<view class="express-popup__item-sku">{{ item.skuText || '-' }}</view>
|
||||
<view class="express-popup__item-info">
|
||||
<text class="express-popup__item-count">数量:x{{ item.count }}</text>
|
||||
<text
|
||||
v-if="item.logisticsNo"
|
||||
class="express-popup__item-logistics"
|
||||
>运单号:{{ item.logisticsNo }}</text>
|
||||
<view v-if="renderItems.length === 0" class="express-popup__empty">
|
||||
暂无物流信息
|
||||
</view>
|
||||
<view
|
||||
v-else
|
||||
class="express-popup__item"
|
||||
:class="{ 'express-popup__item--expanded': item.expanded }"
|
||||
v-for="(item, index) in renderItems"
|
||||
:key="item.itemKey || index"
|
||||
>
|
||||
<view class="express-popup__item-top flex-row al-flex-start">
|
||||
<image class="express-popup__item-image" :src="item.picUrl" mode="aspectFill" />
|
||||
<view class="express-popup__item-main">
|
||||
<view class="express-popup__item-name lineTwo">{{ item.spuName }}</view>
|
||||
<view class="express-popup__item-sku">{{ item.skuText || '-' }}</view>
|
||||
<view class="express-popup__item-info">
|
||||
<text class="express-popup__item-count">数量:x{{ item.count }}</text>
|
||||
<text
|
||||
v-if="item.logisticsNo"
|
||||
class="express-popup__item-logistics"
|
||||
>运单号:{{ item.logisticsNo }}</text>
|
||||
</view>
|
||||
<view class="express-popup__item-action">
|
||||
<view
|
||||
class="express-popup__btn"
|
||||
:class="item.expanded ? 'express-popup__btn--ghost' : 'express-popup__btn--primary'"
|
||||
@tap.stop="handleToggleTrack(item)"
|
||||
>
|
||||
<text v-if="item.loading">加载中...</text>
|
||||
<template v-else>
|
||||
{{ item.expanded ? '收起物流' : '查看物流' }}
|
||||
</template>
|
||||
<text class="express-popup__btn-arrow" :class="{ rotated: item.expanded }">▾</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="express-popup__item-action">
|
||||
<view
|
||||
class="express-popup__btn express-popup__btn--primary"
|
||||
@tap.stop="handleViewExpress(item)"
|
||||
>
|
||||
查看物流
|
||||
<view v-if="item.expanded" class="express-popup__track">
|
||||
<view v-if="item.loading" class="express-popup__track-loading">物流信息加载中...</view>
|
||||
<view v-else-if="!Array.isArray(item.tracks) || item.tracks.length === 0" class="express-popup__track-empty">
|
||||
暂无物流轨迹
|
||||
</view>
|
||||
<view v-else class="express-popup__track-list">
|
||||
<view
|
||||
class="express-popup__track-node"
|
||||
:class="{ 'is-first': i === 0 }"
|
||||
v-for="(node, i) in item.tracks"
|
||||
:key="i"
|
||||
>
|
||||
<view class="express-popup__track-dot" />
|
||||
<view class="express-popup__track-main">
|
||||
<view class="express-popup__track-content">{{ node.content || node.desc || node.text || '-' }}</view>
|
||||
<view class="express-popup__track-time">{{ node.time || node.ftime || node.createTime || '' }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { computed, reactive, ref, watch } from 'vue';
|
||||
import sheep from '@/sheep';
|
||||
import { getAiOrderDelayRecords } from '@/sheep/api/ai';
|
||||
import { getExpressTrackList } from '@/sheep/api/index/index';
|
||||
|
||||
const props = defineProps({
|
||||
popupType: {
|
||||
@@ -274,13 +311,6 @@ const resolveRecordLogisticsNo = (record) =>
|
||||
record?.orderItem?.logisticsNo,
|
||||
);
|
||||
|
||||
const hasRecordLogistics = (record) => {
|
||||
if (Number(record?.logisticsId) > 0) return true;
|
||||
if (hasValue(resolveRecordLogisticsNo(record))) return true;
|
||||
if (hasValue(record?.deliveryTime)) return true;
|
||||
return false;
|
||||
};
|
||||
|
||||
const buildExpressItemList = () => {
|
||||
const records = resolveAllDelayRecords();
|
||||
const expressRecords = records.filter((record) => {
|
||||
@@ -339,7 +369,7 @@ const buildExpressItemList = () => {
|
||||
const delayRecordId = Number(record?.delayRecordId || record?.id) || 0;
|
||||
const logisticsNo = resolveRecordLogisticsNo(record);
|
||||
|
||||
return {
|
||||
return reactive({
|
||||
itemKey: `${delayRecordId}-${idx}`,
|
||||
delayRecordId,
|
||||
spuName: spuName || '商品信息',
|
||||
@@ -347,7 +377,10 @@ const buildExpressItemList = () => {
|
||||
picUrl: picUrl || '',
|
||||
count,
|
||||
logisticsNo,
|
||||
};
|
||||
expanded: false,
|
||||
loading: false,
|
||||
tracks: null,
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -379,36 +412,59 @@ const handleClose = () => {
|
||||
close();
|
||||
};
|
||||
|
||||
const handleViewExpress = (item) => {
|
||||
const loadTrackList = async (item) => {
|
||||
const delayRecordId = Number(item?.delayRecordId) || 0;
|
||||
if (!delayRecordId) {
|
||||
const id = props.orderId || props.orderData?.id || props.orderData?.orderId;
|
||||
if (!delayRecordId || !id) {
|
||||
uni.showToast({
|
||||
title: '物流信息异常',
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
return [];
|
||||
}
|
||||
const id = props.orderId || props.orderData?.id || props.orderData?.orderId;
|
||||
if (!id) {
|
||||
uni.showToast({
|
||||
title: '订单信息异常',
|
||||
icon: 'none',
|
||||
try {
|
||||
const { code, data } = await getExpressTrackList({
|
||||
id,
|
||||
code: 2,
|
||||
delayRecordId,
|
||||
});
|
||||
return;
|
||||
if (code === 0 && Array.isArray(data)) {
|
||||
return data;
|
||||
}
|
||||
return [];
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
const handleToggleTrack = async (item) => {
|
||||
if (!item) return;
|
||||
if (item.loading) return;
|
||||
if (!item.expanded) {
|
||||
const delayRecordId = Number(item?.delayRecordId) || 0;
|
||||
const id = props.orderId || props.orderData?.id || props.orderData?.orderId;
|
||||
if (!delayRecordId || !id) {
|
||||
uni.showToast({
|
||||
title: '物流信息异常',
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
}
|
||||
emit('view-express', {
|
||||
id,
|
||||
delayRecordId,
|
||||
code: 2,
|
||||
});
|
||||
if (!Array.isArray(item.tracks)) {
|
||||
item.loading = true;
|
||||
const data = await loadTrackList(item);
|
||||
item.tracks = data;
|
||||
item.loading = false;
|
||||
}
|
||||
item.expanded = true;
|
||||
} else {
|
||||
item.expanded = false;
|
||||
}
|
||||
emit('view-express', {
|
||||
id,
|
||||
delayRecordId,
|
||||
code: 2,
|
||||
});
|
||||
close();
|
||||
const query = [
|
||||
`id=${encodeURIComponent(id)}`,
|
||||
`code=${encodeURIComponent(2)}`,
|
||||
`delayRecordId=${encodeURIComponent(delayRecordId)}`,
|
||||
].join('&');
|
||||
const url = `/pages/order/express/log?${query}`;
|
||||
uni.navigateTo({ url });
|
||||
};
|
||||
|
||||
defineExpose({ open, close });
|
||||
@@ -423,25 +479,29 @@ defineExpose({ open, close });
|
||||
|
||||
&--bottom {
|
||||
width: 100%;
|
||||
height: 82vh;
|
||||
max-height: 82vh;
|
||||
border-radius: 24rpx 24rpx 0 0;
|
||||
padding: 32rpx 32rpx calc(24rpx + env(safe-area-inset-bottom)) 32rpx;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
&--center {
|
||||
width: 680rpx;
|
||||
height: 78vh;
|
||||
max-height: 78vh;
|
||||
border-radius: 24rpx;
|
||||
padding: 32rpx 32rpx 0 32rpx;
|
||||
padding: 32rpx 32rpx 32rpx 32rpx;
|
||||
margin: 0 auto;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
&--center &__content {
|
||||
max-height: 52vh;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
&--center &__btn {
|
||||
min-width: 160rpx;
|
||||
min-width: 200rpx;
|
||||
}
|
||||
|
||||
&__header {
|
||||
@@ -450,6 +510,10 @@ defineExpose({ open, close });
|
||||
align-items: flex-start;
|
||||
padding-bottom: 24rpx;
|
||||
border-bottom: 1rpx solid #f2f2f2;
|
||||
flex-shrink: 0;
|
||||
flex-grow: 0;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
&__title {
|
||||
font-size: 32rpx;
|
||||
@@ -479,12 +543,25 @@ defineExpose({ open, close });
|
||||
color: #9ca3af;
|
||||
line-height: 1;
|
||||
}
|
||||
&__content {
|
||||
flex: 1;
|
||||
&__scroll-wrap {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
max-height: calc(82vh - 280rpx - env(safe-area-inset-bottom));
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin-top: 20rpx;
|
||||
box-sizing: border-box;
|
||||
overflow: hidden;
|
||||
}
|
||||
&__content {
|
||||
width: 100%;
|
||||
flex: 1 1 auto;
|
||||
height: auto;
|
||||
min-height: 100%;
|
||||
max-height: none;
|
||||
margin: 0;
|
||||
padding-bottom: 40rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
&__empty {
|
||||
padding: 80rpx 0;
|
||||
@@ -494,10 +571,16 @@ defineExpose({ open, close });
|
||||
}
|
||||
&__item {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
padding: 20rpx 0;
|
||||
border-bottom: 1rpx solid #f2f2f2;
|
||||
}
|
||||
&__item--expanded {
|
||||
padding-bottom: 24rpx;
|
||||
}
|
||||
&__item-top {
|
||||
width: 100%;
|
||||
}
|
||||
&__item-image {
|
||||
flex-shrink: 0;
|
||||
width: 140rpx;
|
||||
@@ -552,7 +635,7 @@ defineExpose({ open, close });
|
||||
justify-content: flex-end;
|
||||
}
|
||||
&__btn {
|
||||
min-width: 180rpx;
|
||||
min-width: 200rpx;
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
text-align: center;
|
||||
@@ -560,6 +643,19 @@ defineExpose({ open, close });
|
||||
font-size: 26rpx;
|
||||
font-weight: 500;
|
||||
padding: 0 24rpx;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6rpx;
|
||||
}
|
||||
&__btn-arrow {
|
||||
font-size: 22rpx;
|
||||
transition: transform .2s ease;
|
||||
display: inline-block;
|
||||
transform-origin: center;
|
||||
}
|
||||
&__btn-arrow.rotated {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
&__btn--ghost {
|
||||
border: 2rpx solid #e5e7eb;
|
||||
@@ -573,6 +669,80 @@ defineExpose({ open, close });
|
||||
&__btn--disabled {
|
||||
opacity: 0.6;
|
||||
}
|
||||
&__track {
|
||||
margin-top: 20rpx;
|
||||
margin-left: 160rpx;
|
||||
padding: 20rpx 20rpx 10rpx 20rpx;
|
||||
background: #f8fafc;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
&__track-loading,
|
||||
&__track-empty {
|
||||
padding: 28rpx 0;
|
||||
text-align: center;
|
||||
font-size: 24rpx;
|
||||
color: #9ca3af;
|
||||
}
|
||||
&__track-list {
|
||||
position: relative;
|
||||
padding: 8rpx 0 0 10rpx;
|
||||
}
|
||||
&__track-node {
|
||||
position: relative;
|
||||
padding-left: 24rpx;
|
||||
padding-bottom: 20rpx;
|
||||
&:last-child {
|
||||
padding-bottom: 10rpx;
|
||||
}
|
||||
&:last-child::before {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
&__track-node::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 4rpx;
|
||||
top: 20rpx;
|
||||
bottom: 0;
|
||||
width: 2rpx;
|
||||
background: #e5e7eb;
|
||||
}
|
||||
&__track-dot {
|
||||
position: absolute;
|
||||
left: -4rpx;
|
||||
top: 8rpx;
|
||||
width: 14rpx;
|
||||
height: 14rpx;
|
||||
border-radius: 50%;
|
||||
background: #d1d5db;
|
||||
border: 2rpx solid #ffffff;
|
||||
box-sizing: border-box;
|
||||
box-shadow: 0 0 0 2rpx #e5e7eb;
|
||||
}
|
||||
&__track-node.is-first &__track-dot {
|
||||
background: linear-gradient(135deg, #fa8735 0%, #fe3b48 100%);
|
||||
box-shadow: 0 0 0 2rpx rgba(250,135,53,0.25);
|
||||
width: 16rpx;
|
||||
height: 16rpx;
|
||||
left: -5rpx;
|
||||
}
|
||||
&__track-content {
|
||||
font-size: 24rpx;
|
||||
line-height: 34rpx;
|
||||
color: #374151;
|
||||
word-break: break-all;
|
||||
}
|
||||
&__track-node.is-first &__track-content {
|
||||
color: #111827;
|
||||
font-weight: 600;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
&__track-time {
|
||||
margin-top: 6rpx;
|
||||
font-size: 22rpx;
|
||||
line-height: 30rpx;
|
||||
color: #9ca3af;
|
||||
}
|
||||
}
|
||||
|
||||
::v-deep .uni-popup {
|
||||
|
||||
Reference in New Issue
Block a user