feat: 商户提货列传递门店id

This commit is contained in:
2026-07-14 18:20:00 +08:00
parent 94f8297a01
commit 042c19f4dc
3 changed files with 66 additions and 25 deletions
+10 -2
View File
@@ -1,17 +1,25 @@
<template>
<view class="mode-switch" @tap.stop="open">
<view v-if="showSwitch" class="mode-switch" @tap.stop="open">
<view class="mode-switch__text">{{ label }}</view>
<uni-icons type="bottom" size="14" color="#333" />
</view>
</template>
<script setup>
import { computed } from 'vue';
import { computed, onMounted } from 'vue';
import sheep from '@/sheep';
const appStore = sheep.$store('app');
const userStore = sheep.$store('user');
const label = computed(() => (appStore.bizMode === 'merchant' ? '商户' : '用户'));
const showSwitch = computed(() => Number(userStore?.userInfo?.storeId || 0) > 0);
onMounted(() => {
if (!userStore?.isLogin) return;
if (showSwitch.value) return;
userStore.getInfo();
});
const setMode = (mode) => {
const next = mode === 'merchant' ? 'merchant' : 'user';
+46 -22
View File
@@ -36,7 +36,7 @@
</view>
<view class="list">
<view v-for="item in filteredList" :key="item.id" class="card bg24">
<view v-for="item in displayList" :key="item.id" class="card bg24">
<view class="card-hd flex-center ju-between">
<view class="status" :class="{ statusWait: Number(item.status) === 1 }">
{{ item.statusName }}
@@ -62,14 +62,14 @@
</view>
</view>
</view>
<view v-if="filteredList.length === 0" class="empty c_999">暂无数据</view>
<view v-if="displayList.length === 0" class="empty c_999">暂无数据</view>
</view>
</view>
</s-layout>
</template>
<script setup>
import { computed, ref } from 'vue';
import { computed, ref, watch } from 'vue';
import { onShow } from '@dcloudio/uni-app';
import modeSwitch from '@/components/mode_switch/mode_switch.vue';
import sheep from '@/sheep';
@@ -77,8 +77,8 @@
const tabs = [
{ label: '全部', value: 'all' },
{ label: '待分拣', value: 'sorting' },
{ label: '待取货', value: 'wait' },
{ label: '待分拣', value: 0 },
{ label: '待取货', value: 1 },
];
const currentTab = ref('all');
@@ -86,29 +86,41 @@
const list = ref([]);
const loading = ref(false);
const userStore = sheep.$store('user');
const filteredList = computed(() => {
const k = String(keyword.value || '').trim();
return list.value.filter((item) => {
const s = Number(item.status);
const hitTab =
currentTab.value === 'all' ||
(currentTab.value === 'sorting' && s === 0) ||
(currentTab.value === 'wait' && s === 1);
if (!hitTab) return false;
if (!k) return true;
return (
String(item.orderNo).includes(k) ||
String(item.pickUpCode).includes(k) ||
String(item.spuName).includes(k)
);
});
const displayList = computed(() => list.value);
const pickUpStoreId = computed(() => {
const userInfo = userStore?.userInfo || {};
return Number(userInfo.storeId || 0);
});
const ensureStoreId = async () => {
if (pickUpStoreId.value > 0) return pickUpStoreId.value;
const userInfo = await userStore.getInfo();
return Number(userInfo?.storeId || 0);
};
const buildParams = (storeId) => {
const params = {
pickUpStoreId: storeId,
};
if (currentTab.value !== 'all') params.status = currentTab.value;
const k = String(keyword.value || '').trim();
if (k) params.keyword = k;
return params;
};
const getList = async () => {
if (loading.value) return;
const storeId = await ensureStoreId();
console.log('getList', storeId, );
if (!(storeId > 0)) {
uni.showToast({ title: '缺少门店ID', icon: 'none' });
return;
}
loading.value = true;
const { data, code } = await OrderStoreApi.getPendingList({});
const { data, code } = await OrderStoreApi.getStaffList(buildParams(storeId));
loading.value = false;
if (code !== 0) return;
list.value = Array.isArray(data) ? data : [];
@@ -118,6 +130,18 @@
getList();
});
let searchTimer = null;
watch(
[currentTab, keyword],
() => {
if (searchTimer) clearTimeout(searchTimer);
searchTimer = setTimeout(() => {
getList();
}, 300);
},
{ deep: false },
);
const goScan = () => {
uni.reLaunch({ url: '/pages/merchant/scanVerify' });
};
+10 -1
View File
@@ -11,7 +11,16 @@ const OrderStoreApi = {
},
});
},
getStaffList: (params = {}) => {
return request({
url: '/trade/order-store/staff/list',
method: 'GET',
params,
custom: {
showLoading: false,
},
});
},
};
export default OrderStoreApi;