feat: 选择自提门店列展示状态

This commit is contained in:
2026-08-10 17:24:49 +08:00
parent 14fa7b32c4
commit f8f697f74b
+74 -8
View File
@@ -45,6 +45,13 @@
<view class="store-item__hd"> <view class="store-item__hd">
<view class="store-badge">#{{ index + 1 }}</view> <view class="store-badge">#{{ index + 1 }}</view>
<view class="store-name">{{ item.name }}</view> <view class="store-name">{{ item.name }}</view>
<view
v-if="getStoreStatusText(item.status)"
class="store-status"
:class="`store-status--${getStoreStatusLevel(item.status)}`"
>
{{ getStoreStatusText(item.status) }}
</view>
<view class="store-distance" v-if="item.distance !== undefined && item.distance !== null"> <view class="store-distance" v-if="item.distance !== undefined && item.distance !== null">
{{ formatDistance(item.distance) }} {{ formatDistance(item.distance) }}
</view> </view>
@@ -53,12 +60,18 @@
{{ formatAddress(item) || '--' }} {{ formatAddress(item) || '--' }}
</view> </view>
<view class="store-item__ft"> <view class="store-item__ft">
<view class="store-hours" v-if="formatBusinessHours(item)"> <view class="store-hours">
营业中 {{ formatBusinessHours(item) }} <text v-if="Number(item.status) === 1 && formatBusinessHours(item)">
营业中 {{ formatBusinessHours(item) }}
</text>
</view> </view>
<view class="store-actions"> <view class="store-actions">
<view class="btn btn--ghost" @tap.stop="showMaoLocation(item)">导航</view> <view class="btn btn--ghost" @tap.stop="showMaoLocation(item)">导航</view>
<view class="btn" @tap.stop="checked(item)">选择</view> <view
v-if="Number(item.status) === 1"
class="btn"
@tap.stop="checked(item)"
>选择</view>
</view> </view>
</view> </view>
</view> </view>
@@ -161,6 +174,10 @@
* 选中门店 * 选中门店
*/ */
const checked = (addressInfo) => { const checked = (addressInfo) => {
if (!isStoreOpen(addressInfo)) {
uni.showToast({ title: '当前门店暂不支持自提', icon: 'none' });
return;
}
uni.$emit('SELECT_PICK_UP_INFO', { uni.$emit('SELECT_PICK_UP_INFO', {
addressInfo, addressInfo,
}); });
@@ -168,6 +185,10 @@
}; };
const onSelect = (item) => { const onSelect = (item) => {
if (!isStoreOpen(item)) {
uni.showToast({ title: '当前门店暂不支持自提', icon: 'none' });
return;
}
state.selectedStoreId = Number(item?.id || 0); state.selectedStoreId = Number(item?.id || 0);
const lat = Number(item?.latitude); const lat = Number(item?.latitude);
const lon = Number(item?.longitude); const lon = Number(item?.longitude);
@@ -208,6 +229,12 @@
return `${start}-${end}`; return `${start}-${end}`;
}; };
const STORE_STATUS_TEXT = { 1: '营业中', 2: '休息中', 3: '停用' };
const STORE_STATUS_LEVEL = { 1: 'open', 2: 'rest', 3: 'closed' };
const getStoreStatusText = (status) => STORE_STATUS_TEXT[Number(status)] || '';
const getStoreStatusLevel = (status) => STORE_STATUS_LEVEL[Number(status)] || 'closed';
const isStoreOpen = (item) => Number(item?.status) === 1;
const filteredStoreList = computed(() => { const filteredStoreList = computed(() => {
const list = Array.isArray(state.storeList) ? state.storeList : []; const list = Array.isArray(state.storeList) ? state.storeList : [];
const kw = String(state.keyword || '').trim(); const kw = String(state.keyword || '').trim();
@@ -314,15 +341,18 @@
const ensureDefaultSelectedStore = async (list = []) => { const ensureDefaultSelectedStore = async (list = []) => {
const stores = Array.isArray(list) && list.length ? list : filteredStoreList.value; const stores = Array.isArray(list) && list.length ? list : filteredStoreList.value;
if (!stores.length) return null; if (!stores.length) return null;
const openStores = stores.filter((o) => isStoreOpen(o));
const candidates = openStores.length ? openStores : stores;
let target = null; let target = null;
if (Number(state.selectedStoreId) > 0) { if (Number(state.selectedStoreId) > 0) {
target = stores.find((o) => Number(o?.id || 0) === Number(state.selectedStoreId)); target = candidates.find((o) => Number(o?.id || 0) === Number(state.selectedStoreId));
} }
if (!target) { if (!target) {
target = stores.find((o) => Number(o?.latitude) && Number(o?.longitude)) || stores[0]; target =
state.selectedStoreId = Number(target?.id || 0); candidates.find((o) => Number(o?.latitude) && Number(o?.longitude)) || candidates[0];
state.selectedStoreId = isStoreOpen(target) ? Number(target?.id || 0) : 0;
} }
if (target) { if (target && isStoreOpen(target)) {
const lat = Number(target?.latitude); const lat = Number(target?.latitude);
const lon = Number(target?.longitude); const lon = Number(target?.longitude);
if (lat && lon) { if (lat && lon) {
@@ -331,7 +361,7 @@
} }
await renderMarkerIcon(target, true); await renderMarkerIcon(target, true);
} }
return target; return isStoreOpen(target) ? target : null;
}; };
const markers = computed(() => { const markers = computed(() => {
@@ -575,6 +605,31 @@
margin-left: 10rpx; margin-left: 10rpx;
} }
.store-status {
height: 32rpx;
padding: 0 12rpx;
border-radius: 999rpx;
font-size: 20rpx;
line-height: 32rpx;
margin-left: 12rpx;
flex-shrink: 0;
}
.store-status--open {
background: rgba(18, 180, 107, 0.12);
color: #12b46b;
}
.store-status--rest {
background: rgba(255, 159, 67, 0.12);
color: #ff9f43;
}
.store-status--closed {
background: rgba(153, 153, 153, 0.12);
color: #999;
}
.store-address { .store-address {
margin-top: 10rpx; margin-top: 10rpx;
font-size: 24rpx; font-size: 24rpx;
@@ -590,13 +645,22 @@
} }
.store-hours { .store-hours {
flex: 1;
min-width: 0;
height: 56rpx;
line-height: 56rpx;
font-size: 22rpx; font-size: 22rpx;
color: #12b46b; color: #12b46b;
margin-right: 14rpx;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
} }
.store-actions { .store-actions {
display: flex; display: flex;
align-items: center; align-items: center;
flex-shrink: 0;
} }
.btn { .btn {
@@ -608,10 +672,12 @@
font-size: 24rpx; font-size: 24rpx;
line-height: 56rpx; line-height: 56rpx;
margin-left: 14rpx; margin-left: 14rpx;
flex-shrink: 0;
} }
.btn--ghost { .btn--ghost {
background: rgba(37, 86, 236, 0.12); background: rgba(37, 86, 236, 0.12);
color: #2556ec; color: #2556ec;
margin-left: 0;
} }
</style> </style>