xctc-utils 1.4.2 → 1.4.4

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.
@@ -118,9 +118,9 @@ function weixinLogin(code) {
118
118
  return;
119
119
  (0, index_1.useSessionStorage)("weixinLoginParams", JSON.stringify(obj));
120
120
  // 调试字段 isPassLogin ,为true 时不继续执行微信登录,前端可拿到 code 给后端测试
121
- if (weixinConfig['isPassLogin'])
122
- return;
121
+ // if(weixinConfig['isPassLogin']) return
123
122
  weixinConfig.http(obj).then(function (res) {
123
+ (0, index_1.useSessionStorage)("weixinLoginRes", res);
124
124
  if (res.code == 40163) {
125
125
  // 未登录则先执行登录
126
126
  return weixinCode();
@@ -158,12 +158,24 @@ function weixinLogin(code) {
158
158
  url = "".concat(url, "?").concat(str);
159
159
  }
160
160
  }
161
- loc.replace(url);
161
+ if (weixinConfig['isPassLogin']) {
162
+ console.log("不执行跳转操作");
163
+ }
164
+ else {
165
+ loc.replace(url);
166
+ }
162
167
  }
163
168
  else {
164
169
  url = "".concat(url, "/").concat(hashVal);
165
- loc.replace(url);
170
+ if (weixinConfig['isPassLogin']) {
171
+ console.log("不执行跳转操作");
172
+ }
173
+ else {
174
+ loc.replace(url);
175
+ }
166
176
  }
177
+ }).catch(function (err) {
178
+ (0, index_1.useSessionStorage)("weixinLoginError", err);
167
179
  });
168
180
  }
169
181
  /**
@@ -213,8 +225,8 @@ function weixinCode(appId, scope) {
213
225
  scopeVal = scope;
214
226
  }
215
227
  var base = "https://open.weixin.qq.com/connect/oauth2/authorize?";
216
- var uri = encodeURIComponent(loc.href.split("?")[0]);
217
- var config = "appid=".concat(weixinConfig.appId, "&redirect_uri=").concat(uri, "&response_type=code&scope=").concat(scopeVal, "&state=state#wechat_redirect");
228
+ var uri = encodeURIComponent(loc.origin);
229
+ var config = "appid=".concat(id, "&redirect_uri=").concat(uri, "&response_type=code&scope=").concat(scopeVal, "&state=state#wechat_redirect");
218
230
  var wxJumpURL = base + config;
219
231
  loc.replace(wxJumpURL);
220
232
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xctc-utils",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
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",