充值
This commit is contained in:
parent
8b25aca67a
commit
b1bd8d8e9f
@ -526,6 +526,8 @@ var default_api = 'https://api.global-interaction.com/';
|
|||||||
var query = Object.assign(aslanUserQuery(displayUserID), {
|
var query = Object.assign(aslanUserQuery(displayUserID), {
|
||||||
payCountryId:
|
payCountryId:
|
||||||
extra && (extra.pay_country_id || extra.payCountryId),
|
extra && (extra.pay_country_id || extra.payCountryId),
|
||||||
|
countryCode:
|
||||||
|
extra && (extra.country_code || extra.countryCode),
|
||||||
regionId: extra && (extra.region_id || extra.regionId),
|
regionId: extra && (extra.region_id || extra.regionId),
|
||||||
userId: extra && (extra.user_id || extra.userId),
|
userId: extra && (extra.user_id || extra.userId),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1239,7 +1239,16 @@
|
|||||||
.then(function (context) {
|
.then(function (context) {
|
||||||
// context 只返回安全账号信息和 audience_type;前端不读取手机号、邮箱、余额等敏感字段。
|
// context 只返回安全账号信息和 audience_type;前端不读取手机号、邮箱、余额等敏感字段。
|
||||||
state.context = context;
|
state.context = context;
|
||||||
selectPayCountryFromContext(context);
|
var selectedPayCountry =
|
||||||
|
selectPayCountryFromConfig(context);
|
||||||
|
if (
|
||||||
|
configuredMifaPayCountries().length &&
|
||||||
|
!selectedPayCountry
|
||||||
|
) {
|
||||||
|
return Promise.resolve(
|
||||||
|
emptyOptionsForSelectedCountry(context)
|
||||||
|
);
|
||||||
|
}
|
||||||
return window.HyAppAPI.recharge.options(
|
return window.HyAppAPI.recharge.options(
|
||||||
context.auth_mode === 'token'
|
context.auth_mode === 'token'
|
||||||
? ''
|
? ''
|
||||||
@ -1255,6 +1264,7 @@
|
|||||||
})
|
})
|
||||||
.then(function (options) {
|
.then(function (options) {
|
||||||
// 商品和支付方式必须跟随已确认账号重新加载,切换账号后清空旧选择和旧订单。
|
// 商品和支付方式必须跟随已确认账号重新加载,切换账号后清空旧选择和旧订单。
|
||||||
|
applyResolvedPayCountry(options);
|
||||||
state.options = options;
|
state.options = options;
|
||||||
state.selectedProductID = 0;
|
state.selectedProductID = 0;
|
||||||
state.selectedMethodKey = '';
|
state.selectedMethodKey = '';
|
||||||
@ -2244,7 +2254,36 @@
|
|||||||
return params;
|
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 =
|
var countries =
|
||||||
(context && (context.country_list || context.countryList)) ||
|
(context && (context.country_list || context.countryList)) ||
|
||||||
[];
|
[];
|
||||||
@ -2270,6 +2309,82 @@
|
|||||||
selected.currencyCode ||
|
selected.currencyCode ||
|
||||||
state.selectedCurrencyCode ||
|
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 给服务端幂等使用,包含时间、商品、方式和随机后缀;真实订单号仍由后端生成。
|
// command_id 给服务端幂等使用,包含时间、商品、方式和随机后缀;真实订单号仍由后端生成。
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user