@conecli/cone-render 0.10.1-beta.5 → 0.10.1-beta.7

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.
Files changed (57) hide show
  1. package/dist/api/index.ts +1 -1
  2. package/dist/common/const.ts +1 -1
  3. package/dist/common/environmentType.ts +1 -1
  4. package/dist/common/index.h5.ts +1 -1
  5. package/dist/common/index.jd.ts +1 -1
  6. package/dist/common/index.ts +1 -1
  7. package/dist/common/index.weapp.ts +1 -1
  8. package/dist/common/pageType.ts +1 -1
  9. package/dist/common/sgmCustomCode.ts +1 -1
  10. package/dist/components/base/CountDown/index.module.scss +49 -44
  11. package/dist/components/base/CountDown/index.tsx +1 -1
  12. package/dist/components/base/CustomVideo/common.ts +1 -0
  13. package/dist/components/base/CustomVideo/index.tsx +1 -1
  14. package/dist/components/base/LazyLoadImage/index.h5.module.scss +11 -6
  15. package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
  16. package/dist/components/base/Price/Base/index.tsx +1 -1
  17. package/dist/components/base/Price/Double/index.module.scss +8 -0
  18. package/dist/components/base/Price/Double/index.tsx +1 -1
  19. package/dist/components/floorItem.tsx +1 -1
  20. package/dist/components/isv/Floor/index.tsx +1 -1
  21. package/dist/interface/component.ts +1 -1
  22. package/dist/interface/jumpEventReport.ts +1 -1
  23. package/dist/interface/service.ts +1 -1
  24. package/dist/jumpEventReport/base.ts +1 -1
  25. package/dist/jumpEventReport/index.jd.ts +1 -1
  26. package/dist/jumpEventReport/index.weapp.ts +1 -1
  27. package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
  28. package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
  29. package/dist/jumpEventReport/logEventConfig.ts +1 -1
  30. package/dist/jumpEventReport/web.base.ts +1 -1
  31. package/dist/jumpEventReport/web.jd.ts +1 -1
  32. package/dist/jumpEventReport/web.jdb.ts +1 -1
  33. package/dist/jumpEventReport/web.jdjch.ts +1 -1
  34. package/dist/jumpEventReport/web.jxwxapp.ts +1 -1
  35. package/dist/jumpEventReport/web.pc.ts +1 -1
  36. package/dist/jumpEventReport/web.tjapp.ts +1 -1
  37. package/dist/jumpEventReport/web.tjm.ts +1 -1
  38. package/dist/jumpEventReport/web.wxapp.ts +1 -1
  39. package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
  40. package/dist/modules/ContainerFloorList/index.tsx +1 -1
  41. package/dist/open/api/util.ts +1 -1
  42. package/dist/sass/base.scss +142 -141
  43. package/dist/service/fetchGateway.ts +1 -1
  44. package/dist/service/http/colorSign.ts +1 -1
  45. package/dist/service/http/h5Http.ts +1 -0
  46. package/dist/service/http/index.h5.ts +1 -0
  47. package/dist/service/requestServer.h5.ts +1 -0
  48. package/dist/service/requestServer.ts +1 -1
  49. package/dist/utils/connectNativeJsBridge.ts +1 -1
  50. package/dist/utils/connectNativeJsBridge.weapp.ts +1 -1
  51. package/dist/utils/h5Utils.ts +1 -1
  52. package/dist/utils/index.h5.ts +1 -1
  53. package/dist/utils/index.ts +1 -1
  54. package/dist/utils/index.weapp.ts +1 -1
  55. package/dist/utils/utils.ts +1 -1
  56. package/package.json +35 -29
  57. package/dist/utils/memberFormatUtils.js +0 -1
@@ -1 +1 @@
1
- import Taro from '@tarojs/taro'
2
1
  appEid,
3
2
  userPinKey,
4
3
  jdUserLoginState,
5
4
  WXAPP_LOGIN,
6
5
  WXAPP_BIZ,
7
6
  WXAPP_USER_INFO,
8
7
  WXAPP_NAVIGATOR,
9
8
  WXAPP_REPORT_GDT,
10
9
  WXAPP_PARAMS_SIGN,
11
10
  WXAPP_FINGER_REPORT,
12
11
  WXAPP_REPORT_MANAGE,
13
12
  BUSINESS_TYPE,
14
13
  SHOP_MENU_ID_TYPE,
15
14
  SHOP_MENU_ID_NAME,
16
15
  SECTION_HOME_TAB_NAME_TYPE,
17
16
  SECTION_HOME_TAB_TYPE,
18
17
  TaroEventType,
19
18
  WX_BUSINESS_TYPE,
20
19
  WXAPP_BIZ_KEY,
21
20
  getSystemInfos,
22
21
  getTaroStorageKeyValue,
23
22
  removeTaroStorageKey,
24
23
  setTaroStorage,
25
24
  getWxAppCookieStr,
26
25
  objectToUrlEncode,
27
26
  loginState: jdUserLoginState,
28
27
  cookiesStr: '',
29
28
  userInfo: userPinKey,
30
29
  pageInfo: {
31
30
  wxBusinessType: WX_BUSINESS_TYPE.SHOP,
32
31
  address: '',
33
32
  addressCommaStr: '',
34
33
  un_area: '',
35
34
  vapptype: '1',
36
35
  pageType: 'home',
37
36
  dataType: BUSINESS_TYPE.ONLINE,
38
37
  floorExposureInfo: {},
39
38
  floorVideInfo: {},
40
39
  productVideInfo: {},
41
40
  tabsLoadAllDataInfo: {
42
41
  [SECTION_HOME_TAB_NAME_TYPE[
43
42
  SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN
44
43
  ]]: false,
45
44
  [SHOP_MENU_ID_NAME[SHOP_MENU_ID_TYPE.CLASSIFY]]: true,
46
45
  },
47
46
  updateShopInfosAllState: false,
48
47
  isVipShop: false,
49
48
  isJdShowNativeImmersivePlayer: false,
50
49
  ...shopConfig,
51
50
  pageScrollTop: 0,
52
51
  pageIdxHeightInfo: {
53
52
  list: [],
54
53
  },
55
54
  shopNavBarHeight: 0,
56
55
  },
57
56
  defaultQueryLogInfo: {
58
57
  sourceType: 'JDshop',
59
58
  sourceValue: '',
60
59
  moduleId: 'none',
61
60
  entrance: 'none',
62
61
  },
63
62
  originQueryInfo: {},
64
63
  sysInfo: {
65
64
  windowWidth: 0,
66
65
  windowHeight: 0,
67
66
  eid: appEid,
68
67
  netWorkType: '4g',
69
68
  jdBottomBarHeight: 0,
70
69
  jdNativeHeaderHeight: 0,
71
70
  },
72
71
  queryInfo: {},
73
72
  shopInfo: {},
74
73
  openAppData: {},
75
74
  public info: CommonInterFace.BaseConfigInfo
76
75
  public config: {
77
76
  [key: string]: any
78
77
  }
79
78
  public lazyContainer: CommonInterFace.lazyContainer
80
79
  public rootEleNode: HTMLElement | null
81
80
  public miniApplogUtil: CommonInterFace.MiniApplogUtil
82
81
  public miniAppLogInstance: CommonInterFace.MiniAppLog | null
83
82
  public checkStatusAndLoginPromise: object | null
84
83
  public wxAppLoginInstance: CommonInterFace.WxAppLogin
85
84
  public wxAppBizInstance: CommonInterFace.WxAppUserInfo
86
85
  public wxAppUserInfoInstance: CommonInterFace.WxAppUserInfo
87
86
  public wxAppReportManageInstance: CommonInterFace.wxAppReportManage
88
87
  public wxAppReportGDTInstance: CommonInterFace.WxAppReportGDT
89
88
  public wxAppNavigatorInstance: CommonInterFace.WxAppNavigator
90
89
  public wxAppParamsSignInstance: CommonInterFace.wxAppParamsSign
91
90
  public wxAppFingerReportInstance: CommonInterFace.wxAppParamsSign
92
91
  public wxAppSubsGuider: CommonInterFace.wxAppParamsSign
93
92
  constructor(opt) {
94
93
  this.info = this._getConfig(opt)
95
94
  this.config = {}
96
95
  this.lazyContainer = {
97
96
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: {
98
97
  appLazyContainerList: [],
99
98
  appLazyFinishContainerList: [],
100
99
  },
101
100
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PROMOTION]]: {
102
101
  appLazyContainerList: [],
103
102
  appLazyFinishContainerList: [],
104
103
  },
105
104
  }
106
105
  this.rootEleNode = null
107
106
  this.miniApplogUtil = MiniAppLogUtil
108
107
  this.miniAppLogInstance = null
109
108
  this.checkStatusAndLoginPromise = null
110
109
  this.wxAppLoginInstance = WXAPP_LOGIN
111
110
  this.wxAppBizInstance = WXAPP_BIZ
112
111
  this.wxAppUserInfoInstance = WXAPP_USER_INFO
113
112
  this.wxAppReportManageInstance = WXAPP_REPORT_MANAGE
114
113
  this.wxAppReportGDTInstance = WXAPP_REPORT_GDT
115
114
  this.wxAppNavigatorInstance = WXAPP_NAVIGATOR
116
115
  this.wxAppParamsSignInstance = WXAPP_PARAMS_SIGN
117
116
  this.wxAppFingerReportInstance = WXAPP_FINGER_REPORT
118
117
  ? new WXAPP_FINGER_REPORT()
119
118
  : {}
120
119
  this.wxAppSubsGuider = null
121
120
  }
122
121
  _getConfig(opt) {
123
122
  return Object.assign({}, DefaultConfig, opt)
124
123
  }
125
124
 
126
125
  taskTimeoutPromise(callBack, timeout = 2000) {
127
126
  return new Promise(resolve => {
128
127
  setTimeout(() => {
129
128
  const getCallBackRes = typeof callBack === 'function' && callBack()
130
129
  return resolve(getCallBackRes || false)
131
130
  }, timeout)
132
131
  })
133
132
  }
134
133
 
135
134
  updateBusinessDomainAndApi(domain, api) {
136
135
  }
137
136
 
138
137
  getFullScreenHeight(systemInfo) {
139
138
  const { screenHeight, statusBarHeight, isAndroid } = systemInfo
140
139
  let result = screenHeight
141
140
  if (statusBarHeight > 20 && isAndroid) {
142
141
  result = screenHeight + statusBarHeight
143
142
  }
144
143
  return result
145
144
  }
146
145
 
147
146
  getTabBarHeight(systemInfo) {
148
147
  const { statusBarHeight, isAndroid, isIOS } = systemInfo
149
148
  let result = 50
150
149
  if (statusBarHeight > 20) {
151
150
  if (isIOS) {
152
151
  result = 84
153
152
  } else if (isAndroid) {
154
153
  result = 53
155
154
  }
156
155
  }
157
156
  return result
158
157
  }
159
158
 
160
159
  getSystemInfo() {
161
160
  const info: UtilsInterFace.taroGetSystemInfoSyncRes = getSystemInfos() || {}
162
161
  const actualNavBarHeight =
163
162
  (info?.navBarHeight || 0) + (info?.navBarExtendHeight || 0)
164
163
  const headerHeight = actualNavBarHeight + (info?.statusBarHeight || 0)
165
164
  const fullScreenHeight = this.getFullScreenHeight(info)
166
165
  const tabBarHeight = this.getTabBarHeight(info)
167
166
  const safeContentHeight = fullScreenHeight - headerHeight
168
167
  this.info.sysInfo = {
169
168
  ...this.info.sysInfo,
170
169
  ...info,
171
170
  actualNavBarHeight,
172
171
  headerHeight,
173
172
  fullScreenHeight,
174
173
  tabBarHeight,
175
174
  safeContentHeight,
176
175
  }
177
176
  this.getEid().then((res: { eid: string }) => {
178
177
  res && res.eid && (this.info.sysInfo['eid'] = res.eid)
179
178
  })
180
179
  if (this.info.sysInfo['hostVersionName']) {
181
180
  this.info.sysInfo['hostAppVersion'] = Number(
182
181
  this.info.sysInfo['hostVersionName'].replace(/\./g, ''),
183
182
  )
184
183
  }
185
184
  this.info.sysInfo['wifiVideoAutoPlay'] = false
186
185
  this.getNetWorkType()
187
186
  }
188
187
  async updateMPaasConfig() {}
189
188
 
190
189
  getNetWorkType() {
191
190
  Taro.getNetworkType().then(getRes => {
192
191
  getRes &&
193
192
  getRes.networkType &&
194
193
  (this.info.sysInfo['netWorkType'] = getRes.networkType)
195
194
  })
196
195
  }
197
196
 
198
197
  checkStatusAndLogin(options = {}) {
199
198
  this.checkStatusAndLoginPromise = new Promise((resolve, reject) => {
200
199
  console.log(
201
200
  '微信小程序登录状态及获取cookie状态的promise,之前登录状态',
202
201
  this.info.loginState,
203
202
  )
204
203
  this.toLogin(options)
205
204
  .then(res => {
206
205
  console.log('微信小程序登录状态结果,成功', res)
207
206
  this.info.loginState = true
208
207
  resolve(res)
209
208
  })
210
209
  .catch(err => {
211
210
  console.log('微信小程序登录异常状态结果', err)
212
211
  this.doLogin(options)
213
212
  .then(res2 => {
214
213
  console.log('微信小程序wxDoLogin强制登陆成功:', res2)
215
214
  this.info.loginState = true
216
215
  resolve(res2)
217
216
  })
218
217
  .catch(err2 => {
219
218
  console.log('微信小程序wxDoLogin强制登陆失败:', err2)
220
219
  this.checkStatusAndLoginPromise = null
221
220
  reject(err2)
222
221
  })
223
222
  })
224
223
  })
225
224
  return this.checkStatusAndLoginPromise
226
225
  }
227
226
 
228
227
  checkJdStatusAndLogin(options) {
229
228
  return this.checkStatusAndLogin(options)
230
229
  }
231
230
 
232
231
 
233
232
  doLoginForJdPin(options = {}) {
234
233
  return this.doLogin(options)
235
234
  }
236
235
 
237
236
  getEid() {
238
237
  if (typeof jd !== 'undefined' && jd.getEid) {
239
238
  return new Promise((resolve, reject) => {
240
239
  jd.getEid({
241
240
  success: (res: { eid: string }) => {
242
241
  resolve(res)
243
242
  },
244
243
  fail: (err: any) => {
245
244
  reject(err)
246
245
  },
247
246
  })
248
247
  })
249
248
  } else {
250
249
  return Promise.resolve(false)
251
250
  }
252
251
  }
253
252
 
254
253
  toLogin(options = {}): Promise<any> {
255
254
  return this.wxAppLoginInstance
256
255
  .getLoginPromise({
257
256
  mode: 'silent',
258
257
  loginColor: {
259
258
  biz: WXAPP_BIZ_KEY,
260
259
  dpin: 0,
261
260
  },
262
261
  ...options,
263
262
  })
264
263
  .then(res => {
265
264
  console.log('微信app登录返回信息,微信侧返回code为0表示成功', res)
266
265
  setTimeout(() => {
267
266
  console.log(
268
267
  '微信app登录返回成功后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie',
269
268
  )
270
269
  this.getLoginCookie(`${Date.now()}`)
271
270
  }, 500)
272
271
  })
273
272
  .catch(err => {
274
273
  console.log('微信app登录异常返回信息,也获取cookie', err)
275
274
  this.getLoginCookie(`${Date.now()}`)
276
275
  })
277
276
  }
278
277
 
279
278
  doLogin(options) {
280
279
  console.log('触发松果小程序 doLogin() new new')
281
280
  return new Promise((resolve, reject) => {
282
281
  jd.login({
283
282
  success: res => {
284
283
  if (res.code) {
285
284
  console.log('[common]松果小程序登录成功', res.code)
286
285
  jd.redirectTo({
287
286
  url: `/pages/shopx/pages/index/index?${objectToUrlEncode({
288
287
  ...this.info.originQueryInfo,
289
288
  })}`,
290
289
  })
291
290
  resolve(res)
292
291
  } else {
293
292
  console.error('[common]松果小程序登录失败', res.errMsg)
294
293
  reject()
295
294
  }
296
295
  },
297
296
  fail: res => {
298
297
  console.error('[common]松果小程序登录失败', res.errMsg)
299
298
  reject()
300
299
  },
301
300
  })
302
301
  })
303
302
  }
304
303
 
305
304
  getLoginCookie(updateKey = 'wxapp') {
306
305
  return new Promise(resolve => {
307
306
  console.log('开始获取更新wxapp中的cookie信息', updateKey)
308
307
  if (
309
308
  this.config.wqCookie &&
310
309
  this.config.wqCookieStr &&
311
310
  this.config.getWqCookieKey === updateKey
312
311
  ) {
313
312
  console.log('已有存储wxapp中的cookie信息,直接返回', this.config)
314
313
  resolve({
315
314
  wqCookie: this.config.wqCookie,
316
315
  wqCookieStr: this.config.wqCookieStr,
317
316
  })
318
317
  } else {
319
318
  if (isPublishToWxapp) {
320
319
  const getWxappCookieObj = getTaroStorageKeyValue('cookies') || null
321
320
  if (getWxappCookieObj) {
322
321
  const getCookieObj = getWxappCookieObj['_data']
323
322
  const { wqCookie, wqCookieStr } = getWxAppCookieStr(getCookieObj)
324
323
  const {
325
324
  pin = '',
326
325
  visitkey = '-1',
327
326
  wq_unionid = '',
328
327
  wxapp_openid = '',
329
328
  } = wqCookie
330
329
  this.info.loginState = true
331
330
  this.info.userInfo.wqCookie = wqCookieStr
332
331
  this.info.userInfo.wqVisitkey = visitkey
333
332
  console.log('获取用户完整cookie信息', getCookieObj)
334
333
  const getUserAddress = this.wxAppUserInfoInstance.getAddress()
335
334
  console.log('获取微信用户地址信息', getUserAddress)
336
335
  if (getUserAddress) {
337
336
  this.info.pageInfo.address = getUserAddress?.areaId
338
337
  this.info.pageInfo.addressCommaStr = this.info.pageInfo.address
339
338
  ? this.info.pageInfo.address.replace(/_/g, ',')
340
339
  : ''
341
340
  this.info.pageInfo.un_area = this.info.pageInfo.address
342
341
  Taro.eventCenter.trigger(
343
342
  TaroEventType.USER_AREA_UPDATE,
344
343
  this.info.pageInfo.address,
345
344
  )
346
345
  }
347
346
  if (this.miniAppLogInstance) {
348
347
  this.miniAppLogInstance.set({
349
348
  account: pin,
350
349
  unionid: wq_unionid,
351
350
  openid: wxapp_openid,
352
351
  })
353
352
  }
354
353
  this.config.wqCookie = wqCookie
355
354
  this.config.wqCookieStr = wqCookieStr
356
355
  this.config.getWqCookieKey = updateKey
357
356
  console.log('解析wxapp中的cookie信息成功,返回后存储', this.config)
358
357
  resolve({
359
358
  wqCookie,
360
359
  wqCookieStr,
361
360
  })
362
361
  } else {
363
362
  console.log(
364
363
  '解析wxapp中的cookie信息异常,返回异常结果',
365
364
  this.config,
366
365
  )
367
366
  resolve({
368
367
  wqCookie: false,
369
368
  wqCookieStr: false,
370
369
  })
371
370
  }
372
371
  } else {
373
372
  resolve({
374
373
  wqCookie: false,
375
374
  wqCookieStr: false,
376
375
  })
377
376
  }
378
377
  }
379
378
  })
380
379
  }
381
380
 
382
381
 
383
382
  checkLoginStatus() {
384
383
  return this.getLoginCookie()
385
384
  }
386
385
 
387
386
  getAddressCachePromise = () => {
388
387
  return Promise.reject('该方法只在APP内适用')
389
388
  }
390
389
 
391
390
  getDynamicConfig(key: string) {
392
391
  console.warn(
393
392
  '调用松果小程序的 getDynamicConfig(),注意,此方法还未实现!',
394
393
  )
395
394
  return null
396
395
  }
397
396
 
398
397
  updatePageAndLogInfo(updateQuery = {}) {
399
398
  const createUpdateQueryInfo: {
400
399
  query: {
401
400
  shopId?: string | number
402
401
  venderId?: string | number
403
402
  }
404
403
  updateShopInfoState: boolean
405
404
  } = Object.assign(
406
405
  {},
407
406
  {
408
407
  query: {},
409
408
  updateShopInfoState: false,
410
409
  },
411
410
  updateQuery,
412
411
  )
413
412
  console.log(
414
413
  '获取当前下发的店铺查询参数',
415
414
  updateQuery,
416
415
  '获取之前保存的shopInfo店铺查询参数',
417
416
  this.info?.shopInfo,
418
417
  )
419
418
  const { query, updateShopInfoState } = createUpdateQueryInfo
420
419
  const { shopId, venderId } = query
421
420
  if (updateShopInfoState) {
422
421
  this.info.queryInfo = {
423
422
  ...this.info.queryInfo,
424
423
  ...query,
425
424
  }
426
425
  if (shopId && venderId) {
427
426
  this.info.shopInfo = {
428
427
  shopId: `${shopId}`,
429
428
  venderId: `${venderId}`,
430
429
  }
431
430
  }
432
431
  } else {
433
432
  this.info.queryInfo = {
434
433
  ...query,
435
434
  }
436
435
  this.info.originQueryInfo = {
437
436
  ...query,
438
437
  }
439
438
  if (
440
439
  this.info.shopInfo?.shopId &&
441
440
  this.info.shopInfo?.venderId &&
442
441
  (this.info.shopInfo.shopId == shopId ||
443
442
  this.info.shopInfo.venderId == venderId)
444
443
  ) {
445
444
  this.info.queryInfo.shopId = this.info.shopInfo.shopId
446
445
  this.info.queryInfo.venderId = this.info.shopInfo.venderId
447
446
  console.log(
448
447
  '当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数',
449
448
  this.info.queryInfo,
450
449
  )
451
450
  }
452
451
  }
453
452
  this.info.queryInfo['shopId'] &&
454
453
  (this.info.queryInfo['shopId'] = `${this.info.queryInfo['shopId']}`)
455
454
  this.info.queryInfo['venderId'] &&
456
455
  (this.info.queryInfo['venderId'] = `${this.info.queryInfo['venderId']}`)
457
456
  console.log(
458
457
  'weapp===获取店铺下发查询参数\n',
459
458
  query,
460
459
  '\n获取店铺最后查询参数\n',
461
460
  this.info.queryInfo,
462
461
  '\n是否为更新店铺状态\n',
463
462
  updateShopInfoState,
464
463
  )
465
464
  }
465
+ import Taro from "@tarojs/taro";
466
466
  appEid,
467
467
  userPinKey,
468
468
  jdUserLoginState,
469
469
  WXAPP_LOGIN,
470
470
  WXAPP_BIZ,
471
471
  WXAPP_USER_INFO,
472
472
  WXAPP_NAVIGATOR,
473
473
  WXAPP_REPORT_GDT,
474
474
  WXAPP_PARAMS_SIGN,
475
475
  WXAPP_FINGER_REPORT,
476
476
  WXAPP_REPORT_MANAGE,
477
477
  BUSINESS_TYPE,
478
478
  SHOP_MENU_ID_TYPE,
479
479
  SHOP_MENU_ID_NAME,
480
480
  SECTION_HOME_TAB_NAME_TYPE,
481
481
  SECTION_HOME_TAB_TYPE,
482
482
  TaroEventType,
483
483
  WX_BUSINESS_TYPE,
484
484
  WXAPP_BIZ_KEY,
485
485
  getSystemInfos,
486
486
  getTaroStorageKeyValue,
487
487
  removeTaroStorageKey,
488
488
  setTaroStorage,
489
489
  getWxAppCookieStr,
490
490
  objectToUrlEncode,
491
491
  loginState: jdUserLoginState,
492
492
  cookiesStr: "",
493
493
  userInfo: userPinKey,
494
494
  pageInfo: {
495
495
  wxBusinessType: WX_BUSINESS_TYPE.SHOP,
496
496
  address: "",
497
497
  addressCommaStr: "",
498
498
  un_area: "",
499
499
  vapptype: "1",
500
500
  pageType: "home",
501
501
  dataType: BUSINESS_TYPE.ONLINE,
502
502
  floorExposureInfo: {},
503
503
  floorVideInfo: {},
504
504
  productVideInfo: {},
505
505
  tabsLoadAllDataInfo: {
506
506
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]:
507
507
  false,
508
508
  [SHOP_MENU_ID_NAME[SHOP_MENU_ID_TYPE.CLASSIFY]]: true,
509
509
  },
510
510
  updateShopInfosAllState: false,
511
511
  isVipShop: false,
512
512
  isJdShowNativeImmersivePlayer: false,
513
513
  ...shopConfig,
514
514
  pageScrollTop: 0,
515
515
  pageIdxHeightInfo: {
516
516
  list: [],
517
517
  },
518
518
  shopNavBarHeight: 0,
519
519
  },
520
520
  defaultQueryLogInfo: {
521
521
  sourceType: "JDshop",
522
522
  sourceValue: "",
523
523
  moduleId: "none",
524
524
  entrance: "none",
525
525
  },
526
526
  originQueryInfo: {},
527
527
  sysInfo: {
528
528
  windowWidth: 0,
529
529
  windowHeight: 0,
530
530
  eid: appEid,
531
531
  netWorkType: "4g",
532
532
  jdBottomBarHeight: 0,
533
533
  jdNativeHeaderHeight: 0,
534
534
  },
535
535
  queryInfo: {},
536
536
  shopInfo: {},
537
537
  openAppData: {},
538
538
  public info: CommonInterFace.BaseConfigInfo;
539
539
  public config: {
540
540
  [key: string]: any;
541
541
  };
542
542
  public lazyContainer: CommonInterFace.lazyContainer;
543
543
  public rootEleNode: HTMLElement | null;
544
544
  public miniApplogUtil: CommonInterFace.MiniApplogUtil;
545
545
  public miniAppLogInstance: CommonInterFace.MiniAppLog | null;
546
546
  public checkStatusAndLoginPromise: object | null;
547
547
  public wxAppLoginInstance: CommonInterFace.WxAppLogin;
548
548
  public wxAppBizInstance: CommonInterFace.WxAppUserInfo;
549
549
  public wxAppUserInfoInstance: CommonInterFace.WxAppUserInfo;
550
550
  public wxAppReportManageInstance: CommonInterFace.wxAppReportManage;
551
551
  public wxAppReportGDTInstance: CommonInterFace.WxAppReportGDT;
552
552
  public wxAppNavigatorInstance: CommonInterFace.WxAppNavigator;
553
553
  public wxAppParamsSignInstance: CommonInterFace.wxAppParamsSign;
554
554
  public wxAppFingerReportInstance: CommonInterFace.wxAppParamsSign;
555
555
  public wxAppSubsGuider: CommonInterFace.wxAppParamsSign;
556
556
  public loadJsSdkList: Array<any>
557
557
  public loadJsSdkListCachePromise: any
558
558
  constructor(opt) {
559
559
  this.info = this._getConfig(opt);
560
560
  this.config = {};
561
561
  this.lazyContainer = {
562
562
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: {
563
563
  appLazyContainerList: [],
564
564
  appLazyFinishContainerList: [],
565
565
  },
566
566
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PROMOTION]]: {
567
567
  appLazyContainerList: [],
568
568
  appLazyFinishContainerList: [],
569
569
  },
570
570
  };
571
571
  this.loadJsSdkList = []
572
572
  this.loadJsSdkListCachePromise = {}
573
573
  this.rootEleNode = null;
574
574
  this.miniApplogUtil = MiniAppLogUtil;
575
575
  this.miniAppLogInstance = null;
576
576
  this.checkStatusAndLoginPromise = null;
577
577
  this.wxAppLoginInstance = WXAPP_LOGIN;
578
578
  this.wxAppBizInstance = WXAPP_BIZ;
579
579
  this.wxAppUserInfoInstance = WXAPP_USER_INFO;
580
580
  this.wxAppReportManageInstance = WXAPP_REPORT_MANAGE;
581
581
  this.wxAppReportGDTInstance = WXAPP_REPORT_GDT;
582
582
  this.wxAppNavigatorInstance = WXAPP_NAVIGATOR;
583
583
  this.wxAppParamsSignInstance = WXAPP_PARAMS_SIGN;
584
584
  this.wxAppFingerReportInstance = WXAPP_FINGER_REPORT
585
585
  ? new WXAPP_FINGER_REPORT()
586
586
  : {};
587
587
  this.wxAppSubsGuider = null;
588
588
  }
589
589
  _getConfig(opt) {
590
590
  return Object.assign({}, DefaultConfig, opt);
591
591
  }
592
592
 
593
593
  taskTimeoutPromise(callBack, timeout = 2000) {
594
594
  return new Promise((resolve) => {
595
595
  setTimeout(() => {
596
596
  const getCallBackRes = typeof callBack === "function" && callBack();
597
597
  return resolve(getCallBackRes || false);
598
598
  }, timeout);
599
599
  });
600
600
  }
601
601
 
602
602
  updateBusinessDomainAndApi(domain, api) {
603
603
  }
604
604
 
605
605
  getFullScreenHeight(systemInfo) {
606
606
  const { screenHeight, statusBarHeight, isAndroid } = systemInfo;
607
607
  let result = screenHeight;
608
608
  if (statusBarHeight > 20 && isAndroid) {
609
609
  result = screenHeight + statusBarHeight;
610
610
  }
611
611
  return result;
612
612
  }
613
613
 
614
614
  getTabBarHeight(systemInfo) {
615
615
  const { statusBarHeight, isAndroid, isIOS } = systemInfo;
616
616
  let result = 50;
617
617
  if (statusBarHeight > 20) {
618
618
  if (isIOS) {
619
619
  result = 84;
620
620
  } else if (isAndroid) {
621
621
  result = 53;
622
622
  }
623
623
  }
624
624
  return result;
625
625
  }
626
626
 
627
627
  getSystemInfo() {
628
628
  const info: UtilsInterFace.taroGetSystemInfoSyncRes =
629
629
  getSystemInfos() || {};
630
630
  const actualNavBarHeight =
631
631
  (info?.navBarHeight || 0) + (info?.navBarExtendHeight || 0);
632
632
  const headerHeight = actualNavBarHeight + (info?.statusBarHeight || 0);
633
633
  const fullScreenHeight = this.getFullScreenHeight(info);
634
634
  const tabBarHeight = this.getTabBarHeight(info);
635
635
  const safeContentHeight = fullScreenHeight - headerHeight;
636
636
  this.info.sysInfo = {
637
637
  ...this.info.sysInfo,
638
638
  ...info,
639
639
  actualNavBarHeight,
640
640
  headerHeight,
641
641
  fullScreenHeight,
642
642
  tabBarHeight,
643
643
  safeContentHeight,
644
644
  };
645
645
  this.getEid().then((res: { eid: string }) => {
646
646
  res && res.eid && (this.info.sysInfo["eid"] = res.eid);
647
647
  });
648
648
  if (this.info.sysInfo["hostVersionName"]) {
649
649
  this.info.sysInfo["hostAppVersion"] = Number(
650
650
  this.info.sysInfo["hostVersionName"].replace(/\./g, "")
651
651
  );
652
652
  }
653
653
  this.info.sysInfo["wifiVideoAutoPlay"] = false;
654
654
  this.getNetWorkType();
655
655
  }
656
656
  async updateMPaasConfig() {}
657
657
 
658
658
  getNetWorkType() {
659
659
  Taro.getNetworkType().then((getRes) => {
660
660
  getRes &&
661
661
  getRes.networkType &&
662
662
  (this.info.sysInfo["netWorkType"] = getRes.networkType);
663
663
  });
664
664
  }
665
665
  getAPPUseStraightCorner () {
666
666
  return Promise.resolve(false)
667
667
  }
668
668
 
669
669
  checkStatusAndLogin(options = {}) {
670
670
  this.checkStatusAndLoginPromise = new Promise((resolve, reject) => {
671
671
  console.log(
672
672
  "微信小程序登录状态及获取cookie状态的promise,之前登录状态",
673
673
  this.info.loginState
674
674
  );
675
675
  this.toLogin(options)
676
676
  .then((res) => {
677
677
  console.log("微信小程序登录状态结果,成功", res);
678
678
  this.info.loginState = true;
679
679
  resolve(res);
680
680
  })
681
681
  .catch((err) => {
682
682
  console.log("微信小程序登录异常状态结果", err);
683
683
  this.doLogin(options)
684
684
  .then((res2) => {
685
685
  console.log("微信小程序wxDoLogin强制登陆成功:", res2);
686
686
  this.info.loginState = true;
687
687
  resolve(res2);
688
688
  })
689
689
  .catch((err2) => {
690
690
  console.log("微信小程序wxDoLogin强制登陆失败:", err2);
691
691
  this.checkStatusAndLoginPromise = null;
692
692
  reject(err2);
693
693
  });
694
694
  });
695
695
  });
696
696
  return this.checkStatusAndLoginPromise;
697
697
  }
698
698
 
699
699
  checkJdStatusAndLogin(options) {
700
700
  return this.checkStatusAndLogin(options);
701
701
  }
702
702
 
703
703
 
704
704
  doLoginForJdPin(options = {}) {
705
705
  return this.doLogin(options);
706
706
  }
707
707
 
708
708
  getEid() {
709
709
  if (typeof jd !== "undefined" && jd.getEid) {
710
710
  return new Promise((resolve, reject) => {
711
711
  jd.getEid({
712
712
  success: (res: { eid: string }) => {
713
713
  resolve(res);
714
714
  },
715
715
  fail: (err: any) => {
716
716
  reject(err);
717
717
  },
718
718
  });
719
719
  });
720
720
  } else {
721
721
  return Promise.resolve(false);
722
722
  }
723
723
  }
724
724
 
725
725
  toLogin(options = {}): Promise<any> {
726
726
  return this.wxAppLoginInstance
727
727
  .getLoginPromise({
728
728
  mode: "silent",
729
729
  loginColor: {
730
730
  biz: WXAPP_BIZ_KEY,
731
731
  dpin: 0,
732
732
  },
733
733
  ...options,
734
734
  })
735
735
  .then((res) => {
736
736
  console.log("微信app登录返回信息,微信侧返回code为0表示成功", res);
737
737
  setTimeout(() => {
738
738
  console.log(
739
739
  "微信app登录返回成功后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie"
740
740
  );
741
741
  this.getLoginCookie(`${Date.now()}`);
742
742
  }, 500);
743
743
  })
744
744
  .catch((err) => {
745
745
  console.log("微信app登录异常返回信息,也获取cookie", err);
746
746
  this.getLoginCookie(`${Date.now()}`);
747
747
  });
748
748
  }
749
749
 
750
750
  doLogin(options) {
751
751
  console.log("触发松果小程序 doLogin() new new");
752
752
  return new Promise((resolve, reject) => {
753
753
  jd.login({
754
754
  success: (res) => {
755
755
  if (res.code) {
756
756
  console.log("[common]松果小程序登录成功", res.code);
757
757
  jd.redirectTo({
758
758
  url: `/pages/shopx/pages/index/index?${objectToUrlEncode({
759
759
  ...this.info.originQueryInfo,
760
760
  })}`,
761
761
  });
762
762
  resolve(res);
763
763
  } else {
764
764
  console.error("[common]松果小程序登录失败", res.errMsg);
765
765
  reject();
766
766
  }
767
767
  },
768
768
  fail: (res) => {
769
769
  console.error("[common]松果小程序登录失败", res.errMsg);
770
770
  reject();
771
771
  },
772
772
  });
773
773
  });
774
774
  }
775
775
 
776
776
  getLoginCookie(updateKey = "wxapp") {
777
777
  return new Promise((resolve) => {
778
778
  console.log("开始获取更新wxapp中的cookie信息", updateKey);
779
779
  if (
780
780
  this.config.wqCookie &&
781
781
  this.config.wqCookieStr &&
782
782
  this.config.getWqCookieKey === updateKey
783
783
  ) {
784
784
  console.log("已有存储wxapp中的cookie信息,直接返回", this.config);
785
785
  resolve({
786
786
  wqCookie: this.config.wqCookie,
787
787
  wqCookieStr: this.config.wqCookieStr,
788
788
  });
789
789
  } else {
790
790
  if (isPublishToWxapp) {
791
791
  const getWxappCookieObj = getTaroStorageKeyValue("cookies") || null;
792
792
  if (getWxappCookieObj) {
793
793
  const getCookieObj = getWxappCookieObj["_data"];
794
794
  const { wqCookie, wqCookieStr } = getWxAppCookieStr(getCookieObj);
795
795
  const {
796
796
  pin = "",
797
797
  visitkey = "-1",
798
798
  wq_unionid = "",
799
799
  wxapp_openid = "",
800
800
  } = wqCookie;
801
801
  this.info.loginState = true;
802
802
  this.info.userInfo.wqCookie = wqCookieStr;
803
803
  this.info.userInfo.wqVisitkey = visitkey;
804
804
  console.log("获取用户完整cookie信息", getCookieObj);
805
805
  const getUserAddress = this.wxAppUserInfoInstance.getAddress();
806
806
  console.log("获取微信用户地址信息", getUserAddress);
807
807
  if (getUserAddress) {
808
808
  this.info.pageInfo.address = getUserAddress?.areaId;
809
809
  this.info.pageInfo.addressCommaStr = this.info.pageInfo.address
810
810
  ? this.info.pageInfo.address.replace(/_/g, ",")
811
811
  : "";
812
812
  this.info.pageInfo.un_area = this.info.pageInfo.address;
813
813
  Taro.eventCenter.trigger(
814
814
  TaroEventType.USER_AREA_UPDATE,
815
815
  this.info.pageInfo.address
816
816
  );
817
817
  }
818
818
  if (this.miniAppLogInstance) {
819
819
  this.miniAppLogInstance.set({
820
820
  account: pin,
821
821
  unionid: wq_unionid,
822
822
  openid: wxapp_openid,
823
823
  });
824
824
  }
825
825
  this.config.wqCookie = wqCookie;
826
826
  this.config.wqCookieStr = wqCookieStr;
827
827
  this.config.getWqCookieKey = updateKey;
828
828
  console.log("解析wxapp中的cookie信息成功,返回后存储", this.config);
829
829
  resolve({
830
830
  wqCookie,
831
831
  wqCookieStr,
832
832
  });
833
833
  } else {
834
834
  console.log(
835
835
  "解析wxapp中的cookie信息异常,返回异常结果",
836
836
  this.config
837
837
  );
838
838
  resolve({
839
839
  wqCookie: false,
840
840
  wqCookieStr: false,
841
841
  });
842
842
  }
843
843
  } else {
844
844
  resolve({
845
845
  wqCookie: false,
846
846
  wqCookieStr: false,
847
847
  });
848
848
  }
849
849
  }
850
850
  });
851
851
  }
852
852
 
853
853
 
854
854
  checkLoginStatus() {
855
855
  return this.getLoginCookie();
856
856
  }
857
857
 
858
858
  getAddressCachePromise = () => {
859
859
  return Promise.reject("该方法只在APP内适用");
860
860
  };
861
861
 
862
862
  getDynamicConfig(key: string) {
863
863
  console.warn(
864
864
  "调用松果小程序的 getDynamicConfig(),注意,此方法还未实现!"
865
865
  );
866
866
  return null;
867
867
  }
868
868
 
869
869
  updatePageAndLogInfo(updateQuery = {}) {
870
870
  const createUpdateQueryInfo: {
871
871
  query: {
872
872
  shopId?: string | number;
873
873
  venderId?: string | number;
874
874
  };
875
875
  updateShopInfoState: boolean;
876
876
  } = Object.assign(
877
877
  {},
878
878
  {
879
879
  query: {},
880
880
  updateShopInfoState: false,
881
881
  },
882
882
  updateQuery
883
883
  );
884
884
  console.log(
885
885
  "获取当前下发的店铺查询参数",
886
886
  updateQuery,
887
887
  "获取之前保存的shopInfo店铺查询参数",
888
888
  this.info?.shopInfo
889
889
  );
890
890
  const { query, updateShopInfoState } = createUpdateQueryInfo;
891
891
  const { shopId, venderId } = query;
892
892
  if (updateShopInfoState) {
893
893
  this.info.queryInfo = {
894
894
  ...this.info.queryInfo,
895
895
  ...query,
896
896
  };
897
897
  if (shopId && venderId) {
898
898
  this.info.shopInfo = {
899
899
  shopId: `${shopId}`,
900
900
  venderId: `${venderId}`,
901
901
  };
902
902
  }
903
903
  } else {
904
904
  this.info.queryInfo = {
905
905
  ...query,
906
906
  };
907
907
  this.info.originQueryInfo = {
908
908
  ...query,
909
909
  };
910
910
  if (
911
911
  this.info.shopInfo?.shopId &&
912
912
  this.info.shopInfo?.venderId &&
913
913
  (this.info.shopInfo.shopId == shopId ||
914
914
  this.info.shopInfo.venderId == venderId)
915
915
  ) {
916
916
  this.info.queryInfo.shopId = this.info.shopInfo.shopId;
917
917
  this.info.queryInfo.venderId = this.info.shopInfo.venderId;
918
918
  console.log(
919
919
  "当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数",
920
920
  this.info.queryInfo
921
921
  );
922
922
  }
923
923
  }
924
924
  this.info.queryInfo["shopId"] &&
925
925
  (this.info.queryInfo["shopId"] = `${this.info.queryInfo["shopId"]}`);
926
926
  this.info.queryInfo["venderId"] &&
927
927
  (this.info.queryInfo["venderId"] = `${this.info.queryInfo["venderId"]}`);
928
928
  console.log(
929
929
  "weapp===获取店铺下发查询参数\n",
930
930
  query,
931
931
  "\n获取店铺最后查询参数\n",
932
932
  this.info.queryInfo,
933
933
  "\n是否为更新店铺状态\n",
934
934
  updateShopInfoState
935
935
  );
936
936
  }
937
937
  renderNextTickLoadSdk(){
938
938
  console.warn("暂未实现 index.jd.ts")
939
939
  }
940
940
  loadOtherSdk(){
941
941
  console.warn("暂未实现 index.jd.ts")
942
942
  }
943
943
  loadItemSdkPromise(jsInfo = {}) {
944
944
  console.warn('暂未实现 index.jd.ts')
945
945
  }