@foundbyte/uni-libs 0.0.12 → 0.0.13

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/README.md CHANGED
@@ -22,10 +22,12 @@ const oneTravelSdk = new OneTravelSDK({
22
22
  | appEnv | 环境变量 | EAppEnv | 否 | EAppEnv.PROD |
23
23
  | caller | 调用者 | ECaller | 否 | ECaller.WEB |
24
24
 
25
- ### 2.jumpToGoodsDetailPage
26
- 跳转商品详情页
25
+ ### 2.goodsService
26
+ 商品服务
27
+
28
+ #### 2.1跳转商品详情页
27
29
  ```typescript
28
- oneTravelSdk.jumpToProductDetailPage({
30
+ oneTravelSdk.goodsService.jumpToProductDetailPage({
29
31
  ...
30
32
  })
31
33
  ```
@@ -0,0 +1,35 @@
1
+ //#region src/constants/permission/index.d.ts
2
+ declare const app_permission: {
3
+ microphoneAuthorized: {
4
+ permissionId: string[];
5
+ title: string;
6
+ value: string;
7
+ denied: string;
8
+ };
9
+ locationAccuracy: {
10
+ permissionId: string[];
11
+ title: string;
12
+ value: string;
13
+ denied: string;
14
+ };
15
+ albumAuthorized: {
16
+ permissionId: string[];
17
+ title: string;
18
+ value: string;
19
+ denied: string;
20
+ };
21
+ cameraAuthorized: {
22
+ permissionId: string[];
23
+ title: string;
24
+ value: string;
25
+ denied: string;
26
+ };
27
+ chooseImage: {
28
+ permissionId: string[];
29
+ title: string;
30
+ value: string;
31
+ denied: string;
32
+ };
33
+ };
34
+ //#endregion
35
+ export { app_permission };
@@ -0,0 +1,47 @@
1
+ //#region src/constants/permission/index.ts
2
+ const app_permission = {
3
+ microphoneAuthorized: {
4
+ permissionId: ["android.permission.RECORD_AUDIO"],
5
+ title: "麦克风权限说明",
6
+ value: "请求访问麦克风权限,以便使用语音搜索功能",
7
+ denied: "获取麦克风权限失败,请手动打开授权"
8
+ },
9
+ locationAccuracy: {
10
+ permissionId: ["android.permission.ACCESS_FINE_LOCATION"],
11
+ title: "定位权限说明",
12
+ value: "请求获得您的定位权限,方便为您推荐所在城市的景区、酒店等旅游信息内容",
13
+ denied: "获取定位权限失败,请手动打开授权或检查系统定位开关"
14
+ },
15
+ albumAuthorized: {
16
+ permissionId: [
17
+ "android.permission.READ_EXTERNAL_STORAGE",
18
+ "android.permission.READ_MEDIA_IMAGES",
19
+ "android.permission.READ_MEDIA_VIDEO",
20
+ "android.permission.READ_MEDIA_VISUAL_USER_SELECTED"
21
+ ],
22
+ title: "相册权限说明",
23
+ value: "请求访问相册,便于您使用该功能上传您的照片/图片/视频",
24
+ denied: "获取相册权限失败,请手动打开授权"
25
+ },
26
+ cameraAuthorized: {
27
+ permissionId: ["android.permission.CAMERA"],
28
+ title: "相机权限说明",
29
+ value: "请求访问相机,便于您使用该功能拍摄图片/视频",
30
+ denied: "获取相机权限失败,请手动打开授权"
31
+ },
32
+ chooseImage: {
33
+ permissionId: [
34
+ "android.permission.CAMERA",
35
+ "android.permission.READ_EXTERNAL_STORAGE",
36
+ "android.permission.READ_MEDIA_IMAGES",
37
+ "android.permission.READ_MEDIA_VIDEO",
38
+ "android.permission.READ_MEDIA_VISUAL_USER_SELECTED"
39
+ ],
40
+ title: "权限说明",
41
+ value: "您即将使用上传功能,该功能会请求访问相册,便于您使用该功能上传您的照片/图片/视频;请求访问相机,便于您使用该功能拍摄图片/视频",
42
+ denied: "获取相机/相册权限失败,请手动打开授权"
43
+ }
44
+ };
45
+
46
+ //#endregion
47
+ export { app_permission };
package/es/entry.d.ts CHANGED
@@ -1,25 +1,21 @@
1
1
  import { IOneTravelSDKConfig } from "./types/one-travel-service/index.js";
2
- import { IJumpProductDetailItem } from "./services/goods/type.js";
2
+ import { GoodsService } from "./services/goods/service.js";
3
+ import { NativeAppService } from "./services/native-app/service.js";
3
4
  import { IAppConfig } from "./configs/app/app.type.js";
4
5
 
5
6
  //#region src/entry.d.ts
6
-
7
7
  /**
8
8
  * 一码游SDK
9
9
  */
10
10
  declare class OneTravelSDK {
11
11
  private sdkConfig;
12
- private goodsService;
12
+ readonly goodsService: GoodsService;
13
+ readonly nativeAppService: NativeAppService;
13
14
  constructor(config?: Partial<IOneTravelSDKConfig>);
14
15
  /**
15
16
  * 获取App配置信息
16
17
  */
17
18
  getAppConfig(): IAppConfig;
18
- /**
19
- * 跳转商品详情页
20
- * @param item
21
- */
22
- jumpToProductDetailPage(item: IJumpProductDetailItem): void;
23
19
  }
24
20
  //#endregion
25
21
  export { OneTravelSDK };
package/es/entry.js CHANGED
@@ -2,6 +2,7 @@ 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";
5
6
 
6
7
  //#region src/entry.ts
7
8
  /**
@@ -10,6 +11,7 @@ import { GoodsService } from "./services/goods/service.js";
10
11
  var OneTravelSDK = class {
11
12
  sdkConfig;
12
13
  goodsService;
14
+ nativeAppService;
13
15
  constructor(config) {
14
16
  const value = {
15
17
  appEnv: EAppEnv.prod,
@@ -18,6 +20,7 @@ var OneTravelSDK = class {
18
20
  };
19
21
  this.sdkConfig = value;
20
22
  this.goodsService = new GoodsService({ sdkConfig: value });
23
+ this.nativeAppService = new NativeAppService({ sdkConfig: value });
21
24
  }
22
25
  /**
23
26
  * 获取App配置信息
@@ -25,13 +28,6 @@ var OneTravelSDK = class {
25
28
  getAppConfig() {
26
29
  return getAppConfig(this.sdkConfig.appEnv);
27
30
  }
28
- /**
29
- * 跳转商品详情页
30
- * @param item
31
- */
32
- jumpToProductDetailPage(item) {
33
- this.goodsService.jumpToProductDetailPage(item);
34
- }
35
31
  };
36
32
 
37
33
  //#endregion
package/es/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { routePrefix, routes } from "./constants/routes/index.js";
2
+ import { app_permission } from "./constants/permission/index.js";
2
3
  import { BusinessLineDict, EBusinessLine, ESubBizType } from "./enums/business-line/index.js";
3
4
  import { EAppEnv } from "./enums/environment/index.js";
4
5
  import { ECaller } from "./enums/sdk/index.js";
@@ -12,5 +13,6 @@ import { WebviewPageParams, getWebviewPage } from "./utils/pages/webview/index.j
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";
16
+ import { isAndroid, isApp, isH5, isHarmony, isWeixin, isiOS } from "./utils/uni-env/index.js";
15
17
  import { OneTravelSDK } from "./entry.js";
16
- export { ActivityCalendarDetailPageParams, BusinessLineDict, EAppEnv, EBusinessLine, ECaller, EFoodPackageType, EFoodsModuleType, EHotelType, EMessagesType, ESubBizType, EVenueSimpleTypes, EVenueTypes, IOneTravelSDKConfig, OneTravelSDK, WebviewPageParams, getActivityCalendarDetailPage, getFoodPackagePage, getFoodStorePage, getMoviePage, getQueryParameters, getWebviewPage, isEmpty, navigateBack, navigateTo, postMessage, query2url, redirectTo, routePrefix, routes };
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 };
package/es/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { routePrefix, routes } from "./constants/routes/index.js";
2
+ import { app_permission } from "./constants/permission/index.js";
2
3
  import { BusinessLineDict, EBusinessLine, ESubBizType } from "./enums/business-line/index.js";
3
4
  import { EAppEnv } from "./enums/environment/index.js";
4
5
  import { ECaller } from "./enums/sdk/index.js";
@@ -11,6 +12,7 @@ import { getWebviewPage } from "./utils/pages/webview/index.js";
11
12
  import { getFoodPackagePage, getFoodStorePage } from "./utils/pages/food/index.js";
12
13
  import { getMoviePage } from "./utils/pages/movie/index.js";
13
14
  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";
14
16
  import { OneTravelSDK } from "./entry.js";
15
17
 
16
- export { BusinessLineDict, EAppEnv, EBusinessLine, ECaller, EFoodPackageType, EFoodsModuleType, EHotelType, EMessagesType, ESubBizType, EVenueSimpleTypes, EVenueTypes, OneTravelSDK, getActivityCalendarDetailPage, getFoodPackagePage, getFoodStorePage, getMoviePage, getQueryParameters, getWebviewPage, isEmpty, navigateBack, navigateTo, postMessage, query2url, redirectTo, routePrefix, routes };
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 };
@@ -0,0 +1,18 @@
1
+ import { IOneTravelSDKConfig } from "../../types/one-travel-service/index.js";
2
+ import { IJumpProductDetailItem } from "./type.js";
3
+
4
+ //#region src/services/goods/service.d.ts
5
+ type IGoodsServiceConfig = {
6
+ sdkConfig: IOneTravelSDKConfig;
7
+ };
8
+ declare class GoodsService {
9
+ private goodsServiceConfig;
10
+ constructor(config: IGoodsServiceConfig);
11
+ /**
12
+ * 跳转商品详情页面
13
+ * @param item 商品数据
14
+ */
15
+ jumpToProductDetailPage: (item: IJumpProductDetailItem) => void;
16
+ }
17
+ //#endregion
18
+ export { GoodsService };
@@ -0,0 +1,29 @@
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 };
@@ -0,0 +1,123 @@
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 };
@@ -0,0 +1,33 @@
1
+ //#region src/utils/uni-env/index.d.ts
2
+ /**
3
+ * 是否是web环境
4
+ * @returns
5
+ */
6
+ declare const isH5: () => boolean;
7
+ /**
8
+ * 是否是微信小程序
9
+ * @returns
10
+ */
11
+ declare const isWeixin: () => boolean;
12
+ /**
13
+ * 是否是鸿蒙
14
+ * @returns
15
+ */
16
+ declare const isHarmony: () => boolean;
17
+ /**
18
+ * 是否是app
19
+ * @returns
20
+ */
21
+ declare const isApp: () => boolean;
22
+ /**
23
+ * 是否是安卓
24
+ * @returns
25
+ */
26
+ declare const isAndroid: () => boolean;
27
+ /**
28
+ * 是否是iOS
29
+ * @returns
30
+ */
31
+ declare const isiOS: () => boolean;
32
+ //#endregion
33
+ export { isAndroid, isApp, isH5, isHarmony, isWeixin, isiOS };
@@ -0,0 +1,47 @@
1
+ //#region src/utils/uni-env/index.ts
2
+ /**
3
+ * 是否是web环境
4
+ * @returns
5
+ */
6
+ const isH5 = () => {
7
+ return true;
8
+ };
9
+ /**
10
+ * 是否是微信小程序
11
+ * @returns
12
+ */
13
+ const isWeixin = () => {
14
+ return true;
15
+ };
16
+ /**
17
+ * 是否是鸿蒙
18
+ * @returns
19
+ */
20
+ const isHarmony = () => {
21
+ return true;
22
+ };
23
+ /**
24
+ * 是否是app
25
+ * @returns
26
+ */
27
+ const isApp = () => {
28
+ if (isHarmony()) return true;
29
+ return true;
30
+ };
31
+ /**
32
+ * 是否是安卓
33
+ * @returns
34
+ */
35
+ const isAndroid = () => {
36
+ return true;
37
+ };
38
+ /**
39
+ * 是否是iOS
40
+ * @returns
41
+ */
42
+ const isiOS = () => {
43
+ return true;
44
+ };
45
+
46
+ //#endregion
47
+ export { isAndroid, isApp, isH5, isHarmony, isWeixin, isiOS };
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.12",
5
+ "version": "0.0.13",
6
6
  "private": false,
7
7
  "type": "module",
8
8
  "main": "es/index.js",