xyvcard-wechat-auth 0.0.19 → 0.0.21
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/dist/api/auth/index.js +159 -1
- package/dist/api/auth/types.js +1 -1
- package/dist/api/dict/index.js +36 -1
- package/dist/api/dict/types.js +1 -1
- package/dist/api/dicts.js +53 -1
- package/dist/api/files/index.js +135 -1
- package/dist/api/files/types.js +1 -1
- package/dist/api/index.js +12 -1
- package/dist/api/myorgan/index.js +1 -1
- package/dist/api/myorgan/types.js +1 -1
- package/dist/api/types.js +9 -1
- package/dist/components/auth-user/jmash-update-user/index.js +133 -1
- package/dist/components/auth-user/jmash-user/index.js +56 -1
- package/dist/components/common/auth-avatar/avatar-edit/index.js +82 -1
- package/dist/components/common/auth-basic-title/basic-title-view/index.js +39 -0
- package/dist/{pages/home → components/common/auth-basic-title/basic-title-view}/index.json +1 -0
- package/dist/components/common/auth-basic-title/basic-title-view/index.wxml +5 -0
- package/dist/components/common/auth-basic-title/basic-title-view/index.wxss +1 -0
- package/dist/components/common/auth-btn/double-btn/index.js +67 -1
- package/dist/components/common/auth-btn/single-btn/index.js +34 -1
- package/dist/components/common/auth-none-data/none-data-image/index.js +53 -1
- package/dist/components/common/auth-popup/index.js +53 -1
- package/dist/components/common/auth-popup/index.wxml +3 -3
- package/dist/components/common/auth-popup/index.wxss +1 -1
- package/dist/components/common/auth-search/index.js +60 -1
- package/dist/components/common/auth-top-navigation/index.js +49 -1
- package/dist/components/jmash-half-login/index.js +105 -1
- package/dist/components/jmash-login/index.js +121 -1
- package/dist/constant.js +15 -1
- package/dist/index.js +35 -1
- package/dist/utils/auth.js +212 -1
- package/dist/utils/common.js +113 -1
- package/dist/utils/config.js +29 -1
- package/dist/utils/db.js +188 -1
- package/dist/utils/request.js +86 -1
- package/dist/utils/util.js +88 -1
- package/package.json +1 -1
- package/dist/app.d.ts +0 -0
- package/dist/app.js +0 -1
- package/dist/app.json +0 -27
- package/dist/app.wxss +0 -0
- package/dist/pages/auth/login/index.js +0 -1
- package/dist/pages/auth/login/index.json +0 -5
- package/dist/pages/auth/login/index.wxml +0 -6
- package/dist/pages/auth/login/index.wxss +0 -1
- package/dist/pages/demo/index.d.ts +0 -0
- package/dist/pages/demo/index.js +0 -1
- package/dist/pages/demo/index.json +0 -14
- package/dist/pages/demo/index.wxml +0 -11
- package/dist/pages/demo/index.wxss +0 -0
- package/dist/pages/half-home/index.d.ts +0 -1
- package/dist/pages/half-home/index.js +0 -1
- package/dist/pages/half-home/index.json +0 -5
- package/dist/pages/half-home/index.wxml +0 -5
- package/dist/pages/half-home/index.wxss +0 -0
- package/dist/pages/home/index.d.ts +0 -1
- package/dist/pages/home/index.js +0 -1
- package/dist/pages/home/index.wxml +0 -2
- package/dist/pages/home/index.wxss +0 -0
- package/dist/pages/index/index.d.ts +0 -1
- package/dist/pages/index/index.js +0 -1
- package/dist/pages/index/index.json +0 -4
- package/dist/pages/index/index.wxml +0 -8
- package/dist/pages/index/index.wxss +0 -0
- package/dist/sitemap.json +0 -7
- package/xyvcard-wechat-auth-0.0.1.tgz +0 -0
- /package/dist/{pages/auth/login → components/common/auth-basic-title/basic-title-view}/index.d.ts +0 -0
|
@@ -1 +1,121 @@
|
|
|
1
|
-
|
|
1
|
+
import { auth } from "../../utils/auth.js";
|
|
2
|
+
Component({
|
|
3
|
+
// 在组件定义时的选项中启用多slot支持
|
|
4
|
+
options: {
|
|
5
|
+
multipleSlots: true
|
|
6
|
+
},
|
|
7
|
+
/**
|
|
8
|
+
* 组件的属性列表
|
|
9
|
+
*/
|
|
10
|
+
properties: {
|
|
11
|
+
// 登录按钮样式
|
|
12
|
+
loginStyle: {
|
|
13
|
+
type: String,
|
|
14
|
+
value: "width: 100%;background-color: #2563EB;color: #fff;font-size: 15px;"
|
|
15
|
+
},
|
|
16
|
+
// 单选框选中的颜色
|
|
17
|
+
checkedColor: {
|
|
18
|
+
type: String,
|
|
19
|
+
value: "#0551ff"
|
|
20
|
+
},
|
|
21
|
+
// 协议样式
|
|
22
|
+
agreementStyle: {
|
|
23
|
+
type: String,
|
|
24
|
+
value: "color: #0551ff"
|
|
25
|
+
},
|
|
26
|
+
//登录后跳转页面
|
|
27
|
+
backurl: {
|
|
28
|
+
type: String,
|
|
29
|
+
value: "/pages/home/index"
|
|
30
|
+
},
|
|
31
|
+
// 登录后跳转方式 "redirectTo switchTab reLaunch navigateTo"
|
|
32
|
+
linkType: {
|
|
33
|
+
type: String,
|
|
34
|
+
value: ""
|
|
35
|
+
},
|
|
36
|
+
//遮罩层效果
|
|
37
|
+
isShowModel: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
value: false
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
/**
|
|
43
|
+
* 组件的初始数据
|
|
44
|
+
*/
|
|
45
|
+
data: {
|
|
46
|
+
// 同意协议
|
|
47
|
+
agreeStatus: false
|
|
48
|
+
},
|
|
49
|
+
/**
|
|
50
|
+
* 组件的方法列表
|
|
51
|
+
*/
|
|
52
|
+
methods: {
|
|
53
|
+
// 协议勾选事件
|
|
54
|
+
agreeChange() {
|
|
55
|
+
this.setData({
|
|
56
|
+
agreeStatus: !this.data.agreeStatus
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
// 手机号授权登录
|
|
60
|
+
wxPhoneLogin(event) {
|
|
61
|
+
let that = this;
|
|
62
|
+
if (!this.data.agreeStatus) {
|
|
63
|
+
wx.showModal({
|
|
64
|
+
title: "提示",
|
|
65
|
+
content: "您是否已阅读《用户使用协议》《隐私权政策》?",
|
|
66
|
+
success(res) {
|
|
67
|
+
if (res.confirm) {
|
|
68
|
+
that.setData({ agreeStatus: true });
|
|
69
|
+
} else if (res.cancel) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (event.detail.errMsg === "getPhoneNumber:ok") {
|
|
77
|
+
console.log(event.detail.code);
|
|
78
|
+
auth.phoneCodeLogin(event.detail.code).then((resp) => {
|
|
79
|
+
console.log(resp);
|
|
80
|
+
if (resp.status == false) {
|
|
81
|
+
wx.showToast({
|
|
82
|
+
title: resp.message ? resp.message : "登录失败联系管理员",
|
|
83
|
+
icon: "none",
|
|
84
|
+
duration: 2e3
|
|
85
|
+
});
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (this.properties.linkType === "switchTab") {
|
|
89
|
+
wx.switchTab({
|
|
90
|
+
url: this.properties.backurl
|
|
91
|
+
});
|
|
92
|
+
} else if (this.properties.linkType === "navigateTo") {
|
|
93
|
+
wx.navigateTo({
|
|
94
|
+
url: this.properties.backurl
|
|
95
|
+
});
|
|
96
|
+
} else if (this.properties.linkType === "reLaunch") {
|
|
97
|
+
wx.reLaunch({
|
|
98
|
+
url: this.properties.backurl
|
|
99
|
+
});
|
|
100
|
+
} else {
|
|
101
|
+
wx.redirectTo({
|
|
102
|
+
url: this.properties.backurl
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
} else {
|
|
107
|
+
wx.showToast({
|
|
108
|
+
title: "您已取消授权",
|
|
109
|
+
icon: "none",
|
|
110
|
+
duration: 2e3
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
// 跳转隐私协议
|
|
115
|
+
goInfo(e) {
|
|
116
|
+
var _a;
|
|
117
|
+
const id = (_a = e.currentTarget) == null ? void 0 : _a.id;
|
|
118
|
+
this.triggerEvent("policy", id);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
});
|
package/dist/constant.js
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
3
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
4
|
+
};
|
|
5
|
+
var require_constant = __commonJS({
|
|
6
|
+
"constant.js"(exports, module) {
|
|
7
|
+
const _Constant = class _Constant {
|
|
8
|
+
};
|
|
9
|
+
_Constant.MODULE_RBAC = "rbac";
|
|
10
|
+
_Constant.ENUM_GENDER = "jmash.protobuf.Gender";
|
|
11
|
+
let Constant = _Constant;
|
|
12
|
+
module.exports = Constant;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
export default require_constant();
|
package/dist/index.js
CHANGED
|
@@ -1 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
import { clearEmpty, request, sendRequest } from "./utils/request.js";
|
|
2
|
+
import { config, initconfig } from "./utils/config.js";
|
|
3
|
+
import { auth } from "./utils/auth.js";
|
|
4
|
+
import { db } from "./utils/db.js";
|
|
5
|
+
import { convertToISOString, formatDateTime, getHeight, kbToMb, validateRequired, validateRules } from "./utils/common.js";
|
|
6
|
+
import { splitOrganTenant, splitVcardTenant, splitVcardTenantReturn } from "./utils/util.js";
|
|
7
|
+
import { Dict } from "./api/index.js";
|
|
8
|
+
import { EntryDict, EnumDict } from "./api/dicts.js";
|
|
9
|
+
import { authApi } from "./api/auth/index.js";
|
|
10
|
+
import { dictApi } from "./api/dict/index.js";
|
|
11
|
+
import { fileApi } from "./api/files/index.js";
|
|
12
|
+
export {
|
|
13
|
+
Dict,
|
|
14
|
+
EntryDict,
|
|
15
|
+
EnumDict,
|
|
16
|
+
auth,
|
|
17
|
+
authApi,
|
|
18
|
+
clearEmpty,
|
|
19
|
+
config,
|
|
20
|
+
convertToISOString,
|
|
21
|
+
db,
|
|
22
|
+
dictApi,
|
|
23
|
+
fileApi,
|
|
24
|
+
formatDateTime,
|
|
25
|
+
getHeight,
|
|
26
|
+
initconfig,
|
|
27
|
+
kbToMb,
|
|
28
|
+
request,
|
|
29
|
+
sendRequest,
|
|
30
|
+
splitOrganTenant,
|
|
31
|
+
splitVcardTenant,
|
|
32
|
+
splitVcardTenantReturn,
|
|
33
|
+
validateRequired,
|
|
34
|
+
validateRules
|
|
35
|
+
};
|
package/dist/utils/auth.js
CHANGED
|
@@ -1 +1,212 @@
|
|
|
1
|
-
|
|
1
|
+
import { config } from "./config.js";
|
|
2
|
+
import { db } from "./db.js";
|
|
3
|
+
import { authApi } from "../api/auth/index.js";
|
|
4
|
+
class Auth {
|
|
5
|
+
/** 登录检查 */
|
|
6
|
+
loginOnlyAC() {
|
|
7
|
+
return new Promise((resolve, reject) => {
|
|
8
|
+
if (this.checkLogin()) {
|
|
9
|
+
resolve(true);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (config.dev && config.testNewUser) {
|
|
13
|
+
reject(false);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
this.silentLogin().then((res) => {
|
|
17
|
+
if (res.status) {
|
|
18
|
+
resolve(true);
|
|
19
|
+
} else {
|
|
20
|
+
reject(false);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/** 登录检查并跳转登录 */
|
|
26
|
+
loginAC(backurl, tabbar, loginurl = "/pages/auth/login/index") {
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
28
|
+
if (this.checkLogin()) {
|
|
29
|
+
resolve(true);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (config.dev && config.testNewUser) {
|
|
33
|
+
reject(false);
|
|
34
|
+
let toUrl = loginurl + "?tabbar=" + (tabbar ? "true" : "false");
|
|
35
|
+
toUrl += "&backurl=" + backurl;
|
|
36
|
+
wx.navigateTo({
|
|
37
|
+
url: toUrl
|
|
38
|
+
});
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
this.silentLogin().then((res) => {
|
|
42
|
+
if (res.status) {
|
|
43
|
+
resolve(true);
|
|
44
|
+
} else {
|
|
45
|
+
reject(false);
|
|
46
|
+
let toUrl = loginurl + "?tabbar=" + (tabbar ? "true" : "false");
|
|
47
|
+
toUrl += "&backurl=" + backurl;
|
|
48
|
+
wx.navigateTo({
|
|
49
|
+
url: toUrl
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/** 检查登录是否有效? */
|
|
56
|
+
checkLogin() {
|
|
57
|
+
if (db.getToken() && !db.isTokenExpire()) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
// 判断是否存在有效用户.
|
|
63
|
+
async hasUser() {
|
|
64
|
+
const isLoggedIn = auth.checkLogin();
|
|
65
|
+
if (!isLoggedIn) {
|
|
66
|
+
return auth.silentLogin().then((res) => {
|
|
67
|
+
console.log("静默登录--------", res);
|
|
68
|
+
if (!res.status) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
return true;
|
|
72
|
+
}).catch((err) => {
|
|
73
|
+
console.error("Silent login failed:", err);
|
|
74
|
+
return false;
|
|
75
|
+
});
|
|
76
|
+
} else {
|
|
77
|
+
return Promise.resolve(true);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// 检查角色
|
|
81
|
+
checkRole(role) {
|
|
82
|
+
const roleCodes = db.getRoleCodes();
|
|
83
|
+
return roleCodes.length > 0 && roleCodes.indexOf(role) !== -1;
|
|
84
|
+
}
|
|
85
|
+
/** 静默登录 */
|
|
86
|
+
silentLogin() {
|
|
87
|
+
return new Promise((resolve, reject) => {
|
|
88
|
+
try {
|
|
89
|
+
wx.login({
|
|
90
|
+
success: (res) => {
|
|
91
|
+
if (res.code) {
|
|
92
|
+
authApi.miniappLogin({
|
|
93
|
+
loginCode: res.code,
|
|
94
|
+
appId: config.appId,
|
|
95
|
+
componentAppid: config.componentAppid
|
|
96
|
+
}).then((response) => {
|
|
97
|
+
if (response.code === 200 && response.data.status === true) {
|
|
98
|
+
db.loginStorage(response.data);
|
|
99
|
+
console.log("login success");
|
|
100
|
+
this.getUserInfo(false);
|
|
101
|
+
this.getRolePerm(false).then(() => {
|
|
102
|
+
resolve(response.data);
|
|
103
|
+
});
|
|
104
|
+
} else if (response.code === 200) {
|
|
105
|
+
resolve(response.data);
|
|
106
|
+
} else {
|
|
107
|
+
reject(response.message);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
fail: (fail) => {
|
|
113
|
+
console.log("登录失败2", fail.errMsg);
|
|
114
|
+
reject(fail.errMsg);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
} catch (error) {
|
|
118
|
+
console.log("silentLogin静默登录抛出异常");
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
// 手机号code 注册登录
|
|
123
|
+
phoneCodeLogin(phoneCode, nickName = "") {
|
|
124
|
+
return new Promise((resolve, reject) => {
|
|
125
|
+
wx.login({
|
|
126
|
+
success: (res) => {
|
|
127
|
+
if (res.code) {
|
|
128
|
+
authApi.miniappPhoneNumber({
|
|
129
|
+
phoneCode,
|
|
130
|
+
loginCode: res.code,
|
|
131
|
+
appId: config.appId,
|
|
132
|
+
nickName,
|
|
133
|
+
componentAppid: config.componentAppid
|
|
134
|
+
}).then(
|
|
135
|
+
(resp) => {
|
|
136
|
+
console.log("phoneCodeLogin-res", resp);
|
|
137
|
+
if (resp.code === 200 && resp.data.status === true) {
|
|
138
|
+
db.loginStorage(resp.data);
|
|
139
|
+
console.log("login success");
|
|
140
|
+
this.getRolePerm().then(() => {
|
|
141
|
+
resolve(resp.data);
|
|
142
|
+
});
|
|
143
|
+
} else {
|
|
144
|
+
reject(resp.message);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
fail: (fail) => {
|
|
151
|
+
console.log("登录失败3", fail.errMsg);
|
|
152
|
+
reject(fail.errMsg);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
// 获取角色
|
|
158
|
+
getRolePerm(cache = true) {
|
|
159
|
+
return new Promise((resolve, reject) => {
|
|
160
|
+
let rolesPerms = { roleCodes: db.getRoleCodes(), permCodes: db.getPermCodes() };
|
|
161
|
+
if (cache && (Object.keys(rolesPerms.roleCodes).length > 0 || Object.keys(rolesPerms.permCodes).length > 0)) {
|
|
162
|
+
resolve(rolesPerms);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
authApi.userRolesPerms().then((response) => {
|
|
166
|
+
db.rolesPermsStorage(response.data);
|
|
167
|
+
resolve(response.data);
|
|
168
|
+
}).catch(() => {
|
|
169
|
+
reject("获取角色权限错误!");
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
// 获取用户信息
|
|
174
|
+
getUserInfo(cache = true) {
|
|
175
|
+
return new Promise((resolve, reject) => {
|
|
176
|
+
let userInfo = db.getUserInfo();
|
|
177
|
+
if (cache && Object.keys(userInfo).length > 0) {
|
|
178
|
+
resolve(userInfo);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
authApi.userInfo().then((resp) => {
|
|
182
|
+
db.userInfoStorage(resp.data);
|
|
183
|
+
resolve(resp.data);
|
|
184
|
+
}).catch(() => {
|
|
185
|
+
reject("获取角色权限错误!");
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
// 刷新Token.
|
|
190
|
+
refreshToken() {
|
|
191
|
+
return new Promise((resolve, reject) => {
|
|
192
|
+
authApi.refreshToken({
|
|
193
|
+
tenant: config.tenant,
|
|
194
|
+
refreshToken: db.getRefreshToken(),
|
|
195
|
+
clientId: config.appId
|
|
196
|
+
}).then((response) => {
|
|
197
|
+
db.tokenStorage(response.data);
|
|
198
|
+
resolve(true);
|
|
199
|
+
}).catch((error) => {
|
|
200
|
+
reject(error);
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
// 登出
|
|
205
|
+
loginOut() {
|
|
206
|
+
db.clearStorage();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
const auth = new Auth();
|
|
210
|
+
export {
|
|
211
|
+
auth
|
|
212
|
+
};
|
package/dist/utils/common.js
CHANGED
|
@@ -1 +1,113 @@
|
|
|
1
|
-
|
|
1
|
+
const validateRules = (value, message, rules) => {
|
|
2
|
+
if (value && !rules.test(value)) {
|
|
3
|
+
wx.showToast({
|
|
4
|
+
title: message,
|
|
5
|
+
icon: "none",
|
|
6
|
+
duration: 2e3
|
|
7
|
+
});
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
return true;
|
|
11
|
+
};
|
|
12
|
+
const validateRequired = (value, message) => {
|
|
13
|
+
console.log(value, message);
|
|
14
|
+
const valueStr = typeof value === "number" ? String(value) : value;
|
|
15
|
+
if (!valueStr || valueStr.trim() == "") {
|
|
16
|
+
wx.showToast({
|
|
17
|
+
title: message,
|
|
18
|
+
icon: "none",
|
|
19
|
+
duration: 2e3
|
|
20
|
+
});
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
};
|
|
25
|
+
const formatDateTime = (dateTimeString, format) => {
|
|
26
|
+
var date = new Date(dateTimeString);
|
|
27
|
+
if (isNaN(date.getTime())) {
|
|
28
|
+
return "";
|
|
29
|
+
}
|
|
30
|
+
var year = date.getFullYear();
|
|
31
|
+
var month = ("0" + (date.getMonth() + 1)).slice(-2);
|
|
32
|
+
var day = ("0" + date.getDate()).slice(-2);
|
|
33
|
+
var hours = ("0" + date.getHours()).slice(-2);
|
|
34
|
+
var minutes = ("0" + date.getMinutes()).slice(-2);
|
|
35
|
+
var seconds = ("0" + date.getSeconds()).slice(-2);
|
|
36
|
+
if (format === "YYYY-MM-DD HH:mm:ss") {
|
|
37
|
+
return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
|
|
38
|
+
}
|
|
39
|
+
if (format === "YYYY-MM-DD HH:mm") {
|
|
40
|
+
return year + "-" + month + "-" + day + " " + hours + ":" + minutes;
|
|
41
|
+
}
|
|
42
|
+
if (format === "YYYY-MM-DD") {
|
|
43
|
+
return year + "-" + month + "-" + day;
|
|
44
|
+
}
|
|
45
|
+
return "";
|
|
46
|
+
};
|
|
47
|
+
const kbToMb = (kb, decimalPlaces = 2) => {
|
|
48
|
+
return parseFloat((kb / 1024 / 1024).toFixed(decimalPlaces));
|
|
49
|
+
};
|
|
50
|
+
const convertToISOString = (dateString) => {
|
|
51
|
+
const date = new Date(dateString);
|
|
52
|
+
return date.toISOString();
|
|
53
|
+
};
|
|
54
|
+
const getHeight = () => {
|
|
55
|
+
let navigationPaddingHeight = 0;
|
|
56
|
+
let topHeight = 0;
|
|
57
|
+
let bottomHeight = 0;
|
|
58
|
+
let MenuButtonRight = 0;
|
|
59
|
+
let MenuButtonLeft = 0;
|
|
60
|
+
let MenuButtonTop = 0;
|
|
61
|
+
let MenuButtonBottom = 0;
|
|
62
|
+
let MenuButtonWidth = 0;
|
|
63
|
+
let MenuButtonHeight = 0;
|
|
64
|
+
let MenuButtonBounding = 0;
|
|
65
|
+
let screenWidth = 0;
|
|
66
|
+
let screenHeight = 0;
|
|
67
|
+
try {
|
|
68
|
+
MenuButtonHeight = wx.getMenuButtonBoundingClientRect().height ? wx.getMenuButtonBoundingClientRect().height : 0;
|
|
69
|
+
navigationPaddingHeight = wx.getWindowInfo().statusBarHeight + 7 ? wx.getWindowInfo().statusBarHeight + 7 : 0;
|
|
70
|
+
topHeight = MenuButtonHeight + navigationPaddingHeight;
|
|
71
|
+
bottomHeight = wx.getWindowInfo().screenHeight - wx.getWindowInfo().safeArea.bottom ? wx.getWindowInfo().screenHeight - wx.getWindowInfo().safeArea.bottom : 0;
|
|
72
|
+
MenuButtonRight = wx.getMenuButtonBoundingClientRect().right;
|
|
73
|
+
MenuButtonLeft = wx.getMenuButtonBoundingClientRect().left;
|
|
74
|
+
MenuButtonTop = wx.getMenuButtonBoundingClientRect().top;
|
|
75
|
+
MenuButtonBottom = wx.getMenuButtonBoundingClientRect().bottom;
|
|
76
|
+
MenuButtonWidth = wx.getMenuButtonBoundingClientRect().width;
|
|
77
|
+
MenuButtonBounding = wx.getWindowInfo().statusBarHeight;
|
|
78
|
+
screenWidth = wx.getWindowInfo().screenWidth;
|
|
79
|
+
screenHeight = wx.getWindowInfo().screenHeight;
|
|
80
|
+
} catch (error) {
|
|
81
|
+
console.log("getHeight", error);
|
|
82
|
+
}
|
|
83
|
+
function computeHeightFn(height, stackingHeight) {
|
|
84
|
+
return height !== 0 ? height : height + stackingHeight;
|
|
85
|
+
}
|
|
86
|
+
function addition(height, addHeight) {
|
|
87
|
+
return height + addHeight;
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
navigationPaddingHeight,
|
|
91
|
+
topHeight,
|
|
92
|
+
bottomHeight,
|
|
93
|
+
MenuButtonRight,
|
|
94
|
+
MenuButtonLeft,
|
|
95
|
+
MenuButtonTop,
|
|
96
|
+
MenuButtonBottom,
|
|
97
|
+
MenuButtonWidth,
|
|
98
|
+
MenuButtonHeight,
|
|
99
|
+
MenuButtonBounding,
|
|
100
|
+
screenWidth,
|
|
101
|
+
screenHeight,
|
|
102
|
+
computeHeightFn,
|
|
103
|
+
addition
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
export {
|
|
107
|
+
convertToISOString,
|
|
108
|
+
formatDateTime,
|
|
109
|
+
getHeight,
|
|
110
|
+
kbToMb,
|
|
111
|
+
validateRequired,
|
|
112
|
+
validateRules
|
|
113
|
+
};
|
package/dist/utils/config.js
CHANGED
|
@@ -1 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
const https = "https://";
|
|
2
|
+
const host = "gh.sooyie.cn";
|
|
3
|
+
const agentUrl = "/v1/file/path/wxapp";
|
|
4
|
+
const config = {
|
|
5
|
+
dev: true,
|
|
6
|
+
testNewUser: true,
|
|
7
|
+
name: "Jmash框架",
|
|
8
|
+
baseUrl: https + host,
|
|
9
|
+
// 接口域名
|
|
10
|
+
resourceUrl: https + host + agentUrl,
|
|
11
|
+
// 资源域名
|
|
12
|
+
// 测试版本
|
|
13
|
+
appId: wx.getAccountInfoSync().miniProgram.appId,
|
|
14
|
+
// 小程序appid 查看详情里面id wxf201f46341e0adf6
|
|
15
|
+
tenant: "xyvcard",
|
|
16
|
+
// 登录租户
|
|
17
|
+
componentAppid: "wxe1b784ea80c01f40",
|
|
18
|
+
// 测试版·微信第三方平台,ext.json extAppid
|
|
19
|
+
// componentAppid: "wx8a77494240acd868", // 正式版·微信第三方平台,ext.json extAppid
|
|
20
|
+
siteId: "552416fb-5dc8-46b8-8a35-bc26b1a09be1"
|
|
21
|
+
// 站点id
|
|
22
|
+
};
|
|
23
|
+
const initconfig = (appConfig) => {
|
|
24
|
+
Object.assign(config, appConfig);
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
config,
|
|
28
|
+
initconfig
|
|
29
|
+
};
|