feat:网点列表展示、启/停用api
This commit is contained in:
+140
-12
@@ -10,6 +10,15 @@
|
|||||||
</template>
|
</template>
|
||||||
<view class="page">
|
<view class="page">
|
||||||
<view class="top-bar bg24">
|
<view class="top-bar bg24">
|
||||||
|
<view v-if="storeList.length" class="store-row flex-center ju-between" @tap="openStoreSheet">
|
||||||
|
<view class="store-left flex-center">
|
||||||
|
<view class="store-label c_999 size24">当前网点</view>
|
||||||
|
<view class="store-name lineOne">{{ currentStoreName }}</view>
|
||||||
|
</view>
|
||||||
|
<view v-if="storeList.length > 1" class="store-arrow">
|
||||||
|
<uni-icons type="right" size="16" color="#7b8494" />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
<view class="tabs">
|
<view class="tabs">
|
||||||
<view
|
<view
|
||||||
v-for="item in tabs"
|
v-for="item in tabs"
|
||||||
@@ -134,6 +143,7 @@
|
|||||||
import modeSwitch from '@/components/mode_switch/mode_switch.vue';
|
import modeSwitch from '@/components/mode_switch/mode_switch.vue';
|
||||||
import sheep from '@/sheep';
|
import sheep from '@/sheep';
|
||||||
import OrderStoreApi from '@/sheep/api/trade/orderStore';
|
import OrderStoreApi from '@/sheep/api/trade/orderStore';
|
||||||
|
import StoreApi from '@/sheep/api/trade/store';
|
||||||
|
|
||||||
const tabs = [
|
const tabs = [
|
||||||
{ label: '全部', value: 'all' },
|
{ label: '全部', value: 'all' },
|
||||||
@@ -148,20 +158,97 @@
|
|||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const expandedMap = ref({});
|
const expandedMap = ref({});
|
||||||
const userStore = sheep.$store('user');
|
const userStore = sheep.$store('user');
|
||||||
|
const storeList = ref([]);
|
||||||
|
const storeIdsKey = ref('');
|
||||||
|
const selectedStoreId = ref(0);
|
||||||
|
const storeLoading = ref(false);
|
||||||
|
|
||||||
const displayList = computed(() => list.value);
|
const displayList = computed(() => list.value);
|
||||||
|
|
||||||
const sanitizeText = (value) => String(value || '').replace(/[`"'\s]/g, '');
|
const sanitizeText = (value) => String(value || '').replace(/[`"'\s]/g, '');
|
||||||
|
|
||||||
const pickUpStoreId = computed(() => {
|
const getStoreName = (store) => {
|
||||||
const userInfo = userStore?.userInfo || {};
|
const name = String(store?.name || store?.storeName || store?.title || '').trim();
|
||||||
return Number(userInfo.storeId || 0);
|
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 () => {
|
const currentStoreName = computed(() => getStoreName(currentStore.value) || '请选择网点');
|
||||||
if (pickUpStoreId.value > 0) return pickUpStoreId.value;
|
|
||||||
const userInfo = await userStore.getInfo();
|
const toStoreIdsString = (raw) => {
|
||||||
return Number(userInfo?.storeId || 0);
|
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) => {
|
const buildParams = (storeId) => {
|
||||||
@@ -176,9 +263,9 @@
|
|||||||
|
|
||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
if (loading.value) return;
|
if (loading.value) return;
|
||||||
const storeId = await ensureStoreId();
|
const storeId = await ensurePickUpStoreId();
|
||||||
if (!(storeId > 0)) {
|
if (!(storeId > 0)) {
|
||||||
uni.showToast({ title: '缺少门店ID', icon: 'none' });
|
uni.showToast({ title: '缺少网点信息', icon: 'none' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
@@ -188,13 +275,28 @@
|
|||||||
list.value = Array.isArray(data) ? data : [];
|
list.value = Array.isArray(data) ? data : [];
|
||||||
};
|
};
|
||||||
|
|
||||||
onShow(() => {
|
const openStoreSheet = () => {
|
||||||
getList();
|
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;
|
let searchTimer = null;
|
||||||
watch(
|
watch(
|
||||||
[currentTab, keyword],
|
[currentTab, keyword, selectedStoreId],
|
||||||
() => {
|
() => {
|
||||||
if (searchTimer) clearTimeout(searchTimer);
|
if (searchTimer) clearTimeout(searchTimer);
|
||||||
searchTimer = setTimeout(() => {
|
searchTimer = setTimeout(() => {
|
||||||
@@ -288,6 +390,32 @@
|
|||||||
margin-bottom: 18rpx;
|
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 {
|
.tabs {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 12rpx;
|
gap: 12rpx;
|
||||||
|
|||||||
+377
-55
@@ -39,23 +39,55 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="table bg24">
|
<view class="table bg24">
|
||||||
<view class="thead flex-center">
|
<view v-for="(row, index) in filteredList" :key="row.id" class="tr">
|
||||||
<view class="th w1">店名</view>
|
<view class="store-card flex-center">
|
||||||
<view class="th w2">编号</view>
|
<view class="store-rank">#{{ index + 1 }}</view>
|
||||||
<view class="th w3">状态</view>
|
<view class="store-cover">
|
||||||
<view class="th w4">操作</view>
|
<image
|
||||||
</view>
|
v-if="row.coverImage"
|
||||||
<view v-for="row in filteredList" :key="row.id" class="tr flex-center">
|
class="store-cover__img"
|
||||||
<view class="td w1 lineOne">{{ row.name }}</view>
|
:src="row.coverImage"
|
||||||
<view class="td w2 c_999">{{ row.code }}</view>
|
mode="aspectFill"
|
||||||
<view class="td w3">
|
/>
|
||||||
<view class="badge" :class="{ badgeOpen: row.status === 'open' }">
|
<view v-else class="store-cover__empty">暂无封面</view>
|
||||||
{{ row.status === 'open' ? '营业中' : '休息中' }}
|
</view>
|
||||||
|
<view class="store-main">
|
||||||
|
<view class="store-main__top flex-center ju-between">
|
||||||
|
<view class="store-name lineOne">{{ row.name }}</view>
|
||||||
|
<view class="badge" :class="row.statusClass">
|
||||||
|
{{ row.statusText }}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="store-code c_999">编号:{{ row.code || '--' }}</view>
|
||||||
|
<view class="store-contact c_999 lineOne">联系电话:{{ row.phone || '--' }}</view>
|
||||||
|
<view class="store-address c_999">{{ row.address || '--' }}</view>
|
||||||
|
<view class="store-capacity">
|
||||||
|
<view class="store-capacity__head flex-center ju-between">
|
||||||
|
<view class="store-capacity__label">库存容量</view>
|
||||||
|
<view class="store-capacity__value">{{ row.capacityText }}</view>
|
||||||
|
</view>
|
||||||
|
<view class="store-capacity__bar">
|
||||||
|
<view
|
||||||
|
class="store-capacity__fill"
|
||||||
|
:style="{ width: `${row.capacityPercent}%` }"
|
||||||
|
></view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="td w4 flex-center ju-flex-end">
|
<view class="store-actions flex-center ju-flex-end">
|
||||||
<view class="op opPrimary" @tap="edit(row)">编辑</view>
|
<view class="op opPrimary" @tap="edit(row)">编辑</view>
|
||||||
<view class="op opDanger" @tap="toggle(row)">{{ row.status === 'open' ? '停用' : '启用' }}</view>
|
<view
|
||||||
|
v-if="row.toggleActionText"
|
||||||
|
class="op"
|
||||||
|
:class="[
|
||||||
|
row.toggleActionText === '停用' ? 'opDanger' : 'opSuccess',
|
||||||
|
{ opDisabled: updatingStoreId === row.id },
|
||||||
|
]"
|
||||||
|
@tap="toggle(row)"
|
||||||
|
>
|
||||||
|
{{ updatingStoreId === row.id ? '处理中...' : row.toggleActionText }}
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view v-if="filteredList.length === 0" class="empty c_999">暂无数据</view>
|
<view v-if="filteredList.length === 0" class="empty c_999">暂无数据</view>
|
||||||
@@ -66,29 +98,181 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
|
import { onShow } from '@dcloudio/uni-app';
|
||||||
import modeSwitch from '@/components/mode_switch/mode_switch.vue';
|
import modeSwitch from '@/components/mode_switch/mode_switch.vue';
|
||||||
|
import sheep from '@/sheep';
|
||||||
const stats = ref({
|
import StoreApi from '@/sheep/api/trade/store';
|
||||||
total: 28,
|
|
||||||
open: 24,
|
|
||||||
todayOrders: 156,
|
|
||||||
});
|
|
||||||
|
|
||||||
const keyword = ref('');
|
const keyword = ref('');
|
||||||
|
|
||||||
const list = ref([
|
const list = ref([]);
|
||||||
{ id: 1, name: '虹桥枢纽自提站', code: 'SP-2024001', status: 'open' },
|
const loading = ref(false);
|
||||||
{ id: 2, name: '静安寺中心站', code: 'SP-2024002', status: 'open' },
|
const updatingStoreId = ref(0);
|
||||||
{ id: 3, name: '徐家汇社区站', code: 'SP-2024003', status: 'rest' },
|
const userStore = sheep.$store('user');
|
||||||
{ id: 4, name: '五角场站', code: 'SP-2024004', status: 'open' },
|
|
||||||
]);
|
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 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 getStoreCode = (store) => {
|
||||||
|
const v = store?.code ?? store?.storeCode ?? store?.no ?? store?.storeNo ?? store?.id;
|
||||||
|
return String(v ?? '').trim();
|
||||||
|
};
|
||||||
|
|
||||||
|
const getStorePhone = (store) => {
|
||||||
|
const v = store?.contactPhone ?? '';
|
||||||
|
return String(v ?? '').trim();
|
||||||
|
};
|
||||||
|
|
||||||
|
const getStoreAddress = (store) => {
|
||||||
|
const province = String(store?.province || '').trim();
|
||||||
|
const city = String(store?.city || '').trim();
|
||||||
|
const district = String(store?.district || '').trim();
|
||||||
|
const address = String(store?.address || '').trim();
|
||||||
|
const full = `${province}${city}${district}${address}`.trim();
|
||||||
|
if (full) return full;
|
||||||
|
return address;
|
||||||
|
};
|
||||||
|
|
||||||
|
const sanitizeUrl = (value) => String(value || '').replace(/[`"'\s]/g, '');
|
||||||
|
|
||||||
|
const getStoreCoverImage = (store) => {
|
||||||
|
const raw = sanitizeUrl(store?.coverImage || store?.image || store?.picUrl || '');
|
||||||
|
if (!raw) return '';
|
||||||
|
if (/^https?:\/\//i.test(raw)) return raw;
|
||||||
|
return sheep.$url.cdn(raw);
|
||||||
|
};
|
||||||
|
|
||||||
|
const statusMap = {
|
||||||
|
0: { text: '待审核', className: 'badgePending' },
|
||||||
|
1: { text: '营业中', className: 'badgeOpen' },
|
||||||
|
2: { text: '休息中', className: 'badgeRest' },
|
||||||
|
3: { text: '已关闭', className: 'badgeClosed' },
|
||||||
|
4: { text: '审核拒绝', className: 'badgeRejected' },
|
||||||
|
};
|
||||||
|
|
||||||
|
const getStoreStatus = (store) => {
|
||||||
|
const n = Number(store?.status);
|
||||||
|
return Number.isFinite(n) ? n : -1;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getCapacityInfo = (store) => {
|
||||||
|
const stock = Math.max(0, Number(store?.stock) || 0);
|
||||||
|
const minSales = Math.max(0, Number(store?.minSales) || 0);
|
||||||
|
if (!(stock > 0)) {
|
||||||
|
return {
|
||||||
|
percent: 0,
|
||||||
|
text: '--',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// 当前接口仅返回 stock,没有总容量字段,这里用一个可读的梯度进度来表达库存量级
|
||||||
|
const percent = Math.max(8, Math.min(100, Math.round((stock / Math.max(stock, 100)) * 100)));
|
||||||
|
return {
|
||||||
|
percent,
|
||||||
|
text: minSales > 0 ? `${stock} / 最低销量${minSales}` : `${stock}`,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const normalizeRow = (store) => {
|
||||||
|
const status = getStoreStatus(store);
|
||||||
|
const statusConfig = statusMap[status] || { text: '--', className: '' };
|
||||||
|
const toggleActionText = status === 1 ? '停用' : status === 2 || status === 3 ? '启用' : '';
|
||||||
|
const capacityInfo = getCapacityInfo(store);
|
||||||
|
return {
|
||||||
|
id: Number(store?.id || 0),
|
||||||
|
name: getStoreName(store),
|
||||||
|
code: getStoreCode(store),
|
||||||
|
phone: getStorePhone(store),
|
||||||
|
address: getStoreAddress(store),
|
||||||
|
coverImage: getStoreCoverImage(store),
|
||||||
|
capacityPercent: capacityInfo.percent,
|
||||||
|
capacityText: capacityInfo.text,
|
||||||
|
status,
|
||||||
|
statusText: statusConfig.text,
|
||||||
|
statusClass: statusConfig.className,
|
||||||
|
isOpen: status === 1,
|
||||||
|
toggleActionText,
|
||||||
|
raw: store,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const filteredList = computed(() => {
|
const filteredList = computed(() => {
|
||||||
const k = String(keyword.value || '').trim();
|
const k = String(keyword.value || '').trim();
|
||||||
if (!k) return list.value;
|
if (!k) return list.value;
|
||||||
return list.value.filter((row) => String(row.name).includes(k) || String(row.code).includes(k));
|
return list.value.filter(
|
||||||
|
(row) =>
|
||||||
|
String(row.name).includes(k) ||
|
||||||
|
String(row.code).includes(k) ||
|
||||||
|
String(row.phone).includes(k) ||
|
||||||
|
String(row.address).includes(k),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const stats = computed(() => {
|
||||||
|
const total = Array.isArray(list.value) ? list.value.length : 0;
|
||||||
|
const open = Array.isArray(list.value) ? list.value.filter((r) => r.isOpen).length : 0;
|
||||||
|
return {
|
||||||
|
total,
|
||||||
|
open,
|
||||||
|
todayOrders: 0,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const getList = async () => {
|
||||||
|
if (loading.value) return;
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
const storeIds = await getUserStoreIds();
|
||||||
|
if (!storeIds) {
|
||||||
|
list.value = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const { code, data } = await StoreApi.getStoreListByStoreIds(storeIds);
|
||||||
|
if (code !== 0) return;
|
||||||
|
const rows = Array.isArray(data) ? data : [];
|
||||||
|
list.value = rows.map(normalizeRow).filter((r) => r.id > 0);
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const addStore = () => {
|
const addStore = () => {
|
||||||
uni.showToast({ title: '功能开发中', icon: 'none' });
|
uni.showToast({ title: '功能开发中', icon: 'none' });
|
||||||
};
|
};
|
||||||
@@ -98,9 +282,33 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const toggle = (row) => {
|
const toggle = (row) => {
|
||||||
row.status = row.status === 'open' ? 'rest' : 'open';
|
const storeId = Number(row?.id || 0);
|
||||||
uni.showToast({ title: '已更新', icon: 'success' });
|
const nextStatus = row?.status === 1 ? 2 : row?.status === 2 || row?.status === 3 ? 1 : 0;
|
||||||
|
const actionText = nextStatus === 1 ? '启用' : '停用';
|
||||||
|
if (!(storeId > 0) || !(nextStatus === 1 || nextStatus === 2) || updatingStoreId.value === storeId) return;
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: `确认${actionText}该网店吗?`,
|
||||||
|
success: async ({ confirm }) => {
|
||||||
|
if (!confirm) return;
|
||||||
|
updatingStoreId.value = storeId;
|
||||||
|
try {
|
||||||
|
const { code } = await StoreApi.updateStatus(storeId, nextStatus);
|
||||||
|
if (code !== 0) return;
|
||||||
|
uni.showToast({ title: `${actionText}成功`, icon: 'success' });
|
||||||
|
await getList();
|
||||||
|
} catch (error) {
|
||||||
|
uni.showToast({ title: `${actionText}失败,请稍后重试`, icon: 'none' });
|
||||||
|
} finally {
|
||||||
|
updatingStoreId.value = 0;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onShow(() => {
|
||||||
|
getList();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -173,46 +381,133 @@
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.thead {
|
|
||||||
padding: 10rpx 0;
|
|
||||||
border-bottom: 2rpx solid #f1f2f6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tr {
|
.tr {
|
||||||
padding: 18rpx 0;
|
padding: 18rpx 0;
|
||||||
border-bottom: 2rpx solid #f6f7fb;
|
border-bottom: 2rpx solid #f6f7fb;
|
||||||
}
|
}
|
||||||
|
|
||||||
.th,
|
.store-rank {
|
||||||
.td {
|
position: absolute;
|
||||||
font-size: 24rpx;
|
left: 0;
|
||||||
color: #333;
|
top: 0;
|
||||||
}
|
min-width: 68rpx;
|
||||||
|
height: 36rpx;
|
||||||
.w1 {
|
padding: 0 12rpx;
|
||||||
width: 34%;
|
border-radius: 0 18rpx 18rpx 0;
|
||||||
}
|
background: rgba(37, 86, 236, 0.1);
|
||||||
|
color: #2556ec;
|
||||||
.w2 {
|
font-size: 22rpx;
|
||||||
width: 26%;
|
font-weight: 700;
|
||||||
}
|
|
||||||
|
|
||||||
.w3 {
|
|
||||||
width: 18%;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.w4 {
|
.store-card {
|
||||||
width: 22%;
|
position: relative;
|
||||||
|
align-items: flex-start;
|
||||||
|
padding-top: 52rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-cover {
|
||||||
|
width: 120rpx;
|
||||||
|
height: 120rpx;
|
||||||
|
border-radius: 18rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
flex-shrink: 0;
|
||||||
|
background: #f2f4f7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-cover__img,
|
||||||
|
.store-cover__empty {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-cover__img {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-cover__empty {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: #b4bcc8;
|
||||||
|
font-size: 22rpx;
|
||||||
|
border: 2rpx dashed #e5e7eb;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-main {
|
||||||
|
min-width: 0;
|
||||||
|
flex: 1;
|
||||||
|
margin-left: 18rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-main__top {
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-name {
|
||||||
|
min-width: 0;
|
||||||
|
flex: 1;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #222;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-code {
|
||||||
|
margin-top: 12rpx;
|
||||||
|
font-size: 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-contact,
|
||||||
|
.store-address {
|
||||||
|
margin-top: 8rpx;
|
||||||
|
font-size: 24rpx;
|
||||||
|
line-height: 34rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-capacity {
|
||||||
|
margin-top: 14rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-capacity__head {
|
||||||
|
margin-bottom: 8rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-capacity__label,
|
||||||
|
.store-capacity__value {
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: #667085;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-capacity__bar {
|
||||||
|
width: 100%;
|
||||||
|
height: 12rpx;
|
||||||
|
border-radius: 999rpx;
|
||||||
|
background: #edf1f7;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-capacity__fill {
|
||||||
|
height: 100%;
|
||||||
|
border-radius: 999rpx;
|
||||||
|
background: linear-gradient(90deg, #2556ec 0%, #5b8cff 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-actions {
|
||||||
|
margin-top: 18rpx;
|
||||||
|
gap: 18rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.badge {
|
.badge {
|
||||||
padding: 6rpx 12rpx;
|
padding: 6rpx 12rpx;
|
||||||
border-radius: 999rpx;
|
border-radius: 999rpx;
|
||||||
font-size: 22rpx;
|
font-size: 22rpx;
|
||||||
color: #ff7a00;
|
flex-shrink: 0;
|
||||||
background: rgba(255, 122, 0, 0.12);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.badgeOpen {
|
.badgeOpen {
|
||||||
@@ -220,9 +515,28 @@
|
|||||||
background: rgba(20, 164, 77, 0.12);
|
background: rgba(20, 164, 77, 0.12);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.badgePending {
|
||||||
|
color: #ff8a00;
|
||||||
|
background: rgba(255, 138, 0, 0.12);
|
||||||
|
}
|
||||||
|
|
||||||
|
.badgeRest {
|
||||||
|
color: #5b4eff;
|
||||||
|
background: rgba(91, 78, 255, 0.12);
|
||||||
|
}
|
||||||
|
|
||||||
|
.badgeClosed {
|
||||||
|
color: #8c8c8c;
|
||||||
|
background: rgba(140, 140, 140, 0.12);
|
||||||
|
}
|
||||||
|
|
||||||
|
.badgeRejected {
|
||||||
|
color: #ff4d4f;
|
||||||
|
background: rgba(255, 77, 79, 0.12);
|
||||||
|
}
|
||||||
|
|
||||||
.op {
|
.op {
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
margin-left: 14rpx;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.opPrimary {
|
.opPrimary {
|
||||||
@@ -233,6 +547,14 @@
|
|||||||
color: #ff4d4f;
|
color: #ff4d4f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.opSuccess {
|
||||||
|
color: #14a44d;
|
||||||
|
}
|
||||||
|
|
||||||
|
.opDisabled {
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
|
||||||
.empty {
|
.empty {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 80rpx 0;
|
padding: 80rpx 0;
|
||||||
|
|||||||
@@ -29,6 +29,22 @@ const StoreApi = {
|
|||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
|
getStoreListByStoreIds: async (storeIds) => {
|
||||||
|
const res = await request({
|
||||||
|
url: '/trade/store/list-by-store-ids',
|
||||||
|
method: 'GET',
|
||||||
|
params: {
|
||||||
|
storeIds,
|
||||||
|
},
|
||||||
|
custom: {
|
||||||
|
showLoading: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (res?.code === 0) {
|
||||||
|
res.data = normalizeList(res.data);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
},
|
||||||
getStoreById: (storeId) => {
|
getStoreById: (storeId) => {
|
||||||
return request({
|
return request({
|
||||||
url: '/trade/store/getStoreById',
|
url: '/trade/store/getStoreById',
|
||||||
@@ -41,6 +57,19 @@ const StoreApi = {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
updateStatus: (storeId, status) => {
|
||||||
|
return request({
|
||||||
|
url: '/trade/store/update-status',
|
||||||
|
method: 'PUT',
|
||||||
|
params: {
|
||||||
|
storeId,
|
||||||
|
status,
|
||||||
|
},
|
||||||
|
custom: {
|
||||||
|
showLoading: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default StoreApi;
|
export default StoreApi;
|
||||||
|
|||||||
Reference in New Issue
Block a user