Merge branch 'v2.2' into v1.8.1

* v2.2:
  feat:  延迟发货调试
  feat: 多规格延迟发货
  feat: 店铺订单多规格展示
  feat: 延迟发货api
This commit is contained in:
2026-08-06 13:50:31 +08:00
6 changed files with 2092 additions and 447 deletions
+518
View File
@@ -0,0 +1,518 @@
<template>
<uni-popup ref="popupRef" :type="popupType" background-color="#fff">
<view class="shipment-popup" :class="`shipment-popup--${popupType}`" @tap.stop>
<view class="shipment-popup__header">
<view>
<view class="shipment-popup__title">{{ titleText }}</view>
<view class="shipment-popup__order-no">订单号:{{ orderNo || '-' }}</view>
<view class="shipment-popup__order-time">下单时间:{{ orderTime || '-' }}</view>
</view>
<view class="shipment-popup__close" @tap.stop="handleClose">×</view>
</view>
<view class="shipment-popup__desc">{{ descText }}</view>
<scroll-view scroll-y class="shipment-popup__content">
<view v-if="renderItems.length === 0" class="shipment-popup__empty">
{{ emptyText }}
</view>
<view
v-else
class="shipment-popup__item"
v-for="(item, index) in renderItems"
:key="item.itemKey || index"
>
<image class="shipment-popup__item-image" :src="item.picUrl" mode="aspectFill" />
<view class="shipment-popup__item-main">
<view class="shipment-popup__item-name lineTwo">{{ item.spuName }}</view>
<view class="shipment-popup__item-sku">{{ item.skuText || '-' }}</view>
<view class="shipment-popup__item-footer flex-center ju-between">
<view class="shipment-popup__item-count">最多可选 x{{ item.maxCount }}</view>
<su-number-box
v-model="item.selectedCount"
:min="0"
:max="item.maxCount"
:step="1"
background="#F6F7FB"
color="#333333"
@change="onCountChange(index, $event)"
/>
</view>
</view>
</view>
</scroll-view>
<view class="shipment-popup__actions">
<view class="shipment-popup__btn shipment-popup__btn--ghost" @tap.stop="handleClose">
取消
</view>
<view class="shipment-popup__btn shipment-popup__btn--primary" @tap.stop="handleSubmit">
{{ submitText }}
</view>
</view>
</view>
</uni-popup>
</template>
<script setup>
import { computed, ref } from 'vue';
const props = defineProps({
mode: {
type: String,
default: 'delay',
},
popupType: {
type: String,
default: 'bottom',
},
orderNo: {
type: String,
default: '',
},
orderTime: {
type: String,
default: '',
},
orderData: {
type: Object,
default: () => ({}),
},
delayRecords: {
type: Array,
default: () => [],
},
});
const emit = defineEmits(['close', 'submit']);
const popupRef = ref();
const innerItems = ref([]);
const titleText = computed(() => (props.mode === 'now' ? '立即发货' : '延迟发货'));
const submitText = computed(() => (props.mode === 'now' ? '确认立即发货' : '确认延迟发货'));
const descText = computed(() =>
props.mode === 'now' ? '请选择当前延迟商品及立即发货数量' : '请选择当前商品及延迟发货数量',
);
const emptyText = computed(() =>
props.mode === 'now' ? '暂无可立即发货的商品' : '暂无可延迟发货的商品',
);
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?.key,
property?.label,
);
if (name && value) {
return `${name} ${value}`;
}
return value || name || '';
};
const formatSkuProperties = (properties) => {
if (typeof properties === 'string' && properties.trim()) {
return properties.trim();
}
const list = Array.isArray(properties) ? properties : [];
if (!list.length) {
return '';
}
return list
.map((property) => formatSkuPropertyItem(property))
.filter(Boolean)
.join(' ');
};
const resolveOrderItemId = (item = {}) =>
getFirstValidValue(item?.id, item?.orderItemId, item?.itemId, item?.orderGoodsId, item?.goodsId, item?.skuId);
const resolveDelayItemCount = (item = {}) => {
const candidates = [
item?.count,
item?.remainingCount,
item?.availableCount,
item?.canCount,
item?.maxCount,
];
const matched = candidates
.map((value) => Number(value))
.find((value) => Number.isFinite(value) && value > 0);
return matched || 0;
};
const resolveDelayRecordId = (item = {}) =>
getFirstValidValue(item?.delayRecordId, item?.recordId, item?.id);
const resolveDelayRecordCount = (item = {}) => {
const candidates = [
item?.count,
item?.delayCount,
item?.recordCount,
item?.remainingCount,
item?.availableCount,
item?.canCount,
item?.maxCount,
];
const matched = candidates
.map((value) => Number(value))
.find((value) => Number.isFinite(value) && value > 0);
return matched || 0;
};
const createDelayShipmentItem = (item, parentItem = {}) => {
const maxCount = resolveDelayItemCount(item);
const orderItemId = resolveOrderItemId(item);
const parentOrderItemId = resolveOrderItemId(parentItem);
const submitOrderItemId = getFirstValidValue(orderItemId, parentOrderItemId);
const skuText = getFirstValidValue(
formatSkuProperties(item?.properties || parentItem?.properties),
formatSkuProperties(item?.skuProperties || parentItem?.skuProperties),
formatSkuProperties(item?.attrs || parentItem?.attrs),
formatSkuProperties(item?.specs || parentItem?.specs),
formatSkuProperties(item?.specifications || parentItem?.specifications),
getFirstValidValue(item?.skuText, parentItem?.skuText),
getFirstValidValue(item?.specText, parentItem?.specText),
getFirstValidValue(item?.propertiesText, parentItem?.propertiesText),
getFirstValidValue(item?.skuDesc, parentItem?.skuDesc),
getFirstValidValue(item?.specDesc, parentItem?.specDesc),
);
return {
itemKey: getFirstValidValue(
submitOrderItemId,
`${item?.spuName || item?.name || parentItem?.spuName || parentItem?.name || ''}_${skuText}_${maxCount}`,
),
orderItemId,
parentOrderItemId,
submitOrderItemId,
picUrl: item?.picUrl || parentItem?.picUrl || '',
spuName: item?.spuName || item?.name || parentItem?.spuName || parentItem?.name || '',
skuText,
maxCount,
selectedCount: maxCount,
};
};
const createDelayShipmentItems = (data) => {
const sourceItems = Array.isArray(data?.items) ? data.items : [];
return sourceItems
.flatMap((item) => {
const children = Array.isArray(item?.items) ? item.items : [];
if (children.length) {
return children.filter(Boolean).map((child) => createDelayShipmentItem(child, item));
}
return [createDelayShipmentItem(item, item)];
})
.filter((item) => item.maxCount > 0);
};
const createNowShipmentItem = (item) => {
const maxCount = resolveDelayRecordCount(item);
const delayRecordId = resolveDelayRecordId(item);
const skuText = getFirstValidValue(
formatSkuProperties(item?.properties),
formatSkuProperties(item?.skuProperties),
formatSkuProperties(item?.attrs),
formatSkuProperties(item?.specs),
formatSkuProperties(item?.specifications),
getFirstValidValue(item?.skuText, item?.specText, item?.propertiesText),
getFirstValidValue(item?.propertiesValue, item?.skuValue),
getFirstValidValue(item?.skuDesc, item?.specDesc, item?.specification),
getFirstValidValue(item?.sku, item?.specInfo, item?.attrText),
);
return {
itemKey: getFirstValidValue(
delayRecordId,
`${item?.spuName || item?.name || item?.title || ''}_${skuText}_${maxCount}`,
),
delayRecordId,
picUrl: getFirstValidValue(
item?.picUrl,
item?.image,
item?.imgUrl,
item?.thumbnail,
item?.pic,
item?.cover,
item?.spuImage,
item?.skuImage,
),
spuName: getFirstValidValue(
item?.spuName,
item?.name,
item?.title,
item?.goodsName,
item?.productName,
item?.spuTitle,
),
skuText,
maxCount,
selectedCount: maxCount,
};
};
const createNowShipmentItems = (data) => {
const rawExternal = Array.isArray(props.delayRecords) && props.delayRecords.length > 0
? props.delayRecords
: [];
const rawFromData = Array.isArray(data?.delayRecords)
? data.delayRecords
: Array.isArray(data?.delayRecordList)
? data.delayRecordList
: [];
const raw = rawExternal.length > 0 ? rawExternal : rawFromData;
return raw
.filter(Boolean)
.filter((item) => {
const status = Number(item?.status);
if (!status) return true;
return status === 1;
})
.map((item) => createNowShipmentItem(item))
.filter((item) => item.maxCount > 0);
};
const renderItems = computed(() => innerItems.value || []);
const open = () => {
const nextItems = props.mode === 'now' ? createNowShipmentItems(props.orderData) : createDelayShipmentItems(props.orderData);
innerItems.value = nextItems;
if (!popupRef.value || typeof popupRef.value.open !== 'function') {
uni.showToast({
title: '弹窗组件初始化失败,请重试',
icon: 'none',
});
return;
}
popupRef.value.open();
};
const close = () => {
if (popupRef.value && typeof popupRef.value.close === 'function') {
popupRef.value.close();
}
};
const handleClose = () => {
emit('close');
close();
};
const onCountChange = (index, value) => {
const current = innerItems.value[index];
if (!current) return;
const next = Number(value);
if (!Number.isFinite(next)) {
current.selectedCount = 0;
return;
}
current.selectedCount = Math.min(current.maxCount, Math.max(0, next));
};
const buildSubmitPayload = () => {
if (props.mode === 'now') {
const hasSelectedCount = innerItems.value.some((item) => Number(item.selectedCount) > 0);
const items = innerItems.value
.filter((item) => Number(item.selectedCount) > 0 && hasValue(item.delayRecordId))
.map((item) => ({
delayRecordId: item.delayRecordId,
count: Number(item.selectedCount),
}));
return {
hasSelectedCount,
items,
emptyTitle: hasSelectedCount ? '订单商品信息异常' : '请选择立即发货数量',
};
}
const hasSelectedCount = innerItems.value.some((item) => Number(item.selectedCount) > 0);
const items = innerItems.value
.filter((item) => Number(item.selectedCount) > 0 && hasValue(item.submitOrderItemId))
.map((item) => ({
orderItemId: item.submitOrderItemId,
count: Number(item.selectedCount),
}));
return {
hasSelectedCount,
items,
emptyTitle: hasSelectedCount ? '订单商品信息异常' : '请选择延迟发货数量',
};
};
const handleSubmit = () => {
const payload = buildSubmitPayload();
if (!payload.items.length) {
uni.showToast({
title: payload.emptyTitle,
icon: 'none',
});
return;
}
emit('submit', {
mode: props.mode,
items: payload.items,
close,
});
};
defineExpose({
open,
close,
});
</script>
<style lang="scss" scoped>
.shipment-popup {
background: #ffffff;
box-sizing: border-box;
}
.shipment-popup--bottom {
border-radius: 24rpx 24rpx 0 0;
padding: 32rpx 24rpx calc(24rpx + env(safe-area-inset-bottom));
}
.shipment-popup--center {
width: 680rpx;
max-height: 78vh;
border-radius: 24rpx;
padding: 32rpx 24rpx;
overflow: hidden;
}
.shipment-popup__header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12rpx;
}
.shipment-popup__title {
font-size: 34rpx;
font-weight: 600;
color: #333333;
}
.shipment-popup__order-no {
margin-top: 8rpx;
font-size: 22rpx;
line-height: 32rpx;
color: #999999;
word-break: break-all;
}
.shipment-popup__order-time {
margin-top: 4rpx;
font-size: 22rpx;
line-height: 32rpx;
color: #999999;
}
.shipment-popup__close {
width: 56rpx;
height: 56rpx;
border-radius: 50%;
background: #f3f4f6;
line-height: 56rpx;
text-align: center;
font-size: 36rpx;
color: #666666;
}
.shipment-popup__desc {
font-size: 24rpx;
color: #999999;
margin-bottom: 24rpx;
}
.shipment-popup__content {
max-height: 720rpx;
}
.shipment-popup__item {
display: flex;
padding: 20rpx 0;
border-bottom: 1rpx solid #f2f2f2;
}
.shipment-popup__item-image {
width: 144rpx;
height: 144rpx;
border-radius: 12rpx;
flex-shrink: 0;
margin-right: 20rpx;
background: #f5f5f5;
}
.shipment-popup__item-main {
flex: 1;
min-width: 0;
}
.shipment-popup__item-name {
font-size: 28rpx;
line-height: 40rpx;
color: #333333;
}
.shipment-popup__item-sku {
margin-top: 10rpx;
font-size: 24rpx;
line-height: 34rpx;
color: #999999;
}
.shipment-popup__item-footer {
margin-top: 20rpx;
}
.shipment-popup__item-count {
font-size: 24rpx;
color: #666666;
}
.shipment-popup__actions {
display: flex;
align-items: center;
gap: 20rpx;
margin-top: 32rpx;
}
.shipment-popup__btn {
flex: 1;
height: 84rpx;
line-height: 84rpx;
text-align: center;
border-radius: 42rpx;
font-size: 28rpx;
font-weight: 500;
}
.shipment-popup__btn--ghost {
background: #f2f3f5;
color: #333333;
}
.shipment-popup__btn--primary {
background: linear-gradient(135deg, #fa8735 0%, #fe3b48 100%);
color: #ffffff;
}
.shipment-popup__empty {
padding: 40rpx 24rpx;
text-align: center;
font-size: 26rpx;
color: #999999;
}
</style>
+641 -33
View File
@@ -1,17 +1,10 @@
<template> <template>
<view class="order_con" :class="{ bg24: props.theme == 2 }"> <view class="order_con" :class="{ bg24: props.theme == 2 }">
<view <view class="flex-center ju-between m-b-28" v-if="(props.type == 2 || props.type == 4) && props.data.logisticsNo">
class="flex-center ju-between m-b-28"
v-if="(props.type == 2 || props.type == 4) && props.data.logisticsNo"
>
<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 <truckLine :data="props.data" :code="2" v-if="props.data.deliveryTime && props.data.logisticsNo"></truckLine>
:data="props.data"
:code="2"
v-if="props.data.deliveryTime && props.data.logisticsNo"
></truckLine>
</view> </view>
</view> </view>
@@ -31,37 +24,101 @@
:class="{ 'p-r-10': props.type == 3, c0: props.theme == 2 }" :class="{ 'p-r-10': props.type == 3, c0: props.theme == 2 }"
> >
{{ v.spuName }} {{ v.spuName }}
<text v-if="!isCompletedOrder && getSpuDelayInfo(v).delayed" class="delay-tag delay-tag--spu">
已延迟 {{ getSpuDelayInfo(v).text }}
</text>
</view>
<view class="shrink price" v-if="props.type != 4 && !showMultiSku(v)">
<span class="size24">¥</span>
<span class="size36" style="font-weight: 600">{{ fen2yuan(v.price) }}</span>
</view> </view>
<view class="shrink price" v-if="props.type != 4"
><span class="size24">¥</span
><span class="size36" style="font-weight: 600">{{ fen2yuan(v.price) }}</span></view
>
</view> </view>
<view v-if="props.type == 4"> <view v-if="props.type == 4">
<view class="m-b-12 size24 h_52" v-for="(item, i) in v.items" :key="i"> <view class="m-b-12" v-for="(item, i) in v.items" :key="i">
<view class="flex1 flex-center ju-between h_52 bg18 radius8 p-l-8 p-r-16"> <view class="size24 flex1 flex-center ju-between h_52 bg18 radius8 p-l-8 p-r-16">
<view class="lineOne c19"> <view class="lineOne c19">
{{ formatSkuProperties(item?.properties) }} {{ formatSkuProperties(item?.properties) }}
</view> </view>
<view class="flex-center"> <view class="flex-center">
<view class="c19">x{{ item.count }}</view> <view class="c19">x{{ item.count }}</view>
<view class="size28 m-l-12 weight900" <view class="size28 m-l-12 weight900">
>¥<span class="">{{ fen2yuan(item.price) }}</span> ¥<span class="">{{ fen2yuan(item.price) }}</span>
</view> </view>
</view> </view>
</view> </view>
<view class="c13 size28 weight900"> <view
class="delay-record-line"
:class="`delay-record-line--status-${resolveDelayStatus(record)}`"
v-for="(record, recordIndex) in getSkuDelayRecords(v, item)"
:key="recordIndex"
>
<view class="delay-record-line__dot" />
<view class="delay-record-line__text">
{{ getDelayRecordSkuText(record) }}
</view>
<view class="delay-record-line__meta">
<text class="delay-record-line__status">{{ getDelayStatusText(record) }}</text>
<text class="delay-record-line__count">x{{ getDelayRecordCount(record) }}</text>
</view>
</view>
<view class="c13 size28 weight900 m-t-4">
¥<span class="size40">{{ fen2yuan(item.payPrice) }}</span> ¥<span class="size40">{{ fen2yuan(item.payPrice) }}</span>
</view> </view>
</view> </view>
</view> </view>
<view v-else-if="showMultiSku(v)" class="multi-sku-list">
<view class="multi-sku-item m-b-12" v-for="(item, itemIndex) in v.items" :key="item.id || itemIndex">
<view class="multi-sku-row flex1 flex-center ju-between bg18 radius8 p-l-8 p-r-16">
<view class="multi-sku-text lineOne c19">
{{ formatSkuProperties(item?.properties) }}
</view>
<view class="flex-center">
<view class="c19">x{{ item.count }}</view>
<view class="size28 m-l-12 weight900">
¥<span>{{ fen2yuan(item.payPrice || item.price) }}</span>
</view>
</view>
</view>
<view
class="delay-record-line delay-record-line--nested"
:class="`delay-record-line--status-${resolveDelayStatus(record)}`"
v-for="(record, recordIndex) in getSkuDelayRecords(v, item)"
:key="recordIndex"
>
<view class="delay-record-line__dot" />
<view class="delay-record-line__text">
{{ getDelayRecordSkuText(record) }}
</view>
<view class="delay-record-line__meta">
<text class="delay-record-line__status">{{ getDelayStatusText(record) }}</text>
<text class="delay-record-line__count">x{{ getDelayRecordCount(record) }}</text>
</view>
</view>
</view>
</view>
<view class="flex-row ju-between" :class="{ 'm-t-8': props.type == 3 }" v-else> <view class="flex-row ju-between" :class="{ 'm-t-8': props.type == 3 }" v-else>
<view class="valueName size28" :class="{ c19: props.theme == 2 }">{{ <view class="valueName size28" :class="{ c19: props.theme == 2 }">
formatSkuProperties(v.properties) {{ formatSkuProperties(v.properties) }}
}}</view> </view>
<view class="shrink size28 c_333" :class="{ c0: props.theme == 2 }">{{ <view class="shrink size28 c_333" :class="{ c0: props.theme == 2 }">
`x${v.count}` {{ `x${v.count}` }}
}}</view> </view>
</view>
<view
v-if="!hasNestedSkuBlock(v)"
class="delay-record-line delay-record-line--single"
:class="`delay-record-line--status-${resolveDelayStatus(record)}`"
v-for="(record, recordIndex) in getSkuDelayRecords(v, v)"
:key="`single-${recordIndex}`"
>
<view class="delay-record-line__dot" />
<view class="delay-record-line__text">
{{ getDelayRecordSkuText(record) }}
</view>
<view class="delay-record-line__meta">
<text class="delay-record-line__status">{{ getDelayStatusText(record) }}</text>
<text class="delay-record-line__count">x{{ getDelayRecordCount(record) }}</text>
</view>
</view> </view>
<view class="btn flex-row ju-flex-end" v-if="props.type == 2"> <view class="btn flex-row ju-flex-end" v-if="props.type == 2">
<button <button
@@ -87,7 +144,7 @@
> >
取消售后 取消售后
</view> </view>
<view class="btnItem" v-if="v.afterSaleStatus === 20"> 售后成功 </view> <view class="btnItem" v-if="v.afterSaleStatus === 20">售后成功</view>
</view> </view>
</view> </view>
</view> </view>
@@ -95,11 +152,10 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive, getCurrentInstance, defineProps } from 'vue'; import { computed, defineProps } from 'vue';
import { fen2yuan } 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';
const { proxy } = getCurrentInstance() as any;
let emit = defineEmits(['getOrderDetail']); let emit = defineEmits(['getOrderDetail']);
const formatSkuProperties = (properties: any) => { const formatSkuProperties = (properties: any) => {
const list = Array.isArray(properties) ? properties : []; const list = Array.isArray(properties) ? properties : [];
@@ -108,6 +164,18 @@
.filter(Boolean) .filter(Boolean)
.join(' '); .join(' ');
}; };
const showMultiSku = (item: any) => {
return (
['2', '3'].includes(props.type) &&
[String(props.source), String(props.data?.__source)].includes('aishop') &&
Array.isArray(item?.items) &&
item.items.length > 1
);
};
const hasNestedSkuBlock = (item: any) => {
if (props.type == 4) return true;
return showMultiSku(item);
};
const props = defineProps({ const props = defineProps({
data: { data: {
type: Object, type: Object,
@@ -117,19 +185,355 @@
}, },
type: { type: {
type: String, type: String,
default: '0', //0列表2订单详情 3订单列表 4ai订单详情 default: '0',
},
source: {
type: String,
default: '',
}, },
theme: { theme: {
type: String, type: String,
default: '2', //1浅色 2深色 default: '2',
},
delayRecords: {
type: Array,
default() {
return [];
},
}, },
}); });
const cancelAfterSale = (v) => {
const isAiStoreOrder = computed(() =>
[String(props.source), String(props.data?.__source)].includes('aishop'),
);
const orderStatusText = computed(() => {
try {
return formatOrderStatus(props.data || {});
} catch (e) {
const status = Number(props.data?.status);
if (status === 30) return '已完成';
return '';
}
});
const isCompletedOrder = computed(() => orderStatusText.value === '已完成');
const hasDelayRecords = computed(() => {
if (isCompletedOrder.value) return false;
if (!isAiStoreOrder.value) return false;
if (Array.isArray(props.delayRecords) && props.delayRecords.length > 0) {
return true;
}
const records = Array.isArray(props.data?.delayRecords)
? props.data.delayRecords
: Array.isArray(props.data?.delayRecordList)
? props.data.delayRecordList
: [];
return records.length > 0;
});
const delayRecords = computed(() => {
if (!hasDelayRecords.value) return [];
if (Array.isArray(props.delayRecords) && props.delayRecords.length > 0) {
return props.delayRecords;
}
return Array.isArray(props.data?.delayRecords)
? props.data.delayRecords
: Array.isArray(props.data?.delayRecordList)
? props.data.delayRecordList
: [];
});
const DELAY_STATUS_MAP = {
1: { text: '延迟中', color: '#FA7E31' },
2: { text: '已激活(待发货)', color: '#1AAD19' },
3: { text: '已发货', color: '#1677FF' },
4: { text: '已收货', color: '#999999' },
};
const resolveDelayStatus = (record: any) => {
const status = Number(record?.status);
if ([1, 2, 3, 4].includes(status)) return status;
return 0;
};
const getDelayStatusText = (record: any) => {
const status = resolveDelayStatus(record);
const fallback = getFirstValidValue(record?.statusDesc, '');
if (DELAY_STATUS_MAP[status]) {
return DELAY_STATUS_MAP[status].text;
}
return fallback || '延迟中';
};
const getFirstValidValue = (...values: any[]) =>
values.find((value) => value !== undefined && value !== null && String(value).trim() !== '') ?? '';
const getNumber = (value: any) => {
const n = Number(value);
return Number.isFinite(n) ? n : 0;
};
const resolveItemId = (item: any) =>
getFirstValidValue(item?.orderItemId, item?.itemId, item?.orderGoodsId, item?.id);
const resolveRecordItemId = (record: any) =>
getFirstValidValue(record?.orderItemId, record?.itemId, record?.orderGoodsId);
const resolveRecordCount = (record: any) => {
const candidates = [
record?.count,
record?.delayCount,
record?.recordCount,
record?.remainingCount,
record?.availableCount,
record?.canCount,
record?.maxCount,
];
const matched = candidates.map((value) => getNumber(value)).find((value) => value > 0);
return matched || 0;
};
const isSameSku = (item: any, record: any) => {
const itemProps = Array.isArray(item?.properties)
? item.properties
: Array.isArray(item?.skuProperties)
? item.skuProperties
: Array.isArray(item?.attrs)
? item.attrs
: [];
const recordProps = Array.isArray(record?.properties)
? record.properties
: Array.isArray(record?.skuProperties)
? record.skuProperties
: Array.isArray(record?.attrs)
? record.attrs
: [];
if (itemProps.length && recordProps.length && itemProps.length === recordProps.length) {
const itemKey = itemProps
.map((p) => `${getFirstValidValue(p?.valueName, p?.value)}`)
.filter(Boolean)
.join('|');
const recordKey = recordProps
.map((p) => `${getFirstValidValue(p?.valueName, p?.value)}`)
.filter(Boolean)
.join('|');
if (itemKey && recordKey) {
return itemKey === recordKey;
}
if (itemKey || recordKey) {
return false;
}
} else if (itemProps.length || recordProps.length) {
return false;
}
const itemSkuText = getFirstValidValue(
item?.skuText,
item?.specText,
item?.propertiesText,
item?.skuDesc,
item?.specDesc,
);
const recordSkuText = getFirstValidValue(
record?.skuText,
record?.specText,
record?.propertiesText,
formatSkuProperties(record?.properties),
formatSkuProperties(record?.skuProperties),
formatSkuProperties(record?.attrs),
record?.skuDesc,
record?.specDesc,
);
if (itemSkuText && recordSkuText) {
return itemSkuText === recordSkuText;
}
if (itemSkuText || recordSkuText) {
return false;
}
return false;
};
const resolveRecordUniqueId = (record: any) =>
getFirstValidValue(record?.id, record?.delayRecordId, record?.recordId);
const uniqueByRecordId = (records: any[]) => {
const map = new Map();
(records || []).forEach((record) => {
const key = resolveRecordUniqueId(record) || JSON.stringify(record);
if (!map.has(key)) {
map.set(key, record);
}
});
return Array.from(map.values());
};
const buildSpuRecordAssignment = (spuItem: any) => {
if (!hasDelayRecords.value) {
return { spuRecords: [], skuMap: new Map() };
}
const skuItems = Array.isArray(spuItem?.items) && spuItem.items.length > 0 ? spuItem.items : [spuItem];
const targetSpuId = getFirstValidValue(spuItem?.spuId, spuItem?.productId, spuItem?.goodsId);
const targetSpuName = getFirstValidValue(
spuItem?.spuName,
spuItem?.name,
spuItem?.goodsName,
spuItem?.productName,
);
const matchSpuIdentity = (record: any) => {
const recordSpuId = getFirstValidValue(record?.spuId, record?.productId, record?.goodsId);
if (targetSpuId && recordSpuId) {
return String(targetSpuId) === String(recordSpuId);
}
const recordSpuName = getFirstValidValue(
record?.spuName,
record?.name,
record?.goodsName,
record?.productName,
);
if (targetSpuName && recordSpuName) {
return String(targetSpuName).trim() === String(recordSpuName).trim();
}
if (targetSpuId || recordSpuId) return false;
return false;
};
const spuRecordsRaw = delayRecords.value.filter((record) => {
if (!matchSpuIdentity(record)) return false;
const recordItemId = resolveRecordItemId(record);
const spuItemId = resolveItemId(spuItem);
if (recordItemId && spuItemId && String(recordItemId) === String(spuItemId)) {
return true;
}
const anySkuMatched = skuItems.some((skuItem) => {
const skuItemId = resolveItemId(skuItem);
if (recordItemId && skuItemId && String(recordItemId) === String(skuItemId)) {
return true;
}
return isSameSku(skuItem, record);
});
return anySkuMatched;
});
const spuRecords = uniqueByRecordId(spuRecordsRaw);
const skuMap = new Map();
skuItems.forEach((skuItem, idx) => {
const key = resolveItemId(skuItem) || `sku-${idx}`;
skuMap.set(key, []);
});
const usedRecordKeys = new Set();
const assignRecordToSku = (record: any, skuItem: any, skuIdx: number) => {
const key = resolveRecordUniqueId(record) || JSON.stringify(record);
if (usedRecordKeys.has(key)) return false;
const skuKey = resolveItemId(skuItem) || `sku-${skuIdx}`;
if (!skuMap.has(skuKey)) {
skuMap.set(skuKey, []);
}
skuMap.get(skuKey).push(record);
usedRecordKeys.add(key);
return true;
};
spuRecords.forEach((record) => {
const recordItemId = resolveRecordItemId(record);
if (!recordItemId) return;
const matchedIndex = skuItems.findIndex((skuItem) => {
const skuItemId = resolveItemId(skuItem);
return !!(skuItemId && String(recordItemId) === String(skuItemId));
});
if (matchedIndex >= 0) {
assignRecordToSku(record, skuItems[matchedIndex], matchedIndex);
}
});
spuRecords.forEach((record) => {
const key = resolveRecordUniqueId(record) || JSON.stringify(record);
if (usedRecordKeys.has(key)) return;
const matchedIndex = skuItems.findIndex((skuItem) => isSameSku(skuItem, record));
if (matchedIndex >= 0) {
assignRecordToSku(record, skuItems[matchedIndex], matchedIndex);
}
});
spuRecords.forEach((record) => {
const key = resolveRecordUniqueId(record) || JSON.stringify(record);
if (usedRecordKeys.has(key)) return;
if (skuItems.length === 1 && matchSpuIdentity(record)) {
assignRecordToSku(record, skuItems[0], 0);
}
});
return { spuRecords, skuMap };
};
const findMatchedRecords = (spuItem: any, skuItem?: any) => {
if (!hasDelayRecords.value) return [];
const target = skuItem || spuItem;
const { skuMap, spuRecords } = buildSpuRecordAssignment(spuItem);
const skuItems = Array.isArray(spuItem?.items) && spuItem.items.length > 0 ? spuItem.items : [spuItem];
const targetIndex = skuItems.findIndex((item) => item === target);
if (targetIndex >= 0) {
const skuKey = resolveItemId(target) || `sku-${targetIndex}`;
return uniqueByRecordId(skuMap.get(skuKey) || []);
}
return spuRecords;
};
const sumDelayCount = (records: any[]) =>
records.reduce((sum, record) => sum + resolveRecordCount(record), 0);
const getSpuDelayInfo = (spuItem: any) => {
if (!isAiStoreOrder.value || !hasDelayRecords.value) {
return { delayed: false, count: 0, text: '' };
}
const { spuRecords } = buildSpuRecordAssignment(spuItem);
const count = sumDelayCount(spuRecords);
if (!count) {
return { delayed: false, count: 0, text: '' };
}
return { delayed: true, count, text: `${count}件` };
};
const getSkuDelayRecords = (spuItem: any, skuItem: any) => {
if (!isAiStoreOrder.value || !hasDelayRecords.value || !skuItem) return [];
const skuItems = Array.isArray(spuItem?.items) && spuItem.items.length > 0 ? spuItem.items : [spuItem];
const targetIndex = skuItems.findIndex((item) => item === skuItem);
if (targetIndex < 0) {
if (skuItem === spuItem && skuItems.length === 1) {
return findMatchedRecords(spuItem, skuItem);
}
return [];
}
return findMatchedRecords(spuItem, skuItem);
};
const getDelayRecordCount = (record: any) => resolveRecordCount(record) || 0;
const getDelayRecordSkuText = (record: any) => {
const text = getFirstValidValue(
formatSkuProperties(record?.properties),
formatSkuProperties(record?.skuProperties),
formatSkuProperties(record?.attrs),
formatSkuProperties(record?.specs),
formatSkuProperties(record?.specifications),
getFirstValidValue(
record?.skuText,
record?.specText,
record?.propertiesText,
record?.propertiesValue,
record?.skuValue,
),
getFirstValidValue(record?.skuDesc, record?.specDesc, record?.specification),
getFirstValidValue(record?.sku, record?.specInfo, record?.attrText),
);
if (text && String(text).trim()) {
return text;
}
return getFirstValidValue(record?.spuName, record?.name, record?.goodsName, record?.productName);
};
const cancelAfterSale = (v: any) => {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '确定要取消此申请吗?', content: '确定要取消此申请吗?',
confirmColor: '#FA7E31', confirmColor: '#FA7E31',
success: async function (res) { success: async function (res: any) {
if (!res.confirm) { if (!res.confirm) {
return; return;
} }
@@ -143,10 +547,11 @@
const getOrderDetail = () => { const getOrderDetail = () => {
emit('getOrderDetail'); emit('getOrderDetail');
}; };
const onCopy = (text) => { const onCopy = (text: any) => {
sheep.$helper.copyText(text); sheep.$helper.copyText(text);
}; };
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.order_con { .order_con {
.con_item { .con_item {
@@ -175,6 +580,209 @@
} }
} }
.delay-tag {
display: inline-flex;
align-items: center;
padding: 2rpx 12rpx;
margin-left: 10rpx;
border-radius: 16rpx;
background: #FFF4EA;
color: #FA7E31;
font-size: 20rpx;
line-height: 30rpx;
white-space: nowrap;
vertical-align: middle;
}
.delay-tag--spu {
font-size: 22rpx;
line-height: 32rpx;
}
.delay-tag--sku {
font-size: 20rpx;
line-height: 28rpx;
}
.price {
color: #ee0a24;
font-size: 24rpx;
}
.multi-sku-list {
width: 100%;
}
.multi-sku-item:last-child {
margin-bottom: 0;
}
.multi-sku-row {
height: 52rpx;
}
.multi-sku-text {
flex: 1;
min-width: 0;
color: #777777;
font-size: 24rpx;
}
.delay-record-line {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10rpx 8rpx 10rpx 28rpx;
margin-top: 8rpx;
background: #FFF4EA;
border-radius: 8rpx;
position: relative;
}
.delay-record-line--status-1 {
background: #FFF4EA;
}
.delay-record-line--status-2 {
background: #E8F9E7;
}
.delay-record-line--status-3 {
background: #E8F1FF;
}
.delay-record-line--status-4 {
background: #F5F5F5;
}
.delay-record-line--status-0 {
background: #FFF4EA;
}
.delay-record-line--nested {
margin-left: 8rpx;
margin-right: 16rpx;
}
.delay-record-line--single {
margin-top: 12rpx;
}
.delay-record-line__dot {
position: absolute;
left: 12rpx;
top: 50%;
width: 8rpx;
height: 8rpx;
border-radius: 50%;
background: #FA7E31;
transform: translateY(-50%);
}
.delay-record-line--status-2 .delay-record-line__dot {
background: #1AAD19;
}
.delay-record-line--status-3 .delay-record-line__dot {
background: #1677FF;
}
.delay-record-line--status-4 .delay-record-line__dot {
background: #999999;
}
.delay-record-line--status-0 .delay-record-line__dot {
background: #FA7E31;
}
.delay-record-line__text {
flex: 1;
min-width: 0;
font-size: 22rpx;
line-height: 32rpx;
color: #FA7E31;
overflow: hidden;
word-break: break-all;
}
.delay-record-line--status-2 .delay-record-line__text {
color: #1AAD19;
}
.delay-record-line--status-3 .delay-record-line__text {
color: #1677FF;
}
.delay-record-line--status-4 .delay-record-line__text {
color: #999999;
}
.delay-record-line--status-0 .delay-record-line__text {
color: #FA7E31;
}
.delay-record-line__meta {
flex-shrink: 0;
display: inline-flex;
align-items: center;
margin-left: 12rpx;
gap: 12rpx;
}
.delay-record-line__status {
font-size: 20rpx;
line-height: 30rpx;
padding: 2rpx 12rpx;
border-radius: 16rpx;
background: rgba(250, 126, 49, 0.1);
color: #FA7E31;
white-space: nowrap;
}
.delay-record-line--status-2 .delay-record-line__status {
background: rgba(26, 173, 25, 0.1);
color: #1AAD19;
}
.delay-record-line--status-3 .delay-record-line__status {
background: rgba(22, 119, 255, 0.1);
color: #1677FF;
}
.delay-record-line--status-4 .delay-record-line__status {
background: rgba(153, 153, 153, 0.1);
color: #999999;
}
.delay-record-line--status-0 .delay-record-line__status {
background: rgba(250, 126, 49, 0.1);
color: #FA7E31;
}
.delay-record-line__count {
flex-shrink: 0;
font-size: 22rpx;
line-height: 32rpx;
font-weight: 600;
color: #FA7E31;
}
.delay-record-line--status-2 .delay-record-line__count {
color: #1AAD19;
}
.delay-record-line--status-3 .delay-record-line__count {
color: #1677FF;
}
.delay-record-line--status-4 .delay-record-line__count {
color: #999999;
}
.delay-record-line--status-0 .delay-record-line__count {
color: #FA7E31;
}
.price { .price {
color: #ee0a24; color: #ee0a24;
font-size: 24rpx; font-size: 24rpx;
+296 -71
View File
@@ -1,14 +1,7 @@
<template> <template>
<view <view class="card_order bg24 size34" @click="
class="card_order bg24 size34" utils.go('/pages/order/detail', { id: !props.isAfterSale ? props.data.id : props.data.orderId, type: props.data.type, source: props.data.__source })
@click=" ">
utils.go('/pages/order/detail', {
id: !props.isAfterSale ? props.data.id : props.data.orderId,
type: props.data.type,
source: props.data.__source,
})
"
>
<view class="flex-center ju-between createTime"> <view class="flex-center ju-between createTime">
<view class="flex-center shrink"> <view class="flex-center shrink">
<view class="size28">订单编号: {{ props.data.no }}</view> <view class="size28">订单编号: {{ props.data.no }}</view>
@@ -16,19 +9,15 @@
<image :src="`${$url}goods/copy2.svg`" mode="scaleToFill" /> <image :src="`${$url}goods/copy2.svg`" mode="scaleToFill" />
</view> </view>
</view> </view>
<view <view class="stateText size28" style="margin-left: 10px" :class="formatOrderColor(props.data)"
class="stateText size28" v-if="!props.isAfterSale">
style="margin-left: 10px"
:class="formatOrderColor(props.data)"
v-if="!props.isAfterSale"
>
{{ formatOrderStatus(props.data) }} {{ formatOrderStatus(props.data) }}
</view> </view>
<view class="stateText size28" v-else> <view class="stateText size28" v-else>
{{ formatAfterSaleStatus(props.data) }} {{ formatAfterSaleStatus(props.data) }}
</view> </view>
</view> </view>
<card_order :data="props.data" v-if="!props.isAfterSale" type="3"></card_order> <card_order :data="props.data" :source="props.data.__source" :delay-records="state.delayRecords" v-if="!props.isAfterSale" type="3"></card_order>
<view v-else class="con_item flex-center ju-between al-flex-start"> <view v-else class="con_item flex-center ju-between al-flex-start">
<view class="order_img shrink"> <view class="order_img shrink">
<image :src="`${props.data.picUrl}`" mode="aspectFill" /> <image :src="`${props.data.picUrl}`" mode="aspectFill" />
@@ -37,10 +26,8 @@
<view class="flex-row ju-between"> <view class="flex-row ju-between">
<view class="size28 spuName lineTwo c0">{{ props.data.spuName }}</view> <view class="size28 spuName lineTwo c0">{{ props.data.spuName }}</view>
<view class="shrink price"> <view class="shrink price">
<span class="size24">¥</span <span class="size24">¥</span><span class="size36"
><span class="size36" style="font-weight: 600">{{ style="font-weight: 600">{{ fen2yuan(props.data.refundPrice) }}</span>
fen2yuan(props.data.refundPrice)
}}</span>
</view> </view>
</view> </view>
<view class="flex-row ju-between m-t-10"> <view class="flex-row ju-between m-t-10">
@@ -62,8 +49,7 @@
v-if="statusChange(['20'], String(props.data.status))" v-if="statusChange(['20'], String(props.data.status))"
@tap.stop=" @tap.stop="
sheep.$router.go('/pages/order/aftersale/return-delivery', { id: props.data.id }) sheep.$router.go('/pages/order/aftersale/return-delivery', { id: props.data.id })
" ">
>
填写物流信息 填写物流信息
</button> </button>
</view> </view>
@@ -80,21 +66,17 @@
<view class="size24 c32">已优惠¥{{ fen2yuan(props.data.randomDiscountPrice) }}</view> <view class="size24 c32">已优惠¥{{ fen2yuan(props.data.randomDiscountPrice) }}</view>
</view> </view>
<view class="flex-row ju-flex-end" v-if="!props.isAfterSale"> <view class="flex-row ju-flex-end" v-if="!props.isAfterSale">
<view class="flex-center size24" <view class="flex-center size24">{{ `共${props.data.productCount}件商品 合计: `
>{{ `共${props.data.productCount}件商品 合计: ` }} }}
<!-- <view class="price">¥{{ fen2yuan(props.data.payPrice) }}</view> --> <!-- <view class="price">¥{{ fen2yuan(props.data.payPrice) }}</view> -->
<view class="shrink price" <view class="shrink price"><span class="size24">¥</span><span class="size36"
><span class="size24">¥</span style="font-weight: 600;">{{ fen2yuan(props.data.payPrice) }}</span></view>
><span class="size36" style="font-weight: 600">{{
fen2yuan(props.data.payPrice)
}}</span></view
>
</view> </view>
</view> </view>
<view class="flex-center ju-flex-end m-t-12" v-if="!props.isAfterSale && isAiActionOrder"> <view class="flex-center ju-flex-end m-t-12" v-if="!props.isAfterSale && isAiActionOrder">
<AiOrderActionBar <AiOrderActionBar
:status="currentStatus" :status="currentStatus"
:disableDelayShipment="isPickUpOrder" :disableDelayShipment="isPickUpOrder || !isAiStoreOrder"
:showView="true" :showView="true"
@delay="onDelayShipment" @delay="onDelayShipment"
@now="onNowShipment" @now="onNowShipment"
@@ -108,9 +90,39 @@
<card_orderBan :data="props.data" @downData="downData"></card_orderBan> <card_orderBan :data="props.data" @downData="downData"></card_orderBan>
</view> </view>
</view> </view>
<ShipmentPopup
ref="nowShipmentPopupRef"
mode="now"
popup-type="bottom"
:order-no="props.data.no || ''"
:order-time="formatCreateTime(props.data.createTime) || ''"
:order-data="props.data"
:delay-records="state.delayRecords"
@close="closeNowShipmentPopup"
@submit="handleNowShipmentSubmit"
/>
<ShipmentPopup
ref="delayShipmentPopupRef"
mode="delay"
popup-type="bottom"
:order-no="props.data.no || ''"
:order-time="formatCreateTime(props.data.createTime) || ''"
:order-data="props.data"
@close="closeDelayShipmentPopup"
@submit="handleDelayShipmentSubmit"
/>
</template> </template>
<script setup> <script setup>
import { getCurrentInstance, defineProps, defineEmits, computed, ref, watch } from 'vue'; import {
getCurrentInstance,
defineProps,
defineEmits,
computed,
ref,
reactive,
watch,
onMounted,
} from 'vue';
import { import {
fen2yuan, fen2yuan,
formatOrderColor, formatOrderColor,
@@ -120,6 +132,7 @@
import card_order from './card_order.vue'; import card_order from './card_order.vue';
import card_orderBan from '@/components/card_orderBan/card_orderBan.vue'; import card_orderBan from '@/components/card_orderBan/card_orderBan.vue';
import AiOrderActionBar from '@/components/orderItem/AiOrderActionBar.vue'; import AiOrderActionBar from '@/components/orderItem/AiOrderActionBar.vue';
import ShipmentPopup from '@/components/orderItem/ShipmentPopup.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 {
@@ -129,6 +142,7 @@
giftConfirmReceive, giftConfirmReceive,
cancelOrder as cancelAiOrderRequest, cancelOrder as cancelAiOrderRequest,
cancelOpenOrder, cancelOpenOrder,
getAiOrderDelayRecords,
} from '@/sheep/api/ai'; } from '@/sheep/api/ai';
let emit = defineEmits(['downData']); let emit = defineEmits(['downData']);
let { proxy } = getCurrentInstance(); let { proxy } = getCurrentInstance();
@@ -151,7 +165,6 @@
const downData = () => { const downData = () => {
emit('downData'); emit('downData');
}; };
// 复制
const onCopy = (no) => { const onCopy = (no) => {
proxy.$sheep.$helper.copyText(no); proxy.$sheep.$helper.copyText(no);
}; };
@@ -184,6 +197,7 @@
const isAiActionOrder = const isAiActionOrder =
String(props.data?.__source) === 'aishop' || Number(props.data?.type) === 5; String(props.data?.__source) === 'aishop' || Number(props.data?.type) === 5;
const isAiStoreOrder = computed(() => String(props.data?.__source) === 'aishop');
const isPickUpOrder = computed(() => { const isPickUpOrder = computed(() => {
if (Number(props.data?.deliveryType) === 2) return true; if (Number(props.data?.deliveryType) === 2) return true;
return Boolean( return Boolean(
@@ -201,12 +215,111 @@
}, },
{ immediate: true }, { immediate: true },
); );
const isDelayedShipmentOrder = () => currentStatus.value === 50 && !isPickUpOrder.value; const isDelayedShipmentOrder = () =>
currentStatus.value === 50 && !isPickUpOrder.value;
const state = reactive({
delayRecords: [],
delayRecordsLoaded: false,
});
const resolveAiOrderId = (data) => { const resolveAiOrderId = (data) => {
return data?.id || data?.orderId; return data?.id || data?.orderId;
}; };
const loadDelayRecords = async (force = false) => {
if (props.isAfterSale) return;
if (!isAiStoreOrder.value) return;
const orderId = resolveAiOrderId(props.data);
if (!orderId) return;
if (state.delayRecordsLoaded && !force) return;
try {
const { code, data } = await getAiOrderDelayRecords({ orderId });
if (code === 0 && Array.isArray(data)) {
state.delayRecords = data;
} else {
state.delayRecords = [];
}
} catch (e) {
state.delayRecords = [];
} finally {
state.delayRecordsLoaded = true;
}
};
watch(
() => resolveAiOrderId(props.data),
(value) => {
if (!value) return;
state.delayRecordsLoaded = false;
loadDelayRecords(true);
},
{ immediate: false },
);
onMounted(() => {
loadDelayRecords();
});
const nowShipmentPopupRef = ref();
const delayShipmentPopupRef = ref();
const closeNowShipmentPopup = () => {};
const closeDelayShipmentPopup = () => {};
const openDelayShipmentPopup = (data) => {
const id = resolveAiOrderId(data);
if (!id) {
uni.showToast({
title: '订单信息异常',
icon: 'none',
});
return;
}
delayShipmentPopupRef.value?.open();
};
const openNowShipmentPopup = (data) => {
const id = resolveAiOrderId(data);
if (!id) {
uni.showToast({
title: '订单信息异常',
icon: 'none',
});
return;
}
nowShipmentPopupRef.value?.open();
};
const handleDelayShipmentSubmit = async ({ items, close }) => {
const orderId = resolveAiOrderId(props.data);
if (!orderId || !Array.isArray(items) || items.length === 0) {
return;
}
const { code } = await aiDelayedShipment({
orderId,
items,
});
if (code === 0) {
close?.();
currentStatus.value = 50;
await loadDelayRecords(true);
emit('downData');
}
};
const handleNowShipmentSubmit = async ({ items, close }) => {
const orderId = resolveAiOrderId(props.data);
if (!orderId || !Array.isArray(items) || items.length === 0) {
return;
}
const { code } = await aiPendingShipment({
orderId,
items,
});
if (code === 0) {
close?.();
currentStatus.value = 10;
await loadDelayRecords(true);
emit('downData');
}
};
const onDelayShipment = () => { const onDelayShipment = () => {
delayShipment(props.data); delayShipment(props.data);
}; };
@@ -216,59 +329,39 @@
}; };
function delayShipment(data) { function delayShipment(data) {
if (isPickUpOrder.value) return; if (isPickUpOrder.value) {
const id = resolveAiOrderId(data);
if (!id) {
uni.showToast({ uni.showToast({
title: '订单信息异常', title: '自提订单不支持延迟发货',
icon: 'none', icon: 'none',
}); });
return; return;
} }
uni.showModal({ if (!isAiStoreOrder.value) {
title: '延迟发货', uni.showToast({
content: '请您确认是否暂时不需要发货,确认后该产品将为您安排延迟发货', title: '当前订单不支持延迟发货',
confirmColor: '#FA7E31', icon: 'none',
success: async function (res) {
if (!res.confirm) return;
const { code } = await aiDelayedShipment({
id,
status: 50,
}); });
if (code === 0) { return;
currentStatus.value = 50;
emit('downData');
} }
}, openDelayShipmentPopup(data);
});
} }
function nowShipment(data) { function nowShipment(data) {
if (isPickUpOrder.value) return; if (isPickUpOrder.value) {
const id = resolveAiOrderId(data);
if (!id) {
uni.showToast({ uni.showToast({
title: '订单信息异常', title: '自提订单不支持立即发货',
icon: 'none', icon: 'none',
}); });
return; return;
} }
uni.showModal({ if (!isAiStoreOrder.value) {
title: '立即发货', uni.showToast({
content: '请您确认是否需要立即发货,确认后将尽快为您安排发货', title: '当前订单不支持立即发货',
confirmColor: '#FA7E31', icon: 'none',
success: async function (res) {
if (!res.confirm) return;
const { code } = await aiPendingShipment({
id,
status: 10,
}); });
if (code === 0) { return;
currentStatus.value = 10;
emit('downData');
} }
}, openNowShipmentPopup(data);
});
} }
const goAiOrderInfo = () => { const goAiOrderInfo = () => {
@@ -371,6 +464,138 @@
line-height: 36rpx; line-height: 36rpx;
} }
.delay-popup {
background: #ffffff;
border-radius: 24rpx 24rpx 0 0;
padding: 32rpx 24rpx calc(24rpx + env(safe-area-inset-bottom));
box-sizing: border-box;
}
.delay-popup__header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12rpx;
}
.delay-popup__title {
font-size: 34rpx;
font-weight: 600;
color: #333333;
}
.delay-popup__order-no {
margin-top: 8rpx;
font-size: 22rpx;
line-height: 32rpx;
color: #999999;
word-break: break-all;
}
.delay-popup__order-time {
margin-top: 4rpx;
font-size: 22rpx;
line-height: 32rpx;
color: #999999;
}
.delay-popup__close {
width: 56rpx;
height: 56rpx;
border-radius: 50%;
background: #f3f4f6;
line-height: 56rpx;
text-align: center;
font-size: 36rpx;
color: #666666;
}
.delay-popup__desc {
font-size: 24rpx;
color: #999999;
margin-bottom: 24rpx;
}
.delay-popup__content {
max-height: 720rpx;
}
.delay-popup__item {
display: flex;
padding: 20rpx 0;
border-bottom: 1rpx solid #f2f2f2;
}
.delay-popup__item-image {
width: 144rpx;
height: 144rpx;
border-radius: 12rpx;
flex-shrink: 0;
margin-right: 20rpx;
background: #f5f5f5;
}
.delay-popup__item-main {
flex: 1;
min-width: 0;
}
.delay-popup__item-name {
font-size: 28rpx;
line-height: 40rpx;
color: #333333;
}
.delay-popup__item-sku {
margin-top: 10rpx;
font-size: 24rpx;
line-height: 34rpx;
color: #999999;
}
.delay-popup__item-footer {
margin-top: 20rpx;
}
.delay-popup__item-count {
font-size: 24rpx;
color: #666666;
}
.delay-popup__actions {
display: flex;
align-items: center;
gap: 20rpx;
margin-top: 32rpx;
}
.delay-popup__btn {
flex: 1;
height: 84rpx;
line-height: 84rpx;
text-align: center;
border-radius: 42rpx;
font-size: 28rpx;
font-weight: 500;
}
.delay-popup__btn--ghost {
background: #f2f3f5;
color: #333333;
}
.delay-popup__btn--primary {
background: linear-gradient(135deg, #fa8735 0%, #fe3b48 100%);
color: #ffffff;
}
.now-shipment-empty {
padding: 40rpx 24rpx;
text-align: center;
font-size: 26rpx;
color: #999999;
}
.price { .price {
color: #ee0a24; color: #ee0a24;
font-size: 24rpx; font-size: 24rpx;
+17
View File
@@ -41,6 +41,8 @@
class="order-goods" class="order-goods"
v-if="state?.orderInfo?.items?.length > 0" v-if="state?.orderInfo?.items?.length > 0"
:data="state.orderInfo" :data="state.orderInfo"
source="aishop"
:delay-records="state.delayRecords"
type="4" type="4"
@getOrderDetail="getOrderDetail" @getOrderDetail="getOrderDetail"
></card_order> ></card_order>
@@ -151,6 +153,7 @@
orderInfo: {}, orderInfo: {},
merchantTradeNo: '', // 商户订单号 merchantTradeNo: '', // 商户订单号
comeinType: '', // 进入订单详情的来源类型 comeinType: '', // 进入订单详情的来源类型
delayRecords: [],
}); });
let statusObj = ref({ let statusObj = ref({
0: { 0: {
@@ -229,6 +232,20 @@
if (state.orderInfo.deliveryType === 2 && state.orderInfo.payStatus) { if (state.orderInfo.deliveryType === 2 && state.orderInfo.payStatus) {
pickUpVerifyRef.value && pickUpVerifyRef.value.markCode(res.data.pickUpVerifyCode); pickUpVerifyRef.value && pickUpVerifyRef.value.markCode(res.data.pickUpVerifyCode);
} }
if (orderId.value) {
try {
const delayRes = await OrderApi.getAiOrderDelayRecords({ orderId: orderId.value });
if (delayRes.code === 0 && Array.isArray(delayRes.data)) {
state.delayRecords = delayRes.data;
} else {
state.delayRecords = [];
}
} catch (e) {
state.delayRecords = [];
}
} else {
state.delayRecords = [];
}
} else { } else {
} }
} }
+271 -3
View File
@@ -26,6 +26,8 @@
class="order-goods" class="order-goods"
v-if="state?.orderInfo?.items?.length > 0" v-if="state?.orderInfo?.items?.length > 0"
:data="state.orderInfo" :data="state.orderInfo"
:source="state.source"
:delay-records="state.delayRecords"
type="2" type="2"
theme="2" theme="2"
@getOrderDetail="getOrderDetail" @getOrderDetail="getOrderDetail"
@@ -102,7 +104,7 @@
<AiOrderActionBar <AiOrderActionBar
v-if="isAiActionOrder" v-if="isAiActionOrder"
:status="Number(state.orderInfo.status)" :status="Number(state.orderInfo.status)"
:disableDelayShipment="isPickUpOrder" :disableDelayShipment="isPickUpOrder || !isAiStoreOrder"
@delay="delayShipment" @delay="delayShipment"
@now="nowShipment" @now="nowShipment"
@confirm="confirmReceiveOrder" @confirm="confirmReceiveOrder"
@@ -117,6 +119,27 @@
></card_orderBan> ></card_orderBan>
</view> </view>
</su-fixed> </su-fixed>
<ShipmentPopup
ref="nowShipmentPopupRef"
mode="now"
popup-type="center"
:order-no="state.orderInfo.no || ''"
:order-time="formatCreateTime(state.orderInfo.createTime) || ''"
:order-data="state.orderInfo"
:delay-records="state.delayRecords"
@close="closeNowShipmentPopup"
@submit="handleNowShipmentSubmit"
/>
<ShipmentPopup
ref="delayShipmentPopupRef"
mode="delay"
popup-type="center"
:order-no="state.orderInfo.no || ''"
:order-time="formatCreateTime(state.orderInfo.createTime) || ''"
:order-data="state.orderInfo"
@close="closeDelayShipmentPopup"
@submit="handleDelayShipmentSubmit"
/>
</s-pages> </s-pages>
</template> </template>
@@ -135,10 +158,12 @@
getOpenOrderDetail, getOpenOrderDetail,
cancelOrder as cancelAiOrderRequest, cancelOrder as cancelAiOrderRequest,
cancelOpenOrder, cancelOpenOrder,
getAiOrderDelayRecords,
} from '@/sheep/api/ai'; } from '@/sheep/api/ai';
import StoreApi from '@/sheep/api/trade/store'; import StoreApi from '@/sheep/api/trade/store';
import card_order from '@/components/orderItem/card_order.vue'; import card_order from '@/components/orderItem/card_order.vue';
import AiOrderActionBar from '@/components/orderItem/AiOrderActionBar.vue'; import AiOrderActionBar from '@/components/orderItem/AiOrderActionBar.vue';
import ShipmentPopup from '@/components/orderItem/ShipmentPopup.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';
@@ -150,6 +175,7 @@
comeinType: '', // 进入订单详情的来源类型 comeinType: '', // 进入订单详情的来源类型
orderType: '', orderType: '',
source: '', source: '',
delayRecords: [],
}); });
// ========== 门店自提(核销) ========== // ========== 门店自提(核销) ==========
@@ -159,6 +185,13 @@
const onCopy = () => { const onCopy = () => {
sheep.$helper.copyText(state.orderInfo.no); sheep.$helper.copyText(state.orderInfo.no);
}; };
const formatCreateTime = (value) => {
if (!value) return '';
const s = sheep?.$helper?.timeFormat
? sheep.$helper.timeFormat(value, 'yyyy-mm-dd hh:MM:ss')
: String(value);
return s || '';
};
const pickUpVerifyRef = ref(); const pickUpVerifyRef = ref();
@@ -185,6 +218,7 @@
if (!isAiActionOrder.value) return true; if (!isAiActionOrder.value) return true;
const status = Number(state.orderInfo?.status); const status = Number(state.orderInfo?.status);
if ([0, 20].includes(status)) return true; if ([0, 20].includes(status)) return true;
if (!isAiStoreOrder.value) return false;
if (isPickUpOrder.value) return false; if (isPickUpOrder.value) return false;
return [10, 50, 70].includes(status); return [10, 50, 70].includes(status);
}); });
@@ -206,9 +240,78 @@
const resolveAiOrderId = (data) => { const resolveAiOrderId = (data) => {
return data?.id || data?.orderId; return data?.id || data?.orderId;
}; };
const isAiStoreOrder = computed(() => {
return String(state.source) === 'aishop' || String(state.orderInfo?.__source) === 'aishop';
});
const delayShipmentPopupRef = ref();
const nowShipmentPopupRef = ref();
const closeDelayShipmentPopup = () => {};
const closeNowShipmentPopup = () => {};
const openDelayShipmentPopup = () => {
const id = resolveAiOrderId(state.orderInfo);
if (!id) {
uni.showToast({
title: '订单信息异常',
icon: 'none',
});
return;
}
delayShipmentPopupRef.value?.open();
};
const openNowShipmentPopup = () => {
const id = resolveAiOrderId(state.orderInfo);
if (!id) {
uni.showToast({
title: '订单信息异常',
icon: 'none',
});
return;
}
nowShipmentPopupRef.value?.open();
};
const handleDelayShipmentSubmit = async ({ items, close }) => {
const orderId = resolveAiOrderId(state.orderInfo);
if (!orderId || !Array.isArray(items) || items.length === 0) {
return;
}
const { code } = await aiDelayedShipment({
orderId,
items,
});
if (code === 0) {
close?.();
getOrderDetail();
}
};
const handleNowShipmentSubmit = async ({ items, close }) => {
const orderId = resolveAiOrderId(state.orderInfo);
if (!orderId || !Array.isArray(items) || items.length === 0) {
return;
}
const { code } = await aiPendingShipment({
orderId,
items,
});
if (code === 0) {
close?.();
getOrderDetail();
}
};
function delayShipment() { function delayShipment() {
if (isPickUpOrder.value) return; if (isPickUpOrder.value) {
uni.showToast({
title: '自提订单不支持延迟发货',
icon: 'none',
});
return;
}
if (isAiStoreOrder.value) {
openDelayShipmentPopup();
return;
}
const id = resolveAiOrderId(state.orderInfo); const id = resolveAiOrderId(state.orderInfo);
if (!id) { if (!id) {
uni.showToast({ uni.showToast({
@@ -235,7 +338,17 @@
} }
function nowShipment() { function nowShipment() {
if (isPickUpOrder.value) return; if (isPickUpOrder.value) {
uni.showToast({
title: '自提订单不支持立即发货',
icon: 'none',
});
return;
}
if (isAiStoreOrder.value) {
openNowShipmentPopup();
return;
}
const id = resolveAiOrderId(state.orderInfo); const id = resolveAiOrderId(state.orderInfo);
if (!id) { if (!id) {
uni.showToast({ uni.showToast({
@@ -342,6 +455,26 @@
if (state.orderInfo.deliveryType === 2 && state.orderInfo.payStatus) { if (state.orderInfo.deliveryType === 2 && state.orderInfo.payStatus) {
pickUpVerifyRef.value && pickUpVerifyRef.value.markCode(res.data.pickUpVerifyCode); pickUpVerifyRef.value && pickUpVerifyRef.value.markCode(res.data.pickUpVerifyCode);
} }
// 店铺订单:延迟记录独立拉取
if (isAiStoreOrder.value) {
const orderId = resolveAiOrderId(state.orderInfo);
if (orderId) {
try {
const delayRes = await getAiOrderDelayRecords({ orderId });
if (delayRes.code === 0 && Array.isArray(delayRes.data)) {
state.delayRecords = delayRes.data;
} else {
state.delayRecords = [];
}
} catch (e) {
state.delayRecords = [];
}
} else {
state.delayRecords = [];
}
} else {
state.delayRecords = [];
}
} else { } else {
sheep.$router.back(); sheep.$router.back();
} }
@@ -659,4 +792,139 @@
box-sizing: border-box; box-sizing: border-box;
box-shadow: 0px -4px 30px 0px rgba(0, 0, 0, 0.1); box-shadow: 0px -4px 30px 0px rgba(0, 0, 0, 0.1);
} }
.delay-popup {
width: 680rpx;
max-height: 78vh;
background: #ffffff;
border-radius: 24rpx;
padding: 32rpx 24rpx;
box-sizing: border-box;
overflow: hidden;
}
.delay-popup__header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12rpx;
}
.delay-popup__title {
font-size: 34rpx;
font-weight: 600;
color: #333333;
}
.delay-popup__order-no {
margin-top: 8rpx;
font-size: 22rpx;
line-height: 32rpx;
color: #999999;
word-break: break-all;
}
.delay-popup__order-time {
margin-top: 4rpx;
font-size: 22rpx;
line-height: 32rpx;
color: #999999;
}
.delay-popup__close {
width: 56rpx;
height: 56rpx;
border-radius: 50%;
background: #f3f4f6;
line-height: 56rpx;
text-align: center;
font-size: 36rpx;
color: #666666;
}
.delay-popup__desc {
font-size: 24rpx;
color: #999999;
margin-bottom: 24rpx;
}
.delay-popup__content {
max-height: 760rpx;
}
.delay-popup__item {
display: flex;
padding: 20rpx 0;
border-bottom: 1rpx solid #f2f2f2;
}
.delay-popup__item-image {
width: 144rpx;
height: 144rpx;
border-radius: 12rpx;
flex-shrink: 0;
margin-right: 20rpx;
background: #f5f5f5;
}
.delay-popup__item-main {
flex: 1;
min-width: 0;
}
.delay-popup__item-name {
font-size: 28rpx;
line-height: 40rpx;
color: #333333;
}
.delay-popup__item-sku {
margin-top: 10rpx;
font-size: 24rpx;
line-height: 34rpx;
color: #999999;
}
.delay-popup__item-footer {
margin-top: 20rpx;
}
.delay-popup__item-count {
font-size: 24rpx;
color: #666666;
}
.delay-popup__actions {
display: flex;
align-items: center;
gap: 20rpx;
margin-top: 32rpx;
}
.delay-popup__btn {
flex: 1;
height: 84rpx;
line-height: 84rpx;
text-align: center;
border-radius: 42rpx;
font-size: 28rpx;
font-weight: 500;
}
.delay-popup__btn--ghost {
background: #f2f3f5;
color: #333333;
}
.delay-popup__btn--primary {
background: linear-gradient(135deg, #fa8735 0%, #fe3b48 100%);
color: #ffffff;
}
.now-shipment-empty {
padding: 40rpx 24rpx;
text-align: center;
font-size: 26rpx;
color: #999999;
}
</style> </style>
+15 -6
View File
@@ -344,12 +344,12 @@ export function getAiProduct(params: any) {
}); });
} }
// 延迟发货 // 延迟发货
export function aiDelayedShipment(params: any) { export function aiDelayedShipment(params : any) {
return request({ return request({
url: '/aishop/order/update/delayedShipment', url: '/aishop/order/update/delayedShipment',
method: 'post', method: 'post',
params, data: params,
}); })
} }
export function getMyShop(params: any) { export function getMyShop(params: any) {
@@ -361,10 +361,19 @@ export function getMyShop(params: any) {
} }
// 立即发货 // 立即发货
export function aiPendingShipment(params: any) { export function aiPendingShipment(params : any) {
return request({ return request({
url: '/aishop/order/update/pendingShipment', url: '/aishop/order/update/pendingShipment',
method: 'post', method: 'post',
params, data: params,
}); })
}
// 查询订单延迟记录列表
export function getAiOrderDelayRecords(params : any) {
return request({
url: '/aishop/order/delay-records',
method: 'get',
params,
})
} }