feat: 核销接口参数调整
This commit is contained in:
@@ -92,11 +92,38 @@
|
||||
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();
|
||||
if (!s) return '';
|
||||
if (s.includes(',')) return s.replace(/\s+/g, '');
|
||||
const n = Number(s);
|
||||
if (Number.isFinite(n) && n > 0) return String(n);
|
||||
return s.replace(/\s+/g, '');
|
||||
};
|
||||
|
||||
const getVerifyIds = async () => {
|
||||
const localIds = Array.isArray(userStore?.userInfo?.ids) ? userStore.userInfo.ids : [];
|
||||
if (localIds.length) return localIds;
|
||||
const userInfo = await userStore.getInfo();
|
||||
return Array.isArray(userInfo?.ids) ? userInfo.ids : [];
|
||||
const local = userStore?.userInfo || {};
|
||||
const fromLocal =
|
||||
local.storeIds ??
|
||||
local.storeIdList ??
|
||||
local.pickUpStoreIds ??
|
||||
local.pickUpStoreIdList ??
|
||||
local.storeId;
|
||||
let storeIds = toStoreIdsString(fromLocal);
|
||||
if (storeIds) return storeIds;
|
||||
const fetched = await userStore.getInfo();
|
||||
const fromFetched =
|
||||
fetched?.storeIds ??
|
||||
fetched?.storeIdList ??
|
||||
fetched?.pickUpStoreIds ??
|
||||
fetched?.pickUpStoreIdList ??
|
||||
fetched?.storeId;
|
||||
storeIds = toStoreIdsString(fromFetched);
|
||||
return storeIds;
|
||||
};
|
||||
|
||||
const verifyCode = async (code) => {
|
||||
@@ -107,8 +134,8 @@
|
||||
}
|
||||
if (verifying.value) return false;
|
||||
const ids = await getVerifyIds();
|
||||
if (!ids.length) {
|
||||
uni.showToast({ title: '缺少核销ids', icon: 'none' });
|
||||
if (!ids) {
|
||||
uni.showToast({ title: '缺少门店ID', icon: 'none' });
|
||||
return false;
|
||||
}
|
||||
verifying.value = true;
|
||||
|
||||
Reference in New Issue
Block a user