@foundbyte/uni-libs 0.1.0 → 1.0.1
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 +3 -3
- package/es/index.js +3 -3
- package/es/services/goods/service.js +10 -9
- package/es/services/goods/type.d.ts +1 -1
- package/es/utils/common/index.js +2 -2
- package/es/utils/native-app/index.js +2 -2
- package/es/utils/uni-env/index.d.ts +20 -5
- package/es/utils/uni-env/index.js +23 -8
- package/es/utils/web-view/index.d.ts +8 -2
- package/es/utils/web-view/index.js +13 -7
- package/package.json +1 -1
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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
|
|
97
|
+
} catch {}
|
|
97
98
|
page = getMoviePage(appConfig.domain.movie, movieId);
|
|
98
99
|
break;
|
|
99
100
|
case EBusinessLine.Strategy:
|
package/es/utils/common/index.js
CHANGED
|
@@ -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(([
|
|
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
|
|
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 {
|
|
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 (
|
|
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
|
|
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
|
|
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,
|
|
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
|
|
15
|
+
const isH5Env = () => {
|
|
9
16
|
return true;
|
|
10
17
|
};
|
|
11
18
|
/**
|
|
12
19
|
* 是否是微信小程序
|
|
13
20
|
* @returns
|
|
14
21
|
*/
|
|
15
|
-
const
|
|
22
|
+
const isWeixinEnv = () => {
|
|
16
23
|
return true;
|
|
17
24
|
};
|
|
18
25
|
/**
|
|
19
26
|
* 是否是鸿蒙
|
|
20
27
|
* @returns
|
|
21
28
|
*/
|
|
22
|
-
const
|
|
29
|
+
const isHarmonyEnv = () => {
|
|
23
30
|
return true;
|
|
24
31
|
};
|
|
25
32
|
/**
|
|
26
33
|
* 是否是app
|
|
27
34
|
* @returns
|
|
28
35
|
*/
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
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
|
|
38
|
-
if (
|
|
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,
|
|
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)
|
|
19
|
-
|
|
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";
|
|
@@ -47,7 +53,7 @@ const navigateTo = (parameters) => {
|
|
|
47
53
|
uni?.webView?.navigateTo?.({ url });
|
|
48
54
|
/** 不兼容上面的方法会自动往下执行 */
|
|
49
55
|
wx.miniProgram.navigateTo({ url });
|
|
50
|
-
my
|
|
56
|
+
my?.navigateTo({ url });
|
|
51
57
|
} catch (error) {
|
|
52
58
|
console.error(error);
|
|
53
59
|
}
|
|
@@ -63,7 +69,7 @@ const redirectTo = (parameters) => {
|
|
|
63
69
|
uni?.webView?.redirectTo?.({ url });
|
|
64
70
|
/** 不兼容上面的方法会自动往下执行 */
|
|
65
71
|
wx.miniProgram.redirectTo({ url });
|
|
66
|
-
my
|
|
72
|
+
my?.redirectTo({ url });
|
|
67
73
|
} catch (error) {
|
|
68
74
|
console.error(error);
|
|
69
75
|
}
|
|
@@ -77,7 +83,7 @@ const navigateBack = (parameters) => {
|
|
|
77
83
|
uni?.webView?.navigateBack?.(parameters);
|
|
78
84
|
/** 不兼容上面的方法会自动往下执行 */
|
|
79
85
|
wx.miniProgram.navigateBack(parameters);
|
|
80
|
-
my
|
|
86
|
+
my?.navigateBack(parameters);
|
|
81
87
|
} catch (error) {
|
|
82
88
|
console.error(error);
|
|
83
89
|
}
|
|
@@ -98,7 +104,7 @@ const postMessage = (data) => {
|
|
|
98
104
|
}
|
|
99
105
|
uni?.webView?.postMessage({ data });
|
|
100
106
|
wx.miniProgram.postMessage({ data });
|
|
101
|
-
my
|
|
107
|
+
my?.postMessage({ data });
|
|
102
108
|
};
|
|
103
109
|
/**
|
|
104
110
|
* 设置页面分享信息
|
|
@@ -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 };
|