xctc-utils 1.6.18 → 1.6.19

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.
@@ -156,9 +156,13 @@ function login(code) {
156
156
  if (res === null || res === void 0 ? void 0 : res.hasOwnProperty("code")) {
157
157
  code = res.code;
158
158
  }
159
- if (res === null || res === void 0 ? void 0 : res.hasOwnProperty("Code")) {
159
+ else if (res === null || res === void 0 ? void 0 : res.hasOwnProperty("Code")) {
160
160
  code = res.Code;
161
161
  }
162
+ else {
163
+ console.error("http响应数据格式必须是:res:{code:xx,data:{}}");
164
+ return;
165
+ }
162
166
  if (code == 40163) {
163
167
  // 未登录则先执行登录
164
168
  return getCode();
@@ -167,9 +171,13 @@ function login(code) {
167
171
  if (res === null || res === void 0 ? void 0 : res.hasOwnProperty("data")) {
168
172
  data = res.data;
169
173
  }
170
- if (res === null || res === void 0 ? void 0 : res.hasOwnProperty("Data")) {
174
+ else if (res === null || res === void 0 ? void 0 : res.hasOwnProperty("Data")) {
171
175
  data = res.Data;
172
176
  }
177
+ else {
178
+ console.error("http响应数据格式必须是:res:{code:xx,data:{}}");
179
+ return;
180
+ }
173
181
  for (var key in data) {
174
182
  var item = data[key];
175
183
  if (item instanceof Object) {
@@ -349,9 +357,13 @@ function configReady(config) {
349
357
  if (res === null || res === void 0 ? void 0 : res.hasOwnProperty("data")) {
350
358
  data = res.data;
351
359
  }
352
- if (res === null || res === void 0 ? void 0 : res.hasOwnProperty("Data")) {
360
+ else if (res === null || res === void 0 ? void 0 : res.hasOwnProperty("Data")) {
353
361
  data = res.Data;
354
362
  }
363
+ else {
364
+ console.error("http响应数据格式必须是:res:{data:{appid:xx,timestamp:xx,noncestr:xx,signature:xx}}");
365
+ return;
366
+ }
355
367
  for (var key in data) {
356
368
  var newKey = key.toLowerCase();
357
369
  data[newKey] = data[key];
@@ -360,25 +372,19 @@ function configReady(config) {
360
372
  console.error("后端响应的data数据中缺乏appid或者appId或者AppId字段!");
361
373
  return;
362
374
  }
363
- var timestamp = (data === null || data === void 0 ? void 0 : data.timestamp) || "";
364
- if (!timestamp) {
365
- return;
366
- }
367
- timestamp = Number(timestamp);
368
375
  var obj = {
369
376
  jsApiList: jsApiListData,
370
377
  openTagList: openTagListData,
371
378
  debug: false,
372
379
  appId: data === null || data === void 0 ? void 0 : data.appid,
373
- timestamp: timestamp,
380
+ timestamp: data === null || data === void 0 ? void 0 : data.timestamp,
374
381
  nonceStr: data === null || data === void 0 ? void 0 : data.noncestr,
375
382
  signature: data === null || data === void 0 ? void 0 : data.signature, //必填,生成的签名
376
383
  };
377
384
  var wx = initSdk();
378
- (0, index_1.useSessionStorage)("configReadyData", obj);
379
385
  wx.config(obj);
380
386
  wx.ready(function (res) {
381
- (0, index_1.useSessionStorage)("configReadySuccess", res);
387
+ (0, index_1.useSessionStorage)("configReadySuccess", "wx.ready");
382
388
  if (config['cb'] && typeof config.cb === "function")
383
389
  config.cb();
384
390
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xctc-utils",
3
- "version": "1.6.18",
3
+ "version": "1.6.19",
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",