feat: 新增订单api

This commit is contained in:
2026-07-15 18:29:16 +08:00
parent 7c8352ed56
commit 4c5d0e53d7
5 changed files with 298 additions and 36 deletions
+109 -12
View File
@@ -35,10 +35,23 @@
:styles="{ fontSize: '28rpx' }"
/>
</view>
<view class="btnAdd" @tap="addStore">+ 新增网店</view>
<picker
mode="selector"
class="status-picker"
:value="statusIndex"
:range="statusOptions"
range-key="label"
@change="bindStatusChange"
>
<view class="status-picker__inner">
<text class="status-picker__text">{{ statusOptions[statusIndex].label }}</text>
<uni-icons type="bottom" size="14" color="#8a8a8a" />
</view>
</picker>
<!-- <view class="btnAdd" @tap="addStore">+ 新增网店</view> -->
</view>
<view class="table bg24">
<view class="table">
<view v-for="(row, index) in filteredList" :key="row.id" class="tr">
<view class="store-card flex-center">
<view class="store-rank">#{{ index + 1 }}</view>
@@ -61,7 +74,7 @@
<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">
<view class="store-capacity__head flex-center ju-between">
<view class="store-capacity__label">库存容量</view>
<view class="store-capacity__value">{{ row.capacityText }}</view>
@@ -72,11 +85,11 @@
:style="{ width: `${row.capacityPercent}%` }"
></view>
</view>
</view>
</view> -->
</view>
</view>
<view class="store-actions flex-center ju-flex-end">
<view class="op opPrimary" @tap="edit(row)">编辑</view>
<view v-if="showEdit" class="op opPrimary" @tap="edit(row)">编辑</view>
<view
v-if="row.toggleActionText"
class="op"
@@ -101,14 +114,23 @@
import { onShow } from '@dcloudio/uni-app';
import modeSwitch from '@/components/mode_switch/mode_switch.vue';
import sheep from '@/sheep';
import OrderStoreApi from '@/sheep/api/trade/orderStore';
import StoreApi from '@/sheep/api/trade/store';
const keyword = ref('');
const statusIndex = ref(0);
const showEdit = false;
const list = ref([]);
const loading = ref(false);
const todayOrders = ref(0);
const updatingStoreId = ref(0);
const userStore = sheep.$store('user');
const statusOptions = [
{ label: '全部状态', value: '' },
{ label: '营业中', value: 1 },
{ label: '休息中', value: 2 },
];
const toStoreIdsString = (raw) => {
if (raw === null || raw === undefined) return '';
@@ -251,10 +273,24 @@
return {
total,
open,
todayOrders: 0,
todayOrders: todayOrders.value,
};
});
const updateTodayOrders = async (storeIds = '') => {
const pickUpStoreId = toStoreIdsString(storeIds);
if (!pickUpStoreId) {
todayOrders.value = 0;
return;
}
try {
const { code, data } = await OrderStoreApi.getTodayNewCount(pickUpStoreId);
todayOrders.value = code === 0 ? Math.max(0, Number(data) || 0) : 0;
} catch (error) {
todayOrders.value = 0;
}
};
const getList = async () => {
if (loading.value) return;
loading.value = true;
@@ -262,12 +298,19 @@
const storeIds = await getUserStoreIds();
if (!storeIds) {
list.value = [];
todayOrders.value = 0;
return;
}
const status = statusOptions[statusIndex.value]?.value;
const params = status === '' ? {} : { status };
const { code, data } = await StoreApi.getStoreListByStoreIds(storeIds, params);
if (code !== 0) {
todayOrders.value = 0;
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);
await updateTodayOrders(storeIds);
} finally {
loading.value = false;
}
@@ -277,6 +320,11 @@
uni.showToast({ title: '功能开发中', icon: 'none' });
};
const bindStatusChange = (e) => {
statusIndex.value = Number(e?.detail?.value || 0);
getList();
};
const edit = () => {
uni.showToast({ title: '功能开发中', icon: 'none' });
};
@@ -366,6 +414,29 @@
background: transparent !important;
}
.status-picker {
flex-shrink: 0;
min-width: 180rpx;
border-radius: 18rpx;
background: #f6f7fb;
padding: 0 18rpx;
box-sizing: border-box;
}
.status-picker__inner {
height: 72rpx;
display: flex;
align-items: center;
justify-content: space-between;
gap: 10rpx;
}
.status-picker__text {
font-size: 24rpx;
color: #333;
white-space: nowrap;
}
.btnAdd {
padding: 14rpx 18rpx;
border-radius: 18rpx;
@@ -376,14 +447,22 @@
}
.table {
border-radius: 24rpx;
padding: 16rpx;
padding: 0;
box-sizing: border-box;
background: transparent;
}
.tr {
padding: 18rpx 0;
border-bottom: 2rpx solid #f6f7fb;
margin-bottom: 18rpx;
padding: 18rpx 18rpx 20rpx;
border-radius: 24rpx;
background: #fff;
box-shadow: 0 8rpx 24rpx rgba(15, 23, 42, 0.05);
box-sizing: border-box;
}
.tr:last-child {
margin-bottom: 0;
}
.store-rank {
@@ -537,18 +616,36 @@
.op {
font-size: 24rpx;
min-width: 120rpx;
height: 50rpx;
padding: 0 24rpx;
border-radius: 16rpx;
display: inline-flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
font-weight: 600;
border: 2rpx solid #e5e7eb;
background: #fff;
flex-shrink: 0;
}
.opPrimary {
color: #2556ec;
border-color: rgba(37, 86, 236, 0.2);
background: rgba(37, 86, 236, 0.06);
}
.opDanger {
color: #ff4d4f;
border-color: rgba(255, 77, 79, 0.28);
background: #fff5f5;
}
.opSuccess {
color: #14a44d;
border-color: rgba(20, 164, 77, 0.28);
background: #f2fbf5;
}
.opDisabled {