@foundbyte/uni-libs 0.0.13 → 0.0.14

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 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配置信息
package/es/index.d.ts CHANGED
@@ -14,5 +14,6 @@ import { getFoodPackagePage, getFoodStorePage } from "./utils/pages/food/index.j
14
14
  import { getMoviePage } from "./utils/pages/movie/index.js";
15
15
  import { EMessagesType, navigateBack, navigateTo, postMessage, redirectTo } from "./utils/web-view/index.js";
16
16
  import { isAndroid, isApp, isH5, isHarmony, isWeixin, isiOS } from "./utils/uni-env/index.js";
17
+ import { checkAndRequestNativeAppPermission } from "./utils/native-app/index.js";
17
18
  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 };
19
+ export { ActivityCalendarDetailPageParams, BusinessLineDict, EAppEnv, EBusinessLine, ECaller, EFoodPackageType, EFoodsModuleType, EHotelType, EMessagesType, ESubBizType, EVenueSimpleTypes, EVenueTypes, IOneTravelSDKConfig, OneTravelSDK, WebviewPageParams, app_permission, checkAndRequestNativeAppPermission, getActivityCalendarDetailPage, getFoodPackagePage, getFoodStorePage, getMoviePage, getQueryParameters, getWebviewPage, isAndroid, isApp, isEmpty, isH5, isHarmony, isWeixin, isiOS, navigateBack, navigateTo, postMessage, query2url, redirectTo, routePrefix, routes };
package/es/index.js CHANGED
@@ -13,6 +13,7 @@ import { getFoodPackagePage, getFoodStorePage } from "./utils/pages/food/index.j
13
13
  import { getMoviePage } from "./utils/pages/movie/index.js";
14
14
  import { EMessagesType, navigateBack, navigateTo, postMessage, redirectTo } from "./utils/web-view/index.js";
15
15
  import { isAndroid, isApp, isH5, isHarmony, isWeixin, isiOS } from "./utils/uni-env/index.js";
16
+ import { checkAndRequestNativeAppPermission } from "./utils/native-app/index.js";
16
17
  import { OneTravelSDK } from "./entry.js";
17
18
 
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 };
19
+ export { BusinessLineDict, EAppEnv, EBusinessLine, ECaller, EFoodPackageType, EFoodsModuleType, EHotelType, EMessagesType, ESubBizType, EVenueSimpleTypes, EVenueTypes, OneTravelSDK, app_permission, checkAndRequestNativeAppPermission, getActivityCalendarDetailPage, getFoodPackagePage, getFoodStorePage, getMoviePage, getQueryParameters, 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 };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@foundbyte/uni-libs",
3
3
  "description": "FoundByte Uni Libs",
4
4
  "author": "yangshuai <704807396@qq.com>",
5
- "version": "0.0.13",
5
+ "version": "0.0.14",
6
6
  "private": false,
7
7
  "type": "module",
8
8
  "main": "es/index.js",
@@ -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 };