fix: some
All checks were successful
构建并部署前端到生产环境 / build-and-deploy (push) Successful in 2m59s

This commit is contained in:
luo
2026-10-13 14:53:19 +08:00
parent 77b0e25011
commit da95a914e3
31 changed files with 1702 additions and 116 deletions

View File

@@ -1,25 +1,26 @@
const PHONE_BIND_STATUS_KEY = 'phoneBindStatus';
const readStatuses = () => {
const statuses = uni.getStorageSync(PHONE_BIND_STATUS_KEY);
return statuses && typeof statuses === 'object' && !Array.isArray(statuses) ? statuses : {};
// A customer phone or an old cache does not prove an asset association exists.
export const optionalBoolean = (value) => {
if (value === true || value === 1) return true;
if (value === false || value === 0) return false;
return null;
};
export const getPhoneBindStatus = (identifier) => {
if (!identifier) return null;
const status = readStatuses()[identifier];
return status && status.bound ? status : null;
export const getPhoneBindingMode = (customerPhone, assetPhoneBound) => {
if (customerPhone === null || assetPhoneBound === null) return 'unknown';
if (!customerPhone) return assetPhoneBound ? 'customer' : 'customer-asset';
return assetPhoneBound ? 'none' : 'asset';
};
export const setPhoneBindStatus = (identifier, phone) => {
if (!identifier) return;
const statuses = readStatuses();
statuses[identifier] = {
bound: true,
phone: phone || '',
updatedAt: Date.now()
};
uni.setStorageSync(PHONE_BIND_STATUS_KEY, statuses);
export const getBindingSuccessState = (state, phone, mode) => {
if (mode === 'customer-asset') {
return { customerPhone: phone, assetPhoneBound: true, assetPhoneIsOwn: true, needBindPhone: false };
}
if (mode === 'asset') {
return { assetPhoneBound: true, assetPhoneIsOwn: phone === state.customerPhone, needBindPhone: false };
}
if (mode === 'customer') {
return { customerPhone: phone, assetPhoneIsOwn: null, needBindPhone: false };
}
// An ambiguous success response does not identify which phone was changed.
return { needBindPhone: false };
};