feat: 单个物流查看
This commit is contained in:
@@ -0,0 +1,601 @@
|
|||||||
|
<template>
|
||||||
|
<uni-popup ref="popupRef" :type="popupType" background-color="transparent">
|
||||||
|
<view class="express-popup" :class="`express-popup--${popupType}`" @tap.stop>
|
||||||
|
<view class="express-popup__header">
|
||||||
|
<view>
|
||||||
|
<view class="express-popup__title">查看物流</view>
|
||||||
|
<view class="express-popup__order-no">订单号:{{ orderNo || '-' }}</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"
|
||||||
|
>
|
||||||
|
<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 express-popup__btn--primary"
|
||||||
|
@tap.stop="handleViewExpress(item)"
|
||||||
|
>
|
||||||
|
查看物流
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</scroll-view>
|
||||||
|
</view>
|
||||||
|
</uni-popup>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { computed, ref, watch } from 'vue';
|
||||||
|
import sheep from '@/sheep';
|
||||||
|
import { getAiOrderDelayRecords } from '@/sheep/api/ai';
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
popupType: {
|
||||||
|
type: String,
|
||||||
|
default: 'bottom',
|
||||||
|
},
|
||||||
|
orderNo: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
orderData: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({}),
|
||||||
|
},
|
||||||
|
delayRecords: {
|
||||||
|
type: Array,
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
|
orderId: {
|
||||||
|
type: [Number, String],
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits(['close', 'view-express']);
|
||||||
|
const popupRef = ref();
|
||||||
|
const innerItems = ref([]);
|
||||||
|
const loadedRecords = ref([]);
|
||||||
|
|
||||||
|
const getFirstValidValue = (...values) =>
|
||||||
|
values.find((value) => value !== undefined && value !== null && String(value).trim() !== '') ?? '';
|
||||||
|
|
||||||
|
const hasValue = (value) => value !== undefined && value !== null && String(value).trim() !== '';
|
||||||
|
|
||||||
|
const formatSkuPropertyItem = (property) => {
|
||||||
|
const value = getFirstValidValue(
|
||||||
|
property?.valueName,
|
||||||
|
property?.value,
|
||||||
|
property?.specValue,
|
||||||
|
property?.attrValue,
|
||||||
|
property?.optionValue,
|
||||||
|
property?.propertyValue,
|
||||||
|
typeof property === 'string' ? property : '',
|
||||||
|
);
|
||||||
|
const name = getFirstValidValue(
|
||||||
|
property?.name,
|
||||||
|
property?.propertyName,
|
||||||
|
property?.specName,
|
||||||
|
property?.attrName,
|
||||||
|
property?.optionName,
|
||||||
|
property?.propertyKey,
|
||||||
|
'',
|
||||||
|
);
|
||||||
|
if (hasValue(name) && hasValue(value)) return `${name}:${value}`;
|
||||||
|
if (hasValue(value)) return String(value);
|
||||||
|
if (hasValue(name)) return String(name);
|
||||||
|
return '';
|
||||||
|
};
|
||||||
|
|
||||||
|
const formatSkuProperties = (properties) => {
|
||||||
|
if (!properties) return '';
|
||||||
|
if (typeof properties === 'string' && properties.trim()) return properties.trim();
|
||||||
|
if (Array.isArray(properties)) {
|
||||||
|
return properties.map(formatSkuPropertyItem).filter(Boolean).join(' ');
|
||||||
|
}
|
||||||
|
if (typeof properties === 'object') {
|
||||||
|
return Object.keys(properties)
|
||||||
|
.map((key) => {
|
||||||
|
const value = properties[key];
|
||||||
|
if (typeof value === 'object') return formatSkuPropertyItem(value);
|
||||||
|
return `${key}:${value}`;
|
||||||
|
})
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(' ');
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
};
|
||||||
|
|
||||||
|
const resolveSpuItems = (data) => {
|
||||||
|
const items = Array.isArray(data?.items) ? data.items : [];
|
||||||
|
return items.flatMap((spu) => {
|
||||||
|
const subItems = Array.isArray(spu?.items) ? spu.items : [];
|
||||||
|
if (subItems.length > 0) {
|
||||||
|
return subItems.map((sub) => ({
|
||||||
|
...sub,
|
||||||
|
_spuName: getFirstValidValue(
|
||||||
|
spu?.spuName,
|
||||||
|
spu?.productName,
|
||||||
|
spu?.goodsName,
|
||||||
|
sub?.spuName,
|
||||||
|
sub?.productName,
|
||||||
|
sub?.goodsName,
|
||||||
|
),
|
||||||
|
_spuPic: getFirstValidValue(
|
||||||
|
spu?.picUrl,
|
||||||
|
spu?.imageUrl,
|
||||||
|
spu?.thumbUrl,
|
||||||
|
spu?.goodsPic,
|
||||||
|
sub?.picUrl,
|
||||||
|
sub?.imageUrl,
|
||||||
|
sub?.thumbUrl,
|
||||||
|
sub?.goodsPic,
|
||||||
|
),
|
||||||
|
_spuId: getFirstValidValue(spu?.spuId, spu?.productId, sub?.spuId, sub?.productId),
|
||||||
|
_skuText: getFirstValidValue(
|
||||||
|
sub?.skuProperties,
|
||||||
|
sub?.specInfo,
|
||||||
|
sub?.skuInfo,
|
||||||
|
sub?.skuText,
|
||||||
|
formatSkuProperties(sub?.skuProperties || sub?.specs || sub?.properties),
|
||||||
|
),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
...spu,
|
||||||
|
_spuName: getFirstValidValue(spu?.spuName, spu?.productName, spu?.goodsName),
|
||||||
|
_spuPic: getFirstValidValue(
|
||||||
|
spu?.picUrl,
|
||||||
|
spu?.imageUrl,
|
||||||
|
spu?.thumbUrl,
|
||||||
|
spu?.goodsPic,
|
||||||
|
),
|
||||||
|
_spuId: getFirstValidValue(spu?.spuId, spu?.productId),
|
||||||
|
_skuText: getFirstValidValue(
|
||||||
|
spu?.skuProperties,
|
||||||
|
spu?.specInfo,
|
||||||
|
spu?.skuInfo,
|
||||||
|
spu?.skuText,
|
||||||
|
formatSkuProperties(spu?.skuProperties || spu?.specs || spu?.properties),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const resolveAllDelayRecords = () => {
|
||||||
|
if (Array.isArray(loadedRecords.value) && loadedRecords.value.length > 0) {
|
||||||
|
return loadedRecords.value.filter(Boolean);
|
||||||
|
}
|
||||||
|
const orderLevelRecords = Array.isArray(props.delayRecords)
|
||||||
|
? props.delayRecords
|
||||||
|
: Array.isArray(props.orderData?.delayRecords)
|
||||||
|
? props.orderData.delayRecords
|
||||||
|
: Array.isArray(props.orderData?.delayRecordList)
|
||||||
|
? props.orderData.delayRecordList
|
||||||
|
: [];
|
||||||
|
return orderLevelRecords.filter(Boolean);
|
||||||
|
};
|
||||||
|
|
||||||
|
const resolveCount = (record) =>
|
||||||
|
Number(
|
||||||
|
getFirstValidValue(
|
||||||
|
record?.count,
|
||||||
|
record?.num,
|
||||||
|
record?.quantity,
|
||||||
|
record?.number,
|
||||||
|
record?.totalCount,
|
||||||
|
1,
|
||||||
|
),
|
||||||
|
) || 1;
|
||||||
|
|
||||||
|
const resolveRecordOrderItemId = (record) =>
|
||||||
|
Number(
|
||||||
|
getFirstValidValue(
|
||||||
|
record?.orderItemId,
|
||||||
|
record?.orderItemVO?.id,
|
||||||
|
record?.orderItem?.id,
|
||||||
|
record?.itemId,
|
||||||
|
0,
|
||||||
|
),
|
||||||
|
) || 0;
|
||||||
|
|
||||||
|
const resolveRecordSkuText = (record) => {
|
||||||
|
const direct = getFirstValidValue(
|
||||||
|
record?.skuProperties,
|
||||||
|
record?.specInfo,
|
||||||
|
record?.skuText,
|
||||||
|
record?.skuInfo,
|
||||||
|
formatSkuProperties(record?.skuProperties || record?.specs || record?.properties),
|
||||||
|
);
|
||||||
|
if (direct) return direct;
|
||||||
|
const itemSpec = getFirstValidValue(
|
||||||
|
record?.orderItemVO?.skuProperties,
|
||||||
|
record?.orderItemVO?.specInfo,
|
||||||
|
record?.orderItem?.skuProperties,
|
||||||
|
record?.orderItem?.specInfo,
|
||||||
|
formatSkuProperties(record?.orderItemVO?.skuProperties || record?.orderItem?.specs),
|
||||||
|
);
|
||||||
|
return itemSpec;
|
||||||
|
};
|
||||||
|
|
||||||
|
const resolveRecordSpuName = (record) =>
|
||||||
|
getFirstValidValue(
|
||||||
|
record?.spuName,
|
||||||
|
record?.productName,
|
||||||
|
record?.goodsName,
|
||||||
|
record?.orderItemVO?.spuName,
|
||||||
|
record?.orderItem?.spuName,
|
||||||
|
record?.orderItemVO?.productName,
|
||||||
|
record?.orderItem?.productName,
|
||||||
|
);
|
||||||
|
|
||||||
|
const resolveRecordPicUrl = (record) =>
|
||||||
|
getFirstValidValue(
|
||||||
|
record?.picUrl,
|
||||||
|
record?.imageUrl,
|
||||||
|
record?.thumbUrl,
|
||||||
|
record?.goodsPic,
|
||||||
|
record?.orderItemVO?.picUrl,
|
||||||
|
record?.orderItem?.picUrl,
|
||||||
|
record?.orderItemVO?.imageUrl,
|
||||||
|
record?.orderItem?.imageUrl,
|
||||||
|
);
|
||||||
|
|
||||||
|
const resolveRecordLogisticsNo = (record) =>
|
||||||
|
getFirstValidValue(
|
||||||
|
record?.logisticsNo,
|
||||||
|
record?.waybillNo,
|
||||||
|
record?.trackingNo,
|
||||||
|
record?.expressNo,
|
||||||
|
record?.orderItemVO?.logisticsNo,
|
||||||
|
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) => {
|
||||||
|
const status = Number(record?.status);
|
||||||
|
return status === 3 && Number(record?.delayRecordId || record?.id) > 0;
|
||||||
|
});
|
||||||
|
if (expressRecords.length === 0) return [];
|
||||||
|
|
||||||
|
const spuItems = resolveSpuItems(props.orderData);
|
||||||
|
const findItemByOrderItemId = (id) =>
|
||||||
|
spuItems.find(
|
||||||
|
(sku) => Number(sku?.id || sku?.orderItemId || sku?.itemId || 0) === Number(id),
|
||||||
|
);
|
||||||
|
const findItemBySkuText = (text) =>
|
||||||
|
spuItems.find((sku) => {
|
||||||
|
const skuText = getFirstValidValue(
|
||||||
|
sku?.skuProperties,
|
||||||
|
sku?.specInfo,
|
||||||
|
sku?.skuInfo,
|
||||||
|
sku?.skuText,
|
||||||
|
formatSkuProperties(sku?.skuProperties || sku?.specs || sku?.properties),
|
||||||
|
);
|
||||||
|
return !!text && !!skuText && String(text).trim() === String(skuText).trim();
|
||||||
|
});
|
||||||
|
const singleSpu =
|
||||||
|
spuItems.length === 1
|
||||||
|
? spuItems[0]
|
||||||
|
: new Set(spuItems.map((s) => s?._spuId || s?._spuName)).size === 1
|
||||||
|
? spuItems[0]
|
||||||
|
: null;
|
||||||
|
|
||||||
|
return expressRecords.map((record, idx) => {
|
||||||
|
const orderItemId = resolveRecordOrderItemId(record);
|
||||||
|
const recordSku = resolveRecordSkuText(record);
|
||||||
|
let matched = orderItemId ? findItemByOrderItemId(orderItemId) : null;
|
||||||
|
if (!matched && recordSku) matched = findItemBySkuText(recordSku);
|
||||||
|
if (!matched && singleSpu) matched = singleSpu;
|
||||||
|
|
||||||
|
const count = resolveCount(record);
|
||||||
|
const spuName = matched
|
||||||
|
? getFirstValidValue(matched._spuName, matched?.spuName, matched?.productName)
|
||||||
|
: resolveRecordSpuName(record);
|
||||||
|
const picUrl = matched
|
||||||
|
? getFirstValidValue(matched._spuPic, matched?.picUrl, matched?.imageUrl)
|
||||||
|
: resolveRecordPicUrl(record);
|
||||||
|
const skuText = matched
|
||||||
|
? getFirstValidValue(
|
||||||
|
matched?._skuText,
|
||||||
|
matched?.skuProperties,
|
||||||
|
matched?.specInfo,
|
||||||
|
matched?.skuInfo,
|
||||||
|
matched?.skuText,
|
||||||
|
formatSkuProperties(matched?.skuProperties || matched?.specs || matched?.properties),
|
||||||
|
)
|
||||||
|
: recordSku;
|
||||||
|
const delayRecordId = Number(record?.delayRecordId || record?.id) || 0;
|
||||||
|
const logisticsNo = resolveRecordLogisticsNo(record);
|
||||||
|
|
||||||
|
return {
|
||||||
|
itemKey: `${delayRecordId}-${idx}`,
|
||||||
|
delayRecordId,
|
||||||
|
spuName: spuName || '商品信息',
|
||||||
|
skuText: skuText || '单规格',
|
||||||
|
picUrl: picUrl || '',
|
||||||
|
count,
|
||||||
|
logisticsNo,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const renderItems = computed(() => innerItems.value || []);
|
||||||
|
|
||||||
|
const open = async () => {
|
||||||
|
loadedRecords.value = [];
|
||||||
|
const oid = props.orderId || props.orderData?.id || props.orderData?.orderId;
|
||||||
|
if (oid) {
|
||||||
|
try {
|
||||||
|
const { code, data } = await getAiOrderDelayRecords({ orderId: oid });
|
||||||
|
if (code === 0 && Array.isArray(data)) {
|
||||||
|
loadedRecords.value = data;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
loadedRecords.value = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
innerItems.value = buildExpressItemList();
|
||||||
|
popupRef.value?.open?.();
|
||||||
|
};
|
||||||
|
|
||||||
|
const close = () => {
|
||||||
|
popupRef.value?.close?.();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleClose = () => {
|
||||||
|
emit('close');
|
||||||
|
close();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleViewExpress = (item) => {
|
||||||
|
const delayRecordId = Number(item?.delayRecordId) || 0;
|
||||||
|
if (!delayRecordId) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '物流信息异常',
|
||||||
|
icon: 'none',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const id = props.orderId || props.orderData?.id || props.orderData?.orderId;
|
||||||
|
if (!id) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '订单信息异常',
|
||||||
|
icon: 'none',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
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 });
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.express-popup {
|
||||||
|
background: #ffffff;
|
||||||
|
box-sizing: border-box;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
&--bottom {
|
||||||
|
width: 100%;
|
||||||
|
max-height: 82vh;
|
||||||
|
border-radius: 24rpx 24rpx 0 0;
|
||||||
|
padding: 32rpx 32rpx calc(24rpx + env(safe-area-inset-bottom)) 32rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--center {
|
||||||
|
width: 680rpx;
|
||||||
|
max-height: 78vh;
|
||||||
|
border-radius: 24rpx;
|
||||||
|
padding: 32rpx 32rpx 0 32rpx;
|
||||||
|
margin: 0 auto;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
&--center &__content {
|
||||||
|
max-height: 52vh;
|
||||||
|
}
|
||||||
|
&--center &__btn {
|
||||||
|
min-width: 160rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: flex-start;
|
||||||
|
padding-bottom: 24rpx;
|
||||||
|
border-bottom: 1rpx solid #f2f2f2;
|
||||||
|
}
|
||||||
|
&__title {
|
||||||
|
font-size: 32rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #111827;
|
||||||
|
line-height: 44rpx;
|
||||||
|
}
|
||||||
|
&__order-no {
|
||||||
|
margin-top: 8rpx;
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #6b7280;
|
||||||
|
line-height: 32rpx;
|
||||||
|
}
|
||||||
|
&__tip {
|
||||||
|
margin-top: 8rpx;
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #f97316;
|
||||||
|
line-height: 32rpx;
|
||||||
|
}
|
||||||
|
&__close {
|
||||||
|
width: 48rpx;
|
||||||
|
height: 48rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 40rpx;
|
||||||
|
color: #9ca3af;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
&__content {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
max-height: calc(82vh - 280rpx - env(safe-area-inset-bottom));
|
||||||
|
margin-top: 20rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
&__empty {
|
||||||
|
padding: 80rpx 0;
|
||||||
|
text-align: center;
|
||||||
|
color: #9ca3af;
|
||||||
|
font-size: 26rpx;
|
||||||
|
}
|
||||||
|
&__item {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
padding: 20rpx 0;
|
||||||
|
border-bottom: 1rpx solid #f2f2f2;
|
||||||
|
}
|
||||||
|
&__item-image {
|
||||||
|
flex-shrink: 0;
|
||||||
|
width: 140rpx;
|
||||||
|
height: 140rpx;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
background: #f6f7fb;
|
||||||
|
margin-right: 20rpx;
|
||||||
|
}
|
||||||
|
&__item-main {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
padding-top: 4rpx;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10rpx;
|
||||||
|
}
|
||||||
|
&__item-name {
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #111827;
|
||||||
|
line-height: 40rpx;
|
||||||
|
}
|
||||||
|
&__item-sku {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #6b7280;
|
||||||
|
line-height: 32rpx;
|
||||||
|
background: #f6f7fb;
|
||||||
|
padding: 4rpx 12rpx;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
align-self: flex-start;
|
||||||
|
max-width: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
&__item-info {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4rpx;
|
||||||
|
}
|
||||||
|
&__item-count {
|
||||||
|
font-size: 26rpx;
|
||||||
|
color: #111827;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
&__item-logistics {
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: #6b7280;
|
||||||
|
}
|
||||||
|
&__item-action {
|
||||||
|
margin-top: 10rpx;
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
&__btn {
|
||||||
|
min-width: 180rpx;
|
||||||
|
height: 60rpx;
|
||||||
|
line-height: 60rpx;
|
||||||
|
text-align: center;
|
||||||
|
border-radius: 30rpx;
|
||||||
|
font-size: 26rpx;
|
||||||
|
font-weight: 500;
|
||||||
|
padding: 0 24rpx;
|
||||||
|
}
|
||||||
|
&__btn--ghost {
|
||||||
|
border: 2rpx solid #e5e7eb;
|
||||||
|
color: #4b5563;
|
||||||
|
background: #ffffff;
|
||||||
|
}
|
||||||
|
&__btn--primary {
|
||||||
|
background: linear-gradient(135deg, #fa8735 0%, #fe3b48 100%);
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
&__btn--disabled {
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
::v-deep .uni-popup {
|
||||||
|
background: transparent !important;
|
||||||
|
}
|
||||||
|
::v-deep .uni-popup__wrapper {
|
||||||
|
background: transparent !important;
|
||||||
|
}
|
||||||
|
::v-deep .uni-popup__wrapper-box {
|
||||||
|
background: transparent !important;
|
||||||
|
}
|
||||||
|
::v-deep .uni-popup__content {
|
||||||
|
background: transparent !important;
|
||||||
|
}
|
||||||
|
.express-popup--bottom ::v-deep .uni-popup__content,
|
||||||
|
.express-popup--bottom ::v-deep .uni-popup__wrapper-box {
|
||||||
|
border-radius: 24rpx 24rpx 0 0 !important;
|
||||||
|
overflow: hidden !important;
|
||||||
|
}
|
||||||
|
.express-popup--center ::v-deep .uni-popup__content,
|
||||||
|
.express-popup--center ::v-deep .uni-popup__wrapper-box {
|
||||||
|
border-radius: 24rpx !important;
|
||||||
|
overflow: hidden !important;
|
||||||
|
background: transparent !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
<view>{{ props.data.logisticsName }} {{ props.data.logisticsNo }}</view>
|
<view>{{ props.data.logisticsName }} {{ props.data.logisticsNo }}</view>
|
||||||
<view class="flex-center">
|
<view class="flex-center">
|
||||||
<view @click.stop="onCopy(props.data.logisticsNo)">复制</view>
|
<view @click.stop="onCopy(props.data.logisticsNo)">复制</view>
|
||||||
<truckLine :data="props.data" :code="2" v-if="props.data.deliveryTime && props.data.logisticsNo"></truckLine>
|
<truckLine :data="props.data" :code="2" v-if="props.data.deliveryTime && props.data.logisticsNo" @openExpress="handleTruckLineOpenExpress"></truckLine>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -156,7 +156,7 @@
|
|||||||
import { fen2yuan, formatOrderStatus } from '@/sheep/hooks/useGoods';
|
import { fen2yuan, formatOrderStatus } from '@/sheep/hooks/useGoods';
|
||||||
import AfterSaleApi from '@/sheep/api/trade/afterSale';
|
import AfterSaleApi from '@/sheep/api/trade/afterSale';
|
||||||
import sheep from '@/sheep';
|
import sheep from '@/sheep';
|
||||||
let emit = defineEmits(['getOrderDetail']);
|
let emit = defineEmits(['getOrderDetail', 'openExpress']);
|
||||||
const formatSkuProperties = (properties: any) => {
|
const formatSkuProperties = (properties: any) => {
|
||||||
const list = Array.isArray(properties) ? properties : [];
|
const list = Array.isArray(properties) ? properties : [];
|
||||||
return list
|
return list
|
||||||
@@ -553,6 +553,9 @@
|
|||||||
const onCopy = (text: any) => {
|
const onCopy = (text: any) => {
|
||||||
sheep.$helper.copyText(text);
|
sheep.$helper.copyText(text);
|
||||||
};
|
};
|
||||||
|
const handleTruckLineOpenExpress = (payload: any) => {
|
||||||
|
emit('openExpress', payload);
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
@@ -126,6 +126,15 @@
|
|||||||
@close="closeReceiveItemPopup"
|
@close="closeReceiveItemPopup"
|
||||||
@submit="handleReceiveItemSubmit"
|
@submit="handleReceiveItemSubmit"
|
||||||
/>
|
/>
|
||||||
|
<ExpressListPopup
|
||||||
|
ref="expressListPopupRef"
|
||||||
|
popup-type="bottom"
|
||||||
|
:order-no="props.data.no || ''"
|
||||||
|
:order-data="props.data"
|
||||||
|
:delay-records="state.delayRecords"
|
||||||
|
:order-id="resolveAiOrderId(props.data)"
|
||||||
|
@close="closeExpressListPopup"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import {
|
import {
|
||||||
@@ -149,6 +158,7 @@
|
|||||||
import AiOrderActionBar from '@/components/orderItem/AiOrderActionBar.vue';
|
import AiOrderActionBar from '@/components/orderItem/AiOrderActionBar.vue';
|
||||||
import ShipmentPopup from '@/components/orderItem/ShipmentPopup.vue';
|
import ShipmentPopup from '@/components/orderItem/ShipmentPopup.vue';
|
||||||
import ReceiveItemPopup from '@/components/orderItem/ReceiveItemPopup.vue';
|
import ReceiveItemPopup from '@/components/orderItem/ReceiveItemPopup.vue';
|
||||||
|
import ExpressListPopup from '@/components/orderItem/ExpressListPopup.vue';
|
||||||
import AfterSaleApi from '@/sheep/api/trade/afterSale';
|
import AfterSaleApi from '@/sheep/api/trade/afterSale';
|
||||||
import sheep from '@/sheep';
|
import sheep from '@/sheep';
|
||||||
import {
|
import {
|
||||||
@@ -300,9 +310,11 @@
|
|||||||
const nowShipmentPopupRef = ref();
|
const nowShipmentPopupRef = ref();
|
||||||
const delayShipmentPopupRef = ref();
|
const delayShipmentPopupRef = ref();
|
||||||
const receiveItemPopupRef = ref();
|
const receiveItemPopupRef = ref();
|
||||||
|
const expressListPopupRef = ref();
|
||||||
const closeNowShipmentPopup = () => {};
|
const closeNowShipmentPopup = () => {};
|
||||||
const closeDelayShipmentPopup = () => {};
|
const closeDelayShipmentPopup = () => {};
|
||||||
const closeReceiveItemPopup = () => {};
|
const closeReceiveItemPopup = () => {};
|
||||||
|
const closeExpressListPopup = () => {};
|
||||||
const openDelayShipmentPopup = async (data) => {
|
const openDelayShipmentPopup = async (data) => {
|
||||||
const id = resolveAiOrderId(data);
|
const id = resolveAiOrderId(data);
|
||||||
if (!id) {
|
if (!id) {
|
||||||
@@ -431,6 +443,10 @@
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (isAiStoreOrder.value && !isPickUpOrder.value) {
|
||||||
|
expressListPopupRef.value?.open?.();
|
||||||
|
return;
|
||||||
|
}
|
||||||
proxy.utils.go('/pages/order/express/log', { id });
|
proxy.utils.go('/pages/order/express/log', { id });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -27,10 +27,14 @@
|
|||||||
default: 1, //1:商城订单 2:AI店铺订单 3:AI店铺赠送订单
|
default: 1, //1:商城订单 2:AI店铺订单 3:AI店铺赠送订单
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const emit = defineEmits(['openExpress']);
|
||||||
let show = ref(false);
|
let show = ref(false);
|
||||||
let list = ref([]);
|
let list = ref([]);
|
||||||
const logistics = () => {
|
const logistics = () => {
|
||||||
// 获取物流信息并显示弹窗
|
if (props.code === 2) {
|
||||||
|
emit('openExpress', { data: props.data, code: props.code });
|
||||||
|
return;
|
||||||
|
}
|
||||||
getData();
|
getData();
|
||||||
show.value = true;
|
show.value = true;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
:delay-records="state.delayRecords"
|
:delay-records="state.delayRecords"
|
||||||
type="4"
|
type="4"
|
||||||
@getOrderDetail="getOrderDetail"
|
@getOrderDetail="getOrderDetail"
|
||||||
|
@openExpress="handleOpenExpress"
|
||||||
></card_order>
|
></card_order>
|
||||||
|
|
||||||
<PickUpVerify
|
<PickUpVerify
|
||||||
@@ -126,6 +127,15 @@
|
|||||||
>
|
>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<ExpressListPopup
|
||||||
|
ref="expressListPopupRef"
|
||||||
|
popup-type="center"
|
||||||
|
:order-no="state.orderInfo.no || ''"
|
||||||
|
:order-data="state.orderInfo"
|
||||||
|
:delay-records="state.delayRecords"
|
||||||
|
:order-id="orderId || state.orderInfo.id || 0"
|
||||||
|
@close="closeExpressListPopup"
|
||||||
|
/>
|
||||||
</s-pages>
|
</s-pages>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -144,6 +154,7 @@
|
|||||||
import StoreApi from '@/sheep/api/trade/store';
|
import StoreApi from '@/sheep/api/trade/store';
|
||||||
import PickUpVerify from '@/pages/order/pickUpVerify.vue';
|
import PickUpVerify from '@/pages/order/pickUpVerify.vue';
|
||||||
import card_order from '@/components/orderItem/card_order.vue';
|
import card_order from '@/components/orderItem/card_order.vue';
|
||||||
|
import ExpressListPopup from '@/components/orderItem/ExpressListPopup.vue';
|
||||||
|
|
||||||
const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
|
const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
|
||||||
const headerBg = sheep.$url.css('/static/img/shop/order/order_bg.png');
|
const headerBg = sheep.$url.css('/static/img/shop/order/order_bg.png');
|
||||||
@@ -320,6 +331,20 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const expressListPopupRef = ref();
|
||||||
|
const closeExpressListPopup = () => {};
|
||||||
|
const handleOpenExpress = () => {
|
||||||
|
const id = orderId.value || state.orderInfo?.id || 0;
|
||||||
|
if (!id) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '订单信息异常',
|
||||||
|
icon: 'none',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
expressListPopupRef.value?.open?.();
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
+35
-1
@@ -31,6 +31,7 @@
|
|||||||
type="2"
|
type="2"
|
||||||
theme="2"
|
theme="2"
|
||||||
@getOrderDetail="getOrderDetail"
|
@getOrderDetail="getOrderDetail"
|
||||||
|
@openExpress="handleTruckLineExpress"
|
||||||
></card_order>
|
></card_order>
|
||||||
|
|
||||||
<PickUpVerify
|
<PickUpVerify
|
||||||
@@ -76,8 +77,9 @@
|
|||||||
</view>
|
</view>
|
||||||
<truckLine
|
<truckLine
|
||||||
:data="state.orderInfo"
|
:data="state.orderInfo"
|
||||||
:code="1"
|
:code="Number(isAiStoreOrder ? 2 : 1)"
|
||||||
v-if="state.orderInfo.deliveryTime"
|
v-if="state.orderInfo.deliveryTime"
|
||||||
|
@openExpress="handleTruckLineExpress"
|
||||||
></truckLine>
|
></truckLine>
|
||||||
</view>
|
</view>
|
||||||
<view class="notice-item flex-row ju-between">
|
<view class="notice-item flex-row ju-between">
|
||||||
@@ -156,6 +158,15 @@
|
|||||||
@close="closeReceiveItemPopup"
|
@close="closeReceiveItemPopup"
|
||||||
@submit="handleReceiveItemSubmit"
|
@submit="handleReceiveItemSubmit"
|
||||||
/>
|
/>
|
||||||
|
<ExpressListPopup
|
||||||
|
ref="expressListPopupRef"
|
||||||
|
popup-type="center"
|
||||||
|
:order-no="state.orderInfo.no || ''"
|
||||||
|
:order-data="state.orderInfo"
|
||||||
|
:delay-records="state.delayRecords"
|
||||||
|
:order-id="resolveAiOrderId(state.orderInfo)"
|
||||||
|
@close="closeExpressListPopup"
|
||||||
|
/>
|
||||||
</s-pages>
|
</s-pages>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -182,6 +193,7 @@
|
|||||||
import AiOrderActionBar from '@/components/orderItem/AiOrderActionBar.vue';
|
import AiOrderActionBar from '@/components/orderItem/AiOrderActionBar.vue';
|
||||||
import ShipmentPopup from '@/components/orderItem/ShipmentPopup.vue';
|
import ShipmentPopup from '@/components/orderItem/ShipmentPopup.vue';
|
||||||
import ReceiveItemPopup from '@/components/orderItem/ReceiveItemPopup.vue';
|
import ReceiveItemPopup from '@/components/orderItem/ReceiveItemPopup.vue';
|
||||||
|
import ExpressListPopup from '@/components/orderItem/ExpressListPopup.vue';
|
||||||
import truckLine from '@/components/truckLine/truckLine.vue';
|
import truckLine from '@/components/truckLine/truckLine.vue';
|
||||||
import PickUpVerify from '@/pages/order/pickUpVerify.vue';
|
import PickUpVerify from '@/pages/order/pickUpVerify.vue';
|
||||||
|
|
||||||
@@ -298,9 +310,11 @@
|
|||||||
const delayShipmentPopupRef = ref();
|
const delayShipmentPopupRef = ref();
|
||||||
const nowShipmentPopupRef = ref();
|
const nowShipmentPopupRef = ref();
|
||||||
const receiveItemPopupRef = ref();
|
const receiveItemPopupRef = ref();
|
||||||
|
const expressListPopupRef = ref();
|
||||||
const closeDelayShipmentPopup = () => {};
|
const closeDelayShipmentPopup = () => {};
|
||||||
const closeNowShipmentPopup = () => {};
|
const closeNowShipmentPopup = () => {};
|
||||||
const closeReceiveItemPopup = () => {};
|
const closeReceiveItemPopup = () => {};
|
||||||
|
const closeExpressListPopup = () => {};
|
||||||
|
|
||||||
const reloadDelayRecords = async () => {
|
const reloadDelayRecords = async () => {
|
||||||
if (!isAiStoreOrder.value) {
|
if (!isAiStoreOrder.value) {
|
||||||
@@ -510,6 +524,26 @@
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (isAiStoreOrder.value && !isPickUpOrder.value) {
|
||||||
|
expressListPopupRef.value?.open?.();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sheep.$router.go('/pages/order/express/log', { id });
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleTruckLineExpress = () => {
|
||||||
|
const id = resolveAiOrderId(state.orderInfo);
|
||||||
|
if (!id) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '订单信息异常',
|
||||||
|
icon: 'none',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!isPickUpOrder.value) {
|
||||||
|
expressListPopupRef.value?.open?.();
|
||||||
|
return;
|
||||||
|
}
|
||||||
sheep.$router.go('/pages/order/express/log', { id });
|
sheep.$router.go('/pages/order/express/log', { id });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -58,38 +58,90 @@
|
|||||||
import { onLoad } from '@dcloudio/uni-app';
|
import { onLoad } from '@dcloudio/uni-app';
|
||||||
import { computed, reactive } from 'vue';
|
import { computed, reactive } from 'vue';
|
||||||
import OrderApi from '@/sheep/api/trade/order';
|
import OrderApi from '@/sheep/api/trade/order';
|
||||||
|
import { getOrderDetail as getAiOrderDetail } from '@/sheep/api/ai';
|
||||||
|
import { getExpressTrackList } from '@/sheep/api/index/index';
|
||||||
import HighlightNumber from '@/pages/components/HighlightNumberText.vue';
|
import HighlightNumber from '@/pages/components/HighlightNumberText.vue';
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
info: [],
|
info: {},
|
||||||
tracks: [],
|
tracks: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
const goodsImages = computed(() => {
|
const goodsImages = computed(() => {
|
||||||
let array = [];
|
let array = [];
|
||||||
if (state.info.items) {
|
if (state.info && state.info.items) {
|
||||||
state.info.items.forEach((item) => {
|
state.info.items.forEach((item) => {
|
||||||
array.push({
|
array.push({
|
||||||
image: item.picUrl,
|
image: item.picUrl,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (state.info && state.info.delayRecords && Array.isArray(state.info.delayRecords)) {
|
||||||
|
state.info.delayRecords.forEach((record) => {
|
||||||
|
if (record.picUrl || record.orderItemVO?.picUrl) {
|
||||||
|
array.push({
|
||||||
|
image: record.picUrl || record.orderItemVO?.picUrl,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
return array;
|
return array;
|
||||||
});
|
});
|
||||||
|
|
||||||
async function getExpressDetail(id) {
|
async function getExpressDetail(options) {
|
||||||
const { data } = await OrderApi.getOrderExpressTrackList(id);
|
const id = options?.id;
|
||||||
state.tracks = data;
|
const codeRaw = options?.code;
|
||||||
|
const code =
|
||||||
|
codeRaw !== undefined && codeRaw !== null && String(codeRaw).trim() !== ''
|
||||||
|
? Number(codeRaw)
|
||||||
|
: 0;
|
||||||
|
const delayRecordId = options?.delayRecordId;
|
||||||
|
const hasDelayRecordId =
|
||||||
|
delayRecordId !== undefined &&
|
||||||
|
delayRecordId !== null &&
|
||||||
|
String(delayRecordId).trim() !== '';
|
||||||
|
if (id) {
|
||||||
|
state.info.id = id;
|
||||||
|
}
|
||||||
|
if (code === 2 && hasDelayRecordId) {
|
||||||
|
const { data } = await getExpressTrackList({
|
||||||
|
id,
|
||||||
|
code: 2,
|
||||||
|
delayRecordId,
|
||||||
|
});
|
||||||
|
state.tracks = data;
|
||||||
|
} else if (code > 0) {
|
||||||
|
const { data } = await getExpressTrackList({
|
||||||
|
id,
|
||||||
|
code,
|
||||||
|
});
|
||||||
|
state.tracks = data;
|
||||||
|
} else {
|
||||||
|
const { data } = await OrderApi.getOrderExpressTrackList(id);
|
||||||
|
state.tracks = data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getOrderDetail(id) {
|
async function getOrderDetail(id) {
|
||||||
const { data } = await OrderApi.getOrderDetail(id);
|
if (!id) return;
|
||||||
state.info = data;
|
try {
|
||||||
|
const { data } = await OrderApi.getOrderDetail(id);
|
||||||
|
if (data) {
|
||||||
|
state.info = data;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
try {
|
||||||
|
const { data } = await getAiOrderDetail({ id });
|
||||||
|
if (data) {
|
||||||
|
state.info = data;
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoad((options) => {
|
onLoad((options) => {
|
||||||
getExpressDetail(options.id);
|
getExpressDetail(options || {});
|
||||||
getOrderDetail(options.id);
|
getOrderDetail(options?.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
function handlePhoneClick(data) {
|
function handlePhoneClick(data) {
|
||||||
|
|||||||
@@ -390,3 +390,12 @@ export function getAiOrderDelayRecords(params : any) {
|
|||||||
params,
|
params,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取AI订单物流轨迹(按延迟记录)
|
||||||
|
export function getAiExpressTrackList(params: { id: number | string; code: number; delayRecordId: number | string }) {
|
||||||
|
return request({
|
||||||
|
url: '/aishop/order/all/get-express-track-list',
|
||||||
|
method: 'get',
|
||||||
|
params,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user