xctc-utils 1.6.13 → 1.6.15

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.
@@ -54,13 +54,13 @@ function getUrlCode(config) {
54
54
  weixinConfig['stateKey'] = stateKey;
55
55
  (0, index_1.useSessionStorage)("weixinConfig", weixinConfig);
56
56
  var _b = weixinConfig.cryptoiv, cryptoiv = _b === void 0 ? defaultIv : _b, _c = weixinConfig.cryptokey, cryptokey = _c === void 0 ? defaultKey : _c, _d = weixinConfig.debuggerStatus, debuggerStatus = _d === void 0 ? false : _d;
57
- var search = loc.search; // ?code=0916SzFa1KH9TA0Ke7Ha1AQx6446SzFr&state=123
58
57
  initSdk(); // 加载微信sdk环境
59
58
  // 默认第一次通过链接进入系统,没有code和state
60
59
  var codeIndex = -1;
61
60
  var stateIndex = -1;
62
61
  var msgStr = "";
63
62
  var isAuth = false; // 是否完成 code 授权
63
+ var search = loc.search; // ?code=0916SzFa1KH9TA0Ke7Ha1AQx6446SzFr&state=123
64
64
  if (search) {
65
65
  codeIndex = search.indexOf("code=");
66
66
  stateIndex = search.indexOf("state=");
@@ -304,8 +304,26 @@ var defaultOpenTagList = [
304
304
  "wx-open-subscribe", "wx-open-launch-app", "wx-open-launch-weapp",
305
305
  "wx-open-audio"
306
306
  ];
307
+ var isContinue = function () {
308
+ var localCodeData = (0, index_1.getSessionStorage)("urlParamsData") || "";
309
+ var search = loc.search; // ?code=0916SzFa1KH9TA0Ke7Ha1AQx6446SzFr&state=123
310
+ var codeIndex = -1;
311
+ if (search) {
312
+ codeIndex = search.indexOf("code=");
313
+ }
314
+ if (localCodeData && localCodeData.hasOwnProperty("code") && codeIndex == -1) {
315
+ return true;
316
+ }
317
+ else {
318
+ return false;
319
+ }
320
+ };
307
321
  function configReady(config) {
308
322
  var _a;
323
+ if (!isContinue()) {
324
+ console.error("还未执行微信登录流程");
325
+ return;
326
+ }
309
327
  var _b = config || {}, appId = _b.appId, url = _b.url, _c = _b.urlKey, urlKey = _c === void 0 ? "url" : _c, _d = _b.appIdKey, appIdKey = _d === void 0 ? "appId" : _d, cb = _b.cb, _e = _b.jsApiList, jsApiList = _e === void 0 ? [] : _e, _f = _b.openTagList, openTagList = _f === void 0 ? [] : _f, _g = _b.http, http = _g === void 0 ? "" : _g;
310
328
  if (!http)
311
329
  return;
@@ -327,7 +345,6 @@ function configReady(config) {
327
345
  }
328
346
  config.http(param).then(function (res) {
329
347
  if (res) {
330
- (0, index_1.useSessionStorage)("configReady-res", res);
331
348
  var data = {};
332
349
  if (res === null || res === void 0 ? void 0 : res.hasOwnProperty("data")) {
333
350
  data = res.data;
@@ -339,7 +356,6 @@ function configReady(config) {
339
356
  var newKey = key.toLowerCase();
340
357
  data[newKey] = data[key];
341
358
  }
342
- (0, index_1.useSessionStorage)("configReady-data", data);
343
359
  if (!(data === null || data === void 0 ? void 0 : data.appid)) {
344
360
  console.error("后端响应的data数据中缺乏appid或者appId或者AppId字段!");
345
361
  return;
@@ -353,7 +369,6 @@ function configReady(config) {
353
369
  nonceStr: data === null || data === void 0 ? void 0 : data.noncestr,
354
370
  signature: data === null || data === void 0 ? void 0 : data.signature, //必填,生成的签名
355
371
  };
356
- (0, index_1.useSessionStorage)("configReady-obj", obj);
357
372
  var wx = initSdk();
358
373
  wx.config(obj);
359
374
  wx.ready(function (res) {
@@ -370,6 +385,10 @@ function configReady(config) {
370
385
  }
371
386
  exports.configReady = configReady;
372
387
  function shareReady(options) {
388
+ if (!isContinue()) {
389
+ console.error("还未执行微信登录流程");
390
+ return;
391
+ }
373
392
  var title = "微信分享标题";
374
393
  if (options['title'])
375
394
  title = options.title;
@@ -432,6 +451,10 @@ function shareReady(options) {
432
451
  }
433
452
  exports.shareReady = shareReady;
434
453
  function onlinePay(config) {
454
+ if (!isContinue()) {
455
+ console.error("还未执行微信登录流程");
456
+ return;
457
+ }
435
458
  var wx = initSdk();
436
459
  // let { timeStamp,signType,prepay_id,paySign,package,nonceStr,appId } = params
437
460
  var cb = "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xctc-utils",
3
- "version": "1.6.13",
3
+ "version": "1.6.15",
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",