This commit is contained in:
parent
d7a32793ed
commit
fcbc113be0
|
|
@ -38,15 +38,22 @@ export interface BoundMerchantInfo {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
supplier?: {
|
supplier?: {
|
||||||
give_rate?: string | number;
|
fee_rate?: string | number;
|
||||||
};
|
};
|
||||||
give_rate?: string | number;
|
fee_rate?: string | number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SupplierInfo {
|
export interface SupplierInfo {
|
||||||
supplier_id?: string | number;
|
supplier_id?: string | number;
|
||||||
supplier_name?: string;
|
supplier_name?: string;
|
||||||
logo?: string;
|
logo?: string;
|
||||||
|
fee_rate?: string | number;
|
||||||
|
supplier?: {
|
||||||
|
supplier_id?: string | number;
|
||||||
|
supplier_name?: string;
|
||||||
|
logo?: string;
|
||||||
|
fee_rate?: string | number;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ApiResult<T = any> {
|
export interface ApiResult<T = any> {
|
||||||
|
|
|
||||||
|
|
@ -149,9 +149,9 @@ const accumulationAmount = computed(() => {
|
||||||
const showBenefitTip = computed(() => Number(merchant.value.accumulationRate) > 0);
|
const showBenefitTip = computed(() => Number(merchant.value.accumulationRate) > 0);
|
||||||
const benefitTitle = computed(() => `预计获得${scoreName.value || '物业公积金'}`);
|
const benefitTitle = computed(() => `预计获得${scoreName.value || '物业公积金'}`);
|
||||||
|
|
||||||
const parseGiveRate = (giveRate: unknown) => {
|
const parseFeeRate = (feeRate: unknown) => {
|
||||||
if (giveRate === undefined || giveRate === null || giveRate === '') return 0;
|
if (feeRate === undefined || feeRate === null || feeRate === '') return 0;
|
||||||
const rate = Number(giveRate);
|
const rate = Number(feeRate);
|
||||||
if (!Number.isFinite(rate) || rate <= 0) return 0;
|
if (!Number.isFinite(rate) || rate <= 0) return 0;
|
||||||
return rate / 100;
|
return rate / 100;
|
||||||
};
|
};
|
||||||
|
|
@ -174,13 +174,14 @@ interface PropertyBindingCache {
|
||||||
merchant_id?: string;
|
merchant_id?: string;
|
||||||
merchant_name?: string;
|
merchant_name?: string;
|
||||||
score_name?: string;
|
score_name?: string;
|
||||||
give_rate?: string | number;
|
fee_rate?: string | number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SupplierCache {
|
interface SupplierCache {
|
||||||
supplier_id?: string | number;
|
supplier_id?: string | number;
|
||||||
supplier_name?: string;
|
supplier_name?: string;
|
||||||
logo?: string;
|
logo?: string;
|
||||||
|
fee_rate?: string | number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const applyBindingInfo = (binding?: PropertyBindingCache | null) => {
|
const applyBindingInfo = (binding?: PropertyBindingCache | null) => {
|
||||||
|
|
@ -188,7 +189,7 @@ const applyBindingInfo = (binding?: PropertyBindingCache | null) => {
|
||||||
applyMerchantInfo({
|
applyMerchantInfo({
|
||||||
merchant_id: binding.merchant_id,
|
merchant_id: binding.merchant_id,
|
||||||
merchant_name: binding.merchant_name,
|
merchant_name: binding.merchant_name,
|
||||||
accumulationRate: parseGiveRate(binding.give_rate)
|
accumulationRate: parseFeeRate(binding.fee_rate)
|
||||||
});
|
});
|
||||||
if (binding.score_name) {
|
if (binding.score_name) {
|
||||||
scoreName.value = binding.score_name;
|
scoreName.value = binding.score_name;
|
||||||
|
|
@ -199,7 +200,8 @@ const applySupplierInfo = (supplier?: SupplierCache | null) => {
|
||||||
if (!supplier) return;
|
if (!supplier) return;
|
||||||
applyMerchantInfo({
|
applyMerchantInfo({
|
||||||
name: supplier.supplier_name,
|
name: supplier.supplier_name,
|
||||||
background: supplier.logo
|
background: supplier.logo,
|
||||||
|
accumulationRate: parseFeeRate(supplier.fee_rate)
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -289,7 +291,7 @@ const loadPropertyBinding = async (merchantUrl: string) => {
|
||||||
merchant_id: merchantData.merchant_id,
|
merchant_id: merchantData.merchant_id,
|
||||||
merchant_name: merchantData.merchant_name,
|
merchant_name: merchantData.merchant_name,
|
||||||
score_name: merchantData.config?.score_name,
|
score_name: merchantData.config?.score_name,
|
||||||
give_rate: supplierData.give_rate ?? payload.give_rate
|
fee_rate: supplierData.fee_rate ?? payload.fee_rate
|
||||||
};
|
};
|
||||||
applyBindingInfo(latestBinding);
|
applyBindingInfo(latestBinding);
|
||||||
encryptedStorage.set(cacheKey, latestBinding, PROPERTY_CACHE_TTL_SECONDS);
|
encryptedStorage.set(cacheKey, latestBinding, PROPERTY_CACHE_TTL_SECONDS);
|
||||||
|
|
@ -309,10 +311,13 @@ const loadSupplier = async (merchantUrl: string) => {
|
||||||
const response = await supplierByUrl(merchantUrl);
|
const response = await supplierByUrl(merchantUrl);
|
||||||
if (Number(response?.code) !== 200 || !response?.data) return;
|
if (Number(response?.code) !== 200 || !response?.data) return;
|
||||||
|
|
||||||
|
const payload = response.data || {};
|
||||||
|
const supplierData = payload.supplier || payload;
|
||||||
const latestSupplier: SupplierCache = {
|
const latestSupplier: SupplierCache = {
|
||||||
supplier_id: response.data.supplier_id,
|
supplier_id: supplierData.supplier_id,
|
||||||
supplier_name: response.data.supplier_name,
|
supplier_name: supplierData.supplier_name,
|
||||||
logo: response.data.logo
|
logo: supplierData.logo,
|
||||||
|
fee_rate: supplierData.fee_rate
|
||||||
};
|
};
|
||||||
applySupplierInfo(latestSupplier);
|
applySupplierInfo(latestSupplier);
|
||||||
encryptedStorage.set(cacheKey, latestSupplier, SUPPLIER_CACHE_TTL_SECONDS);
|
encryptedStorage.set(cacheKey, latestSupplier, SUPPLIER_CACHE_TTL_SECONDS);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue