@foundbyte/uni-libs 0.0.12 → 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/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,5 +1,5 @@
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
3
  import { IAppConfig } from "./configs/app/app.type.js";
4
4
 
5
5
  //#region src/entry.d.ts
@@ -9,17 +9,12 @@ import { IAppConfig } from "./configs/app/app.type.js";
9
9
  */
10
10
  declare class OneTravelSDK {
11
11
  private sdkConfig;
12
- private goodsService;
12
+ readonly goodsService: GoodsService;
13
13
  constructor(config?: Partial<IOneTravelSDKConfig>);
14
14
  /**
15
15
  * 获取App配置信息
16
16
  */
17
17
  getAppConfig(): IAppConfig;
18
- /**
19
- * 跳转商品详情页
20
- * @param item
21
- */
22
- jumpToProductDetailPage(item: IJumpProductDetailItem): void;
23
18
  }
24
19
  //#endregion
25
20
  export { OneTravelSDK };
package/es/entry.js CHANGED
@@ -25,13 +25,6 @@ var OneTravelSDK = class {
25
25
  getAppConfig() {
26
26
  return getAppConfig(this.sdkConfig.appEnv);
27
27
  }
28
- /**
29
- * 跳转商品详情页
30
- * @param item
31
- */
32
- jumpToProductDetailPage(item) {
33
- this.goodsService.jumpToProductDetailPage(item);
34
- }
35
28
  };
36
29
 
37
30
  //#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,7 @@ 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";
17
+ import { checkAndRequestNativeAppPermission } from "./utils/native-app/index.js";
15
18
  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 };
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
@@ -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,8 @@ 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";
16
+ import { checkAndRequestNativeAppPermission } from "./utils/native-app/index.js";
14
17
  import { OneTravelSDK } from "./entry.js";
15
18
 
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 };
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,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,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 };
@@ -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.14",
6
6
  "private": false,
7
7
  "type": "module",
8
8
  "main": "es/index.js",