@conecli/cone-render 0.10.1-shop3.17 → 0.10.1-shop3.18

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.
@@ -1 +1 @@
1
- import Taro from '@tarojs/taro'
2
1
  abTestLabels: {},
3
2
  floorVideInfo: {},
4
3
  productVideInfo: {},
5
4
  isVipShop: false,
6
5
  isJdShowNativeImmersivePlayer: false,
7
6
  pageIdxHeightInfo: {
8
7
  list: []
9
8
  },
10
9
  jdBottomBarHeight: 0,
11
10
  jdNativeHeaderHeight: 0,
12
11
  openAppData: {}
13
12
  public config: {
14
13
  [key: string]: any
15
14
  }
16
15
  public lazyContainer: CommonInterFace.lazyContainer
17
16
  public renderedIsvComponents: CommonInterFace.renderedIsvComponents
18
17
  public loadJsSdkList: Array<any>
19
18
  public loadJsSdkListCachePromise: any
20
19
  this.config = {}
21
20
  this.loadJsSdkList = []
22
21
  this.loadJsSdkListCachePromise = {}
23
22
  this.renderedIsvComponents = {}
24
23
 
25
24
  taskTimeoutPromise(callBack, timeout = 2000){
26
25
  return new Promise((resolve) => {
27
26
  setTimeout(() => {
28
27
  const getCallBackRes = typeof callBack === 'function' && callBack()
29
28
  return resolve(getCallBackRes || false)
30
29
  }, timeout)
31
30
  })
32
31
  }
33
32
  removeJdAndroidRquestEventForTouchStart(){}
34
33
  this.info.sysInfo['wifiVideoAutoPlay'] = false
35
34
  getAPPUseStraightCorner () {
36
35
  return Promise.resolve(false)
37
36
  }
38
37
  checkStatusAndLogin(options = {}) {
39
38
 
40
39
  checkJdStatusAndLogin(options){
41
40
  return this.checkStatusAndLogin(options)
42
41
  }
43
42
 
44
43
  doLoginForJdPin(options = {}) {
45
44
  return this.doLogin(options)
46
45
  }
47
46
 
48
47
  getLoginCookie(updateKey = 'wxapp') {
49
48
  return new Promise((resolve) => {
50
49
  console.log("开始获取更新wxapp中的cookie信息", updateKey)
51
50
  if(this.config.wqCookie && this.config.wqCookieStr && this.config.getWqCookieKey === updateKey){
52
51
  console.log("已有存储wxapp中的cookie信息,直接返回",this.config)
53
52
  resolve({
54
53
  wqCookie: this.config.wqCookie,
55
54
  wqCookieStr: this.config.wqCookieStr,
56
55
  })
57
56
  }else {
58
57
  if (isPublishToWxapp) {
59
58
  const getWxappCookieObj = getTaroStorageKeyValue('cookies') || null
60
59
  if (getWxappCookieObj) {
61
60
  const getCookieObj = getWxappCookieObj['_data']
62
61
  const { wqCookie, wqCookieStr } = getWxAppCookieStr(getCookieObj)
63
62
  const { pin = '', visitkey = '-1', wq_unionid = '', wxapp_openid = '' } = wqCookie
64
63
  this.info.loginState = true
65
64
  this.info.userInfo.wqCookie = wqCookieStr
66
65
  this.info.userInfo.wqVisitkey = visitkey
67
66
  console.log('获取用户完整cookie信息', getCookieObj)
68
67
  const getUserAddress = this.wxAppUserInfoInstance.getAddress()
69
68
  console.log('获取微信用户地址信息', getUserAddress)
70
69
  if (getUserAddress) {
71
70
  this.info.pageInfo.address = getUserAddress?.areaId
72
71
  this.info.pageInfo.addressCommaStr = this.info.pageInfo
73
72
  .address
74
73
  ? this.info.pageInfo.address.replace(/_/g, ',')
75
74
  : ''
76
75
  this.info.pageInfo.un_area = this.info.pageInfo.address
77
76
  Taro.eventCenter.trigger(
78
77
  TaroEventType.USER_AREA_UPDATE,
79
78
  this.info.pageInfo.address,
80
79
  )
81
80
  }
82
81
  if(this.miniAppLogInstance){
83
82
  this.miniAppLogInstance.set({
84
83
  account: pin,
85
84
  unionid: wq_unionid,
86
85
  openid: wxapp_openid,
87
86
  })
88
87
  }
89
88
  this.config.wqCookie = wqCookie
90
89
  this.config.wqCookieStr = wqCookieStr
91
90
  this.config.getWqCookieKey = updateKey
92
91
  console.log("解析wxapp中的cookie信息成功,返回后存储",this.config)
93
92
  resolve({
94
93
  wqCookie,
95
94
  wqCookieStr,
96
95
  })
97
96
  }else {
98
97
  console.log("解析wxapp中的cookie信息异常,返回异常结果",this.config)
99
98
  resolve({
100
99
  wqCookie: false,
101
100
  wqCookieStr: false,
102
101
  })
103
102
  }
104
103
  }else {
105
104
  resolve({
106
105
  wqCookie: false,
107
106
  wqCookieStr: false,
108
107
  })
109
108
  }
110
109
  }
111
110
  })
112
111
  }
113
112
  return this.getLoginCookie()
114
113
 
115
114
  getAddressCachePromise = () => {
116
115
  return Promise.reject("该方法只在APP内适用")
117
116
  }
118
117
 
119
118
  getDynamicConfig(key: string){
120
119
  console.warn('调用默认的 getDynamicConfig(),注意,此方法还未实现!')
121
120
  return null
122
121
  }
123
122
  renderNextTickLoadSdk(){
124
123
  console.warn("暂未实现 index.ts")
125
124
  }
126
125
  loadOtherSdk(){
127
126
  console.warn("暂未实现 index.ts")
128
127
  }
129
128
  loadItemSdkPromise(jsInfo = {}) {
130
129
  console.warn('暂未实现 index.ts')
131
130
  }
131
+ import Taro from '@tarojs/taro';
132
132
  WXAPP_LOGIN,
133
133
  WXAPP_BIZ,
134
134
  WXAPP_USER_INFO,
135
135
  WXAPP_NAVIGATOR,
136
136
  WXAPP_REPORT_GDT,
137
137
  WXAPP_PARAMS_SIGN,
138
138
  BUSINESS_TYPE,
139
139
  SHOP_MENU_ID_TYPE,
140
140
  SHOP_MENU_ID_NAME,
141
141
  SECTION_HOME_TAB_NAME_TYPE,
142
142
  SECTION_HOME_TAB_TYPE,
143
143
  WXAPP_BIZ_KEY,
144
144
  WX_BUSINESS_TYPE,
145
145
  TaroEventType,
146
146
  abTestLabels: {},
147
147
  nonSellableSkuids: {},
148
148
  loginState: jdUserLoginState,
149
149
  cookiesStr: '',
150
150
  userInfo: userPinKey,
151
151
  isImmersive: false,
152
152
  pageInfo: {
153
153
  wxBusinessType: WX_BUSINESS_TYPE.SHOP,
154
154
  address: '',
155
155
  addressCommaStr: '',
156
156
  un_area: '',
157
157
  userLbsAddress: '',
158
158
  vapptype: '1',
159
159
  pageType: 'home',
160
160
  dataType: BUSINESS_TYPE.ONLINE,
161
161
  floorExposureInfo: {},
162
162
  floorVideInfo: {},
163
163
  productVideInfo: {},
164
164
  tabsLoadAllDataInfo: {
165
165
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: false,
166
166
  [SHOP_MENU_ID_NAME[SHOP_MENU_ID_TYPE.CLASSIFY]]: true,
167
167
  },
168
168
  updateShopInfosAllState: false,
169
169
  isVipShop: false,
170
170
  isJdShowNativeImmersivePlayer: false,
171
171
  ...shopConfig,
172
172
  pageScrollTop: 0,
173
173
  pageIdxHeightInfo: {
174
174
  list: [],
175
175
  },
176
176
  shopNavBarHeight: 0,
177
177
  },
178
178
  defaultQueryLogInfo: {
179
179
  sourceType: 'JDshop',
180
180
  sourceValue: '',
181
181
  moduleId: 'none',
182
182
  entrance: 'none',
183
183
  },
184
184
  sysInfo: {
185
185
  windowWidth: 0,
186
186
  windowHeight: 0,
187
187
  netWorkType: '4g',
188
188
  jdBottomBarHeight: 0,
189
189
  jdNativeHeaderHeight: 0,
190
190
  },
191
191
  queryInfo: {},
192
192
  shopInfo: {},
193
193
  openAppData: {},
194
194
  public info: CommonInterFace.BaseConfigInfo;
195
195
  public config: {
196
196
  [key: string]: any;
197
197
  };
198
198
  public lazyContainer: CommonInterFace.lazyContainer;
199
199
  public renderedIsvComponents: CommonInterFace.renderedIsvComponents;
200
200
  public rootEleNode: HTMLElement | null;
201
201
  public miniApplogUtil: CommonInterFace.MiniApplogUtil;
202
202
  public miniAppLogInstance: CommonInterFace.MiniAppLog | null;
203
203
  public checkStatusAndLoginPromise: object | null;
204
204
  public wxAppLoginInstance: CommonInterFace.WxAppLogin;
205
205
  public wxAppBizInstance: CommonInterFace.WxAppUserInfo;
206
206
  public wxAppUserInfoInstance: CommonInterFace.WxAppUserInfo;
207
207
  public wxAppReportGDTInstance: CommonInterFace.WxAppReportGDT;
208
208
  public wxAppNavigatorInstance: CommonInterFace.WxAppNavigator;
209
209
  public wxAppParamsSignInstance: CommonInterFace.wxAppParamsSign;
210
210
  public loadJsSdkList: Array<any>;
211
211
  public loadJsSdkListCachePromise: any;
212
212
  constructor(opt) {
213
213
  this.info = this._getConfig(opt);
214
214
  this.config = {};
215
215
  this.lazyContainer = {
216
216
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: {
217
217
  appLazyContainerList: [],
218
218
  appLazyFinishContainerList: [],
219
219
  },
220
220
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PROMOTION]]: {
221
221
  appLazyContainerList: [],
222
222
  appLazyFinishContainerList: [],
223
223
  },
224
224
  };
225
225
  this.loadJsSdkList = [];
226
226
  this.loadJsSdkListCachePromise = {};
227
227
  this.renderedIsvComponents = {};
228
228
  this.rootEleNode = null;
229
229
  this.miniApplogUtil = MiniAppLogUtil;
230
230
  this.miniAppLogInstance = null;
231
231
  this.checkStatusAndLoginPromise = null;
232
232
  this.wxAppLoginInstance = WXAPP_LOGIN;
233
233
  this.wxAppBizInstance = WXAPP_BIZ;
234
234
  this.wxAppUserInfoInstance = WXAPP_USER_INFO;
235
235
  this.wxAppReportGDTInstance = WXAPP_REPORT_GDT;
236
236
  this.wxAppNavigatorInstance = WXAPP_NAVIGATOR;
237
237
  this.wxAppParamsSignInstance = WXAPP_PARAMS_SIGN;
238
238
  }
239
239
  _getConfig(opt) {
240
240
  return Object.assign({}, DefaultConfig, opt);
241
241
  }
242
242
 
243
243
  taskTimeoutPromise(callBack, timeout = 2000) {
244
244
  return new Promise((resolve) => {
245
245
  setTimeout(() => {
246
246
  const getCallBackRes = typeof callBack === 'function' && callBack();
247
247
  return resolve(getCallBackRes || false);
248
248
  }, timeout);
249
249
  });
250
250
  }
251
251
  removeJdAndroidRquestEventForTouchStart() {}
252
252
 
253
253
  updateBusinessDomainAndApi(domain, api) {
254
254
  }
255
255
 
256
256
  getFullScreenHeight(systemInfo) {
257
257
  const { screenHeight, statusBarHeight, isAndroid } = systemInfo;
258
258
  let result = screenHeight;
259
259
  if (statusBarHeight > 20 && isAndroid) {
260
260
  result = screenHeight + statusBarHeight;
261
261
  }
262
262
  return result;
263
263
  }
264
264
 
265
265
  getTabBarHeight(systemInfo) {
266
266
  const { statusBarHeight, isAndroid, isIOS } = systemInfo;
267
267
  let result = 50;
268
268
  if (statusBarHeight > 20) {
269
269
  if (isIOS) {
270
270
  result = 84;
271
271
  } else if (isAndroid) {
272
272
  result = 53;
273
273
  }
274
274
  }
275
275
  return result;
276
276
  }
277
277
 
278
278
  getSystemInfo() {
279
279
  const info: UtilsInterFace.taroGetSystemInfoSyncRes = getSystemInfos() || {};
280
280
  const actualNavBarHeight = (info?.navBarHeight || 0) + (info?.navBarExtendHeight || 0);
281
281
  const headerHeight = actualNavBarHeight + (info?.statusBarHeight || 0);
282
282
  const fullScreenHeight = this.getFullScreenHeight(info);
283
283
  const tabBarHeight = this.getTabBarHeight(info);
284
284
  const safeContentHeight = fullScreenHeight - headerHeight;
285
285
  this.info.sysInfo = {
286
286
  ...this.info.sysInfo,
287
287
  ...info,
288
288
  actualNavBarHeight,
289
289
  headerHeight,
290
290
  fullScreenHeight,
291
291
  tabBarHeight,
292
292
  safeContentHeight,
293
293
  };
294
294
  if (this.info.sysInfo['hostVersionName']) {
295
295
  this.info.sysInfo['hostAppVersion'] = Number(
296
296
  this.info.sysInfo['hostVersionName'].replace(/\./g, ''),
297
297
  );
298
298
  }
299
299
  this.info.sysInfo['wifiVideoAutoPlay'] = false;
300
300
  this.getNetWorkType();
301
301
  }
302
302
  async updateMPaasConfig() {}
303
303
 
304
304
  getNetWorkType() {
305
305
  Taro.getNetworkType().then((getRes) => {
306
306
  getRes && getRes.networkType && (this.info.sysInfo['netWorkType'] = getRes.networkType);
307
307
  });
308
308
  }
309
309
  getAPPUseStraightCorner() {
310
310
  return Promise.resolve(false);
311
311
  }
312
312
  checkStatusAndLogin(options = {}) {
313
313
  this.checkStatusAndLoginPromise = new Promise((resolve, reject) => {
314
314
  console.log('微信小程序登录状态及获取cookie状态的promise,之前登录状态', this.info.loginState);
315
315
  this.toLogin(options)
316
316
  .then((res) => {
317
317
  console.log('微信小程序登录状态结果,成功', res);
318
318
  this.info.loginState = true;
319
319
  resolve(res);
320
320
  })
321
321
  .catch((err) => {
322
322
  console.log('微信小程序登录异常状态结果', err);
323
323
  this.doLogin(options)
324
324
  .then((res2) => {
325
325
  console.log('微信小程序wxDoLogin强制登陆成功:', res2);
326
326
  this.info.loginState = true;
327
327
  resolve(res2);
328
328
  })
329
329
  .catch((err2) => {
330
330
  console.log('微信小程序wxDoLogin强制登陆失败:', err2);
331
331
  this.checkStatusAndLoginPromise = null;
332
332
  reject(err2);
333
333
  });
334
334
  });
335
335
  });
336
336
  return this.checkStatusAndLoginPromise;
337
337
  }
338
338
 
339
339
  checkJdStatusAndLogin(options) {
340
340
  return this.checkStatusAndLogin(options);
341
341
  }
342
342
 
343
343
  toLogin(options = {}): Promise<any> {
344
344
  return this.wxAppLoginInstance
345
345
  .getLoginPromise({
346
346
  mode: 'silent',
347
347
  loginColor: {
348
348
  biz: WXAPP_BIZ_KEY,
349
349
  dpin: 0,
350
350
  },
351
351
  ...options,
352
352
  })
353
353
  .then((res) => {
354
354
  console.log('微信app登录返回信息,微信侧返回code为0表示成功', res);
355
355
  this.getLoginCookie();
356
356
  })
357
357
  .catch((err) => {
358
358
  console.log('微信app登录异常返回信息', err);
359
359
  });
360
360
  }
361
361
 
362
362
  doLogin(options = {}) {
363
363
  return this.wxAppLoginInstance
364
364
  .doLogin({
365
365
  loginColor: {
366
366
  biz: WXAPP_BIZ_KEY,
367
367
  dpin: 0,
368
368
  },
369
369
  ...options,
370
370
  })
371
371
  .then((res) => {
372
372
  this.getLoginCookie();
373
373
  console.log('微信小程序强制登录返回信息,微信侧返回code为0表示成功', res);
374
374
  return res;
375
375
  });
376
376
  }
377
377
 
378
378
  doLoginForJdPin(options = {}) {
379
379
  return this.doLogin(options);
380
380
  }
381
381
 
382
382
  getLoginCookie(updateKey = 'wxapp') {
383
383
  return new Promise((resolve) => {
384
384
  console.log('开始获取更新wxapp中的cookie信息', updateKey);
385
385
  if (
386
386
  this.config.wqCookie &&
387
387
  this.config.wqCookieStr &&
388
388
  this.config.getWqCookieKey === updateKey
389
389
  ) {
390
390
  console.log('已有存储wxapp中的cookie信息,直接返回', this.config);
391
391
  resolve({
392
392
  wqCookie: this.config.wqCookie,
393
393
  wqCookieStr: this.config.wqCookieStr,
394
394
  });
395
395
  } else {
396
396
  if (isPublishToWxapp) {
397
397
  const getWxappCookieObj = getTaroStorageKeyValue('cookies') || null;
398
398
  if (getWxappCookieObj) {
399
399
  const getCookieObj = getWxappCookieObj['_data'];
400
400
  const { wqCookie, wqCookieStr } = getWxAppCookieStr(getCookieObj);
401
401
  const { pin = '', visitkey = '-1', wq_unionid = '', wxapp_openid = '' } = wqCookie;
402
402
  this.info.loginState = true;
403
403
  this.info.userInfo.wqCookie = wqCookieStr;
404
404
  this.info.userInfo.wqVisitkey = visitkey;
405
405
  console.log('获取用户完整cookie信息', getCookieObj);
406
406
  const getUserAddress = this.wxAppUserInfoInstance.getAddress();
407
407
  console.log('获取微信用户地址信息', getUserAddress);
408
408
  if (getUserAddress) {
409
409
  this.info.pageInfo.address = getUserAddress?.areaId;
410
410
  this.info.pageInfo.addressCommaStr = this.info.pageInfo.address
411
411
  ? this.info.pageInfo.address.replace(/_/g, ',')
412
412
  : '';
413
413
  this.info.pageInfo.un_area = this.info.pageInfo.address;
414
414
  Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, {
415
415
  area: this.info.pageInfo.address,
416
416
  });
417
417
  }
418
418
  if (this.miniAppLogInstance) {
419
419
  this.miniAppLogInstance.set({
420
420
  account: pin,
421
421
  unionid: wq_unionid,
422
422
  openid: wxapp_openid,
423
423
  });
424
424
  }
425
425
  this.config.wqCookie = wqCookie;
426
426
  this.config.wqCookieStr = wqCookieStr;
427
427
  this.config.getWqCookieKey = updateKey;
428
428
  console.log('解析wxapp中的cookie信息成功,返回后存储', this.config);
429
429
  resolve({
430
430
  wqCookie,
431
431
  wqCookieStr,
432
432
  });
433
433
  } else {
434
434
  console.log('解析wxapp中的cookie信息异常,返回异常结果', this.config);
435
435
  resolve({
436
436
  wqCookie: false,
437
437
  wqCookieStr: false,
438
438
  });
439
439
  }
440
440
  } else {
441
441
  resolve({
442
442
  wqCookie: false,
443
443
  wqCookieStr: false,
444
444
  });
445
445
  }
446
446
  }
447
447
  });
448
448
  }
449
449
 
450
450
 
451
451
  checkLoginStatus() {
452
452
  return this.getLoginCookie();
453
453
  }
454
454
 
455
455
  getAddressCachePromise() {
456
456
  return Promise.reject('该方法只在APP内适用');
457
457
  }
458
458
 
459
459
  getLbsAddressCachePromise() {
460
460
  return Promise.resolve({
461
461
  status: '-1005',
462
462
  msg: '暂未实现,获取失败',
463
463
  });
464
464
  }
465
465
 
466
466
  getDynamicConfig(key: string) {
467
467
  console.warn('调用默认的 getDynamicConfig(),注意,此方法还未实现!');
468
468
  return null;
469
469
  }
470
470
 
471
471
  updatePageAndLogInfo(updateQuery = {}) {
472
472
  const createUpdateQueryInfo: {
473
473
  query: {
474
474
  shopId?: string | number;
475
475
  venderId?: string | number;
476
476
  };
477
477
  updateShopInfoState: boolean;
478
478
  } = Object.assign(
479
479
  {},
480
480
  {
481
481
  query: {},
482
482
  updateShopInfoState: false,
483
483
  },
484
484
  updateQuery,
485
485
  );
486
486
  console.log(
487
487
  '获取当前下发的店铺查询参数',
488
488
  updateQuery,
489
489
  '获取之前保存的shopInfo店铺查询参数',
490
490
  this.info?.shopInfo,
491
491
  );
492
492
  const { query, updateShopInfoState } = createUpdateQueryInfo;
493
493
  const { shopId, venderId } = query;
494
494
  if (updateShopInfoState) {
495
495
  this.info.queryInfo = {
496
496
  ...this.info.queryInfo,
497
497
  ...query,
498
498
  };
499
499
  if (shopId && venderId) {
500
500
  this.info.shopInfo = {
501
501
  shopId: `${shopId}`,
502
502
  venderId: `${venderId}`,
503
503
  };
504
504
  }
505
505
  } else {
506
506
  this.info.queryInfo = {
507
507
  ...query,
508
508
  };
509
509
  if (
510
510
  this.info.shopInfo?.shopId &&
511
511
  this.info.shopInfo?.venderId &&
512
512
  (this.info.shopInfo.shopId == shopId || this.info.shopInfo.venderId == venderId)
513
513
  ) {
514
514
  this.info.queryInfo.shopId = this.info.shopInfo.shopId;
515
515
  this.info.queryInfo.venderId = this.info.shopInfo.venderId;
516
516
  console.log(
517
517
  '当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数',
518
518
  this.info.queryInfo,
519
519
  );
520
520
  }
521
521
  }
522
522
  this.info.queryInfo['shopId'] &&
523
523
  (this.info.queryInfo['shopId'] = `${this.info.queryInfo['shopId']}`);
524
524
  this.info.queryInfo['venderId'] &&
525
525
  (this.info.queryInfo['venderId'] = `${this.info.queryInfo['venderId']}`);
526
526
  console.log(
527
527
  '默认==获取店铺下发查询参数\n',
528
528
  query,
529
529
  '\n获取店铺最后查询参数\n',
530
530
  this.info.queryInfo,
531
531
  '\n是否为更新店铺状态\n',
532
532
  updateShopInfoState,
533
533
  );
534
534
  }
535
535
 
536
536
  checkJingGouWxappEnv() {
537
537
  return false;
538
538
  }
539
539
  renderNextTickLoadSdk() {
540
540
  console.warn('暂未实现 index.ts');
541
541
  }
542
542
  loadOtherSdk() {
543
543
  console.warn('暂未实现 index.ts');
544
544
  }
545
545
  loadItemSdkPromise(jsInfo = {}) {
546
546
  console.warn('暂未实现 index.ts');
547
547
  }