feat: 添加催一催按钮、应用宝跳转配置
This commit is contained in:
@@ -15,6 +15,214 @@
|
||||
import {
|
||||
ShoproInit
|
||||
} from './sheep';
|
||||
|
||||
const SCHEME_TAG = '[Scheme]';
|
||||
const HOME_PATH = '/pages/index/index';
|
||||
const SCHEME_PROTOCOL = 'yougou://';
|
||||
|
||||
const schemeState = {
|
||||
lastScheme: '',
|
||||
lastHandleAt: 0,
|
||||
launching: false,
|
||||
schemeHandledInLaunch: false,
|
||||
};
|
||||
|
||||
const isSameSchemeDebounce = (scheme) => {
|
||||
const now = Date.now();
|
||||
const same = schemeState.lastScheme === scheme && now - schemeState.lastHandleAt < 800;
|
||||
schemeState.lastScheme = scheme;
|
||||
schemeState.lastHandleAt = now;
|
||||
return same;
|
||||
};
|
||||
|
||||
const parseSchemeQuery = (query = {}) => {
|
||||
try {
|
||||
const result = {};
|
||||
Object.keys(query || {}).forEach((k) => {
|
||||
const v = query[k];
|
||||
if (v === undefined || v === null) return;
|
||||
if (typeof v === 'string' && v.length > 512) {
|
||||
result[k] = v.slice(0, 512);
|
||||
return;
|
||||
}
|
||||
result[k] = v;
|
||||
});
|
||||
return result;
|
||||
} catch (e) {
|
||||
console.warn(SCHEME_TAG, 'parseSchemeQuery error', e);
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
const resolveTargetPath = (scheme = '', query = {}) => {
|
||||
try {
|
||||
const url = String(scheme || '').trim();
|
||||
if (!url) return { path: HOME_PATH, query: parseSchemeQuery(query) };
|
||||
const withoutProtocol = url.replace(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//, '');
|
||||
if (!withoutProtocol) return { path: HOME_PATH, query: parseSchemeQuery(query) };
|
||||
const [pathRaw = '', queryRaw = ''] = withoutProtocol.split('?');
|
||||
const cleanPath = pathRaw.replace(/^\/+/, '/').trim();
|
||||
const path = cleanPath.startsWith('/pages/') ? cleanPath : HOME_PATH;
|
||||
const merged = { ...parseSchemeQuery(query) };
|
||||
if (queryRaw) {
|
||||
queryRaw.split('&').forEach((pair) => {
|
||||
const [k, v] = pair.split('=');
|
||||
if (!k) return;
|
||||
try { merged[decodeURIComponent(k)] = v === undefined ? '' : decodeURIComponent(v); } catch (_) {}
|
||||
});
|
||||
}
|
||||
return { path, query: merged };
|
||||
} catch (e) {
|
||||
console.warn(SCHEME_TAG, 'resolveTargetPath error, fallback to home', e);
|
||||
return { path: HOME_PATH, query: parseSchemeQuery(query) };
|
||||
}
|
||||
};
|
||||
|
||||
const buildUrl = (path, query) => {
|
||||
try {
|
||||
const q = query || {};
|
||||
const keys = Object.keys(q).filter((k) => q[k] !== undefined && q[k] !== null && q[k] !== '');
|
||||
if (!keys.length) return path;
|
||||
const qs = keys
|
||||
.map((k) => `${encodeURIComponent(k)}=${encodeURIComponent(String(q[k]))}`)
|
||||
.join('&');
|
||||
return `${path}${path.includes('?') ? '&' : '?'}${qs}`;
|
||||
} catch (e) {
|
||||
return path;
|
||||
}
|
||||
};
|
||||
|
||||
const safeReLaunch = (path, query, source) => {
|
||||
const finalUrl = buildUrl(path, query);
|
||||
console.log(SCHEME_TAG, `${source} → reLaunch`, finalUrl);
|
||||
try {
|
||||
uni.reLaunch({
|
||||
url: finalUrl,
|
||||
fail: (err) => {
|
||||
console.warn(SCHEME_TAG, 'reLaunch fail, fallback to switchTab/home', err);
|
||||
if (path === HOME_PATH) {
|
||||
try {
|
||||
uni.switchTab({
|
||||
url: HOME_PATH,
|
||||
fail: (err2) => {
|
||||
console.warn(SCHEME_TAG, 'switchTab also fail', err2);
|
||||
uni.navigateTo({ url: HOME_PATH, fail: () => {} });
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
console.warn(SCHEME_TAG, 'switchTab catch', e);
|
||||
}
|
||||
} else {
|
||||
uni.navigateTo({ url: finalUrl, fail: () => uni.reLaunch({ url: HOME_PATH }) });
|
||||
}
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(SCHEME_TAG, 'safeReLaunch catch error', e);
|
||||
try { uni.reLaunch({ url: HOME_PATH }); } catch (_) {}
|
||||
}
|
||||
};
|
||||
|
||||
const isSchemeTrigger = (options) => {
|
||||
if (!options) return false;
|
||||
if (String(options?.path || '').toLowerCase() === 'scheme') return true;
|
||||
const scheme = String(options?.scheme || options?.argv?.scheme || '');
|
||||
if (scheme.startsWith(SCHEME_PROTOCOL)) return true;
|
||||
const referrer = String(options?.referrer || '');
|
||||
if (referrer.startsWith(SCHEME_PROTOCOL)) return true;
|
||||
return false;
|
||||
};
|
||||
|
||||
const handleSchemeByOptions = (options, source) => {
|
||||
const scheme = String(options?.scheme || options?.argv?.scheme || options?.referrer || '');
|
||||
if (isSameSchemeDebounce(scheme)) {
|
||||
console.log(SCHEME_TAG, `${source} 防抖跳过`, scheme);
|
||||
return;
|
||||
}
|
||||
console.log(SCHEME_TAG, `${source} 触发`, options);
|
||||
const query = { ...(options?.query || {}), ...(options?.argv?.query || {}) };
|
||||
const { path, query: resolvedQuery } = resolveTargetPath(scheme, query);
|
||||
safeReLaunch(path, resolvedQuery, source);
|
||||
};
|
||||
|
||||
let schemeEventListenerRegistered = false;
|
||||
const registerSchemeEventListener = () => {
|
||||
if (schemeEventListenerRegistered) return;
|
||||
if (typeof plus === 'undefined' || !plus?.globalEvent) return;
|
||||
try {
|
||||
plus.globalEvent.addEventListener('newintent', (e) => {
|
||||
const intent = e?.intent || e;
|
||||
let scheme = '';
|
||||
let query = {};
|
||||
try {
|
||||
if (typeof plus?.runtime?.arguments === 'function' || typeof plus?.runtime?.arguments !== 'undefined') {
|
||||
const args = plus.runtime.arguments;
|
||||
if (args && typeof args === 'object') {
|
||||
scheme = String(args.scheme || args.url || args.action || '');
|
||||
query = args.query || {};
|
||||
} else if (typeof args === 'string') {
|
||||
scheme = args;
|
||||
}
|
||||
}
|
||||
if (!scheme && intent?.data) {
|
||||
const data = String(intent.data || '');
|
||||
scheme = data;
|
||||
const i = data.indexOf('?');
|
||||
if (i > -1) {
|
||||
data.slice(i + 1).split('&').forEach((pair) => {
|
||||
const [k, v] = pair.split('=');
|
||||
if (!k) return;
|
||||
try { query[decodeURIComponent(k)] = v === undefined ? '' : decodeURIComponent(v); } catch (_) {}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (!scheme && intent?.extras) {
|
||||
scheme = String(intent.extras.scheme || intent.extras.url || intent.extras['android.intent.extra.TEXT'] || '');
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn(SCHEME_TAG, 'newintent parse error', err);
|
||||
}
|
||||
if (!scheme) return;
|
||||
if (isSameSchemeDebounce(scheme)) {
|
||||
console.log(SCHEME_TAG, 'newintent 防抖跳过', scheme);
|
||||
return;
|
||||
}
|
||||
console.log(SCHEME_TAG, 'newintent(plus.globalEvent) 触发', { scheme, query, intent });
|
||||
const { path, query: resolvedQuery } = resolveTargetPath(scheme, query);
|
||||
safeReLaunch(path, resolvedQuery, 'newintent后台唤起');
|
||||
});
|
||||
schemeEventListenerRegistered = true;
|
||||
console.log(SCHEME_TAG, 'plus.globalEvent newintent 监听已注册');
|
||||
} catch (e) {
|
||||
console.warn(SCHEME_TAG, 'registerSchemeEventListener catch', e);
|
||||
}
|
||||
};
|
||||
|
||||
const registerSchemeRuntimeArguments = () => {
|
||||
if (typeof plus === 'undefined' || !plus?.runtime) return;
|
||||
try {
|
||||
const args = plus.runtime.arguments;
|
||||
let scheme = '';
|
||||
let query = {};
|
||||
if (args && typeof args === 'object') {
|
||||
scheme = String(args.scheme || args.url || '');
|
||||
query = args.query || {};
|
||||
} else if (typeof args === 'string' && args) {
|
||||
scheme = args;
|
||||
}
|
||||
if (!scheme) return;
|
||||
if (isSameSchemeDebounce(scheme)) {
|
||||
console.log(SCHEME_TAG, 'runtime.arguments 防抖跳过', scheme);
|
||||
return;
|
||||
}
|
||||
console.log(SCHEME_TAG, 'plus.runtime.arguments 读取', { scheme, query });
|
||||
const { path, query: resolvedQuery } = resolveTargetPath(scheme, query);
|
||||
safeReLaunch(path, resolvedQuery, 'plus.runtime.arguments冷启动');
|
||||
} catch (e) {
|
||||
console.warn(SCHEME_TAG, 'registerSchemeRuntimeArguments catch', e);
|
||||
}
|
||||
};
|
||||
|
||||
let globalData = ref({
|
||||
statusBarHeight: 0, // 状态导航栏高度
|
||||
navHeight: 0, // 总体高度
|
||||
@@ -194,7 +402,7 @@
|
||||
ensureGlobalHotUpdateChecked();
|
||||
// socket()
|
||||
});
|
||||
onLaunch(() => {
|
||||
onLaunch((options = {}) => {
|
||||
try {
|
||||
uni.hideTabBar({
|
||||
fail: () => {},
|
||||
@@ -219,20 +427,54 @@
|
||||
uni.setStorageSync('globalData', globalData.value);
|
||||
// 加载Shopro底层依赖
|
||||
ShoproInit();
|
||||
|
||||
console.log(SCHEME_TAG, 'onLaunch', options);
|
||||
schemeState.launching = true;
|
||||
schemeState.schemeHandledInLaunch = false;
|
||||
// #ifdef APP-PLUS
|
||||
const boot = () => {
|
||||
registerSchemeEventListener();
|
||||
const optionsHit = isSchemeTrigger(options);
|
||||
if (optionsHit) {
|
||||
schemeState.schemeHandledInLaunch = true;
|
||||
handleSchemeByOptions(options, 'onLaunch冷启动scheme');
|
||||
} else {
|
||||
registerSchemeRuntimeArguments();
|
||||
}
|
||||
};
|
||||
if (typeof plus === 'undefined' || !plus?.runtime) {
|
||||
const start = Date.now();
|
||||
const t = setInterval(() => {
|
||||
if (typeof plus !== 'undefined' && plus?.runtime) {
|
||||
clearInterval(t);
|
||||
boot();
|
||||
} else if (Date.now() - start > 4000) {
|
||||
clearInterval(t);
|
||||
boot();
|
||||
}
|
||||
}, 50);
|
||||
} else {
|
||||
boot();
|
||||
}
|
||||
setTimeout(() => { schemeState.launching = false; }, 1500);
|
||||
// #endif
|
||||
});
|
||||
|
||||
onShow(() => {
|
||||
onShow((options = {}) => {
|
||||
try {
|
||||
uni.hideTabBar({
|
||||
fail: () => {},
|
||||
});
|
||||
} catch (e) {}
|
||||
// #ifdef APP-PLUS
|
||||
// 获取urlSchemes参数
|
||||
const args =
|
||||
typeof plus !== 'undefined' && plus?.runtime ? plus.runtime.arguments : '';
|
||||
if (args) {}
|
||||
|
||||
if (
|
||||
!schemeState.launching &&
|
||||
!schemeState.schemeHandledInLaunch &&
|
||||
isSchemeTrigger(options)
|
||||
) {
|
||||
handleSchemeByOptions(options, 'onShow兜底scheme');
|
||||
}
|
||||
schemeState.schemeHandledInLaunch = false;
|
||||
// 获取剪贴板
|
||||
uni.getClipboardData({
|
||||
success: (res) => {},
|
||||
|
||||
@@ -8,6 +8,13 @@
|
||||
>
|
||||
<view class="more size24" v-if="props.type != 2"></view>
|
||||
<view class="flex-center ju-flex-end">
|
||||
<view
|
||||
v-if="showRemind"
|
||||
class="btn size28 f500 remind-btn"
|
||||
@click.stop="btnClick(7)"
|
||||
>
|
||||
催一催
|
||||
</view>
|
||||
<view v-for="(item, index) in btns" :key="index">
|
||||
<view
|
||||
v-if="
|
||||
@@ -36,7 +43,7 @@
|
||||
import OrderApi from '@/sheep/api/trade/order';
|
||||
const { proxy } = getCurrentInstance();
|
||||
|
||||
let emit = defineEmits(['downData']);
|
||||
let emit = defineEmits(['downData', 'remind']);
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Object,
|
||||
@@ -57,6 +64,47 @@
|
||||
return Number(v) || 0;
|
||||
});
|
||||
const isAllRefunded = computed(() => refundStatus.value === 20);
|
||||
|
||||
const isVerifyCompleted = computed(() => {
|
||||
const info = props.data || {};
|
||||
const status = Number(info?.status);
|
||||
return Boolean(
|
||||
info?.pickUpVerifyTime ||
|
||||
info?.verifyTime ||
|
||||
info?.completedTime ||
|
||||
status === 30 ||
|
||||
status === 3,
|
||||
);
|
||||
});
|
||||
|
||||
const resolveStage = () => {
|
||||
const data = props.data || {};
|
||||
const external = Number(data?.preparationStatus);
|
||||
const rawStatus = Number.isFinite(external) ? external : Number(data?.preparationStatus ?? data?.status ?? 0);
|
||||
if (isVerifyCompleted.value) return 'done';
|
||||
if (rawStatus === 1 || rawStatus === 2) return 'wait';
|
||||
if (
|
||||
data?.deliveryTime ||
|
||||
data?.arriveStoreTime ||
|
||||
data?.deliveredTime ||
|
||||
rawStatus === 20
|
||||
) {
|
||||
return 'delivered';
|
||||
}
|
||||
return 'sorting';
|
||||
};
|
||||
|
||||
const isSorting = computed(() => resolveStage() === 'sorting');
|
||||
|
||||
const showRemind = computed(() => {
|
||||
const info = props.data || {};
|
||||
return (
|
||||
Number(info?.deliveryType) === 2 &&
|
||||
Boolean(info?.payStatus) &&
|
||||
!isVerifyCompleted.value &&
|
||||
isSorting.value
|
||||
);
|
||||
});
|
||||
let btns = ref([
|
||||
{
|
||||
id: 1,
|
||||
@@ -138,6 +186,9 @@
|
||||
case 6:
|
||||
cancelAfterSale();
|
||||
break;
|
||||
case 7:
|
||||
remindStore();
|
||||
break;
|
||||
}
|
||||
};
|
||||
// 取消订单
|
||||
@@ -222,6 +273,10 @@
|
||||
const buyAgain = () => {};
|
||||
// 取消售后
|
||||
const cancelAfterSale = () => {};
|
||||
// 催一催
|
||||
const remindStore = async () => {
|
||||
emit('remind');
|
||||
};
|
||||
const upData = () => {
|
||||
emit('downData');
|
||||
};
|
||||
@@ -244,4 +299,10 @@
|
||||
// line-height: 74rpx;
|
||||
// padding: 0 30rpx;
|
||||
}
|
||||
|
||||
.remind-btn {
|
||||
color: #2556ec;
|
||||
background: rgba(37, 86, 236, 0.08);
|
||||
border: 2rpx solid rgba(37, 86, 236, 0.28);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
<template>
|
||||
<view class="flex-center ju-flex-end w100">
|
||||
<view
|
||||
class="ai-button3 w_144 m-r-10 remind-ai-btn"
|
||||
v-if="showRemind"
|
||||
@tap.stop="emit('remind')"
|
||||
>
|
||||
催一催
|
||||
</view>
|
||||
<view
|
||||
class="ai-button3 w_144 m-r-10"
|
||||
v-if="showDelay && !props.disableDelayShipment"
|
||||
@@ -90,6 +97,38 @@
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
deliveryType: {
|
||||
type: [Number, String],
|
||||
default: 0,
|
||||
},
|
||||
payStatus: {
|
||||
type: [Boolean, Number, String],
|
||||
default: false,
|
||||
},
|
||||
preparationStatus: {
|
||||
type: [Number, String],
|
||||
default: null,
|
||||
},
|
||||
pickUpVerifyTime: {
|
||||
type: [Number, String],
|
||||
default: '',
|
||||
},
|
||||
verifyTime: {
|
||||
type: [Number, String],
|
||||
default: '',
|
||||
},
|
||||
completedTime: {
|
||||
type: [Number, String],
|
||||
default: '',
|
||||
},
|
||||
arriveStoreTime: {
|
||||
type: [Number, String],
|
||||
default: '',
|
||||
},
|
||||
deliveredTime: {
|
||||
type: [Number, String],
|
||||
default: '',
|
||||
},
|
||||
});
|
||||
|
||||
// 延迟发货按钮:仅允许【待发货(10/伪50)、部分发货(15)】状态展示
|
||||
@@ -120,5 +159,51 @@
|
||||
return false;
|
||||
});
|
||||
|
||||
const emit = defineEmits(['delay', 'now', 'view', 'confirm', 'pay', 'cancel', 'express']);
|
||||
const isVerifyCompleted = computed(() => {
|
||||
const status = Number(props.status);
|
||||
return Boolean(
|
||||
props.pickUpVerifyTime ||
|
||||
props.verifyTime ||
|
||||
props.completedTime ||
|
||||
status === 30 ||
|
||||
status === 3,
|
||||
);
|
||||
});
|
||||
|
||||
const resolveStage = () => {
|
||||
const external = Number(props.preparationStatus);
|
||||
const rawStatus = Number.isFinite(external) ? external : Number(props.preparationStatus ?? props.status ?? 0);
|
||||
if (isVerifyCompleted.value) return 'done';
|
||||
if (rawStatus === 1 || rawStatus === 2) return 'wait';
|
||||
if (
|
||||
props.deliveryTime ||
|
||||
props.arriveStoreTime ||
|
||||
props.deliveredTime ||
|
||||
rawStatus === 20
|
||||
) {
|
||||
return 'delivered';
|
||||
}
|
||||
return 'sorting';
|
||||
};
|
||||
|
||||
const isSorting = computed(() => resolveStage() === 'sorting');
|
||||
|
||||
const showRemind = computed(() => {
|
||||
return (
|
||||
Number(props.deliveryType) === 2 &&
|
||||
Boolean(props.payStatus) &&
|
||||
!isVerifyCompleted.value &&
|
||||
isSorting.value
|
||||
);
|
||||
});
|
||||
|
||||
const emit = defineEmits(['delay', 'now', 'view', 'confirm', 'pay', 'cancel', 'express', 'remind']);
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.remind-ai-btn {
|
||||
color: #2556ec !important;
|
||||
background: rgba(37, 86, 236, 0.08);
|
||||
border: 2rpx solid rgba(37, 86, 236, 0.28) !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -5,9 +5,11 @@
|
||||
<view class="flex-center ju-between createTime">
|
||||
<view class="flex-center shrink">
|
||||
<view class="size28">订单编号: {{ props.data.no }}</view>
|
||||
|
||||
<view class="copy flex-center" @tap.stop="onCopy(props.data.no)" style="margin-left: 10px">
|
||||
<image :src="`${$url}goods/copy2.svg`" mode="scaleToFill" />
|
||||
</view>
|
||||
<view class="pickup-tag" v-if="Number(props.data?.deliveryType) === 2">自提</view>
|
||||
</view>
|
||||
<view class="stateText size28" style="margin-left: 10px" :class="formatOrderColor(props.data)"
|
||||
v-if="!props.isAfterSale">
|
||||
@@ -778,6 +780,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
.pickup-tag {
|
||||
margin-left: 16rpx;
|
||||
padding: 4rpx 16rpx;
|
||||
line-height: 1.6;
|
||||
font-size: 22rpx;
|
||||
color: #2556ec;
|
||||
background: rgba(37, 86, 236, 0.08);
|
||||
border: 2rpx solid rgba(37, 86, 236, 0.18);
|
||||
border-radius: 8rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.con_item {
|
||||
margin-bottom: 24rpx;
|
||||
|
||||
|
||||
+4
-3
@@ -2,8 +2,8 @@
|
||||
"name" : "优购商城",
|
||||
"appid" : "__UNI__8B19741",
|
||||
"description" : "",
|
||||
"versionName" : "1.7.0",
|
||||
"versionCode" : 170,
|
||||
"versionName" : "1.7.1",
|
||||
"versionCode" : 171,
|
||||
"transformPx" : false,
|
||||
"app-plus" : {
|
||||
"privacy" : {
|
||||
@@ -29,7 +29,7 @@
|
||||
},
|
||||
"distribute" : {
|
||||
"android" : {
|
||||
"schemes" : [ "weixin" ],
|
||||
"schemes" : [ "yougou" ],
|
||||
"permissions" : [
|
||||
"<uses-feature android:name=\"android.hardware.camera\"/>",
|
||||
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
|
||||
@@ -47,6 +47,7 @@
|
||||
"minSdkVersion" : 21
|
||||
},
|
||||
"ios" : {
|
||||
"schemes" : [ "yougou" ],
|
||||
"privacyDescription" : {
|
||||
"NSPhotoLibraryUsageDescription" : "需要同意访问您的相册选取图片才能完善该条目",
|
||||
"NSPhotoLibraryAddUsageDescription" : ""
|
||||
|
||||
+113
-1
@@ -116,17 +116,27 @@
|
||||
:logisticsNo="state.orderInfo.logisticsNo"
|
||||
:deliveryTime="state.orderInfo.deliveryTime"
|
||||
:hasLogistics="hasLogistics"
|
||||
:deliveryType="state.orderInfo.deliveryType"
|
||||
:payStatus="state.orderInfo.payStatus"
|
||||
:preparationStatus="state.orderInfo.preparationStatus"
|
||||
:pickUpVerifyTime="state.orderInfo.pickUpVerifyTime"
|
||||
:verifyTime="state.orderInfo.verifyTime"
|
||||
:completedTime="state.orderInfo.completedTime"
|
||||
:arriveStoreTime="state.orderInfo.arriveStoreTime"
|
||||
:deliveredTime="state.orderInfo.deliveredTime"
|
||||
@delay="delayShipment"
|
||||
@now="nowShipment"
|
||||
@confirm="confirmReceiveOrder"
|
||||
@pay="goPay"
|
||||
@cancel="cancelAiOrder"
|
||||
@express="goExpressLog"
|
||||
@remind="handleRemind"
|
||||
/>
|
||||
<card_orderBan
|
||||
v-else
|
||||
:data="state.orderInfo"
|
||||
@downData="getOrderDetail"
|
||||
@remind="handleRemind"
|
||||
type="2"
|
||||
></card_orderBan>
|
||||
</view>
|
||||
@@ -193,6 +203,7 @@
|
||||
aiReceiveItem,
|
||||
} from '@/sheep/api/ai';
|
||||
import StoreApi from '@/sheep/api/trade/store';
|
||||
import OrderStoreApi from '@/sheep/api/trade/orderStore';
|
||||
import card_order from '@/components/orderItem/card_order.vue';
|
||||
import AiOrderActionBar from '@/components/orderItem/AiOrderActionBar.vue';
|
||||
import ShipmentPopup from '@/components/orderItem/ShipmentPopup.vue';
|
||||
@@ -228,6 +239,53 @@
|
||||
};
|
||||
|
||||
const pickUpVerifyRef = ref();
|
||||
const remindLock = ref(false);
|
||||
|
||||
const resolvePickUpStoreIdForRemind = () => {
|
||||
const data = state.orderInfo || {};
|
||||
return Number(
|
||||
data?.pickUpStoreId ||
|
||||
data?.pickUpStore?.id ||
|
||||
data?.pickUpStore?.storeId ||
|
||||
data?.pickUpStoreVO?.id ||
|
||||
data?.pickUpStoreVO?.storeId ||
|
||||
data?.store?.id ||
|
||||
data?.store?.storeId ||
|
||||
systemStore.value?.id ||
|
||||
systemStore.value?.storeId ||
|
||||
data?.storeId ||
|
||||
0,
|
||||
);
|
||||
};
|
||||
|
||||
const handleRemind = async () => {
|
||||
return sheep.$helper.toast('已通知门店备货');
|
||||
if (remindLock.value) {
|
||||
sheep.$helper.toast('操作太频繁,请稍后再试');
|
||||
return;
|
||||
}
|
||||
const pickUpStoreId = resolvePickUpStoreIdForRemind();
|
||||
const orderId = state.orderInfo?.id || state.orderInfo?.orderId;
|
||||
if (!orderId || !(pickUpStoreId > 0)) {
|
||||
sheep.$helper.toast('订单信息异常');
|
||||
return;
|
||||
}
|
||||
remindLock.value = true;
|
||||
try {
|
||||
const res = await OrderStoreApi.remindStore(pickUpStoreId, orderId);
|
||||
if (res?.code === 0) {
|
||||
sheep.$helper.toast(res?.msg || '已通知门店备货');
|
||||
} else {
|
||||
sheep.$helper.toast(res?.msg || '催一催失败,请稍后重试');
|
||||
}
|
||||
} catch (e) {
|
||||
sheep.$helper.toast('催一催失败,请稍后重试');
|
||||
} finally {
|
||||
setTimeout(() => {
|
||||
remindLock.value = false;
|
||||
}, 5000);
|
||||
}
|
||||
};
|
||||
|
||||
const isAiActionOrder = computed(() => {
|
||||
const orderType = Number(state.orderInfo?.type ?? state.orderType ?? 0);
|
||||
@@ -319,6 +377,30 @@
|
||||
return false;
|
||||
});
|
||||
|
||||
const resolvePickUpStage = () => {
|
||||
const data = state.orderInfo || {};
|
||||
const external = Number(data?.preparationStatus);
|
||||
const rawStatus = Number.isFinite(external) ? external : Number(data?.preparationStatus ?? data?.status ?? 0);
|
||||
const isVerifyCompleted = Boolean(
|
||||
data?.pickUpVerifyTime ||
|
||||
data?.verifyTime ||
|
||||
data?.completedTime ||
|
||||
rawStatus === 30 ||
|
||||
rawStatus === 3,
|
||||
);
|
||||
if (isVerifyCompleted) return 'done';
|
||||
if (rawStatus === 1 || rawStatus === 2) return 'wait';
|
||||
if (
|
||||
data?.deliveryTime ||
|
||||
data?.arriveStoreTime ||
|
||||
data?.deliveredTime ||
|
||||
rawStatus === 20
|
||||
) {
|
||||
return 'delivered';
|
||||
}
|
||||
return 'sorting';
|
||||
};
|
||||
|
||||
const showBottomBar = computed(() => {
|
||||
if (!isAiActionOrder.value) return true;
|
||||
const status = Number(state.orderInfo?.status);
|
||||
@@ -326,7 +408,11 @@
|
||||
if (hasLogistics.value) return true;
|
||||
if ([0, 15, 20, 30].includes(status)) return true;
|
||||
if (!isAiStoreOrder.value) return hasLogistics.value;
|
||||
if (isPickUpOrder.value) return false;
|
||||
// AI 店铺自提订单:分拣中/已送达门店时显示底部栏(展示催一催按钮);待取货/已核销后隐藏
|
||||
if (isPickUpOrder.value) {
|
||||
const stage = resolvePickUpStage();
|
||||
return stage === 'sorting' || stage === 'delivered';
|
||||
}
|
||||
if (hasDelayedItems.value) return true;
|
||||
return [10, 15, 50, 70].includes(status);
|
||||
});
|
||||
@@ -660,6 +746,32 @@
|
||||
} else {
|
||||
systemStore.value = {};
|
||||
}
|
||||
// 自提订单:同步备货进度(用于核销区是否展示二维码、门店卡片是否展示、状态 Tag 同步)
|
||||
if (isPickUp && (state.orderInfo.deliveryType === 2 || pickUpStoreId > 0) && state.orderInfo.payStatus) {
|
||||
try {
|
||||
const prepRes = await OrderStoreApi.getPreparationStatus(pickUpStoreId, state.orderInfo.id || state.orderInfo.orderId);
|
||||
if (prepRes?.code === 0) {
|
||||
const raw = prepRes.data;
|
||||
if (raw !== null && typeof raw === 'object') {
|
||||
const merged = raw?.orderInfo || raw;
|
||||
state.orderInfo = {
|
||||
...state.orderInfo,
|
||||
...(merged || {}),
|
||||
};
|
||||
const nextStatus = Number(merged?.preparationStatus ?? merged?.status);
|
||||
if (Number.isFinite(nextStatus)) {
|
||||
state.orderInfo.preparationStatus = nextStatus;
|
||||
}
|
||||
} else {
|
||||
const nextStatus = Number(raw);
|
||||
if (Number.isFinite(nextStatus)) {
|
||||
state.orderInfo.preparationStatus = nextStatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
if (state.orderInfo.deliveryType === 2 && state.orderInfo.payStatus) {
|
||||
pickUpVerifyRef.value && pickUpVerifyRef.value.markCode(res.data.pickUpVerifyCode);
|
||||
}
|
||||
|
||||
+178
-32
@@ -3,34 +3,54 @@
|
||||
<!-- 自提商品核销 -->
|
||||
<view v-if="orderInfo.deliveryType === 2 && orderInfo.payStatus" class="writeOff borRadius14">
|
||||
<view class="title-row">
|
||||
<view class="title">核销信息</view>
|
||||
<view class="title-left flex-center">
|
||||
<view class="title">核销信息</view>
|
||||
<view class="status-tag" :class="statusTagClass">{{ statusTagText }}</view>
|
||||
</view>
|
||||
<view class="progress-btn" @tap.stop="goStockProgress">备货进度</view>
|
||||
</view>
|
||||
<view class="grayBg flex-center">
|
||||
<view class="pictrue">
|
||||
<image
|
||||
v-if="!!painterImageUrl"
|
||||
:src="painterImageUrl"
|
||||
:style="{ width: `${state.qrcodeSize}px`, height: `${state.qrcodeSize}px` }"
|
||||
:show-menu-by-longpress="true"
|
||||
/>
|
||||
<view v-if="isVerifyCompleted" class="verify-mask">
|
||||
<view class="verify-mask__icon">
|
||||
<uni-icons type="checkmarkempty" size="40" color="#ffffff" />
|
||||
</view>
|
||||
<view class="verify-mask__text">已核销</view>
|
||||
<template v-if="isSorting">
|
||||
<view class="preparation-placeholder">
|
||||
<view class="preparation-placeholder__emoji">📦</view>
|
||||
<view class="preparation-placeholder__title">门店正快马加鞭备货中</view>
|
||||
<view class="preparation-placeholder__desc">
|
||||
分拣完成后将生成取货码并发送通知,请耐心等待~
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="gear">
|
||||
<image :src="sheep.$url.static('/static/img/shop/writeOff.png')"></image>
|
||||
</view>
|
||||
<view v-if="isVerifyCompleted" class="num-wrap">
|
||||
<view class="num num--done">该商品券已完成核销</view>
|
||||
</view>
|
||||
<view v-else class="num-wrap" @tap="copyVerifyCode">
|
||||
<view class="num">{{ orderInfo.pickUpVerifyCode }}</view>
|
||||
</view>
|
||||
<view v-if="isVerifyCompleted" class="num-wrap">
|
||||
<view class="num num--done">该商品券已完成核销</view>
|
||||
</view>
|
||||
<view v-else class="num-wrap">
|
||||
<view class="num num--pending">— 待备货完成后解锁 —</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view class="grayBg flex-center">
|
||||
<view class="pictrue">
|
||||
<image
|
||||
v-if="!!painterImageUrl"
|
||||
:src="painterImageUrl"
|
||||
:style="{ width: `${state.qrcodeSize}px`, height: `${state.qrcodeSize}px` }"
|
||||
:show-menu-by-longpress="true"
|
||||
/>
|
||||
<view v-if="isVerifyCompleted" class="verify-mask">
|
||||
<view class="verify-mask__icon">
|
||||
<uni-icons type="checkmarkempty" size="40" color="#ffffff" />
|
||||
</view>
|
||||
<view class="verify-mask__text">已核销</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="gear">
|
||||
<image :src="sheep.$url.static('/static/img/shop/writeOff.png')"></image>
|
||||
</view>
|
||||
<view v-if="isVerifyCompleted" class="num-wrap">
|
||||
<view class="num num--done">该商品券已完成核销</view>
|
||||
</view>
|
||||
<view v-else class="num-wrap" @tap="copyVerifyCode">
|
||||
<view class="num">{{ orderInfo.pickUpVerifyCode }}</view>
|
||||
</view>
|
||||
</template>
|
||||
<view class="rules">
|
||||
<view class="item">
|
||||
<view class="rulesTitle flex flex-wrap align-center"> 核销时间 </view>
|
||||
@@ -44,12 +64,12 @@
|
||||
<text class="iconfont icon-shuoming1"></text>
|
||||
使用说明
|
||||
</view>
|
||||
<view class="info">可将二维码出示给店员扫描或提供数字核销码</view>
|
||||
<view class="info">{{ isSorting ? '分拣完成后将生成核销码,出示给店员扫描即可' : '可将二维码出示给店员扫描或提供数字核销码' }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
v-if="orderInfo.deliveryType === 2"
|
||||
v-if="orderInfo.deliveryType === 2 && !isSorting"
|
||||
class="pickup-card borRadius14"
|
||||
>
|
||||
<image v-if="coverImageUrl" class="pickup-cover" :src="coverImageUrl" mode="aspectFill" />
|
||||
@@ -102,9 +122,6 @@
|
||||
default: 'order',
|
||||
},
|
||||
});
|
||||
const state = reactive({
|
||||
qrcodeSize: 145,
|
||||
});
|
||||
|
||||
const resolvePickUpStoreId = () => {
|
||||
return Number(
|
||||
@@ -208,6 +225,46 @@
|
||||
);
|
||||
});
|
||||
|
||||
const resolveStage = () => {
|
||||
const data = props.orderInfo || {};
|
||||
const external = Number(data?.preparationStatus);
|
||||
const rawStatus = Number.isFinite(external) ? external : Number(data?.preparationStatus ?? data?.status ?? 0);
|
||||
if (isVerifyCompleted.value) return 'done';
|
||||
if (rawStatus === 1 || rawStatus === 2) return 'wait';
|
||||
if (
|
||||
data?.deliveryTime ||
|
||||
data?.arriveStoreTime ||
|
||||
data?.deliveredTime ||
|
||||
rawStatus === 20
|
||||
) {
|
||||
return 'delivered';
|
||||
}
|
||||
return 'sorting';
|
||||
};
|
||||
|
||||
const isSorting = computed(() => resolveStage() === 'sorting');
|
||||
|
||||
const state = reactive({
|
||||
qrcodeSize: 145,
|
||||
});
|
||||
|
||||
const statusTagText = computed(() => {
|
||||
const s = resolveStage();
|
||||
if (s === 'sorting') return '分拣中';
|
||||
if (s === 'delivered') return '已送达门店';
|
||||
if (s === 'wait') return '待取货';
|
||||
if (s === 'done') return isVerifyCompleted.value ? '已核销' : '已完成';
|
||||
return '';
|
||||
});
|
||||
|
||||
const statusTagClass = computed(() => {
|
||||
const s = resolveStage();
|
||||
if (s === 'sorting') return 'status-tag--sorting';
|
||||
if (s === 'delivered') return 'status-tag--delivered';
|
||||
if (s === 'wait') return 'status-tag--wait';
|
||||
return 'status-tag--done';
|
||||
});
|
||||
|
||||
const addressText = computed(() => {
|
||||
const s = props.systemStore || {};
|
||||
const province = s.province || '';
|
||||
@@ -237,19 +294,30 @@
|
||||
const painterRef = ref(); // 海报画板
|
||||
const painterImageUrl = ref(); // 海报 url
|
||||
const showPainter = ref(true);
|
||||
const lastMarkCodeText = ref('');
|
||||
// 渲染海报
|
||||
const renderPoster = async (poster) => {
|
||||
if (!painterRef.value) return;
|
||||
await painterRef.value.render(poster);
|
||||
};
|
||||
// 获得生成的图片
|
||||
const setPainterImageUrl = (path) => {
|
||||
painterImageUrl.value = path;
|
||||
showPainter.value = false;
|
||||
};
|
||||
/**
|
||||
* 生成核销二维码
|
||||
*/
|
||||
const markCode = (text) => {
|
||||
const markCode = async (text) => {
|
||||
const code = String(text || '').trim();
|
||||
if (!code) return;
|
||||
// 相同取货码无需重复生成,避免重复触发海报组件销毁/重建的空指针
|
||||
if (lastMarkCodeText.value === code && painterImageUrl.value) return;
|
||||
lastMarkCodeText.value = code;
|
||||
// 如果 painterRef 已被销毁(showPainter=false 时 v-if 销毁了组件),先重建组件,等下一个 tick 再渲染
|
||||
if (!painterRef.value) {
|
||||
showPainter.value = true;
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
}
|
||||
renderPoster({
|
||||
css: {
|
||||
width: `${state.qrcodeSize}px`,
|
||||
@@ -258,7 +326,7 @@
|
||||
views: [
|
||||
{
|
||||
type: 'qrcode',
|
||||
text: text,
|
||||
text: code,
|
||||
css: {
|
||||
width: `${state.qrcodeSize}px`,
|
||||
height: `${state.qrcodeSize}px`,
|
||||
@@ -284,6 +352,7 @@
|
||||
border-radius: 10rpx;
|
||||
margin: 0 20rpx 20rpx 20rpx;
|
||||
}
|
||||
|
||||
.order-details .writeOff {
|
||||
background-color: #fff;
|
||||
margin-top: 15rpx;
|
||||
@@ -303,6 +372,11 @@
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.order-details .writeOff .title-left {
|
||||
gap: 16rpx;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.order-details .writeOff .title {
|
||||
font-size: 30rpx;
|
||||
color: #282828;
|
||||
@@ -310,6 +384,36 @@
|
||||
line-height: 87rpx;
|
||||
}
|
||||
|
||||
.order-details .writeOff .status-tag {
|
||||
flex-shrink: 0;
|
||||
height: 44rpx;
|
||||
line-height: 44rpx;
|
||||
padding: 0 16rpx;
|
||||
border-radius: 22rpx;
|
||||
font-size: 22rpx;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.order-details .writeOff .status-tag--sorting {
|
||||
color: #e8852f;
|
||||
background: rgba(232, 133, 47, 0.12);
|
||||
}
|
||||
|
||||
.order-details .writeOff .status-tag--delivered {
|
||||
color: #2556ec;
|
||||
background: rgba(37, 86, 236, 0.1);
|
||||
}
|
||||
|
||||
.order-details .writeOff .status-tag--wait {
|
||||
color: #12a06a;
|
||||
background: rgba(18, 160, 106, 0.1);
|
||||
}
|
||||
|
||||
.order-details .writeOff .status-tag--done {
|
||||
color: #86909c;
|
||||
background: rgba(134, 144, 156, 0.12);
|
||||
}
|
||||
|
||||
.order-details .writeOff .progress-btn {
|
||||
height: 52rpx;
|
||||
line-height: 52rpx;
|
||||
@@ -320,6 +424,48 @@
|
||||
background: rgba(91, 78, 255, 0.12);
|
||||
}
|
||||
|
||||
.preparation-placeholder {
|
||||
width: 590rpx;
|
||||
min-height: 384rpx;
|
||||
margin: 50rpx auto 0 auto;
|
||||
border-radius: 20rpx 20rpx 0 0;
|
||||
background: linear-gradient(180deg, #fff7ea 0%, #ffe9c8 100%);
|
||||
padding: 72rpx 48rpx 56rpx;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&__emoji {
|
||||
font-size: 84rpx;
|
||||
line-height: 1;
|
||||
margin-bottom: 28rpx;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
color: #7a4a00;
|
||||
line-height: 1.5;
|
||||
margin-bottom: 14rpx;
|
||||
}
|
||||
|
||||
&__desc {
|
||||
font-size: 24rpx;
|
||||
color: #a36d1a;
|
||||
line-height: 1.7;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.order-details .writeOff .num .num--pending {
|
||||
background: #f7f8fa;
|
||||
color: #98a2b3;
|
||||
font-size: 26rpx;
|
||||
letter-spacing: 2rpx;
|
||||
}
|
||||
|
||||
.order-details .writeOff .grayBg {
|
||||
background-color: #f2f5f7;
|
||||
width: 590rpx;
|
||||
|
||||
@@ -105,10 +105,6 @@
|
||||
return sheep.$helper.timeFormat(t, 'yyyy-mm-dd hh:MM:ss');
|
||||
};
|
||||
|
||||
const hasVerifyCode = computed(() => {
|
||||
return Boolean(state.orderInfo?.pickUpVerifyCode) && Boolean(state.orderInfo?.payStatus);
|
||||
});
|
||||
|
||||
const resolvePickUpStoreId = (data = {}) => {
|
||||
return Number(
|
||||
data?.pickUpStoreId ||
|
||||
@@ -145,6 +141,11 @@
|
||||
return resolveStage(state.orderInfo, state.preparationStatus);
|
||||
});
|
||||
|
||||
const hasVerifyCode = computed(() => {
|
||||
if (stage.value === 'sorting') return false;
|
||||
return Boolean(state.orderInfo?.pickUpVerifyCode) && Boolean(state.orderInfo?.payStatus);
|
||||
});
|
||||
|
||||
const steps = computed(() => {
|
||||
const createTime = formatTime(state.orderInfo?.createTime);
|
||||
const s = stage.value;
|
||||
|
||||
@@ -235,14 +235,29 @@
|
||||
const getStoreStatusLevel = (status) => STORE_STATUS_LEVEL[Number(status)] || 'closed';
|
||||
const isStoreOpen = (item) => Number(item?.status) === 1;
|
||||
|
||||
const sortStoreList = (list = []) => {
|
||||
const STATUS_WEIGHT = { 1: 0, 2: 1, 3: 2 };
|
||||
return [...list].sort((a, b) => {
|
||||
const wa = STATUS_WEIGHT[Number(a?.status)] ?? 99;
|
||||
const wb = STATUS_WEIGHT[Number(b?.status)] ?? 99;
|
||||
if (wa !== wb) return wa - wb;
|
||||
const da = Number(a?.distance);
|
||||
const db = Number(b?.distance);
|
||||
if (da >= 0 && db >= 0) return da - db;
|
||||
return 0;
|
||||
});
|
||||
};
|
||||
|
||||
const filteredStoreList = computed(() => {
|
||||
const list = Array.isArray(state.storeList) ? state.storeList : [];
|
||||
const kw = String(state.keyword || '').trim();
|
||||
if (!kw) return list;
|
||||
return list.filter((item) => {
|
||||
const s = `${item?.name || ''} ${formatAddress(item)}`.toLowerCase();
|
||||
return s.includes(kw.toLowerCase());
|
||||
});
|
||||
const raw = !kw
|
||||
? list
|
||||
: list.filter((item) => {
|
||||
const s = `${item?.name || ''} ${formatAddress(item)}`.toLowerCase();
|
||||
return s.includes(kw.toLowerCase());
|
||||
});
|
||||
return sortStoreList(raw);
|
||||
});
|
||||
|
||||
const selectedStore = computed(() => {
|
||||
|
||||
@@ -59,6 +59,19 @@ const OrderStoreApi = {
|
||||
},
|
||||
});
|
||||
},
|
||||
remindStore: (pickUpStoreId, orderId) => {
|
||||
return request({
|
||||
url: '/trade/order-store/remind',
|
||||
method: 'POST',
|
||||
params: {
|
||||
pickUpStoreId,
|
||||
orderId,
|
||||
},
|
||||
custom: {
|
||||
showLoading: false,
|
||||
},
|
||||
});
|
||||
},
|
||||
markSorted: (ids) => {
|
||||
const idText = Array.isArray(ids) ? ids.filter(Boolean).join(',') : String(ids || '');
|
||||
return request({
|
||||
|
||||
Reference in New Issue
Block a user