35 lines
1.0 KiB
JavaScript
35 lines
1.0 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.getWpProductTypeFromEnv = getWpProductTypeFromEnv;
|
|
exports.canStartPay = canStartPay;
|
|
const utils_1 = require("oak-frontend-base/es/utils/utils");
|
|
function getWpProductTypeFromEnv() {
|
|
switch (process.env.OAK_PLATFORM) {
|
|
case 'web': {
|
|
if (utils_1.isWeiXin) {
|
|
return ['jsapi', 'native'];
|
|
}
|
|
else if (utils_1.isPc) {
|
|
return ['native', 'h5'];
|
|
}
|
|
// 手机端非微信环境
|
|
return ['h5', 'native'];
|
|
}
|
|
case 'wechatMp': {
|
|
return ['mp'];
|
|
}
|
|
case 'native': {
|
|
return ['app'];
|
|
}
|
|
}
|
|
return [];
|
|
}
|
|
function canStartPay(pay, features) {
|
|
const { applicationId, wpProduct } = pay;
|
|
if (features.application.getApplicationId() !== applicationId) {
|
|
return false;
|
|
}
|
|
const types = getWpProductTypeFromEnv();
|
|
return types.includes(wpProduct.type) && wpProduct.type !== 'native';
|
|
}
|