This commit is contained in:
zhx 2026-06-23 21:30:12 +08:00
parent 8b25aca67a
commit b1bd8d8e9f
2 changed files with 119 additions and 2 deletions

View File

@ -526,6 +526,8 @@ var default_api = 'https://api.global-interaction.com/';
var query = Object.assign(aslanUserQuery(displayUserID), {
payCountryId:
extra && (extra.pay_country_id || extra.payCountryId),
countryCode:
extra && (extra.country_code || extra.countryCode),
regionId: extra && (extra.region_id || extra.regionId),
userId: extra && (extra.user_id || extra.userId),
});

View File

@ -1239,7 +1239,16 @@
.then(function (context) {
// context 只返回安全账号信息和 audience_type前端不读取手机号、邮箱、余额等敏感字段。
state.context = context;
selectPayCountryFromContext(context);
var selectedPayCountry =
selectPayCountryFromConfig(context);
if (
configuredMifaPayCountries().length &&
!selectedPayCountry
) {
return Promise.resolve(
emptyOptionsForSelectedCountry(context)
);
}
return window.HyAppAPI.recharge.options(
context.auth_mode === 'token'
? ''
@ -1255,6 +1264,7 @@
})
.then(function (options) {
// 商品和支付方式必须跟随已确认账号重新加载,切换账号后清空旧选择和旧订单。
applyResolvedPayCountry(options);
state.options = options;
state.selectedProductID = 0;
state.selectedMethodKey = '';
@ -2244,7 +2254,36 @@
return params;
}
function selectPayCountryFromContext(context) {
function selectPayCountryFromConfig(context) {
var configured = selectedConfiguredPayCountry(context);
if (configured) {
state.selectedPayCountryID =
configured.pay_country_id ||
configured.payCountryId ||
configured.id ||
'';
state.selectedCountryCode = String(
configured.country_code ||
configured.countryCode ||
''
).toUpperCase();
state.selectedCurrencyCode =
configured.currency_code ||
configured.currencyCode ||
state.selectedCurrencyCode ||
'';
return configured;
}
if (configuredMifaPayCountries().length) {
// Aslan H5 只按接口返回的用户国家匹配本地支付 JSON没有对应国家时不兜底到其它国家。
state.selectedPayCountryID = '';
state.selectedCountryCode =
userCountryCodeFromContext(context);
state.selectedCurrencyCode = '';
return null;
}
var countries =
(context && (context.country_list || context.countryList)) ||
[];
@ -2270,6 +2309,82 @@
selected.currencyCode ||
state.selectedCurrencyCode ||
'';
return selected && Object.keys(selected).length
? selected
: null;
}
function selectedConfiguredPayCountry(context) {
var countries = configuredMifaPayCountries();
if (!countries.length) return null;
var userCountryCode = userCountryCodeFromContext(context);
if (!userCountryCode) return null;
return (
countries.find(function (country) {
return (
String(
country.country_code ||
country.countryCode ||
''
).toUpperCase() === userCountryCode
);
}) || null
);
}
function configuredMifaPayCountries() {
var config = state.appConfig || {};
var providers = config.providers || {};
var mifapay = providers.mifapay || {};
return Array.isArray(mifapay.countries)
? mifapay.countries
: [];
}
function userCountryCodeFromContext(context) {
context = context || {};
var account = (context && context.account) || {};
return String(
account.country_code ||
account.countryCode ||
context.country_code ||
context.countryCode ||
''
).toUpperCase();
}
function emptyOptionsForSelectedCountry(context) {
return {
products: [],
payment_methods: [],
pay_country_id: state.selectedPayCountryID,
country_code:
state.selectedCountryCode ||
userCountryCodeFromContext(context),
currency_code: state.selectedCurrencyCode,
usd_to_currency_rate: 0,
usdt_trc20_enabled: false,
};
}
function applyResolvedPayCountry(options) {
options = options || {};
state.selectedPayCountryID =
options.pay_country_id ||
options.payCountryId ||
state.selectedPayCountryID ||
'';
state.selectedCountryCode = String(
options.country_code ||
options.countryCode ||
state.selectedCountryCode ||
''
).toUpperCase();
state.selectedCurrencyCode =
options.currency_code ||
options.currencyCode ||
state.selectedCurrencyCode ||
'';
}
// command_id 给服务端幂等使用,包含时间、商品、方式和随机后缀;真实订单号仍由后端生成。