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
+153 -14
View File
@@ -59,6 +59,14 @@
下单时间:{{ sheep.$helper.timeFormat(item.createTime, 'yyyy-mm-dd hh:MM') }}
</view>
</view>
<view v-if="getReceiverName(item) || getMaskedReceiverMobile(item)" class="buyer-top">
<view class="buyer-top__left">
<text v-if="getReceiverName(item)" class="buyer-top__name">{{ getReceiverName(item) }}</text>
<text v-if="getMaskedReceiverMobile(item)" class="buyer-top__mobile">
{{ getMaskedReceiverMobile(item) }}
</text>
</view>
</view>
<view class="card-bd flex-center al-flex-start">
<view class="goods-thumb">
<image
@@ -75,15 +83,27 @@
规格:{{ getItemSpec(getMainItem(item)) }}
</view>
<view class="meta c_999 size24 m-t-8">数量:x{{ getMainItem(item)?.count || 0 }}</view>
<view class="meta c_999 size24 m-t-10">订单号:{{ item.orderNo }}</view>
<view class="order-no-row c_999 size24 m-t-10">
<text class="order-no-row__text">订单号:{{ item.orderNo || '--' }}</text>
<view v-if="item.orderNo" class="order-no-row__copy" @tap.stop="copyOrderNo(item.orderNo)">
<image class="order-no-row__copy-icon" :src="`${$url}goods/copy2.svg`" mode="scaleToFill" />
</view>
</view>
</view>
<view class="actions">
<view v-if="Number(item.status) === 0" class="btn btnPrimary" @tap="markPicked(item)">
标记已分拣
</view>
<view v-else-if="Number(item.status) === 1" class="btn btnOutline" @tap="goScan">
去核销
</view>
</view>
<view
v-if="getReceiverMobileDigits(item) || Number(item.status) === 0 || Number(item.status) === 1"
class="actions"
>
<view v-if="getReceiverMobileDigits(item)" class="btn btnGhost" @tap.stop="callReceiver(item)">
<uni-icons type="phone" size="16" color="#2556ec" />
<text>拨打电话</text>
</view>
<view v-if="Number(item.status) === 0" class="btn btnPrimary" @tap="markPicked(item)">
标记已分拣
</view>
<view v-else-if="Number(item.status) === 1" class="btn btnOutline" @tap="goScan">
去核销
</view>
</view>
<view
@@ -346,6 +366,49 @@
return goods?.spec || '';
};
const getReceiverName = (item) => {
return String(item?.receiverName || item?.userName || item?.nickname || '').trim();
};
const maskMobile = (mobile) => {
const digits = String(mobile || '').replace(/\D/g, '');
if (digits.length < 7) return String(mobile || '').trim();
if (digits.length === 11) return `${digits.slice(0, 3)}****${digits.slice(7)}`;
return `${digits.slice(0, 3)}**${digits.slice(-4)}`;
};
const getMaskedReceiverMobile = (item) => {
const mobile = String(item?.receiverMobile || item?.receiverPhone || item?.mobile || '').trim();
return mobile ? maskMobile(mobile) : '';
};
const getReceiverMobileDigits = (item) => {
return String(item?.receiverMobile || item?.receiverPhone || item?.mobile || '').replace(/\D/g, '');
};
const callReceiver = (item) => {
const phoneNumber = getReceiverMobileDigits(item);
if (!phoneNumber) {
uni.showToast({ title: '暂无手机号', icon: 'none' });
return;
}
uni.makePhoneCall({
phoneNumber,
fail: () => {
uni.showToast({ title: '拨打失败', icon: 'none' });
},
});
};
const copyOrderNo = (orderNo) => {
const text = String(orderNo || '').trim();
if (!text) {
uni.showToast({ title: '暂无订单号', icon: 'none' });
return;
}
sheep.$helper.copyText(text);
};
const getExpandKey = (item) => {
return String(item?.orderId || item?.id || '');
};
@@ -481,6 +544,38 @@
margin-bottom: 14rpx;
}
.buyer-top {
display: flex;
align-items: center;
gap: 12rpx;
padding: 10rpx 12rpx;
border-radius: 16rpx;
background: #f7f8fc;
margin-bottom: 14rpx;
}
.buyer-top__left {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 12rpx;
min-width: 0;
flex: 1;
}
.buyer-top__name {
font-size: 24rpx;
line-height: 34rpx;
color: #222;
font-weight: 600;
}
.buyer-top__mobile {
font-size: 24rpx;
line-height: 34rpx;
color: #7b8494;
}
.status-wrap {
display: flex;
align-items: center;
@@ -542,20 +637,56 @@
font-weight: 600;
}
.order-no-row {
display: flex;
align-items: center;
gap: 10rpx;
min-width: 0;
}
.order-no-row__text {
min-width: 0;
flex: 0 1 auto;
}
.order-no-row__copy {
width: 24rpx;
height: 24rpx;
display: inline-flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.order-no-row__copy-icon {
width: 100%;
height: 100%;
display: block;
}
.actions {
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 12rpx;
flex-shrink: 0;
margin-left: 14rpx;
align-items: center;
justify-content: flex-end;
gap: 16rpx;
margin-top: 16rpx;
padding-top: 16rpx;
border-top: 2rpx solid #f1f3f7;
}
.btn {
padding: 14rpx 20rpx;
min-width: 176rpx;
height: 64rpx;
padding: 0 26rpx;
border-radius: 18rpx;
font-size: 24rpx;
line-height: 1;
display: inline-flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
font-weight: 600;
gap: 8rpx;
}
.btnPrimary {
@@ -568,6 +699,14 @@
color: #2556ec;
}
.btnGhost {
min-width: 0;
padding: 0 20rpx;
border: 2rpx solid #dbe3f2;
color: #2556ec;
background: #f7faff;
}
.fold-box {
margin-top: 16rpx;
border-radius: 18rpx;
+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 {