xctc-utils 1.6.45 → 1.6.47

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.
@@ -33,4 +33,3 @@ export declare const updateParentToIframeData: (cb: any) => void;
33
33
  * @returns
34
34
  */
35
35
  export declare const iframeSendToParentData: (data: any, url: string) => void;
36
- export declare const updateWeiXinShareReady: () => void;
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateWeiXinShareReady = exports.iframeSendToParentData = exports.updateParentToIframeData = exports.updateIframeToParentData = exports.parentSendIframeData = exports.initParentDataToIframe = exports.$iframe = void 0;
3
+ exports.iframeSendToParentData = exports.updateParentToIframeData = exports.updateIframeToParentData = exports.parentSendIframeData = exports.initParentDataToIframe = exports.$iframe = void 0;
4
4
  var is_1 = require("../is");
5
- var weixin_1 = require("../weixin");
6
5
  var utils_1 = require("../utils");
7
6
  var storage_1 = require("../storage");
8
7
  /**
@@ -117,7 +116,7 @@ var parentSendIframeData = function (id, data, url, duration) {
117
116
  return;
118
117
  }
119
118
  if (!duration)
120
- duration = 200;
119
+ duration = 100;
121
120
  var iframe = (0, exports.$iframe)(id);
122
121
  if (!iframe['src']) {
123
122
  if (!url) {
@@ -180,13 +179,3 @@ var iframeSendToParentData = function (data, url) {
180
179
  window.parent.postMessage(sendData, url);
181
180
  };
182
181
  exports.iframeSendToParentData = iframeSendToParentData;
183
- var updateWeiXinShareReady = function () {
184
- window.addEventListener('message', function (event) {
185
- var data = event.data;
186
- var messageData = (0, utils_1.isJson)(data) || "";
187
- if ((messageData === null || messageData === void 0 ? void 0 : messageData.type) == "share" && (messageData === null || messageData === void 0 ? void 0 : messageData.data)) {
188
- (0, weixin_1.shareReady)(messageData.data);
189
- }
190
- });
191
- };
192
- exports.updateWeiXinShareReady = updateWeiXinShareReady;
@@ -25,6 +25,7 @@ interface ShareConfig {
25
25
  url?: string;
26
26
  urlKey?: string;
27
27
  appIdKey?: string;
28
+ dataType?: string;
28
29
  }
29
30
  export declare function configReady(config: ShareConfig): void;
30
31
  interface ShareOptions {
@@ -37,6 +38,7 @@ interface ShareOptions {
37
38
  key?: string;
38
39
  shareUrl?: string;
39
40
  dbug?: boolean;
41
+ dataType?: string;
40
42
  }
41
43
  export declare function shareReady(options: ShareOptions): void;
42
44
  /**
@@ -51,6 +53,7 @@ interface ConfigPay {
51
53
  signType: string;
52
54
  paySign: string;
53
55
  cb?: any;
56
+ dataType?: string;
54
57
  }
55
58
  export declare function onlinePay(config: ConfigPay): void;
56
59
  export {};
@@ -314,15 +314,24 @@ var defaultOpenTagList = [
314
314
  "wx-open-subscribe", "wx-open-launch-app", "wx-open-launch-weapp",
315
315
  "wx-open-audio"
316
316
  ];
317
- var isContinue = function () {
317
+ var isContinue = function (dataType) {
318
318
  var localCodeData = (0, index_1.getSessionStorage)("urlParamsData") || "";
319
+ var wxInfo = (0, index_1.getLocalStorage)("WxInfo") || "";
319
320
  var search = loc.search; // ?code=0916SzFa1KH9TA0Ke7Ha1AQx6446SzFr&state=123
320
321
  var codeIndex = -1;
321
322
  if (search) {
322
323
  codeIndex = search.indexOf("code=");
323
324
  }
324
325
  // 必须是已经存储微信授权 code ,并且链接中已无 code 字段,已完成刷新状态
325
- if (localCodeData && localCodeData.hasOwnProperty("code") && codeIndex == -1) {
326
+ if (!dataType || dataType == "session") {
327
+ if (localCodeData && localCodeData.hasOwnProperty("code") && codeIndex == -1) {
328
+ return true;
329
+ }
330
+ else {
331
+ return false;
332
+ }
333
+ }
334
+ else if (dataType == "local" && wxInfo && wxInfo['openid'] && codeIndex == -1) {
326
335
  return true;
327
336
  }
328
337
  else {
@@ -331,7 +340,7 @@ var isContinue = function () {
331
340
  };
332
341
  function configReady(config) {
333
342
  var _a;
334
- if (!isContinue()) {
343
+ if (!isContinue(config === null || config === void 0 ? void 0 : config.dataType)) {
335
344
  console.error("还未执行微信登录流程");
336
345
  return;
337
346
  }
@@ -399,7 +408,7 @@ function configReady(config) {
399
408
  }
400
409
  exports.configReady = configReady;
401
410
  function shareReady(options) {
402
- if (!isContinue()) {
411
+ if (!isContinue(options === null || options === void 0 ? void 0 : options.dataType)) {
403
412
  console.error("还未执行微信登录流程");
404
413
  return;
405
414
  }
@@ -468,7 +477,7 @@ function shareReady(options) {
468
477
  }
469
478
  exports.shareReady = shareReady;
470
479
  function onlinePay(config) {
471
- if (!isContinue()) {
480
+ if (!isContinue(config === null || config === void 0 ? void 0 : config.dataType)) {
472
481
  console.error("还未执行微信登录流程");
473
482
  return;
474
483
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xctc-utils",
3
- "version": "1.6.45",
3
+ "version": "1.6.47",
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",