@conecli/cone-render 0.10.1-shop-beta.4 → 0.10.1-shop-beta.5

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 (63) 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/sgmCustomCode.ts +1 -1
  9. package/dist/components/ErrorBoundary.tsx +1 -1
  10. package/dist/components/base/CustomScrollView/index.tsx +1 -1
  11. package/dist/components/base/CustomVideo/index.tsx +1 -1
  12. package/dist/components/base/InOrOutViewObserver/index.tsx +1 -1
  13. package/dist/components/base/InViewRender/index.weapp.tsx +1 -1
  14. package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
  15. package/dist/components/base/LazyLayoutLoad/index.weapp.tsx +1 -1
  16. package/dist/components/base/LazyLoadImage/index.h5.module.scss +4 -0
  17. package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
  18. package/dist/components/base/LazyLoadImage/index.tsx +1 -1
  19. package/dist/components/base/MobileCommonHeader/index.tsx +1 -1
  20. package/dist/components/base/NetworkDataError/index.module.scss +3 -0
  21. package/dist/components/base/NetworkDataError/index.tsx +1 -1
  22. package/dist/components/decorate/DecorateFloorModule/index.module.scss +11 -0
  23. package/dist/components/decorate/DecorateFloorModule/index.tsx +1 -1
  24. package/dist/components/decorate/EmptyFloorModule/index.tsx +1 -1
  25. package/dist/components/decorate/PlaceHolder/index.tsx +1 -1
  26. package/dist/components/floorItem.jd.tsx +1 -1
  27. package/dist/components/floorItem.tsx +1 -1
  28. package/dist/components/floorItem.weapp.tsx +1 -1
  29. package/dist/components/remoteFloorItem.tsx +1 -1
  30. package/dist/interface/common.ts +1 -1
  31. package/dist/interface/component.ts +1 -1
  32. package/dist/interface/jumpEventReport.ts +1 -1
  33. package/dist/interface/service.ts +1 -1
  34. package/dist/jumpEventReport/base.ts +1 -1
  35. package/dist/jumpEventReport/const.ts +1 -1
  36. package/dist/jumpEventReport/index.jd.ts +1 -1
  37. package/dist/jumpEventReport/index.weapp.ts +1 -1
  38. package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
  39. package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
  40. package/dist/jumpEventReport/logEventConfig.ts +1 -1
  41. package/dist/jumpEventReport/web.base.ts +1 -1
  42. package/dist/jumpEventReport/web.jd.ts +1 -1
  43. package/dist/jumpEventReport/web.tjm.ts +1 -1
  44. package/dist/modules/ContainerFloorList/index.h5.module.scss +1 -0
  45. package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
  46. package/dist/open/api/device.ts +1 -1
  47. package/dist/open/api/request.ts +1 -1
  48. package/dist/open/api/shopMember.ts +1 -1
  49. package/dist/open/api/util.ts +1 -1
  50. package/dist/open/components/index.ts +1 -1
  51. package/dist/sass/app.h5.scss +5 -0
  52. package/dist/sass/base.scss +45 -0
  53. package/dist/service/requestServer.ts +1 -1
  54. package/dist/utils/connectNativeJsBridge.ts +1 -1
  55. package/dist/utils/connectNativeJsBridge.weapp.ts +1 -1
  56. package/dist/utils/h5Utils.ts +1 -1
  57. package/dist/utils/index.h5.ts +1 -1
  58. package/dist/utils/index.ts +1 -1
  59. package/dist/utils/index.weapp.ts +1 -1
  60. package/dist/utils/sgmCodeUtils.ts +1 -1
  61. package/dist/utils/taroRenderUtil.ts +1 -1
  62. package/dist/utils/utils.ts +1 -1
  63. package/package.json +24 -23
@@ -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
 
666
666
  checkStatusAndLogin(options = {}) {
667
667
  this.checkStatusAndLoginPromise = new Promise((resolve, reject) => {
668
668
  console.log(
669
669
  "微信小程序登录状态及获取cookie状态的promise,之前登录状态",
670
670
  this.info.loginState
671
671
  );
672
672
  this.toLogin(options)
673
673
  .then((res) => {
674
674
  console.log("微信小程序登录状态结果,成功", res);
675
675
  this.info.loginState = true;
676
676
  resolve(res);
677
677
  })
678
678
  .catch((err) => {
679
679
  console.log("微信小程序登录异常状态结果", err);
680
680
  this.doLogin(options)
681
681
  .then((res2) => {
682
682
  console.log("微信小程序wxDoLogin强制登陆成功:", res2);
683
683
  this.info.loginState = true;
684
684
  resolve(res2);
685
685
  })
686
686
  .catch((err2) => {
687
687
  console.log("微信小程序wxDoLogin强制登陆失败:", err2);
688
688
  this.checkStatusAndLoginPromise = null;
689
689
  reject(err2);
690
690
  });
691
691
  });
692
692
  });
693
693
  return this.checkStatusAndLoginPromise;
694
694
  }
695
695
 
696
696
  checkJdStatusAndLogin(options) {
697
697
  return this.checkStatusAndLogin(options);
698
698
  }
699
699
 
700
700
 
701
701
  doLoginForJdPin(options = {}) {
702
702
  return this.doLogin(options);
703
703
  }
704
704
 
705
705
  getEid() {
706
706
  if (typeof jd !== "undefined" && jd.getEid) {
707
707
  return new Promise((resolve, reject) => {
708
708
  jd.getEid({
709
709
  success: (res: { eid: string }) => {
710
710
  resolve(res);
711
711
  },
712
712
  fail: (err: any) => {
713
713
  reject(err);
714
714
  },
715
715
  });
716
716
  });
717
717
  } else {
718
718
  return Promise.resolve(false);
719
719
  }
720
720
  }
721
721
 
722
722
  toLogin(options = {}): Promise<any> {
723
723
  return this.wxAppLoginInstance
724
724
  .getLoginPromise({
725
725
  mode: "silent",
726
726
  loginColor: {
727
727
  biz: WXAPP_BIZ_KEY,
728
728
  dpin: 0,
729
729
  },
730
730
  ...options,
731
731
  })
732
732
  .then((res) => {
733
733
  console.log("微信app登录返回信息,微信侧返回code为0表示成功", res);
734
734
  setTimeout(() => {
735
735
  console.log(
736
736
  "微信app登录返回成功后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie"
737
737
  );
738
738
  this.getLoginCookie(`${Date.now()}`);
739
739
  }, 500);
740
740
  })
741
741
  .catch((err) => {
742
742
  console.log("微信app登录异常返回信息,也获取cookie", err);
743
743
  this.getLoginCookie(`${Date.now()}`);
744
744
  });
745
745
  }
746
746
 
747
747
  doLogin(options) {
748
748
  console.log("触发松果小程序 doLogin() new new");
749
749
  return new Promise((resolve, reject) => {
750
750
  jd.login({
751
751
  success: (res) => {
752
752
  if (res.code) {
753
753
  console.log("[common]松果小程序登录成功", res.code);
754
754
  jd.redirectTo({
755
755
  url: `/pages/shopx/pages/index/index?${objectToUrlEncode({
756
756
  ...this.info.originQueryInfo,
757
757
  })}`,
758
758
  });
759
759
  resolve(res);
760
760
  } else {
761
761
  console.error("[common]松果小程序登录失败", res.errMsg);
762
762
  reject();
763
763
  }
764
764
  },
765
765
  fail: (res) => {
766
766
  console.error("[common]松果小程序登录失败", res.errMsg);
767
767
  reject();
768
768
  },
769
769
  });
770
770
  });
771
771
  }
772
772
 
773
773
  getLoginCookie(updateKey = "wxapp") {
774
774
  return new Promise((resolve) => {
775
775
  console.log("开始获取更新wxapp中的cookie信息", updateKey);
776
776
  if (
777
777
  this.config.wqCookie &&
778
778
  this.config.wqCookieStr &&
779
779
  this.config.getWqCookieKey === updateKey
780
780
  ) {
781
781
  console.log("已有存储wxapp中的cookie信息,直接返回", this.config);
782
782
  resolve({
783
783
  wqCookie: this.config.wqCookie,
784
784
  wqCookieStr: this.config.wqCookieStr,
785
785
  });
786
786
  } else {
787
787
  if (isPublishToWxapp) {
788
788
  const getWxappCookieObj = getTaroStorageKeyValue("cookies") || null;
789
789
  if (getWxappCookieObj) {
790
790
  const getCookieObj = getWxappCookieObj["_data"];
791
791
  const { wqCookie, wqCookieStr } = getWxAppCookieStr(getCookieObj);
792
792
  const {
793
793
  pin = "",
794
794
  visitkey = "-1",
795
795
  wq_unionid = "",
796
796
  wxapp_openid = "",
797
797
  } = wqCookie;
798
798
  this.info.loginState = true;
799
799
  this.info.userInfo.wqCookie = wqCookieStr;
800
800
  this.info.userInfo.wqVisitkey = visitkey;
801
801
  console.log("获取用户完整cookie信息", getCookieObj);
802
802
  const getUserAddress = this.wxAppUserInfoInstance.getAddress();
803
803
  console.log("获取微信用户地址信息", getUserAddress);
804
804
  if (getUserAddress) {
805
805
  this.info.pageInfo.address = getUserAddress?.areaId;
806
806
  this.info.pageInfo.addressCommaStr = this.info.pageInfo.address
807
807
  ? this.info.pageInfo.address.replace(/_/g, ",")
808
808
  : "";
809
809
  this.info.pageInfo.un_area = this.info.pageInfo.address;
810
810
  Taro.eventCenter.trigger(
811
811
  TaroEventType.USER_AREA_UPDATE,
812
812
  this.info.pageInfo.address
813
813
  );
814
814
  }
815
815
  if (this.miniAppLogInstance) {
816
816
  this.miniAppLogInstance.set({
817
817
  account: pin,
818
818
  unionid: wq_unionid,
819
819
  openid: wxapp_openid,
820
820
  });
821
821
  }
822
822
  this.config.wqCookie = wqCookie;
823
823
  this.config.wqCookieStr = wqCookieStr;
824
824
  this.config.getWqCookieKey = updateKey;
825
825
  console.log("解析wxapp中的cookie信息成功,返回后存储", this.config);
826
826
  resolve({
827
827
  wqCookie,
828
828
  wqCookieStr,
829
829
  });
830
830
  } else {
831
831
  console.log(
832
832
  "解析wxapp中的cookie信息异常,返回异常结果",
833
833
  this.config
834
834
  );
835
835
  resolve({
836
836
  wqCookie: false,
837
837
  wqCookieStr: false,
838
838
  });
839
839
  }
840
840
  } else {
841
841
  resolve({
842
842
  wqCookie: false,
843
843
  wqCookieStr: false,
844
844
  });
845
845
  }
846
846
  }
847
847
  });
848
848
  }
849
849
 
850
850
 
851
851
  checkLoginStatus() {
852
852
  return this.getLoginCookie();
853
853
  }
854
854
 
855
855
  getAddressCachePromise = () => {
856
856
  return Promise.reject("该方法只在APP内适用");
857
857
  };
858
858
 
859
859
  getDynamicConfig(key: string) {
860
860
  console.warn(
861
861
  "调用松果小程序的 getDynamicConfig(),注意,此方法还未实现!"
862
862
  );
863
863
  return null;
864
864
  }
865
865
 
866
866
  updatePageAndLogInfo(updateQuery = {}) {
867
867
  const createUpdateQueryInfo: {
868
868
  query: {
869
869
  shopId?: string | number;
870
870
  venderId?: string | number;
871
871
  };
872
872
  updateShopInfoState: boolean;
873
873
  } = Object.assign(
874
874
  {},
875
875
  {
876
876
  query: {},
877
877
  updateShopInfoState: false,
878
878
  },
879
879
  updateQuery
880
880
  );
881
881
  console.log(
882
882
  "获取当前下发的店铺查询参数",
883
883
  updateQuery,
884
884
  "获取之前保存的shopInfo店铺查询参数",
885
885
  this.info?.shopInfo
886
886
  );
887
887
  const { query, updateShopInfoState } = createUpdateQueryInfo;
888
888
  const { shopId, venderId } = query;
889
889
  if (updateShopInfoState) {
890
890
  this.info.queryInfo = {
891
891
  ...this.info.queryInfo,
892
892
  ...query,
893
893
  };
894
894
  if (shopId && venderId) {
895
895
  this.info.shopInfo = {
896
896
  shopId: `${shopId}`,
897
897
  venderId: `${venderId}`,
898
898
  };
899
899
  }
900
900
  } else {
901
901
  this.info.queryInfo = {
902
902
  ...query,
903
903
  };
904
904
  this.info.originQueryInfo = {
905
905
  ...query,
906
906
  };
907
907
  if (
908
908
  this.info.shopInfo?.shopId &&
909
909
  this.info.shopInfo?.venderId &&
910
910
  (this.info.shopInfo.shopId == shopId ||
911
911
  this.info.shopInfo.venderId == venderId)
912
912
  ) {
913
913
  this.info.queryInfo.shopId = this.info.shopInfo.shopId;
914
914
  this.info.queryInfo.venderId = this.info.shopInfo.venderId;
915
915
  console.log(
916
916
  "当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数",
917
917
  this.info.queryInfo
918
918
  );
919
919
  }
920
920
  }
921
921
  this.info.queryInfo["shopId"] &&
922
922
  (this.info.queryInfo["shopId"] = `${this.info.queryInfo["shopId"]}`);
923
923
  this.info.queryInfo["venderId"] &&
924
924
  (this.info.queryInfo["venderId"] = `${this.info.queryInfo["venderId"]}`);
925
925
  console.log(
926
926
  "weapp===获取店铺下发查询参数\n",
927
927
  query,
928
928
  "\n获取店铺最后查询参数\n",
929
929
  this.info.queryInfo,
930
930
  "\n是否为更新店铺状态\n",
931
931
  updateShopInfoState
932
932
  );
933
933
  }
934
934
  renderNextTickLoadSdk() {
935
935
  console.warn("暂未实现 index.jd.ts");
936
936
  }
937
937
  loadOtherSdk() {
938
938
  console.warn("暂未实现 index.jd.ts");
939
939
  }
940
940
  loadItemSdkPromise() {
941
941
  console.warn("暂未实现 index.jd.ts");
942
942
  }