xyvcard-wechat-auth 0.0.24 → 0.0.26
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
.auth-mask-box{position:fixed;left:0;top:0;bottom:0;right:0;width:100%;background-color:rgba(0,0,0,.5);z-index:99999}.auth-mask-popup{position:fixed;bottom:0;left:0;padding:0 30rpx env(safe-area-inset-bottom);box-sizing:border-box;z-index:99999}.auth-mask-popup .popup-title{color:#333;font-size:28rpx;padding:
|
|
1
|
+
.auth-mask-box{position:fixed;left:0;top:0;bottom:0;right:0;width:100%;background-color:rgba(0,0,0,.5);z-index:99999}.auth-mask-popup{position:fixed;bottom:0;left:0;width:92%;padding:0 30rpx env(safe-area-inset-bottom);box-sizing:border-box;z-index:99999}.auth-mask-popup .popup-title{color:#333;font-size:28rpx;padding:20px 10px 10px;font-weight:bold;display:flex;align-items:center;justify-content:space-between}.auth-mask-popup .popup-title .close-icon{width:40rpx;height:40rpx}
|
|
@@ -31,7 +31,7 @@ Component({
|
|
|
31
31
|
// 登录后跳转方式 "redirectTo switchTab reLaunch navigateTo"
|
|
32
32
|
linkType: {
|
|
33
33
|
type: String,
|
|
34
|
-
value: ""
|
|
34
|
+
value: "redirectTo"
|
|
35
35
|
},
|
|
36
36
|
//遮罩层效果
|
|
37
37
|
isShowModel: {
|
|
@@ -76,7 +76,6 @@ Component({
|
|
|
76
76
|
if (event.detail.errMsg === "getPhoneNumber:ok") {
|
|
77
77
|
console.log(event.detail.code);
|
|
78
78
|
auth.phoneCodeLogin(event.detail.code).then((resp) => {
|
|
79
|
-
console.log(resp);
|
|
80
79
|
if (resp.status == false) {
|
|
81
80
|
wx.showToast({
|
|
82
81
|
title: resp.message ? resp.message : "登录失败联系管理员",
|
|
@@ -85,22 +84,15 @@ Component({
|
|
|
85
84
|
});
|
|
86
85
|
return;
|
|
87
86
|
}
|
|
87
|
+
const backurl = decodeURIComponent(this.properties.backurl);
|
|
88
88
|
if (this.properties.linkType === "switchTab") {
|
|
89
|
-
wx.switchTab({
|
|
90
|
-
url: this.properties.backurl
|
|
91
|
-
});
|
|
89
|
+
wx.switchTab({ url: backurl });
|
|
92
90
|
} else if (this.properties.linkType === "navigateTo") {
|
|
93
|
-
wx.navigateTo({
|
|
94
|
-
url: this.properties.backurl
|
|
95
|
-
});
|
|
91
|
+
wx.navigateTo({ url: backurl });
|
|
96
92
|
} else if (this.properties.linkType === "reLaunch") {
|
|
97
|
-
wx.reLaunch({
|
|
98
|
-
url: this.properties.backurl
|
|
99
|
-
});
|
|
93
|
+
wx.reLaunch({ url: backurl });
|
|
100
94
|
} else {
|
|
101
|
-
wx.redirectTo({
|
|
102
|
-
url: this.properties.backurl
|
|
103
|
-
});
|
|
95
|
+
wx.redirectTo({ url: backurl });
|
|
104
96
|
}
|
|
105
97
|
});
|
|
106
98
|
} else {
|
package/dist/utils/auth.js
CHANGED
|
@@ -29,13 +29,11 @@ class Auth {
|
|
|
29
29
|
resolve(true);
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
+
let toUrl = loginurl + "?tabbar=" + (tabbar ? "true" : "false");
|
|
33
|
+
toUrl += "&backurl=" + encodeURIComponent(backurl);
|
|
32
34
|
if (config.dev && config.testNewUser) {
|
|
33
35
|
reject(false);
|
|
34
|
-
|
|
35
|
-
toUrl += "&backurl=" + backurl;
|
|
36
|
-
wx.navigateTo({
|
|
37
|
-
url: toUrl
|
|
38
|
-
});
|
|
36
|
+
wx.navigateTo({ url: toUrl });
|
|
39
37
|
return;
|
|
40
38
|
}
|
|
41
39
|
this.silentLogin().then((res) => {
|
|
@@ -43,11 +41,7 @@ class Auth {
|
|
|
43
41
|
resolve(true);
|
|
44
42
|
} else {
|
|
45
43
|
reject(false);
|
|
46
|
-
|
|
47
|
-
toUrl += "&backurl=" + backurl;
|
|
48
|
-
wx.navigateTo({
|
|
49
|
-
url: toUrl
|
|
50
|
-
});
|
|
44
|
+
wx.navigateTo({ url: toUrl });
|
|
51
45
|
}
|
|
52
46
|
});
|
|
53
47
|
});
|
|
@@ -131,20 +125,18 @@ class Auth {
|
|
|
131
125
|
appId: config.appId,
|
|
132
126
|
nickName,
|
|
133
127
|
componentAppid: config.componentAppid
|
|
134
|
-
}).then(
|
|
135
|
-
(resp)
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
reject(resp.message);
|
|
145
|
-
}
|
|
128
|
+
}).then((resp) => {
|
|
129
|
+
console.log("phoneCodeLogin-res", resp);
|
|
130
|
+
if (resp.code === 200 && resp.data.status === true) {
|
|
131
|
+
db.loginStorage(resp.data);
|
|
132
|
+
console.log("login success");
|
|
133
|
+
this.getRolePerm().then(() => {
|
|
134
|
+
resolve(resp.data);
|
|
135
|
+
});
|
|
136
|
+
} else {
|
|
137
|
+
reject(resp.message);
|
|
146
138
|
}
|
|
147
|
-
);
|
|
139
|
+
});
|
|
148
140
|
}
|
|
149
141
|
},
|
|
150
142
|
fail: (fail) => {
|
|
@@ -157,7 +149,10 @@ class Auth {
|
|
|
157
149
|
// 获取角色
|
|
158
150
|
getRolePerm(cache = true) {
|
|
159
151
|
return new Promise((resolve, reject) => {
|
|
160
|
-
let rolesPerms = {
|
|
152
|
+
let rolesPerms = {
|
|
153
|
+
roleCodes: db.getRoleCodes(),
|
|
154
|
+
permCodes: db.getPermCodes()
|
|
155
|
+
};
|
|
161
156
|
if (cache && (Object.keys(rolesPerms.roleCodes).length > 0 || Object.keys(rolesPerms.permCodes).length > 0)) {
|
|
162
157
|
resolve(rolesPerms);
|
|
163
158
|
return;
|
package/dist/utils/config.js
CHANGED
package/dist/utils/request.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { RequestData, ResponseData, RequestHeader } from "../api/types";
|
|
2
|
-
declare const request: (options?: RequestData<any>, tenant?: string) => Promise<ResponseData<any>>;
|
|
3
|
-
declare const sendRequest: (options: RequestData<any>, header: RequestHeader) => Promise<ResponseData<any>>;
|
|
4
|
-
declare function clearEmpty(params: any): any;
|
|
5
|
-
export { request, sendRequest, clearEmpty };
|
|
2
|
+
export declare const request: (options?: RequestData<any>, tenant?: string) => Promise<ResponseData<any>>;
|
|
3
|
+
export declare const sendRequest: (options: RequestData<any>, header: RequestHeader) => Promise<ResponseData<any>>;
|
|
4
|
+
export declare function clearEmpty(params: any): any;
|
package/dist/utils/request.js
CHANGED
|
@@ -24,7 +24,7 @@ const request = async (options = {}, tenant = "") => {
|
|
|
24
24
|
try {
|
|
25
25
|
let header = {
|
|
26
26
|
"content-type": "application/json",
|
|
27
|
-
|
|
27
|
+
Authorization: db.getBearerToken(),
|
|
28
28
|
"Grpc-Metadata-Tenant": tenant
|
|
29
29
|
};
|
|
30
30
|
const response = await sendRequest(options, header);
|
|
@@ -67,15 +67,14 @@ const sendRequest = (options, header) => {
|
|
|
67
67
|
};
|
|
68
68
|
function clearEmpty(params) {
|
|
69
69
|
for (const key in params) {
|
|
70
|
-
if (typeof params[key] === "object") {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (params[key] === "") {
|
|
77
|
-
delete params[key];
|
|
70
|
+
if (params[key] !== null && typeof params[key] === "object") {
|
|
71
|
+
if (Object.keys(params[key]).length === 0) {
|
|
72
|
+
delete params[key];
|
|
73
|
+
} else {
|
|
74
|
+
clearEmpty(params[key]);
|
|
75
|
+
}
|
|
78
76
|
}
|
|
77
|
+
if ([void 0, null, ""].includes(params[key])) delete params[key];
|
|
79
78
|
}
|
|
80
79
|
return params;
|
|
81
80
|
}
|