@foundbyte/uni-libs 0.0.13 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/entry.d.ts +1 -2
- package/es/entry.js +0 -3
- package/es/enums/platform/index.d.ts +8 -0
- package/es/enums/platform/index.js +10 -0
- package/es/index.d.ts +4 -2
- package/es/index.js +4 -2
- package/es/utils/native-app/index.d.ts +15 -0
- package/es/utils/native-app/index.js +115 -0
- package/es/utils/uni-env/index.d.ts +24 -1
- package/es/utils/uni-env/index.js +13 -3
- package/package.json +1 -1
- package/es/services/native-app/service.d.ts +0 -29
- package/es/services/native-app/service.js +0 -123
package/es/entry.d.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { IOneTravelSDKConfig } from "./types/one-travel-service/index.js";
|
|
2
2
|
import { GoodsService } from "./services/goods/service.js";
|
|
3
|
-
import { NativeAppService } from "./services/native-app/service.js";
|
|
4
3
|
import { IAppConfig } from "./configs/app/app.type.js";
|
|
5
4
|
|
|
6
5
|
//#region src/entry.d.ts
|
|
6
|
+
|
|
7
7
|
/**
|
|
8
8
|
* 一码游SDK
|
|
9
9
|
*/
|
|
10
10
|
declare class OneTravelSDK {
|
|
11
11
|
private sdkConfig;
|
|
12
12
|
readonly goodsService: GoodsService;
|
|
13
|
-
readonly nativeAppService: NativeAppService;
|
|
14
13
|
constructor(config?: Partial<IOneTravelSDKConfig>);
|
|
15
14
|
/**
|
|
16
15
|
* 获取App配置信息
|
package/es/entry.js
CHANGED
|
@@ -2,7 +2,6 @@ import { EAppEnv } from "./enums/environment/index.js";
|
|
|
2
2
|
import { ECaller } from "./enums/sdk/index.js";
|
|
3
3
|
import { getAppConfig } from "./configs/app/index.js";
|
|
4
4
|
import { GoodsService } from "./services/goods/service.js";
|
|
5
|
-
import { NativeAppService } from "./services/native-app/service.js";
|
|
6
5
|
|
|
7
6
|
//#region src/entry.ts
|
|
8
7
|
/**
|
|
@@ -11,7 +10,6 @@ import { NativeAppService } from "./services/native-app/service.js";
|
|
|
11
10
|
var OneTravelSDK = class {
|
|
12
11
|
sdkConfig;
|
|
13
12
|
goodsService;
|
|
14
|
-
nativeAppService;
|
|
15
13
|
constructor(config) {
|
|
16
14
|
const value = {
|
|
17
15
|
appEnv: EAppEnv.prod,
|
|
@@ -20,7 +18,6 @@ var OneTravelSDK = class {
|
|
|
20
18
|
};
|
|
21
19
|
this.sdkConfig = value;
|
|
22
20
|
this.goodsService = new GoodsService({ sdkConfig: value });
|
|
23
|
-
this.nativeAppService = new NativeAppService({ sdkConfig: value });
|
|
24
21
|
}
|
|
25
22
|
/**
|
|
26
23
|
* 获取App配置信息
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/enums/platform/index.ts
|
|
2
|
+
let EUniPlatform = /* @__PURE__ */ function(EUniPlatform$1) {
|
|
3
|
+
EUniPlatform$1["android"] = "android";
|
|
4
|
+
EUniPlatform$1["ios"] = "ios";
|
|
5
|
+
EUniPlatform$1["harmony"] = "harmony";
|
|
6
|
+
return EUniPlatform$1;
|
|
7
|
+
}({});
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { EUniPlatform };
|
package/es/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { ECaller } from "./enums/sdk/index.js";
|
|
|
6
6
|
import { EVenueSimpleTypes, EVenueTypes } from "./enums/sub/enjoy/index.js";
|
|
7
7
|
import { EFoodPackageType, EFoodsModuleType } from "./enums/sub/foods/index.js";
|
|
8
8
|
import { EHotelType } from "./enums/sub/hotel/index.js";
|
|
9
|
+
import { EUniPlatform } from "./enums/platform/index.js";
|
|
9
10
|
import { IOneTravelSDKConfig } from "./types/one-travel-service/index.js";
|
|
10
11
|
import { getQueryParameters, isEmpty, query2url } from "./utils/common/index.js";
|
|
11
12
|
import { ActivityCalendarDetailPageParams, getActivityCalendarDetailPage } from "./utils/pages/activity-calendar/index.js";
|
|
@@ -13,6 +14,7 @@ import { WebviewPageParams, getWebviewPage } from "./utils/pages/webview/index.j
|
|
|
13
14
|
import { getFoodPackagePage, getFoodStorePage } from "./utils/pages/food/index.js";
|
|
14
15
|
import { getMoviePage } from "./utils/pages/movie/index.js";
|
|
15
16
|
import { EMessagesType, navigateBack, navigateTo, postMessage, redirectTo } from "./utils/web-view/index.js";
|
|
16
|
-
import { isAndroid, isApp, isH5, isHarmony, isWeixin, isiOS } from "./utils/uni-env/index.js";
|
|
17
|
+
import { getSystemInfoSync, isAndroid, isApp, isH5, isHarmony, isWeixin, isiOS } from "./utils/uni-env/index.js";
|
|
18
|
+
import { checkAndRequestNativeAppPermission } from "./utils/native-app/index.js";
|
|
17
19
|
import { OneTravelSDK } from "./entry.js";
|
|
18
|
-
export { ActivityCalendarDetailPageParams, BusinessLineDict, EAppEnv, EBusinessLine, ECaller, EFoodPackageType, EFoodsModuleType, EHotelType, EMessagesType, ESubBizType, EVenueSimpleTypes, EVenueTypes, IOneTravelSDKConfig, OneTravelSDK, WebviewPageParams, app_permission, getActivityCalendarDetailPage, getFoodPackagePage, getFoodStorePage, getMoviePage, getQueryParameters, getWebviewPage, isAndroid, isApp, isEmpty, isH5, isHarmony, isWeixin, isiOS, navigateBack, navigateTo, postMessage, query2url, redirectTo, routePrefix, routes };
|
|
20
|
+
export { ActivityCalendarDetailPageParams, BusinessLineDict, EAppEnv, EBusinessLine, ECaller, EFoodPackageType, EFoodsModuleType, EHotelType, EMessagesType, ESubBizType, EUniPlatform, EVenueSimpleTypes, EVenueTypes, IOneTravelSDKConfig, OneTravelSDK, WebviewPageParams, app_permission, checkAndRequestNativeAppPermission, getActivityCalendarDetailPage, getFoodPackagePage, getFoodStorePage, getMoviePage, getQueryParameters, getSystemInfoSync, getWebviewPage, isAndroid, isApp, isEmpty, isH5, isHarmony, isWeixin, isiOS, navigateBack, navigateTo, postMessage, query2url, redirectTo, routePrefix, routes };
|
package/es/index.js
CHANGED
|
@@ -6,13 +6,15 @@ import { ECaller } from "./enums/sdk/index.js";
|
|
|
6
6
|
import { EVenueSimpleTypes, EVenueTypes } from "./enums/sub/enjoy/index.js";
|
|
7
7
|
import { EFoodPackageType, EFoodsModuleType } from "./enums/sub/foods/index.js";
|
|
8
8
|
import { EHotelType } from "./enums/sub/hotel/index.js";
|
|
9
|
+
import { EUniPlatform } from "./enums/platform/index.js";
|
|
9
10
|
import { getQueryParameters, isEmpty, query2url } from "./utils/common/index.js";
|
|
10
11
|
import { getActivityCalendarDetailPage } from "./utils/pages/activity-calendar/index.js";
|
|
11
12
|
import { getWebviewPage } from "./utils/pages/webview/index.js";
|
|
12
13
|
import { getFoodPackagePage, getFoodStorePage } from "./utils/pages/food/index.js";
|
|
13
14
|
import { getMoviePage } from "./utils/pages/movie/index.js";
|
|
14
15
|
import { EMessagesType, navigateBack, navigateTo, postMessage, redirectTo } from "./utils/web-view/index.js";
|
|
15
|
-
import { isAndroid, isApp, isH5, isHarmony, isWeixin, isiOS } from "./utils/uni-env/index.js";
|
|
16
|
+
import { getSystemInfoSync, isAndroid, isApp, isH5, isHarmony, isWeixin, isiOS } from "./utils/uni-env/index.js";
|
|
17
|
+
import { checkAndRequestNativeAppPermission } from "./utils/native-app/index.js";
|
|
16
18
|
import { OneTravelSDK } from "./entry.js";
|
|
17
19
|
|
|
18
|
-
export { BusinessLineDict, EAppEnv, EBusinessLine, ECaller, EFoodPackageType, EFoodsModuleType, EHotelType, EMessagesType, ESubBizType, EVenueSimpleTypes, EVenueTypes, OneTravelSDK, app_permission, getActivityCalendarDetailPage, getFoodPackagePage, getFoodStorePage, getMoviePage, getQueryParameters, getWebviewPage, isAndroid, isApp, isEmpty, isH5, isHarmony, isWeixin, isiOS, navigateBack, navigateTo, postMessage, query2url, redirectTo, routePrefix, routes };
|
|
20
|
+
export { BusinessLineDict, EAppEnv, EBusinessLine, ECaller, EFoodPackageType, EFoodsModuleType, EHotelType, EMessagesType, ESubBizType, EUniPlatform, EVenueSimpleTypes, EVenueTypes, OneTravelSDK, app_permission, checkAndRequestNativeAppPermission, getActivityCalendarDetailPage, getFoodPackagePage, getFoodStorePage, getMoviePage, getQueryParameters, getSystemInfoSync, getWebviewPage, isAndroid, isApp, isEmpty, isH5, isHarmony, isWeixin, isiOS, navigateBack, navigateTo, postMessage, query2url, redirectTo, routePrefix, routes };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { app_permission } from "../../constants/permission/index.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/native-app/index.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 检测并申请app权限
|
|
7
|
+
* @param options
|
|
8
|
+
*/
|
|
9
|
+
declare const checkAndRequestNativeAppPermission: (options: {
|
|
10
|
+
type: keyof typeof app_permission;
|
|
11
|
+
success?: () => void;
|
|
12
|
+
fail?: () => void;
|
|
13
|
+
}) => void;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { checkAndRequestNativeAppPermission };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { app_permission } from "../../constants/permission/index.js";
|
|
2
|
+
import { isH5, isHarmony, isWeixin, isiOS } from "../uni-env/index.js";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/native-app/index.ts
|
|
5
|
+
let plusNativeObjView;
|
|
6
|
+
/**
|
|
7
|
+
* 关闭安卓提示弹框
|
|
8
|
+
*/
|
|
9
|
+
const closeAndroidTip = () => {
|
|
10
|
+
if (plusNativeObjView) {
|
|
11
|
+
plusNativeObjView.close();
|
|
12
|
+
plusNativeObjView = void 0;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* 显示安卓提示弹框
|
|
17
|
+
* @param options
|
|
18
|
+
*/
|
|
19
|
+
const showAndroidTip = (options) => {
|
|
20
|
+
const { title, value } = options;
|
|
21
|
+
plusNativeObjView = new plus.nativeObj.View("per-modal", {
|
|
22
|
+
top: "0px",
|
|
23
|
+
left: "0px",
|
|
24
|
+
width: "100%",
|
|
25
|
+
backgroundColor: "rgba(0,0,0,0.2)"
|
|
26
|
+
});
|
|
27
|
+
plusNativeObjView.drawRect({
|
|
28
|
+
color: "#fff",
|
|
29
|
+
radius: "5px"
|
|
30
|
+
}, {
|
|
31
|
+
top: "45px",
|
|
32
|
+
left: "5%",
|
|
33
|
+
width: "90%",
|
|
34
|
+
height: "130px"
|
|
35
|
+
});
|
|
36
|
+
plusNativeObjView.drawText(title, {
|
|
37
|
+
top: "50px",
|
|
38
|
+
left: "8%",
|
|
39
|
+
height: "30px"
|
|
40
|
+
}, {
|
|
41
|
+
align: "left",
|
|
42
|
+
weight: "bold",
|
|
43
|
+
color: "#000"
|
|
44
|
+
});
|
|
45
|
+
plusNativeObjView.drawText(value, {
|
|
46
|
+
top: "75px",
|
|
47
|
+
height: "90px",
|
|
48
|
+
left: "8%",
|
|
49
|
+
width: "84%"
|
|
50
|
+
}, {
|
|
51
|
+
whiteSpace: "normal",
|
|
52
|
+
size: "14px",
|
|
53
|
+
align: "left",
|
|
54
|
+
color: "#656563"
|
|
55
|
+
});
|
|
56
|
+
plusNativeObjView.show();
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* 检测并申请app权限
|
|
60
|
+
* @param options
|
|
61
|
+
*/
|
|
62
|
+
const checkAndRequestNativeAppPermission = (options) => {
|
|
63
|
+
const { type, success, fail } = options || {};
|
|
64
|
+
if (isWeixin() || isH5() || isHarmony() || isiOS()) {
|
|
65
|
+
success?.();
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const ActivityCompat = plus.android.importClass("androidx.core.app.ActivityCompat");
|
|
69
|
+
const PackageManager = plus.android.importClass("android.content.pm.PackageManager");
|
|
70
|
+
const context = plus.android.runtimeMainActivity();
|
|
71
|
+
const detail = app_permission[type];
|
|
72
|
+
let hasPermission = false;
|
|
73
|
+
detail.permissionId.forEach((item) => {
|
|
74
|
+
if (ActivityCompat.checkSelfPermission(context, item) !== PackageManager.PERMISSION_GRANTED) {
|
|
75
|
+
hasPermission = true;
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
if (!hasPermission) {
|
|
80
|
+
success?.();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
showAndroidTip(detail);
|
|
84
|
+
plus.android.requestPermissions(detail.permissionId, function(resultObj) {
|
|
85
|
+
if (resultObj.granted.length > 0) {
|
|
86
|
+
closeAndroidTip();
|
|
87
|
+
success?.();
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (resultObj.deniedPresent.length > 0) {
|
|
91
|
+
closeAndroidTip();
|
|
92
|
+
fail?.();
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (resultObj.deniedAlways.length > 0) {
|
|
96
|
+
uni.showModal({
|
|
97
|
+
title: "提示",
|
|
98
|
+
content: app_permission[type].denied,
|
|
99
|
+
confirmText: "去设置",
|
|
100
|
+
success: function(res) {
|
|
101
|
+
closeAndroidTip();
|
|
102
|
+
if (res.confirm) uni.openAppAuthorizeSetting({ success: () => fail?.() });
|
|
103
|
+
if (res.cancel) fail?.();
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
}, function() {
|
|
109
|
+
closeAndroidTip();
|
|
110
|
+
fail?.();
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
//#endregion
|
|
115
|
+
export { checkAndRequestNativeAppPermission };
|
|
@@ -29,5 +29,28 @@ declare const isAndroid: () => boolean;
|
|
|
29
29
|
* @returns
|
|
30
30
|
*/
|
|
31
31
|
declare const isiOS: () => boolean;
|
|
32
|
+
declare function getSystemInfoSync(): UniApp.GetSystemInfoResult | {
|
|
33
|
+
pixelRatio: number;
|
|
34
|
+
screenWidth: number;
|
|
35
|
+
screenHeight: number;
|
|
36
|
+
windowWidth: number;
|
|
37
|
+
windowHeight: number;
|
|
38
|
+
statusBarHeight: number;
|
|
39
|
+
windowTop: number;
|
|
40
|
+
windowBottom: number;
|
|
41
|
+
safeArea: UniApp.SafeArea;
|
|
42
|
+
safeAreaInsets: UniApp.SafeAreaInsets;
|
|
43
|
+
screenTop: number;
|
|
44
|
+
deviceBrand?: string;
|
|
45
|
+
deviceModel: string;
|
|
46
|
+
deviceId: string;
|
|
47
|
+
deviceType: string;
|
|
48
|
+
devicePixelRatio: number;
|
|
49
|
+
deviceOrientation: "portrait" | "landscape";
|
|
50
|
+
brand?: string;
|
|
51
|
+
model: string;
|
|
52
|
+
system: string;
|
|
53
|
+
platform: string;
|
|
54
|
+
};
|
|
32
55
|
//#endregion
|
|
33
|
-
export { isAndroid, isApp, isH5, isHarmony, isWeixin, isiOS };
|
|
56
|
+
export { getSystemInfoSync, isAndroid, isApp, isH5, isHarmony, isWeixin, isiOS };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { EUniPlatform } from "../../enums/platform/index.js";
|
|
2
|
+
|
|
1
3
|
//#region src/utils/uni-env/index.ts
|
|
2
4
|
/**
|
|
3
5
|
* 是否是web环境
|
|
@@ -33,15 +35,23 @@ const isApp = () => {
|
|
|
33
35
|
* @returns
|
|
34
36
|
*/
|
|
35
37
|
const isAndroid = () => {
|
|
36
|
-
return true;
|
|
38
|
+
if (isApp() && getSystemInfoSync().platform === EUniPlatform.android) return true;
|
|
39
|
+
return false;
|
|
37
40
|
};
|
|
38
41
|
/**
|
|
39
42
|
* 是否是iOS
|
|
40
43
|
* @returns
|
|
41
44
|
*/
|
|
42
45
|
const isiOS = () => {
|
|
43
|
-
return true;
|
|
46
|
+
if (isApp() && getSystemInfoSync().platform === EUniPlatform.ios) return true;
|
|
47
|
+
return false;
|
|
44
48
|
};
|
|
49
|
+
function getSystemInfoSync() {
|
|
50
|
+
return {
|
|
51
|
+
...uni.getDeviceInfo(),
|
|
52
|
+
...uni.getWindowInfo()
|
|
53
|
+
};
|
|
54
|
+
}
|
|
45
55
|
|
|
46
56
|
//#endregion
|
|
47
|
-
export { isAndroid, isApp, isH5, isHarmony, isWeixin, isiOS };
|
|
57
|
+
export { getSystemInfoSync, isAndroid, isApp, isH5, isHarmony, isWeixin, isiOS };
|
package/package.json
CHANGED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { app_permission } from "../../constants/permission/index.js";
|
|
2
|
-
import { IOneTravelSDKConfig } from "../../types/one-travel-service/index.js";
|
|
3
|
-
|
|
4
|
-
//#region src/services/native-app/service.d.ts
|
|
5
|
-
type INativeAppServiceConfig = {
|
|
6
|
-
sdkConfig: IOneTravelSDKConfig;
|
|
7
|
-
};
|
|
8
|
-
declare class NativeAppService {
|
|
9
|
-
private nativeAppServiceConfig;
|
|
10
|
-
constructor(config: INativeAppServiceConfig);
|
|
11
|
-
/**
|
|
12
|
-
* 关闭安卓提示弹框
|
|
13
|
-
*/
|
|
14
|
-
private closeAndroidTip;
|
|
15
|
-
/**
|
|
16
|
-
* 显示安卓提示弹框
|
|
17
|
-
* @param options
|
|
18
|
-
*/
|
|
19
|
-
private showAndroidTip;
|
|
20
|
-
/**
|
|
21
|
-
* 检测并申请app权限
|
|
22
|
-
* @param type
|
|
23
|
-
* @param success
|
|
24
|
-
* @param fail
|
|
25
|
-
*/
|
|
26
|
-
checkAndRequestNativeAppPermissions: (type: keyof typeof app_permission, success?: () => void, fail?: () => void) => void;
|
|
27
|
-
}
|
|
28
|
-
//#endregion
|
|
29
|
-
export { NativeAppService };
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { app_permission } from "../../constants/permission/index.js";
|
|
2
|
-
import { isH5, isHarmony, isWeixin, isiOS } from "../../utils/uni-env/index.js";
|
|
3
|
-
|
|
4
|
-
//#region src/services/native-app/service.ts
|
|
5
|
-
let view;
|
|
6
|
-
var NativeAppService = class {
|
|
7
|
-
nativeAppServiceConfig;
|
|
8
|
-
constructor(config) {
|
|
9
|
-
this.nativeAppServiceConfig = config;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* 关闭安卓提示弹框
|
|
13
|
-
*/
|
|
14
|
-
closeAndroidTip = () => {
|
|
15
|
-
if (view) {
|
|
16
|
-
view.close();
|
|
17
|
-
view = void 0;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* 显示安卓提示弹框
|
|
22
|
-
* @param options
|
|
23
|
-
*/
|
|
24
|
-
showAndroidTip = (options) => {
|
|
25
|
-
const { title, value } = options;
|
|
26
|
-
view = new plus.nativeObj.View("per-modal", {
|
|
27
|
-
top: "0px",
|
|
28
|
-
left: "0px",
|
|
29
|
-
width: "100%",
|
|
30
|
-
backgroundColor: "rgba(0,0,0,0.2)"
|
|
31
|
-
});
|
|
32
|
-
view.drawRect({
|
|
33
|
-
color: "#fff",
|
|
34
|
-
radius: "5px"
|
|
35
|
-
}, {
|
|
36
|
-
top: "45px",
|
|
37
|
-
left: "5%",
|
|
38
|
-
width: "90%",
|
|
39
|
-
height: "130px"
|
|
40
|
-
});
|
|
41
|
-
view.drawText(title, {
|
|
42
|
-
top: "50px",
|
|
43
|
-
left: "8%",
|
|
44
|
-
height: "30px"
|
|
45
|
-
}, {
|
|
46
|
-
align: "left",
|
|
47
|
-
weight: "bold",
|
|
48
|
-
color: "#000"
|
|
49
|
-
});
|
|
50
|
-
view.drawText(value, {
|
|
51
|
-
top: "75px",
|
|
52
|
-
height: "90px",
|
|
53
|
-
left: "8%",
|
|
54
|
-
width: "84%"
|
|
55
|
-
}, {
|
|
56
|
-
whiteSpace: "normal",
|
|
57
|
-
size: "14px",
|
|
58
|
-
align: "left",
|
|
59
|
-
color: "#656563"
|
|
60
|
-
});
|
|
61
|
-
view.show();
|
|
62
|
-
};
|
|
63
|
-
/**
|
|
64
|
-
* 检测并申请app权限
|
|
65
|
-
* @param type
|
|
66
|
-
* @param success
|
|
67
|
-
* @param fail
|
|
68
|
-
*/
|
|
69
|
-
checkAndRequestNativeAppPermissions = (type, success, fail) => {
|
|
70
|
-
let that = this;
|
|
71
|
-
if (isWeixin() || isH5() || isHarmony() || isiOS()) {
|
|
72
|
-
success?.();
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
const ActivityCompat = plus.android.importClass("androidx.core.app.ActivityCompat");
|
|
76
|
-
const PackageManager = plus.android.importClass("android.content.pm.PackageManager");
|
|
77
|
-
const context = plus.android.runtimeMainActivity();
|
|
78
|
-
const detail = app_permission[type];
|
|
79
|
-
let hasPermission = false;
|
|
80
|
-
detail.permissionId.forEach((item) => {
|
|
81
|
-
if (ActivityCompat.checkSelfPermission(context, item) !== PackageManager.PERMISSION_GRANTED) {
|
|
82
|
-
hasPermission = true;
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
if (!hasPermission) {
|
|
87
|
-
success?.();
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
that.showAndroidTip(detail);
|
|
91
|
-
plus.android.requestPermissions(detail.permissionId, function(resultObj) {
|
|
92
|
-
if (resultObj.granted.length > 0) {
|
|
93
|
-
that.closeAndroidTip();
|
|
94
|
-
success?.();
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
if (resultObj.deniedPresent.length > 0) {
|
|
98
|
-
that.closeAndroidTip();
|
|
99
|
-
fail?.();
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
if (resultObj.deniedAlways.length > 0) {
|
|
103
|
-
uni.showModal({
|
|
104
|
-
title: "提示",
|
|
105
|
-
content: app_permission[type].denied,
|
|
106
|
-
confirmText: "去设置",
|
|
107
|
-
success: function(res) {
|
|
108
|
-
that.closeAndroidTip();
|
|
109
|
-
if (res.confirm) uni.openAppAuthorizeSetting({ success: () => fail?.() });
|
|
110
|
-
if (res.cancel) fail?.();
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
}, function() {
|
|
116
|
-
that.closeAndroidTip();
|
|
117
|
-
fail?.();
|
|
118
|
-
});
|
|
119
|
-
};
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
//#endregion
|
|
123
|
-
export { NativeAppService };
|