feat: 新增订单api
This commit is contained in:
@@ -75,6 +75,7 @@
|
||||
const state = reactive({
|
||||
orderId: 0,
|
||||
pickUpStoreId: 0,
|
||||
preparationStatus: null,
|
||||
orderInfo: {},
|
||||
loading: false,
|
||||
});
|
||||
@@ -105,11 +106,13 @@
|
||||
);
|
||||
};
|
||||
|
||||
const resolveStage = (data = {}) => {
|
||||
const rawStatus = Number(data?.preparationStatus ?? data?.status ?? 0);
|
||||
const resolveStage = (data = {}, preparationStatus) => {
|
||||
const external = Number(preparationStatus);
|
||||
const rawStatus = Number.isFinite(external) ? external : Number(data?.preparationStatus ?? data?.status ?? 0);
|
||||
if (data?.pickUpVerifyTime || data?.verifyTime || data?.completedTime || rawStatus === 30 || rawStatus === 3) {
|
||||
return 'done';
|
||||
}
|
||||
if (rawStatus === 1) return 'wait';
|
||||
if (
|
||||
data?.deliveryTime ||
|
||||
data?.arriveStoreTime ||
|
||||
@@ -123,7 +126,7 @@
|
||||
};
|
||||
|
||||
const stage = computed(() => {
|
||||
return resolveStage(state.orderInfo);
|
||||
return resolveStage(state.orderInfo, state.preparationStatus);
|
||||
});
|
||||
|
||||
const steps = computed(() => {
|
||||
@@ -131,7 +134,7 @@
|
||||
const s = stage.value;
|
||||
const sortingState = s === 'sorting' ? 'active' : 'done';
|
||||
const deliveredState = s === 'delivered' ? 'active' : s === 'sorting' ? 'todo' : 'done';
|
||||
const waitState = s === 'done' ? 'done' : 'todo';
|
||||
const waitState = s === 'wait' ? 'active' : s === 'done' ? 'done' : 'todo';
|
||||
return [
|
||||
{
|
||||
key: 'created',
|
||||
@@ -190,9 +193,10 @@
|
||||
|
||||
const getDetail = async () => {
|
||||
if (!state.orderId || state.loading) return;
|
||||
if (!(state.pickUpStoreId > 0)) {
|
||||
if (!state.orderInfo || !Object.keys(state.orderInfo).length || !(state.pickUpStoreId > 0)) {
|
||||
const detailRes = await OrderApi.getOrderDetail(state.orderId);
|
||||
if (detailRes?.code === 0) {
|
||||
state.orderInfo = detailRes.data || {};
|
||||
state.pickUpStoreId = resolvePickUpStoreId(detailRes.data);
|
||||
}
|
||||
}
|
||||
@@ -207,11 +211,20 @@
|
||||
const res = await OrderStoreApi.getPreparationStatus(state.pickUpStoreId, state.orderId);
|
||||
state.loading = false;
|
||||
if (res?.code !== 0) return;
|
||||
const data = res.data || {};
|
||||
state.orderInfo = data?.orderInfo || data;
|
||||
if (!(state.pickUpStoreId > 0)) {
|
||||
state.pickUpStoreId = resolvePickUpStoreId(state.orderInfo);
|
||||
const data = res.data;
|
||||
if (data !== null && typeof data === 'object') {
|
||||
const merged = data?.orderInfo || data;
|
||||
state.orderInfo = {
|
||||
...(state.orderInfo || {}),
|
||||
...(merged || {}),
|
||||
};
|
||||
const next = Number(merged?.preparationStatus ?? merged?.status);
|
||||
if (Number.isFinite(next)) state.preparationStatus = next;
|
||||
} else {
|
||||
const next = Number(data);
|
||||
if (Number.isFinite(next)) state.preparationStatus = next;
|
||||
}
|
||||
if (!(state.pickUpStoreId > 0)) state.pickUpStoreId = resolvePickUpStoreId(state.orderInfo);
|
||||
};
|
||||
|
||||
const notifyStore = () => {
|
||||
|
||||
Reference in New Issue
Block a user