31 lines
883 B
JavaScript
31 lines
883 B
JavaScript
import { isPc, isWeiXin } from 'oak-frontend-base/es/utils/utils';
|
|
export function getWpProductTypeFromEnv() {
|
|
switch (process.env.OAK_PLATFORM) {
|
|
case 'web': {
|
|
if (isWeiXin) {
|
|
return ['jsapi', 'native'];
|
|
}
|
|
else if (isPc) {
|
|
return ['native'];
|
|
}
|
|
// 手机端非微信环境
|
|
return ['h5', 'native'];
|
|
}
|
|
case 'wechatMp': {
|
|
return ['mp'];
|
|
}
|
|
case 'native': {
|
|
return ['app'];
|
|
}
|
|
}
|
|
return [];
|
|
}
|
|
export 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';
|
|
}
|