zhl-methods 1.0.5 → 1.1.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/README.md +5 -0
- package/VERSION.md +14 -0
- package/index.css +1 -0
- package/package.json +1 -3
- package/wx/index.js +11 -12
package/README.md
CHANGED
|
@@ -46,20 +46,25 @@ isPhone(123)
|
|
|
46
46
|
|
|
47
47
|
##### 获取导航栏高度
|
|
48
48
|
|
|
49
|
+
- @example getNavBarHeight() => 100
|
|
49
50
|
- @returns {number}
|
|
50
51
|
|
|
51
52
|
##### 弹窗二次确认
|
|
52
53
|
|
|
54
|
+
- @example showModal(query,callback)
|
|
53
55
|
- @param {Function} callback
|
|
54
56
|
|
|
55
57
|
##### 获取当前环境
|
|
56
58
|
|
|
59
|
+
- @example getEnv()
|
|
57
60
|
- @returns {string} release 线上 trial 测试 develop 开发
|
|
58
61
|
|
|
59
62
|
##### 获取 appId
|
|
60
63
|
|
|
64
|
+
- @example getAppId()
|
|
61
65
|
- @returns {string}
|
|
62
66
|
|
|
63
67
|
##### 获取底部安全距离
|
|
64
68
|
|
|
69
|
+
- @example getSafeBottom()
|
|
65
70
|
- @returns {string}
|
package/VERSION.md
ADDED
package/index.css
CHANGED
package/package.json
CHANGED
package/wx/index.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
wx = uni;
|
|
3
|
-
}
|
|
1
|
+
const thit = uni ? uni : wx;
|
|
4
2
|
/**
|
|
5
3
|
* 获取导航栏高度
|
|
4
|
+
* @example getNavBarHeight() => 100
|
|
6
5
|
* @returns {number}
|
|
7
6
|
*/
|
|
8
7
|
export const getNavBarHeight = () => {
|
|
9
|
-
let res =
|
|
8
|
+
let res = thit.getSystemInfoSync();
|
|
10
9
|
let nav = 48;
|
|
11
10
|
if (res.system.indexOf("iOS") > -1) {
|
|
12
11
|
nav = 44;
|
|
@@ -18,7 +17,7 @@ export const getNavBarHeight = () => {
|
|
|
18
17
|
* @param {Function} callback
|
|
19
18
|
*/
|
|
20
19
|
export const requestApi = (callback) => {
|
|
21
|
-
|
|
20
|
+
thit.showModal({
|
|
22
21
|
title: "确认该操作吗?",
|
|
23
22
|
confirmText: "确认",
|
|
24
23
|
cancelText: "取消",
|
|
@@ -35,7 +34,7 @@ export const requestApi = (callback) => {
|
|
|
35
34
|
* @param {Function} callback
|
|
36
35
|
*/
|
|
37
36
|
export const showModal = (query = {}, callback) => {
|
|
38
|
-
|
|
37
|
+
thit.showModal({
|
|
39
38
|
title: query.title ? query.title : "确认该操作吗?",
|
|
40
39
|
content: query.content ? query.content : "",
|
|
41
40
|
confirmText: "确认",
|
|
@@ -52,21 +51,21 @@ export const showModal = (query = {}, callback) => {
|
|
|
52
51
|
* @returns {string} release线上 trial测试 develop开发
|
|
53
52
|
*/
|
|
54
53
|
export const getEnv = () => {
|
|
55
|
-
return
|
|
54
|
+
return thit.getAccountInfoSync().miniProgram.envVersion;
|
|
56
55
|
};
|
|
57
56
|
/**
|
|
58
57
|
* 获取appId
|
|
59
58
|
* @returns {string}
|
|
60
59
|
*/
|
|
61
60
|
export const getAppId = () => {
|
|
62
|
-
return
|
|
61
|
+
return thit.getAccountInfoSync().miniProgram.appId;
|
|
63
62
|
};
|
|
64
63
|
/**
|
|
65
64
|
* 获取底部安全距离
|
|
66
65
|
* @returns {string}
|
|
67
66
|
*/
|
|
68
67
|
export const getSafeBottom = () => {
|
|
69
|
-
let winInfo =
|
|
68
|
+
let winInfo = thit.getWindowInfo();
|
|
70
69
|
return winInfo.safeArea.bottom - winInfo.safeArea.height;
|
|
71
70
|
};
|
|
72
71
|
/**
|
|
@@ -74,13 +73,13 @@ export const getSafeBottom = () => {
|
|
|
74
73
|
* @param {string|number} 要复制的数据
|
|
75
74
|
*/
|
|
76
75
|
export const copyText = (val) => {
|
|
77
|
-
|
|
76
|
+
thit.setClipboardData({
|
|
78
77
|
data: val,
|
|
79
78
|
success: () => {
|
|
80
|
-
|
|
79
|
+
thit.showToast({ title: "复制成功", icon: "none" });
|
|
81
80
|
},
|
|
82
81
|
fail: (res) => {
|
|
83
|
-
|
|
82
|
+
thit.showToast({ title: "复制失败", icon: "none" });
|
|
84
83
|
},
|
|
85
84
|
});
|
|
86
85
|
};
|