diff --git a/pages/merchant/pickupList.vue b/pages/merchant/pickupList.vue index c22b0dc..e10152c 100644 --- a/pages/merchant/pickupList.vue +++ b/pages/merchant/pickupList.vue @@ -10,6 +10,15 @@ + + + 当前网点 + {{ currentStoreName }} + + + + + list.value); const sanitizeText = (value) => String(value || '').replace(/[`"'\s]/g, ''); - const pickUpStoreId = computed(() => { - const userInfo = userStore?.userInfo || {}; - return Number(userInfo.storeId || 0); + const getStoreName = (store) => { + const name = String(store?.name || store?.storeName || store?.title || '').trim(); + if (name) return name; + const id = Number(store?.id || 0); + return id ? `网点${id}` : ''; + }; + + const currentStore = computed(() => { + const id = Number(selectedStoreId.value || 0); + const list = Array.isArray(storeList.value) ? storeList.value : []; + return list.find((s) => Number(s?.id || 0) === id) || list[0] || {}; }); - const ensureStoreId = async () => { - if (pickUpStoreId.value > 0) return pickUpStoreId.value; - const userInfo = await userStore.getInfo(); - return Number(userInfo?.storeId || 0); + const currentStoreName = computed(() => getStoreName(currentStore.value) || '请选择网点'); + + const toStoreIdsString = (raw) => { + if (raw === null || raw === undefined) return ''; + if (Array.isArray(raw)) { + return raw.map((v) => String(v).trim()).filter(Boolean).join(','); + } + const s = String(raw).trim(); + if (!s) return ''; + if (s.includes(',')) return s.replace(/\s+/g, ''); + const n = Number(s); + if (Number.isFinite(n) && n > 0) return String(n); + return s.replace(/\s+/g, ''); + }; + + const getUserStoreIds = async () => { + const local = userStore?.userInfo || {}; + const fromLocal = + local.storeIds ?? + local.storeIdList ?? + local.pickUpStoreIds ?? + local.pickUpStoreIdList ?? + local.storeId; + let storeIds = toStoreIdsString(fromLocal); + if (storeIds) return storeIds; + const fetched = await userStore.getInfo(); + const fromFetched = + fetched?.storeIds ?? + fetched?.storeIdList ?? + fetched?.pickUpStoreIds ?? + fetched?.pickUpStoreIdList ?? + fetched?.storeId; + storeIds = toStoreIdsString(fromFetched); + return storeIds; + }; + + const ensureStoreList = async () => { + const storeIds = await getUserStoreIds(); + if (!storeIds) { + storeList.value = []; + storeIdsKey.value = ''; + selectedStoreId.value = 0; + return ''; + } + if (storeLoading.value) return storeIds; + if (storeIdsKey.value === storeIds && storeList.value.length) return storeIds; + storeLoading.value = true; + try { + const { code, data } = await StoreApi.getStoreListByStoreIds(storeIds); + if (code !== 0) return storeIds; + storeList.value = Array.isArray(data) ? data : []; + storeIdsKey.value = storeIds; + const currentSelected = Number(selectedStoreId.value || 0); + const existsSelected = storeList.value.some((s) => Number(s?.id || 0) === currentSelected); + if (!existsSelected) { + const preferred = Number(userStore?.userInfo?.storeId || 0); + const nextFromPreferred = storeList.value.find((s) => Number(s?.id || 0) === preferred); + const nextId = Number(nextFromPreferred?.id || storeList.value[0]?.id || 0); + if (nextId > 0) selectedStoreId.value = nextId; + } + return storeIds; + } finally { + storeLoading.value = false; + } + }; + + const ensurePickUpStoreId = async () => { + await ensureStoreList(); + return Number(selectedStoreId.value || 0); }; const buildParams = (storeId) => { @@ -176,9 +263,9 @@ const getList = async () => { if (loading.value) return; - const storeId = await ensureStoreId(); + const storeId = await ensurePickUpStoreId(); if (!(storeId > 0)) { - uni.showToast({ title: '缺少门店ID', icon: 'none' }); + uni.showToast({ title: '缺少网点信息', icon: 'none' }); return; } loading.value = true; @@ -188,13 +275,28 @@ list.value = Array.isArray(data) ? data : []; }; - onShow(() => { - getList(); + const openStoreSheet = () => { + if (storeList.value.length <= 1) return; + const itemList = storeList.value.map((s) => getStoreName(s) || '未命名网点'); + uni.showActionSheet({ + itemList, + success: ({ tapIndex }) => { + const next = Number(storeList.value?.[tapIndex]?.id || 0); + if (next > 0 && next !== selectedStoreId.value) { + selectedStoreId.value = next; + } + }, + }); + }; + + onShow(async () => { + await ensureStoreList(); + await getList(); }); let searchTimer = null; watch( - [currentTab, keyword], + [currentTab, keyword, selectedStoreId], () => { if (searchTimer) clearTimeout(searchTimer); searchTimer = setTimeout(() => { @@ -288,6 +390,32 @@ margin-bottom: 18rpx; } + .store-row { + padding: 10rpx 4rpx 14rpx; + border-bottom: 2rpx solid #f1f2f6; + margin-bottom: 14rpx; + } + + .store-left { + min-width: 0; + gap: 12rpx; + } + + .store-label { + flex-shrink: 0; + } + + .store-name { + font-size: 28rpx; + color: #222; + font-weight: 600; + max-width: 520rpx; + } + + .store-arrow { + flex-shrink: 0; + } + .tabs { display: flex; gap: 12rpx; diff --git a/pages/merchant/storeManage.vue b/pages/merchant/storeManage.vue index 2caf045..c117167 100644 --- a/pages/merchant/storeManage.vue +++ b/pages/merchant/storeManage.vue @@ -39,23 +39,55 @@ - - 店名 - 编号 - 状态 - 操作 - - - {{ row.name }} - {{ row.code }} - - - {{ row.status === 'open' ? '营业中' : '休息中' }} + + + #{{ index + 1 }} + + + 暂无封面 + + + + {{ row.name }} + + {{ row.statusText }} + + + 编号:{{ row.code || '--' }} + 联系电话:{{ row.phone || '--' }} + {{ row.address || '--' }} + + + 库存容量 + {{ row.capacityText }} + + + + + - + 编辑 - {{ row.status === 'open' ? '停用' : '启用' }} + + {{ updatingStoreId === row.id ? '处理中...' : row.toggleActionText }} + 暂无数据 @@ -66,29 +98,181 @@