zhl-methods 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.
Files changed (3) hide show
  1. package/js/index.js +15 -0
  2. package/package.json +7 -0
  3. package/wx/index.js +51 -0
package/js/index.js ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * 手机号校验
3
+ * @example isPhone('15093676561') => true
4
+ * @param {value} 要校验的数据
5
+ * @returns {Boolean} true false 是 否
6
+ */
7
+ export const isPhone = (value) => {
8
+ if (typeof value == "number" || typeof value == "string") {
9
+ if (typeof value == "number") {
10
+ value = String(value);
11
+ }
12
+ return /^1[3456789]\d{9}$/.test(value);
13
+ }
14
+ return false;
15
+ };
package/package.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "zhl-methods",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "license": "ISC"
7
+ }
package/wx/index.js ADDED
@@ -0,0 +1,51 @@
1
+ /**
2
+ * 导航栏高度
3
+ * @returns {number}
4
+ */
5
+ export const getNavBarHeight = () => {
6
+ let res = wx.getSystemInfoSync();
7
+ let nav = 48;
8
+ if (res.system.indexOf("iOS") > -1) {
9
+ nav = 44;
10
+ }
11
+ return nav + res.statusBarHeight;
12
+ };
13
+ /**
14
+ * 弹窗二次确认
15
+ * @param {Function} callback
16
+ */
17
+ export const requestApi = (callback) => {
18
+ wx.showModal({
19
+ title: "确认该操作吗?",
20
+ confirmText: "确认",
21
+ cancelText: "取消",
22
+ async success(res) {
23
+ if (res.confirm) {
24
+ callback();
25
+ }
26
+ },
27
+ });
28
+ };
29
+ /**
30
+ * 获取当前环境
31
+ * @returns {string} release线上 trial测试 develop开发
32
+ */
33
+ export const getEnv = () => {
34
+ return wx.getAccountInfoSync().miniProgram.envVersion;
35
+ };
36
+ /**
37
+ * 获取appId
38
+ * @returns {string}
39
+ */
40
+ export const getAppId = () => {
41
+ return wx.getAccountInfoSync().miniProgram.appId;
42
+ };
43
+ /**
44
+ * 获取底部安全距离
45
+ * @returns {string}
46
+ */
47
+ export const getSafeBottom = () => {
48
+ let winInfo = wx.getWindowInfo();
49
+ console.log(winInfo)
50
+ return winInfo.safeArea.bottom - winInfo.safeArea.height;
51
+ };