feat: 标记分拣、取货门店展示

This commit is contained in:
2026-07-15 10:31:51 +08:00
parent 042c19f4dc
commit eb6aed3a86
5 changed files with 292 additions and 46 deletions
+131 -11
View File
@@ -46,11 +46,26 @@
</view> </view>
</view> </view>
<view class="card-bd flex-center al-flex-start"> <view class="card-bd flex-center al-flex-start">
<image class="thumb" :src="item.picUrl" mode="aspectFill" /> <view class="thumb-stack">
<view
v-for="(pic, picIndex) in getStackPics(item)"
:key="`${item.orderId || item.id}-${picIndex}`"
class="thumb-card"
:style="{ left: `${picIndex * 22}rpx`, zIndex: getStackPics(item).length - picIndex }"
>
<image class="thumb-img" :src="resolvePicUrl(pic)" mode="aspectFill" />
</view>
<view v-if="!getStackPics(item).length" class="thumb-empty">
暂无图片
</view>
<view v-if="getPicCount(item) > 1" class="thumb-count">
{{ getPicCount(item) }}
</view>
</view>
<view class="flex1"> <view class="flex1">
<view class="name lineTwo">{{ item.spuName }}</view> <view class="name lineTwo">{{ getOrderTitle(item) }}</view>
<view class="meta c_999 size24 m-t-10">订单号:{{ item.orderNo }}</view> <view class="meta c_999 size24 m-t-10">订单号:{{ item.orderNo }}</view>
<view class="meta c_999 size24 m-t-6">取货码:{{ item.pickUpCode }}</view> <view class="meta c_999 size24 m-t-6">取货码:{{ getPickUpCode(item) || '--' }}</view>
</view> </view>
<view class="actions"> <view class="actions">
<view v-if="Number(item.status) === 0" class="btn btnPrimary" @tap="markPicked(item)"> <view v-if="Number(item.status) === 0" class="btn btnPrimary" @tap="markPicked(item)">
@@ -90,6 +105,8 @@
const displayList = computed(() => list.value); const displayList = computed(() => list.value);
const sanitizeText = (value) => String(value || '').replace(/[`"'\s]/g, '');
const pickUpStoreId = computed(() => { const pickUpStoreId = computed(() => {
const userInfo = userStore?.userInfo || {}; const userInfo = userStore?.userInfo || {};
return Number(userInfo.storeId || 0); return Number(userInfo.storeId || 0);
@@ -114,7 +131,6 @@
const getList = async () => { const getList = async () => {
if (loading.value) return; if (loading.value) return;
const storeId = await ensureStoreId(); const storeId = await ensureStoreId();
console.log('getList', storeId, );
if (!(storeId > 0)) { if (!(storeId > 0)) {
uni.showToast({ title: '缺少门店ID', icon: 'none' }); uni.showToast({ title: '缺少门店ID', icon: 'none' });
return; return;
@@ -146,10 +162,64 @@
uni.reLaunch({ url: '/pages/merchant/scanVerify' }); uni.reLaunch({ url: '/pages/merchant/scanVerify' });
}; };
const markPicked = (item) => { const getOrderItems = (item) => {
item.status = 1; return Array.isArray(item?.items) ? item.items.filter(Boolean) : [];
item.statusName = '待取货'; };
uni.showToast({ title: '已标记', icon: 'success' });
const getPicList = (item) => {
const pics = getOrderItems(item)
.map((it) => sanitizeText(it?.picUrl))
.filter(Boolean);
const fallback = sanitizeText(item?.picUrl);
return pics.length ? pics : [fallback].filter(Boolean);
};
const getStackPics = (item) => {
return getPicList(item).slice(0, 3);
};
const getPicCount = (item) => {
return getPicList(item).length;
};
const resolvePicUrl = (url) => {
const text = sanitizeText(url);
if (!text) return '';
if (/^https?:\/\//i.test(text)) return text;
return sheep.$url.cdn(text);
};
const getOrderTitle = (item) => {
const firstName = getOrderItems(item)[0]?.spuName || item?.spuName || '';
const totalCount = Number(item?.totalCount || getOrderItems(item).length || 0);
if (!firstName) return '商品信息暂无';
return totalCount > 1 ? `${firstName} 等${totalCount}件商品` : firstName;
};
const getPickUpCode = (item) => {
return item?.pickUpVerifyCode || item?.pickUpCode || '';
};
const markPicked = async (item) => {
const ids = Array.isArray(item?.ids) ? item.ids : [];
if (!ids.length) {
uni.showToast({ title: '缺少分拣ID', icon: 'none' });
return;
}
uni.showModal({
title: '提示',
content: '确认标记为已分拣吗?',
success: async ({ confirm }) => {
if (!confirm) return;
try {
const { code } = await OrderStoreApi.markSorted(ids);
if (code !== 0) return;
await getList();
} catch (error) {
uni.showToast({ title: '标记失败,请稍后重试', icon: 'none' });
}
},
});
}; };
</script> </script>
@@ -231,13 +301,63 @@
background: rgba(107, 78, 255, 0.12); background: rgba(107, 78, 255, 0.12);
} }
.thumb { .thumb-stack {
width: 184rpx;
height: 140rpx;
margin-right: 16rpx;
flex-shrink: 0;
position: relative;
}
.thumb-card {
position: absolute;
top: 0;
width: 140rpx; width: 140rpx;
height: 140rpx; height: 140rpx;
border-radius: 18rpx; border-radius: 18rpx;
margin-right: 16rpx; overflow: hidden;
flex-shrink: 0;
background: #f2f4f7; background: #f2f4f7;
box-shadow: 0 6rpx 18rpx rgba(0, 0, 0, 0.08);
border: 2rpx solid rgba(255, 255, 255, 0.9);
}
.thumb-img {
width: 100%;
height: 100%;
display: block;
}
.thumb-empty {
width: 140rpx;
height: 140rpx;
border-radius: 18rpx;
background: #f2f4f7;
color: #bbb;
font-size: 22rpx;
display: flex;
align-items: center;
justify-content: center;
border: 2rpx dashed #e3e6ee;
box-sizing: border-box;
}
.thumb-count {
position: absolute;
right: 45rpx;
bottom: 0;
min-width: 36rpx;
height: 36rpx;
padding: 0 10rpx;
font-size: 22rpx;
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
border-radius: 18rpx;
color: rgba(0, 0, 0, 0.75);
background: rgba(255, 255, 255, 0.7);
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
z-index: 5;
} }
.name { .name {
+2 -2
View File
@@ -123,7 +123,7 @@
getOrderDetail as getAiOrderDetail, getOrderDetail as getAiOrderDetail,
getOpenOrderDetail, getOpenOrderDetail,
} from '@/sheep/api/ai'; } from '@/sheep/api/ai';
import DeliveryApi from '@/sheep/api/trade/delivery'; 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 truckLine from '@/components/truckLine/truckLine.vue' import truckLine from '@/components/truckLine/truckLine.vue'
@@ -266,7 +266,7 @@
handleOrderButtons(state.orderInfo); handleOrderButtons(state.orderInfo);
// 配送方式:门店自提 // 配送方式:门店自提
if (res.data.pickUpStoreId) { if (res.data.pickUpStoreId) {
const { data } = await DeliveryApi.getDeliveryPickUpStore(res.data.pickUpStoreId); const { data } = await StoreApi.getStoreById(res.data.pickUpStoreId);
systemStore.value = data || {}; systemStore.value = data || {};
} }
if (state.orderInfo.deliveryType === 2 && state.orderInfo.payStatus) { if (state.orderInfo.deliveryType === 2 && state.orderInfo.payStatus) {
+133 -33
View File
@@ -25,7 +25,7 @@
<view class="rulesTitle flex flex-wrap align-center"> 核销时间 </view> <view class="rulesTitle flex flex-wrap align-center"> 核销时间 </view>
<view class="info"> <view class="info">
每日: 每日:
<text class="time">{{ systemStore.openingTime }} - {{ systemStore.closingTime }}</text> <text class="time">{{ openingTimeText }} - {{ closingTimeText }}</text>
</view> </view>
</view> </view>
<view class="item"> <view class="item">
@@ -39,12 +39,19 @@
</view> </view>
<view <view
v-if="orderInfo.deliveryType === 2" v-if="orderInfo.deliveryType === 2"
class="map flex flex-wrap align-center ss-row-between borRadius14" class="pickup-card borRadius14"
> >
<view>自提地址信息</view> <image v-if="coverImageUrl" class="pickup-cover" :src="coverImageUrl" mode="aspectFill" />
<view class="place cart-color flex flex-wrap flex-center" @tap="showMaoLocation"> <view class="pickup-hd">
查看位置 <view class="pickup-title">{{ systemStore.name || '自提门店' }}</view>
<view v-if="distanceText" class="pickup-distance">{{ distanceText }}</view>
</view> </view>
<view class="pickup-address">{{ pickupAddressText || '--' }}</view>
<view class="pickup-hours">
<uni-icons type="clock" size="14" color="#8c8c8c" />
<view class="pickup-hours__text">营业时间:{{ openingTimeText }} - {{ closingTimeText }}</view>
</view>
<view class="pickup-btn" @tap="showMaoLocation">查看位置导航</view>
</view> </view>
<!-- 海报画板:默认隐藏只用来生成海报。生成方式为主动调用 --> <!-- 海报画板:默认隐藏只用来生成海报。生成方式为主动调用 -->
<l-painter <l-painter
@@ -60,7 +67,7 @@
<script setup> <script setup>
import sheep from '@/sheep'; import sheep from '@/sheep';
import { reactive, ref } from 'vue'; import { computed, reactive, ref } from 'vue';
const props = defineProps({ const props = defineProps({
orderInfo: { orderInfo: {
@@ -87,26 +94,70 @@
/** /**
* 打开地图 * 打开地图
*/ */
const formatHm = (hm) => {
if (!Array.isArray(hm) || hm.length < 2) return '';
const h = String(hm[0]).padStart(2, '0');
const m = String(hm[1]).padStart(2, '0');
return `${h}:${m}`;
};
const openingTimeText = computed(() => {
return props.systemStore?.openingTime || formatHm(props.systemStore?.businessHoursStart) || '--';
});
const closingTimeText = computed(() => {
return props.systemStore?.closingTime || formatHm(props.systemStore?.businessHoursEnd) || '--';
});
const pickupAddressText = computed(() => {
const s = props.systemStore || {};
const province = s.province || '';
const city = s.city || '';
const district = s.district || '';
const address = s.address || '';
const legacy = `${s.areaName || ''}${s.detailAddress || ''}`;
return `${province}${city}${district}${address}` || legacy || s.description || '';
});
const distanceText = computed(() => {
const d = Number(props.systemStore?.distance);
if (!(d > 0)) return '';
const t = d >= 1000 ? `${(d / 1000).toFixed(1)}km` : `${Math.round(d)}m`;
return `距离${t}`;
});
const sanitizeUrl = (value) => String(value || '').replace(/[`"'\s]/g, '');
const coverImageUrl = computed(() => {
const raw = sanitizeUrl(props.systemStore?.coverImage);
if (!raw) return '';
if (/^https?:\/\//i.test(raw)) return raw;
return sheep.$url.cdn(raw);
});
const addressText = computed(() => {
const s = props.systemStore || {};
const province = s.province || '';
const city = s.city || '';
const district = s.district || '';
const description = s.description || '';
const legacy = `${s.areaName || ''}${s.detailAddress || ''}`;
return `${province}${city}${district}${description}` || legacy || s.address || '';
});
const showMaoLocation = () => { const showMaoLocation = () => {
if (!props.systemStore.latitude || !props.systemStore.longitude) { const latitude = Number(props.systemStore?.latitude);
const longitude = Number(props.systemStore?.longitude);
if (!(latitude && longitude)) {
sheep.$helper.toast('缺少经纬度信息无法查看地图!'); sheep.$helper.toast('缺少经纬度信息无法查看地图!');
return; return;
} }
uni.openLocation({ uni.openLocation({
latitude: props.systemStore.latitude, latitude,
longitude: props.systemStore.longitude, longitude,
scale: 8, scale: 8,
name: props.systemStore.name, name: props.systemStore?.name,
address: props.systemStore.areaName + props.systemStore.detailAddress, address: addressText.value,
});
};
/**
* 拨打电话
*/
const makePhone = () => {
uni.makePhoneCall({
phoneNumber: props.systemStore.phone,
}); });
}; };
@@ -270,23 +321,72 @@
margin-left: 20rpx; margin-left: 20rpx;
} }
.order-details .map { .order-details .pickup-card {
height: 86rpx;
font-size: 30rpx;
color: #282828;
line-height: 86rpx;
border-bottom: 1px solid #f0f0f0;
margin-top: 15rpx; margin-top: 15rpx;
background-color: #fff; background-color: #fff;
padding: 0 24rpx; padding: 22rpx 24rpx 24rpx;
box-sizing: border-box;
} }
.order-details .map .place { .order-details .pickup-hd {
display: flex;
align-items: center;
justify-content: space-between;
}
.order-details .pickup-title {
font-size: 30rpx;
color: #282828;
font-weight: 700;
}
.order-details .pickup-distance {
padding: 4rpx 12rpx;
border-radius: 999rpx;
font-size: 22rpx;
color: #2556ec;
background: rgba(37, 86, 236, 0.12);
}
.order-details .pickup-address {
margin-top: 10rpx;
font-size: 26rpx; font-size: 26rpx;
width: 176rpx; color: #666;
height: 50rpx; line-height: 36rpx;
border-radius: 25rpx; }
line-height: 50rpx;
text-align: center; .order-details .pickup-cover {
width: 100%;
height: 168rpx;
border-radius: 16rpx;
display: block;
margin-bottom: 14rpx;
background: #f2f4f7;
}
.order-details .pickup-hours {
margin-top: 10rpx;
display: flex;
align-items: center;
gap: 10rpx;
}
.order-details .pickup-hours__text {
font-size: 24rpx;
color: #8c8c8c;
}
.order-details .pickup-btn {
margin-top: 16rpx;
height: 76rpx;
border-radius: 16rpx;
border: 2rpx solid rgba(37, 86, 236, 0.35);
background: #fff;
color: #2556ec;
font-size: 28rpx;
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
} }
</style> </style>
+14
View File
@@ -21,6 +21,20 @@ const OrderStoreApi = {
}, },
}); });
}, },
markSorted: (ids) => {
const idText = Array.isArray(ids) ? ids.filter(Boolean).join(',') : String(ids || '');
return request({
url: '/trade/order-store/staff/mark-sorted',
method: 'PUT',
params: {
ids: idText,
},
custom: {
showSuccess: true,
successMsg: '已标记分拣',
},
});
},
}; };
export default OrderStoreApi; export default OrderStoreApi;
+12
View File
@@ -29,6 +29,18 @@ const StoreApi = {
} }
return res; return res;
}, },
getStoreById: (storeId) => {
return request({
url: '/trade/store/getStoreById',
method: 'GET',
params: {
storeId,
},
custom: {
showLoading: false,
},
});
},
}; };
export default StoreApi; export default StoreApi;