xctc-utils 1.4.3 → 1.4.5
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/weixin/index.js +18 -4
- package/package.json +1 -1
package/dist/weixin/index.js
CHANGED
|
@@ -26,6 +26,7 @@ function weixinUrlCode(config) {
|
|
|
26
26
|
(0, index_1.useSessionStorage)("weixinConfig", weixinConfig);
|
|
27
27
|
var _a = weixinConfig.cryptoiv, cryptoiv = _a === void 0 ? "" : _a, _b = weixinConfig.cryptokey, cryptokey = _b === void 0 ? "" : _b;
|
|
28
28
|
var search = loc.search; // ?code=0916SzFa1KH9TA0Ke7Ha1AQx6446SzFr&state=123
|
|
29
|
+
weixinInit();
|
|
29
30
|
// 获取地址栏返回 code 参数
|
|
30
31
|
var localCode = "";
|
|
31
32
|
if (codeKey) {
|
|
@@ -118,9 +119,9 @@ function weixinLogin(code) {
|
|
|
118
119
|
return;
|
|
119
120
|
(0, index_1.useSessionStorage)("weixinLoginParams", JSON.stringify(obj));
|
|
120
121
|
// 调试字段 isPassLogin ,为true 时不继续执行微信登录,前端可拿到 code 给后端测试
|
|
121
|
-
if
|
|
122
|
-
return;
|
|
122
|
+
// if(weixinConfig['isPassLogin']) return
|
|
123
123
|
weixinConfig.http(obj).then(function (res) {
|
|
124
|
+
(0, index_1.useSessionStorage)("weixinLoginRes", res);
|
|
124
125
|
if (res.code == 40163) {
|
|
125
126
|
// 未登录则先执行登录
|
|
126
127
|
return weixinCode();
|
|
@@ -158,12 +159,24 @@ function weixinLogin(code) {
|
|
|
158
159
|
url = "".concat(url, "?").concat(str);
|
|
159
160
|
}
|
|
160
161
|
}
|
|
161
|
-
|
|
162
|
+
if (weixinConfig['isPassLogin']) {
|
|
163
|
+
console.log("不执行跳转操作");
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
loc.replace(url);
|
|
167
|
+
}
|
|
162
168
|
}
|
|
163
169
|
else {
|
|
164
170
|
url = "".concat(url, "/").concat(hashVal);
|
|
165
|
-
|
|
171
|
+
if (weixinConfig['isPassLogin']) {
|
|
172
|
+
console.log("不执行跳转操作");
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
loc.replace(url);
|
|
176
|
+
}
|
|
166
177
|
}
|
|
178
|
+
}).catch(function (err) {
|
|
179
|
+
(0, index_1.useSessionStorage)("weixinLoginError", err);
|
|
167
180
|
});
|
|
168
181
|
}
|
|
169
182
|
/**
|
|
@@ -189,6 +202,7 @@ function weixinInit() {
|
|
|
189
202
|
else {
|
|
190
203
|
wx = weixin;
|
|
191
204
|
}
|
|
205
|
+
w['weixinConfig'] = wx;
|
|
192
206
|
return wx;
|
|
193
207
|
}
|
|
194
208
|
// 前往微信授权登录页面
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xctc-utils",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.5",
|
|
4
4
|
"description": "localStorage存储\r ```\r sessionStorage存储\r ```\r crypto-js加密、解密\r ```\r 微信授权登录、微信分享\r ```\r 设备环境获取\r ```\r 是否是微信浏览器\r ```\r 时间戳转时间,字符串转时间戳",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|