@foundbyte/uni-libs 0.1.0 → 1.0.0

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/index.d.ts CHANGED
@@ -13,8 +13,8 @@ import { ActivityCalendarDetailPageParams, getActivityCalendarDetailPage } from
13
13
  import { WebviewPageParams, getWebviewPage } from "./utils/pages/webview/index.js";
14
14
  import { getFoodPackagePage, getFoodStorePage } from "./utils/pages/food/index.js";
15
15
  import { getMoviePage } from "./utils/pages/movie/index.js";
16
- import { EMessagesType, IShareParam, isAlipay, isIOSOrAndroid, navigateBack, navigateTo, postMessage, redirectTo, setShareParam, toPay } from "./utils/web-view/index.js";
17
- import { getSystemInfoSync, isApp, isH5 } from "./utils/uni-env/index.js";
16
+ import { EMessagesType, IShareParam, isAlipay, isAndroid, isHarmony, isIOSOrAndroid, isWeixin, isiOS, navigateBack, navigateTo, postMessage, redirectTo, setShareParam, toPay } from "./utils/web-view/index.js";
17
+ import { getSystemInfoSync, isAlipayEnv, isAndroidEnv, isAppEnv, isH5Env, isHarmonyEnv, isWeixinEnv, isiOSEnv } from "./utils/uni-env/index.js";
18
18
  import { checkAndRequestNativeAppPermission } from "./utils/native-app/index.js";
19
19
  import { OneTravelSDK } from "./entry.js";
20
- export { ActivityCalendarDetailPageParams, BusinessLineDict, EAppEnv, EBusinessLine, ECaller, EFoodPackageType, EFoodsModuleType, EHotelType, EMessagesType, ESubBizType, EUniPlatform, EVenueSimpleTypes, EVenueTypes, IOneTravelSDKConfig, IShareParam, OneTravelSDK, WebviewPageParams, app_permission, checkAndRequestNativeAppPermission, getActivityCalendarDetailPage, getFoodPackagePage, getFoodStorePage, getMoviePage, getQueryParameters, getSystemInfoSync, getWebviewPage, isAlipay, isApp, isEmpty, isH5, isIOSOrAndroid, navigateBack, navigateTo, postMessage, query2url, redirectTo, routePrefix, routes, setShareParam, toPay };
20
+ export { ActivityCalendarDetailPageParams, BusinessLineDict, EAppEnv, EBusinessLine, ECaller, EFoodPackageType, EFoodsModuleType, EHotelType, EMessagesType, ESubBizType, EUniPlatform, EVenueSimpleTypes, EVenueTypes, IOneTravelSDKConfig, IShareParam, OneTravelSDK, WebviewPageParams, app_permission, checkAndRequestNativeAppPermission, getActivityCalendarDetailPage, getFoodPackagePage, getFoodStorePage, getMoviePage, getQueryParameters, getSystemInfoSync, getWebviewPage, isAlipay, isAlipayEnv, isAndroid, isAndroidEnv, isAppEnv, isEmpty, isH5Env, isHarmony, isHarmonyEnv, isIOSOrAndroid, isWeixin, isWeixinEnv, isiOS, isiOSEnv, navigateBack, navigateTo, postMessage, query2url, redirectTo, routePrefix, routes, setShareParam, toPay };
package/es/index.js CHANGED
@@ -12,9 +12,9 @@ import { getActivityCalendarDetailPage } from "./utils/pages/activity-calendar/i
12
12
  import { getWebviewPage } from "./utils/pages/webview/index.js";
13
13
  import { getFoodPackagePage, getFoodStorePage } from "./utils/pages/food/index.js";
14
14
  import { getMoviePage } from "./utils/pages/movie/index.js";
15
- import { EMessagesType, isAlipay, isIOSOrAndroid, isWeixin, navigateBack, navigateTo, postMessage, redirectTo, setShareParam, toPay } from "./utils/web-view/index.js";
16
- import { getSystemInfoSync, isApp, isH5 } from "./utils/uni-env/index.js";
15
+ import { EMessagesType, isAlipay, isAndroid, isHarmony, isIOSOrAndroid, isWeixin, isiOS, navigateBack, navigateTo, postMessage, redirectTo, setShareParam, toPay } from "./utils/web-view/index.js";
16
+ import { getSystemInfoSync, isAlipayEnv, isAndroidEnv, isAppEnv, isH5Env, isHarmonyEnv, isWeixinEnv, isiOSEnv } from "./utils/uni-env/index.js";
17
17
  import { checkAndRequestNativeAppPermission } from "./utils/native-app/index.js";
18
18
  import { OneTravelSDK } from "./entry.js";
19
19
 
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, isAlipay, isApp, isEmpty, isH5, isIOSOrAndroid, navigateBack, navigateTo, postMessage, query2url, redirectTo, routePrefix, routes, setShareParam, toPay };
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, isAlipay, isAlipayEnv, isAndroid, isAndroidEnv, isAppEnv, isEmpty, isH5Env, isHarmony, isHarmonyEnv, isIOSOrAndroid, isWeixin, isWeixinEnv, isiOS, isiOSEnv, navigateBack, navigateTo, postMessage, query2url, redirectTo, routePrefix, routes, setShareParam, toPay };
@@ -28,27 +28,28 @@ var GoodsService = class {
28
28
  const extInfo = item?.common?.extInfoMap || item?.common?.extInfo;
29
29
  switch (businessLine) {
30
30
  case EBusinessLine.Scenic:
31
- const scenicId = item?.scenic?.id || item?.common?.spuId || item?.common?.id;
32
- const scenicReservationId = item?.scenic?.reservationId || extInfo?.reservationId || item?.common?.reservationId;
31
+ const scenicId = item?.scenic?.id || item?.common?.spuId || item?.common?.id || "";
32
+ const scenicReservationId = item?.scenic?.reservationId || extInfo?.reservationId || item?.common?.reservationId || "";
33
33
  const scenicIsOld = item?.scenic?.isOld || extInfo?.isOld;
34
34
  page = `${routePrefix.ticket}/detail/index?scenicId=${scenicId}&reservationId=${scenicReservationId}&isOld=${scenicIsOld}`;
35
35
  break;
36
36
  case EBusinessLine.Hotel:
37
- const hotelId = item?.hotel?.id || extInfo?.storeId || item?.common?.storeId;
37
+ const hotelId = item?.hotel?.id || extInfo?.storeId || item?.common?.storeId || "";
38
38
  page = `${routePrefix.hotel}/home/details/index?id=${hotelId}`;
39
39
  break;
40
40
  case EBusinessLine.Homestay:
41
- const homestayType = item?.homestay?.type || extInfo?.type || item?.common?.type;
41
+ const homestayType = item?.homestay?.type || extInfo?.type || item?.common?.type || "";
42
42
  if (homestayType === EHotelType.hotel) {
43
- /** 酒店 (天下房仓酒店详情页)*/
44
- const id = item?.homestay?.id || extInfo?.storeId || item?.common?.storeId;
43
+ /** 酒店 (天下房仓酒店详情页) */
44
+ const id = item?.homestay?.id || extInfo?.storeId || item?.common?.storeId || "";
45
45
  page = `${routePrefix.hotel}/home/details/index?id=${id}`;
46
46
  } else {
47
47
  const subBizType = item?.homestay?.subBizType || extInfo?.subBizType;
48
- const id = item?.homestay?.id || item?.common?.spuId || item?.common?.id;
48
+ const id = item?.homestay?.id || item?.common?.spuId || item?.common?.id || "";
49
49
  /** 民宿 */
50
50
  if (`${subBizType}` === `${ESubBizType.HomestayHotel}`) page = `${routePrefix.hotel}/home/details/index?id=${id}`;
51
- else page = `${routePrefix.hotel}/home/hot-sale-details/index?id=${id}`;
51
+ else if (`${subBizType}` === `${ESubBizType.HomestayHot}`) page = `${routePrefix.hotel}/home/hot-sale-details/index?id=${id}`;
52
+ else page = `${routePrefix.hotel}/home/pms-details/index?id=${id}`;
52
53
  }
53
54
  break;
54
55
  case EBusinessLine.Route:
@@ -93,7 +94,7 @@ var GoodsService = class {
93
94
  let movieId = item?.movie?.id || "";
94
95
  try {
95
96
  movieId = JSON.parse(extInfo?.extInfo || "{}")?.thirdMovieId || "";
96
- } catch (e) {}
97
+ } catch {}
97
98
  page = getMoviePage(appConfig.domain.movie, movieId);
98
99
  break;
99
100
  case EBusinessLine.Strategy:
@@ -75,7 +75,7 @@ type IJumpProductDetailItem = {
75
75
  buy?: {
76
76
  spuId: string;
77
77
  };
78
- /** 购物(新)*/
78
+ /** 购物(新) */
79
79
  onebuygz?: {
80
80
  spuId: string;
81
81
  skuId: string;
@@ -13,7 +13,7 @@ function isEmpty(value) {
13
13
  */
14
14
  function query2url(query, options) {
15
15
  const { encode = true } = options || {};
16
- const url = Object.entries(query || {}).filter(([key, val]) => val !== void 0 && val !== null).map(([key, val]) => {
16
+ const url = Object.entries(query || {}).filter(([_, val]) => val !== void 0 && val !== null).map(([key, val]) => {
17
17
  return encode ? `${encodeURIComponent(key)}=${encodeURIComponent(val)}` : `${key}=${val}`;
18
18
  }).join("&");
19
19
  return url ? `?${url}` : "";
@@ -33,7 +33,7 @@ function getQueryParameters(url) {
33
33
  let value = decodeURIComponent(pair[1] || "");
34
34
  try {
35
35
  value = JSON.parse(value);
36
- } catch (error) {}
36
+ } catch {}
37
37
  params[key] = value;
38
38
  }
39
39
  }
@@ -1,5 +1,5 @@
1
1
  import { app_permission } from "../../constants/permission/index.js";
2
- import { isH5, isHarmony, isWeixin, isiOS } from "../uni-env/index.js";
2
+ import { isH5Env, isHarmonyEnv, isWeixinEnv, isiOSEnv } from "../uni-env/index.js";
3
3
 
4
4
  //#region src/utils/native-app/index.ts
5
5
  let plusNativeObjView;
@@ -61,7 +61,7 @@ const showAndroidTip = (options) => {
61
61
  */
62
62
  const checkAndRequestNativeAppPermission = (options) => {
63
63
  const { type, success, fail } = options || {};
64
- if (isWeixin() || isH5() || isHarmony() || isiOS()) {
64
+ if (isWeixinEnv() || isH5Env() || isHarmonyEnv() || isiOSEnv()) {
65
65
  success?.();
66
66
  return;
67
67
  }
@@ -1,24 +1,39 @@
1
1
  //#region src/utils/uni-env/index.d.ts
2
+ /**
3
+ * 是否是支付宝小程序
4
+ * @returns
5
+ */
6
+ declare const isAlipayEnv: () => boolean;
2
7
  /**
3
8
  * 是否是web环境
4
9
  * @returns
5
10
  */
6
- declare const isH5: () => boolean;
11
+ declare const isH5Env: () => boolean;
7
12
  /**
8
13
  * 是否是微信小程序
9
14
  * @returns
10
15
  */
11
-
16
+ declare const isWeixinEnv: () => boolean;
17
+ /**
18
+ * 是否是鸿蒙
19
+ * @returns
20
+ */
21
+ declare const isHarmonyEnv: () => boolean;
12
22
  /**
13
23
  * 是否是app
14
24
  * @returns
15
25
  */
16
- declare const isApp: () => boolean;
26
+ declare const isAppEnv: () => boolean;
17
27
  /**
18
28
  * 是否是安卓
19
29
  * @returns
20
30
  */
21
-
31
+ declare const isAndroidEnv: () => boolean;
32
+ /**
33
+ * 是否是iOS
34
+ * @returns
35
+ */
36
+ declare const isiOSEnv: () => boolean;
22
37
  declare function getSystemInfoSync(): UniApp.GetSystemInfoResult | {
23
38
  pixelRatio: number;
24
39
  screenWidth: number;
@@ -43,4 +58,4 @@ declare function getSystemInfoSync(): UniApp.GetSystemInfoResult | {
43
58
  platform: string;
44
59
  };
45
60
  //#endregion
46
- export { getSystemInfoSync, isApp, isH5 };
61
+ export { getSystemInfoSync, isAlipayEnv, isAndroidEnv, isAppEnv, isH5Env, isHarmonyEnv, isWeixinEnv, isiOSEnv };
@@ -2,40 +2,55 @@ import { EUniPlatform } from "../../enums/platform/index.js";
2
2
 
3
3
  //#region src/utils/uni-env/index.ts
4
4
  /**
5
+ * 是否是支付宝小程序
6
+ * @returns
7
+ */
8
+ const isAlipayEnv = () => {
9
+ return true;
10
+ };
11
+ /**
5
12
  * 是否是web环境
6
13
  * @returns
7
14
  */
8
- const isH5 = () => {
15
+ const isH5Env = () => {
9
16
  return true;
10
17
  };
11
18
  /**
12
19
  * 是否是微信小程序
13
20
  * @returns
14
21
  */
15
- const isWeixin = () => {
22
+ const isWeixinEnv = () => {
16
23
  return true;
17
24
  };
18
25
  /**
19
26
  * 是否是鸿蒙
20
27
  * @returns
21
28
  */
22
- const isHarmony = () => {
29
+ const isHarmonyEnv = () => {
23
30
  return true;
24
31
  };
25
32
  /**
26
33
  * 是否是app
27
34
  * @returns
28
35
  */
29
- const isApp = () => {
30
- if (isHarmony()) return true;
36
+ const isAppEnv = () => {
37
+ if (isHarmonyEnv()) return true;
31
38
  return true;
32
39
  };
33
40
  /**
41
+ * 是否是安卓
42
+ * @returns
43
+ */
44
+ const isAndroidEnv = () => {
45
+ if (isAppEnv() && getSystemInfoSync().platform === EUniPlatform.android) return true;
46
+ return false;
47
+ };
48
+ /**
34
49
  * 是否是iOS
35
50
  * @returns
36
51
  */
37
- const isiOS = () => {
38
- if (isApp() && getSystemInfoSync().platform === EUniPlatform.ios) return true;
52
+ const isiOSEnv = () => {
53
+ if (isAppEnv() && getSystemInfoSync().platform === EUniPlatform.ios) return true;
39
54
  return false;
40
55
  };
41
56
  function getSystemInfoSync() {
@@ -46,4 +61,4 @@ function getSystemInfoSync() {
46
61
  }
47
62
 
48
63
  //#endregion
49
- export { getSystemInfoSync, isApp, isH5, isHarmony, isWeixin, isiOS };
64
+ export { getSystemInfoSync, isAlipayEnv, isAndroidEnv, isAppEnv, isH5Env, isHarmonyEnv, isWeixinEnv, isiOSEnv };
@@ -6,7 +6,13 @@ declare const isIOSOrAndroid: boolean;
6
6
  /** 判断是否支付宝小程序 */
7
7
  declare const isAlipay: boolean;
8
8
  /** 判断是否微信小程序 */
9
-
9
+ declare const isWeixin: boolean;
10
+ /** 判断是否鸿蒙APP */
11
+ declare const isHarmony: boolean;
12
+ /** 判断是否安卓APP */
13
+ declare const isAndroid: boolean;
14
+ /** 判断是否苹果APP */
15
+ declare const isiOS: boolean;
10
16
  declare enum EMessagesType {
11
17
  /** app直接调用分享 */
12
18
  share = "share",
@@ -72,4 +78,4 @@ declare const toPay: (data: {
72
78
  orderNo: string;
73
79
  }) => void;
74
80
  //#endregion
75
- export { EMessagesType, IShareParam, isAlipay, isIOSOrAndroid, navigateBack, navigateTo, postMessage, redirectTo, setShareParam, toPay };
81
+ export { EMessagesType, IShareParam, isAlipay, isAndroid, isHarmony, isIOSOrAndroid, isWeixin, isiOS, navigateBack, navigateTo, postMessage, redirectTo, setShareParam, toPay };
@@ -14,9 +14,15 @@ const isHarmony = !userAgent.includes("miniprogram") && !userAgent.includes("and
14
14
  const isAndroid = !userAgent.includes("miniprogram") && userAgent.includes("android");
15
15
  /** 判断是否苹果APP */
16
16
  const isiOS = !userAgent.includes("miniprogram") && (userAgent.includes("iphone") || userAgent.includes("ipad"));
17
+ let uni = {};
17
18
  async function loadWebview() {
18
- if (isIOSOrAndroid) await import("../../assets/js/webview/uni.webview.1.5.6.js");
19
- else await import("../../assets/js/webview/uni.webview.1.5.5.js");
19
+ if (isIOSOrAndroid) {
20
+ const res = await import("../../assets/js/webview/uni.webview.1.5.6.js");
21
+ uni = res.default;
22
+ } else {
23
+ const res = await import("../../assets/js/webview/uni.webview.1.5.5.js");
24
+ uni = res.default;
25
+ }
20
26
  if (isAlipay) {
21
27
  const scriptTag = document.createElement("script");
22
28
  scriptTag.src = "https://appx/web-view.min.js";
@@ -138,4 +144,4 @@ function objectToQueryString(obj) {
138
144
  }
139
145
 
140
146
  //#endregion
141
- export { EMessagesType, isAlipay, isIOSOrAndroid, isWeixin, navigateBack, navigateTo, postMessage, redirectTo, setShareParam, toPay };
147
+ export { EMessagesType, isAlipay, isAndroid, isHarmony, isIOSOrAndroid, isWeixin, isiOS, navigateBack, navigateTo, postMessage, redirectTo, setShareParam, toPay };
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.1.0",
5
+ "version": "1.0.0",
6
6
  "private": false,
7
7
  "type": "module",
8
8
  "main": "es/index.js",