feat: 提货清单隐藏取货码
This commit is contained in:
@@ -36,7 +36,7 @@
|
|||||||
<uni-easyinput
|
<uni-easyinput
|
||||||
class="search-input flex1"
|
class="search-input flex1"
|
||||||
v-model="keyword"
|
v-model="keyword"
|
||||||
placeholder="搜索订单号/取货码/商品名称"
|
placeholder="搜索订单号/商品名称"
|
||||||
:inputBorder="false"
|
:inputBorder="false"
|
||||||
:styles="{ fontSize: '28rpx' }"
|
:styles="{ fontSize: '28rpx' }"
|
||||||
/>
|
/>
|
||||||
@@ -76,7 +76,6 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="meta c_999 size24 m-t-8">数量:x{{ getMainItem(item)?.count || 0 }}</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="meta c_999 size24 m-t-10">订单号:{{ item.orderNo }}</view>
|
||||||
<view class="meta c_999 size24 m-t-6">取货码:{{ getPickUpCode(item) || '--' }}</view>
|
|
||||||
</view>
|
</view>
|
||||||
<view class="actions">
|
<view class="actions">
|
||||||
<view v-if="Number(item.status) === 0" class="btn btnPrimary" @tap="markPicked(item)">
|
<view v-if="Number(item.status) === 0" class="btn btnPrimary" @tap="markPicked(item)">
|
||||||
@@ -162,6 +161,7 @@
|
|||||||
const storeIdsKey = ref('');
|
const storeIdsKey = ref('');
|
||||||
const selectedStoreId = ref(0);
|
const selectedStoreId = ref(0);
|
||||||
const storeLoading = ref(false);
|
const storeLoading = ref(false);
|
||||||
|
const STORE_SELECTED_KEY = 'merchant.pickup.selectedStoreId';
|
||||||
|
|
||||||
const displayList = computed(() => list.value);
|
const displayList = computed(() => list.value);
|
||||||
|
|
||||||
@@ -290,7 +290,11 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
onShow(async () => {
|
onShow(async () => {
|
||||||
|
const saved = Number(uni.getStorageSync(STORE_SELECTED_KEY) || 0);
|
||||||
|
if (saved > 0 && saved !== selectedStoreId.value) selectedStoreId.value = saved;
|
||||||
await ensureStoreList();
|
await ensureStoreList();
|
||||||
|
const current = Number(selectedStoreId.value || 0);
|
||||||
|
if (current > 0) uni.setStorageSync(STORE_SELECTED_KEY, current);
|
||||||
await getList();
|
await getList();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -306,6 +310,15 @@
|
|||||||
{ deep: false },
|
{ deep: false },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
selectedStoreId,
|
||||||
|
(v) => {
|
||||||
|
const n = Number(v || 0);
|
||||||
|
if (n > 0) uni.setStorageSync(STORE_SELECTED_KEY, n);
|
||||||
|
},
|
||||||
|
{ deep: false },
|
||||||
|
);
|
||||||
|
|
||||||
const goScan = () => {
|
const goScan = () => {
|
||||||
uni.reLaunch({ url: '/pages/merchant/scanVerify' });
|
uni.reLaunch({ url: '/pages/merchant/scanVerify' });
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
<view class="records bg24">
|
<view class="records bg24">
|
||||||
<view class="records-hd flex-center ju-between">
|
<view class="records-hd flex-center ju-between">
|
||||||
<view class="records-title">近期核销记录</view>
|
<view class="records-title">近期核销记录</view>
|
||||||
<view class="records-link" @tap="clear">清空</view>
|
<view class="records-link" @tap="refreshRecords">刷新</view>
|
||||||
</view>
|
</view>
|
||||||
<view v-for="row in records" :key="row.id" class="record flex-center ju-between">
|
<view v-for="row in records" :key="row.id" class="record flex-center ju-between">
|
||||||
<view class="record-left">
|
<view class="record-left">
|
||||||
@@ -66,6 +66,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue';
|
import { 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';
|
import sheep from '@/sheep';
|
||||||
import OrderStoreApi from '@/sheep/api/trade/orderStore';
|
import OrderStoreApi from '@/sheep/api/trade/orderStore';
|
||||||
@@ -75,55 +76,62 @@
|
|||||||
const verifying = ref(false);
|
const verifying = ref(false);
|
||||||
const userStore = sheep.$store('user');
|
const userStore = sheep.$store('user');
|
||||||
|
|
||||||
const STORAGE_KEY = 'merchant.verify.records';
|
const STORE_SELECTED_KEY = 'merchant.pickup.selectedStoreId';
|
||||||
const records = ref(uni.getStorageSync(STORAGE_KEY) || []);
|
const days = ref(7);
|
||||||
|
const records = ref([]);
|
||||||
|
|
||||||
const pushRecord = (code) => {
|
const formatRecordTime = (value) => {
|
||||||
const next = [
|
if (value === null || value === undefined) return '';
|
||||||
{
|
if (typeof value === 'string') {
|
||||||
id: `${Date.now()}-${Math.random()}`,
|
const s = value.trim();
|
||||||
code,
|
if (!s) return '';
|
||||||
time: new Date().toLocaleString(),
|
const n = Number(s);
|
||||||
operator: '当前账号',
|
if (Number.isFinite(n)) return new Date(n).toLocaleString();
|
||||||
},
|
const d = new Date(s);
|
||||||
...records.value,
|
if (!Number.isNaN(d.getTime())) return d.toLocaleString();
|
||||||
].slice(0, 20);
|
return s;
|
||||||
records.value = next;
|
|
||||||
uni.setStorageSync(STORAGE_KEY, next);
|
|
||||||
};
|
|
||||||
|
|
||||||
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();
|
const n = Number(value);
|
||||||
if (!s) return '';
|
if (Number.isFinite(n)) return new Date(n).toLocaleString();
|
||||||
if (s.includes(',')) return s.replace(/\s+/g, '');
|
const d = new Date(value);
|
||||||
const n = Number(s);
|
if (!Number.isNaN(d.getTime())) return d.toLocaleString();
|
||||||
if (Number.isFinite(n) && n > 0) return String(n);
|
return String(value);
|
||||||
return s.replace(/\s+/g, '');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getVerifyIds = async () => {
|
const mapRecentRow = (row, index) => {
|
||||||
const local = userStore?.userInfo || {};
|
const raw = row || {};
|
||||||
const fromLocal =
|
const code = String(raw.pickUpVerifyCode || raw.pickUpCode || raw.code || '').trim();
|
||||||
local.storeIds ??
|
const time = formatRecordTime(raw.completeTime || raw.completedTime || raw.verifyTime || raw.updateTime);
|
||||||
local.storeIdList ??
|
const operator = String(raw.operatorName || raw.staffName || raw.operator || raw.creator || '').trim();
|
||||||
local.pickUpStoreIds ??
|
const id = String(raw.id || raw.orderId || code || `${Date.now()}-${index}`);
|
||||||
local.pickUpStoreIdList ??
|
return { id, code, time, operator };
|
||||||
local.storeId;
|
};
|
||||||
let storeIds = toStoreIdsString(fromLocal);
|
|
||||||
if (storeIds) return storeIds;
|
const getPickUpStoreId = async () => {
|
||||||
|
const stored = Number(uni.getStorageSync(STORE_SELECTED_KEY) || 0);
|
||||||
|
if (stored > 0) return stored;
|
||||||
|
const local = Number(userStore?.userInfo?.storeId || 0);
|
||||||
|
if (local > 0) return local;
|
||||||
const fetched = await userStore.getInfo();
|
const fetched = await userStore.getInfo();
|
||||||
const fromFetched =
|
return Number(fetched?.storeId || 0);
|
||||||
fetched?.storeIds ??
|
};
|
||||||
fetched?.storeIdList ??
|
|
||||||
fetched?.pickUpStoreIds ??
|
const loadRecentRecords = async () => {
|
||||||
fetched?.pickUpStoreIdList ??
|
const storeId = await getPickUpStoreId();
|
||||||
fetched?.storeId;
|
if (!(storeId > 0)) {
|
||||||
storeIds = toStoreIdsString(fromFetched);
|
records.value = [];
|
||||||
return storeIds;
|
return;
|
||||||
|
}
|
||||||
|
const { code, data } = await OrderStoreApi.getRecentCompleted(storeId, days.value);
|
||||||
|
if (code !== 0) return;
|
||||||
|
const list = Array.isArray(data)
|
||||||
|
? data
|
||||||
|
: Array.isArray(data?.list)
|
||||||
|
? data.list
|
||||||
|
: Array.isArray(data?.records)
|
||||||
|
? data.records
|
||||||
|
: [];
|
||||||
|
records.value = list.map(mapRecentRow).filter((v) => v.code);
|
||||||
};
|
};
|
||||||
|
|
||||||
const verifyCode = async (code) => {
|
const verifyCode = async (code) => {
|
||||||
@@ -133,16 +141,11 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (verifying.value) return false;
|
if (verifying.value) return false;
|
||||||
const ids = await getVerifyIds();
|
|
||||||
if (!ids) {
|
|
||||||
uni.showToast({ title: '缺少门店ID', icon: 'none' });
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
verifying.value = true;
|
verifying.value = true;
|
||||||
try {
|
try {
|
||||||
const { code: resCode } = await OrderStoreApi.verify(ids, pickUpVerifyCode);
|
const { code: resCode } = await OrderStoreApi.verify(pickUpVerifyCode);
|
||||||
if (resCode !== 0) return false;
|
if (resCode !== 0) return false;
|
||||||
pushRecord(pickUpVerifyCode);
|
await loadRecentRecords();
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
uni.showToast({ title: '核销失败,请稍后重试', icon: 'none' });
|
uni.showToast({ title: '核销失败,请稍后重试', icon: 'none' });
|
||||||
@@ -182,10 +185,13 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const clear = () => {
|
const refreshRecords = async () => {
|
||||||
records.value = [];
|
await loadRecentRecords();
|
||||||
uni.setStorageSync(STORAGE_KEY, []);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onShow(async () => {
|
||||||
|
await loadRecentRecords();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
@@ -19,7 +19,9 @@
|
|||||||
<view class="gear">
|
<view class="gear">
|
||||||
<image :src="sheep.$url.static('/static/img/shop/writeOff.png')"></image>
|
<image :src="sheep.$url.static('/static/img/shop/writeOff.png')"></image>
|
||||||
</view>
|
</view>
|
||||||
<view class="num">{{ orderInfo.pickUpVerifyCode }}</view>
|
<view class="num-wrap" @tap="copyVerifyCode">
|
||||||
|
<view class="num">{{ orderInfo.pickUpVerifyCode }}</view>
|
||||||
|
</view>
|
||||||
<view class="rules">
|
<view class="rules">
|
||||||
<view class="item">
|
<view class="item">
|
||||||
<view class="rulesTitle flex flex-wrap align-center"> 核销时间 </view>
|
<view class="rulesTitle flex flex-wrap align-center"> 核销时间 </view>
|
||||||
@@ -85,9 +87,34 @@
|
|||||||
|
|
||||||
const goStockProgress = () => {
|
const goStockProgress = () => {
|
||||||
const id = props.orderInfo?.id || props.orderInfo?.orderId;
|
const id = props.orderInfo?.id || props.orderInfo?.orderId;
|
||||||
|
const pickUpStoreId = Number(
|
||||||
|
props.orderInfo?.pickUpStoreId ||
|
||||||
|
props.orderInfo?.pickUpStore?.id ||
|
||||||
|
props.orderInfo?.pickUpStore?.storeId ||
|
||||||
|
props.systemStore?.id ||
|
||||||
|
props.systemStore?.storeId ||
|
||||||
|
props.orderInfo?.storeId ||
|
||||||
|
0,
|
||||||
|
);
|
||||||
if (!id) return;
|
if (!id) return;
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/order/stockProgress?id=${id}`,
|
url: `/pages/order/stockProgress?id=${id}${
|
||||||
|
pickUpStoreId > 0 ? `&pickUpStoreId=${pickUpStoreId}` : ''
|
||||||
|
}`,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const copyVerifyCode = () => {
|
||||||
|
const code = String(props.orderInfo?.pickUpVerifyCode || '').trim();
|
||||||
|
if (!code) {
|
||||||
|
sheep.$helper.toast('暂无核销码');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
uni.setClipboardData({
|
||||||
|
data: code,
|
||||||
|
success: () => {
|
||||||
|
sheep.$helper.toast('核销码已复制');
|
||||||
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -277,13 +304,17 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.order-details .writeOff .num-wrap {
|
||||||
|
width: 590rpx;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
.order-details .writeOff .num {
|
.order-details .writeOff .num {
|
||||||
background-color: #f0c34c;
|
background-color: #f0c34c;
|
||||||
width: 590rpx;
|
width: 100%;
|
||||||
height: 84rpx;
|
height: 84rpx;
|
||||||
color: #282828;
|
color: #282828;
|
||||||
font-size: 48rpx;
|
font-size: 48rpx;
|
||||||
margin: 0 auto;
|
|
||||||
border-radius: 0 0 20rpx 20rpx;
|
border-radius: 0 0 20rpx 20rpx;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding-top: 4rpx;
|
padding-top: 4rpx;
|
||||||
|
|||||||
@@ -70,9 +70,11 @@
|
|||||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||||
import sheep from '@/sheep';
|
import sheep from '@/sheep';
|
||||||
import OrderApi from '@/sheep/api/trade/order';
|
import OrderApi from '@/sheep/api/trade/order';
|
||||||
|
import OrderStoreApi from '@/sheep/api/trade/orderStore';
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
orderId: 0,
|
orderId: 0,
|
||||||
|
pickUpStoreId: 0,
|
||||||
orderInfo: {},
|
orderInfo: {},
|
||||||
loading: false,
|
loading: false,
|
||||||
});
|
});
|
||||||
@@ -80,7 +82,11 @@
|
|||||||
const sortingPercent = ref(72);
|
const sortingPercent = ref(72);
|
||||||
|
|
||||||
const items = computed(() => {
|
const items = computed(() => {
|
||||||
const list = state.orderInfo?.items;
|
const list =
|
||||||
|
state.orderInfo?.items ||
|
||||||
|
state.orderInfo?.orderItems ||
|
||||||
|
state.orderInfo?.itemList ||
|
||||||
|
state.orderInfo?.productList;
|
||||||
return Array.isArray(list) ? list : [];
|
return Array.isArray(list) ? list : [];
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -93,10 +99,31 @@
|
|||||||
return Boolean(state.orderInfo?.pickUpVerifyCode) && Boolean(state.orderInfo?.payStatus);
|
return Boolean(state.orderInfo?.pickUpVerifyCode) && Boolean(state.orderInfo?.payStatus);
|
||||||
});
|
});
|
||||||
|
|
||||||
const stage = computed(() => {
|
const resolvePickUpStoreId = (data = {}) => {
|
||||||
if (state.orderInfo?.pickUpVerifyTime || Number(state.orderInfo?.status) === 30) return 'done';
|
return Number(
|
||||||
if (state.orderInfo?.deliveryTime) return 'delivered';
|
data?.pickUpStoreId || data?.pickUpStore?.id || data?.pickUpStore?.storeId || data?.storeId || 0,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const resolveStage = (data = {}) => {
|
||||||
|
const rawStatus = Number(data?.preparationStatus ?? data?.status ?? 0);
|
||||||
|
if (data?.pickUpVerifyTime || data?.verifyTime || data?.completedTime || rawStatus === 30 || rawStatus === 3) {
|
||||||
|
return 'done';
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
data?.deliveryTime ||
|
||||||
|
data?.arriveStoreTime ||
|
||||||
|
data?.deliveredTime ||
|
||||||
|
rawStatus === 20 ||
|
||||||
|
rawStatus === 2
|
||||||
|
) {
|
||||||
|
return 'delivered';
|
||||||
|
}
|
||||||
return 'sorting';
|
return 'sorting';
|
||||||
|
};
|
||||||
|
|
||||||
|
const stage = computed(() => {
|
||||||
|
return resolveStage(state.orderInfo);
|
||||||
});
|
});
|
||||||
|
|
||||||
const steps = computed(() => {
|
const steps = computed(() => {
|
||||||
@@ -163,11 +190,28 @@
|
|||||||
|
|
||||||
const getDetail = async () => {
|
const getDetail = async () => {
|
||||||
if (!state.orderId || state.loading) return;
|
if (!state.orderId || state.loading) return;
|
||||||
|
if (!(state.pickUpStoreId > 0)) {
|
||||||
|
const detailRes = await OrderApi.getOrderDetail(state.orderId);
|
||||||
|
if (detailRes?.code === 0) {
|
||||||
|
state.pickUpStoreId = resolvePickUpStoreId(detailRes.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!(state.pickUpStoreId > 0)) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '缺少门店信息',
|
||||||
|
icon: 'none',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
state.loading = true;
|
state.loading = true;
|
||||||
const res = await OrderApi.getOrderDetail(state.orderId);
|
const res = await OrderStoreApi.getPreparationStatus(state.pickUpStoreId, state.orderId);
|
||||||
state.loading = false;
|
state.loading = false;
|
||||||
if (res?.code !== 0) return;
|
if (res?.code !== 0) return;
|
||||||
state.orderInfo = res.data || {};
|
const data = res.data || {};
|
||||||
|
state.orderInfo = data?.orderInfo || data;
|
||||||
|
if (!(state.pickUpStoreId > 0)) {
|
||||||
|
state.pickUpStoreId = resolvePickUpStoreId(state.orderInfo);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const notifyStore = () => {
|
const notifyStore = () => {
|
||||||
@@ -180,6 +224,8 @@
|
|||||||
onLoad((options) => {
|
onLoad((options) => {
|
||||||
const id = Number(options?.id || 0);
|
const id = Number(options?.id || 0);
|
||||||
if (id) state.orderId = id;
|
if (id) state.orderId = id;
|
||||||
|
const pickUpStoreId = Number(options?.pickUpStoreId || options?.storeId || 0);
|
||||||
|
if (pickUpStoreId > 0) state.pickUpStoreId = pickUpStoreId;
|
||||||
});
|
});
|
||||||
|
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
|
|||||||
@@ -21,6 +21,32 @@ const OrderStoreApi = {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
getRecentCompleted: (pickUpStoreId, days = 7) => {
|
||||||
|
return request({
|
||||||
|
url: '/trade/order-store/staff/recent-completed',
|
||||||
|
method: 'GET',
|
||||||
|
params: {
|
||||||
|
pickUpStoreId,
|
||||||
|
days,
|
||||||
|
},
|
||||||
|
custom: {
|
||||||
|
showLoading: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
getPreparationStatus: (pickUpStoreId, orderId) => {
|
||||||
|
return request({
|
||||||
|
url: '/trade/order-store/preparation-status',
|
||||||
|
method: 'GET',
|
||||||
|
params: {
|
||||||
|
pickUpStoreId,
|
||||||
|
orderId,
|
||||||
|
},
|
||||||
|
custom: {
|
||||||
|
showLoading: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
markSorted: (ids) => {
|
markSorted: (ids) => {
|
||||||
const idText = Array.isArray(ids) ? ids.filter(Boolean).join(',') : String(ids || '');
|
const idText = Array.isArray(ids) ? ids.filter(Boolean).join(',') : String(ids || '');
|
||||||
return request({
|
return request({
|
||||||
@@ -35,13 +61,11 @@ const OrderStoreApi = {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
verify: (ids, pickUpVerifyCode) => {
|
verify: (pickUpVerifyCode) => {
|
||||||
const idText = Array.isArray(ids) ? ids.filter(Boolean).join(',') : String(ids || '');
|
|
||||||
return request({
|
return request({
|
||||||
url: '/trade/order-store/staff/verify',
|
url: '/trade/order-store/staff/verify',
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
params: {
|
params: {
|
||||||
ids: idText,
|
|
||||||
pickUpVerifyCode: String(pickUpVerifyCode || '').trim(),
|
pickUpVerifyCode: String(pickUpVerifyCode || '').trim(),
|
||||||
},
|
},
|
||||||
custom: {
|
custom: {
|
||||||
|
|||||||
Reference in New Issue
Block a user