@conecli/cone-render 0.10.1-isv2.1 → 0.10.1-isv2.4

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 (111) 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/jssdk.ts +1 -1
  9. package/dist/common/pageType.ts +1 -1
  10. package/dist/common/sgmCustomCode.ts +1 -1
  11. package/dist/common/token/index.h5.ts +1 -1
  12. package/dist/common/token/token.jd.ts +1 -1
  13. package/dist/common/wxappApi.ts +1 -1
  14. package/dist/components/ErrorBoundary.tsx +1 -1
  15. package/dist/components/base/CommonFloorHead/index.module.scss +126 -111
  16. package/dist/components/base/CommonFloorHead/index.tsx +1 -1
  17. package/dist/components/base/CountDown/index.module.scss +49 -44
  18. package/dist/components/base/CountDown/index.tsx +1 -1
  19. package/dist/components/base/CustomScrollView/index-back.tsx +1 -0
  20. package/dist/components/base/CustomScrollView/index.tsx +1 -1
  21. package/dist/components/base/CustomVideo/common.ts +1 -0
  22. package/dist/components/base/CustomVideo/index.tsx +1 -1
  23. package/dist/components/base/Dialog/index.module.scss +11 -0
  24. package/dist/components/base/ExposureSmart/index.h5.module.scss +12 -2
  25. package/dist/components/base/ExposureSmart/index.h5.tsx +1 -1
  26. package/dist/components/base/ExposureSmart/reporter.tsx +1 -1
  27. package/dist/components/base/InOrOutViewObserver/index.tsx +1 -1
  28. package/dist/components/base/InViewRender/index.tsx +1 -1
  29. package/dist/components/base/InViewRender/index.weapp.tsx +1 -1
  30. package/dist/components/base/ItemViewExposureSmart/index.module.scss +2 -2
  31. package/dist/components/base/ItemViewExposureSmart/index.tsx +1 -1
  32. package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
  33. package/dist/components/base/LazyLayoutLoad/index.weapp.tsx +1 -1
  34. package/dist/components/base/LazyLoadImage/index.h5.module.scss +11 -3
  35. package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
  36. package/dist/components/base/LazyLoadImage/index.tsx +1 -1
  37. package/dist/components/base/MobileCommonHeader/index.tsx +1 -1
  38. package/dist/components/base/NetworkDataError/index.module.scss +3 -0
  39. package/dist/components/base/NetworkDataError/index.tsx +1 -1
  40. package/dist/components/base/Price/Base/index.tsx +1 -1
  41. package/dist/components/base/Price/Double/index.module.scss +8 -0
  42. package/dist/components/base/Price/Double/index.tsx +1 -1
  43. package/dist/components/debug/DebugLayout/index.module.scss +2 -2
  44. package/dist/components/decorate/DecorateFloorModule/index.module.scss +11 -0
  45. package/dist/components/decorate/DecorateFloorModule/index.tsx +1 -1
  46. package/dist/components/decorate/EmptyFloorModule/index.tsx +1 -1
  47. package/dist/components/decorate/PlaceHolder/index.tsx +1 -1
  48. package/dist/components/floorItem.jd.tsx +1 -1
  49. package/dist/components/floorItem.tsx +1 -1
  50. package/dist/components/floorItem.weapp.tsx +1 -1
  51. package/dist/components/isv/Floor/index.tsx +1 -1
  52. package/dist/components/remoteFloorItem.tsx +1 -1
  53. package/dist/interface/common.ts +1 -1
  54. package/dist/interface/component.ts +1 -1
  55. package/dist/interface/jumpEventReport.ts +1 -1
  56. package/dist/interface/service.ts +1 -1
  57. package/dist/jumpEventReport/base.ts +1 -1
  58. package/dist/jumpEventReport/const.ts +1 -1
  59. package/dist/jumpEventReport/index.jd.ts +1 -1
  60. package/dist/jumpEventReport/index.weapp.ts +1 -1
  61. package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
  62. package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
  63. package/dist/jumpEventReport/logEventConfig.ts +1 -1
  64. package/dist/jumpEventReport/web/report.ts +1 -1
  65. package/dist/jumpEventReport/web.base.ts +1 -1
  66. package/dist/jumpEventReport/web.jd.ts +1 -1
  67. package/dist/jumpEventReport/web.jdb.ts +1 -1
  68. package/dist/jumpEventReport/web.jdjch.ts +1 -1
  69. package/dist/jumpEventReport/web.jxwxapp.ts +1 -1
  70. package/dist/jumpEventReport/web.pc.ts +1 -1
  71. package/dist/jumpEventReport/web.tjapp.ts +1 -1
  72. package/dist/jumpEventReport/web.tjm.ts +1 -1
  73. package/dist/jumpEventReport/web.wxapp.ts +1 -1
  74. package/dist/libs/taroAppReport.js +2 -2
  75. package/dist/modules/ContainerFloorList/index.h5.module.scss +66 -52
  76. package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
  77. package/dist/modules/ContainerFloorList/index.tsx +1 -1
  78. package/dist/open/api/device.ts +1 -1
  79. package/dist/open/api/environment.ts +1 -1
  80. package/dist/open/api/request.ts +1 -1
  81. package/dist/open/api/shopMember.ts +1 -1
  82. package/dist/open/api/util.ts +1 -1
  83. package/dist/open/components/index.ts +1 -1
  84. package/dist/sass/app.h5.scss +275 -221
  85. package/dist/sass/base.scss +183 -137
  86. package/dist/service/fetchGateway.ts +1 -1
  87. package/dist/service/fetchGateway.weapp.ts +1 -0
  88. package/dist/service/http/colorSign.ts +1 -1
  89. package/dist/service/http/const.ts +1 -1
  90. package/dist/service/http/h5Http.ts +1 -0
  91. package/dist/service/http/index.h5.ts +1 -0
  92. package/dist/service/requestServer.h5.ts +1 -0
  93. package/dist/service/requestServer.ts +1 -1
  94. package/dist/service/requestServer.weapp.ts +1 -0
  95. package/dist/utils/connectNativeJsBridge.ts +1 -1
  96. package/dist/utils/connectNativeJsBridge.weapp.ts +1 -1
  97. package/dist/utils/h5Utils.ts +1 -1
  98. package/dist/utils/index.h5.ts +1 -1
  99. package/dist/utils/index.ts +1 -1
  100. package/dist/utils/index.weapp.ts +1 -1
  101. package/dist/utils/jumpExtMapUtil.h5.ts +1 -0
  102. package/dist/utils/jumpExtMapUtil.ts +1 -0
  103. package/dist/utils/log.ts +1 -0
  104. package/dist/utils/sColor.js +1 -0
  105. package/dist/utils/sgmCodeUtils.ts +1 -1
  106. package/dist/utils/taroRenderUtil.ts +1 -1
  107. package/dist/utils/utils.ts +1 -1
  108. package/dist/wxapp/common/address_api/address_api_v2.js +1 -0
  109. package/dist/wxapp/common/user_info.js +1 -1
  110. package/package.json +158 -135
  111. 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
  WXAPP_LOGIN,
467
467
  WXAPP_BIZ,
468
468
  WXAPP_USER_INFO,
469
469
  WXAPP_NAVIGATOR,
470
470
  WXAPP_REPORT_GDT,
471
471
  WXAPP_PARAMS_SIGN,
472
472
  WXAPP_FINGER_REPORT,
473
473
  WXAPP_REPORT_MANAGE,
474
474
  BUSINESS_TYPE,
475
475
  SHOP_MENU_ID_TYPE,
476
476
  SHOP_MENU_ID_NAME,
477
477
  SECTION_HOME_TAB_NAME_TYPE,
478
478
  SECTION_HOME_TAB_TYPE,
479
479
  TaroEventType,
480
480
  WX_BUSINESS_TYPE,
481
481
  WXAPP_BIZ_KEY,
482
482
  getSystemInfos,
483
483
  getTaroStorageKeyValue,
484
484
  removeTaroStorageKey,
485
485
  setTaroStorage,
486
486
  getWxAppCookieStr,
487
487
  objectToUrlEncode,
488
488
  abTestLabels: {},
489
489
  nonSellableSkuids: {},
490
490
  loginState: jdUserLoginState,
491
491
  cookiesStr: '',
492
492
  userInfo: userPinKey,
493
493
  isImmersive: false,
494
494
  pageInfo: {
495
495
  wxBusinessType: WX_BUSINESS_TYPE.SHOP,
496
496
  address: '',
497
497
  addressCommaStr: '',
498
498
  un_area: '',
499
499
  userLbsAddress: '',
500
500
  vapptype: '1',
501
501
  pageType: 'home',
502
502
  dataType: BUSINESS_TYPE.ONLINE,
503
503
  floorExposureInfo: {},
504
504
  floorVideInfo: {},
505
505
  productVideInfo: {},
506
506
  tabsLoadAllDataInfo: {
507
507
  [SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: 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 ? new WXAPP_FINGER_REPORT() : {};
585
585
  this.wxAppSubsGuider = null;
586
586
  }
587
587
  _getConfig(opt) {
588
588
  return Object.assign({}, DefaultConfig, opt);
589
589
  }
590
590
 
591
591
  taskTimeoutPromise(callBack, timeout = 2000) {
592
592
  return new Promise((resolve) => {
593
593
  setTimeout(() => {
594
594
  const getCallBackRes = typeof callBack === 'function' && callBack();
595
595
  return resolve(getCallBackRes || false);
596
596
  }, timeout);
597
597
  });
598
598
  }
599
599
 
600
600
  updateBusinessDomainAndApi(domain, api) {
601
601
  }
602
602
 
603
603
  getFullScreenHeight(systemInfo) {
604
604
  const { screenHeight, statusBarHeight, isAndroid } = systemInfo;
605
605
  let result = screenHeight;
606
606
  if (statusBarHeight > 20 && isAndroid) {
607
607
  result = screenHeight + statusBarHeight;
608
608
  }
609
609
  return result;
610
610
  }
611
611
 
612
612
  getTabBarHeight(systemInfo) {
613
613
  const { statusBarHeight, isAndroid, isIOS } = systemInfo;
614
614
  let result = 50;
615
615
  if (statusBarHeight > 20) {
616
616
  if (isIOS) {
617
617
  result = 84;
618
618
  } else if (isAndroid) {
619
619
  result = 53;
620
620
  }
621
621
  }
622
622
  return result;
623
623
  }
624
624
 
625
625
  getSystemInfo() {
626
626
  const info: UtilsInterFace.taroGetSystemInfoSyncRes = getSystemInfos() || {};
627
627
  const actualNavBarHeight = (info?.navBarHeight || 0) + (info?.navBarExtendHeight || 0);
628
628
  const headerHeight = actualNavBarHeight + (info?.statusBarHeight || 0);
629
629
  const fullScreenHeight = this.getFullScreenHeight(info);
630
630
  const tabBarHeight = this.getTabBarHeight(info);
631
631
  const safeContentHeight = fullScreenHeight - headerHeight;
632
632
  this.info.sysInfo = {
633
633
  ...this.info.sysInfo,
634
634
  ...info,
635
635
  actualNavBarHeight,
636
636
  headerHeight,
637
637
  fullScreenHeight,
638
638
  tabBarHeight,
639
639
  safeContentHeight,
640
640
  };
641
641
  this.getEid().then((res: { eid: string }) => {
642
642
  res && res.eid && (this.info.sysInfo['eid'] = res.eid);
643
643
  });
644
644
  if (this.info.sysInfo['hostVersionName']) {
645
645
  this.info.sysInfo['hostAppVersion'] = Number(
646
646
  this.info.sysInfo['hostVersionName'].replace(/\./g, ''),
647
647
  );
648
648
  }
649
649
  this.info.sysInfo['wifiVideoAutoPlay'] = false;
650
650
  this.getNetWorkType();
651
651
  }
652
652
  async updateMPaasConfig() {}
653
653
 
654
654
  getNetWorkType() {
655
655
  Taro.getNetworkType().then((getRes) => {
656
656
  getRes && getRes.networkType && (this.info.sysInfo['netWorkType'] = getRes.networkType);
657
657
  });
658
658
  }
659
659
  getAPPUseStraightCorner() {
660
660
  return Promise.resolve(false);
661
661
  }
662
662
 
663
663
  checkStatusAndLogin(options = {}) {
664
664
  this.checkStatusAndLoginPromise = new Promise((resolve, reject) => {
665
665
  console.log('微信小程序登录状态及获取cookie状态的promise,之前登录状态', this.info.loginState);
666
666
  this.toLogin(options)
667
667
  .then((res) => {
668
668
  console.log('微信小程序登录状态结果,成功', res);
669
669
  this.info.loginState = true;
670
670
  resolve(res);
671
671
  })
672
672
  .catch((err) => {
673
673
  console.log('微信小程序登录异常状态结果', err);
674
674
  this.doLogin(options)
675
675
  .then((res2) => {
676
676
  console.log('微信小程序wxDoLogin强制登陆成功:', res2);
677
677
  this.info.loginState = true;
678
678
  resolve(res2);
679
679
  })
680
680
  .catch((err2) => {
681
681
  console.log('微信小程序wxDoLogin强制登陆失败:', err2);
682
682
  this.checkStatusAndLoginPromise = null;
683
683
  reject(err2);
684
684
  });
685
685
  });
686
686
  });
687
687
  return this.checkStatusAndLoginPromise;
688
688
  }
689
689
 
690
690
  checkJdStatusAndLogin(options) {
691
691
  return this.checkStatusAndLogin(options);
692
692
  }
693
693
 
694
694
 
695
695
  doLoginForJdPin(options = {}) {
696
696
  return this.doLogin(options);
697
697
  }
698
698
 
699
699
  getEid() {
700
700
  if (typeof jd !== 'undefined' && jd.getEid) {
701
701
  return new Promise((resolve, reject) => {
702
702
  jd.getEid({
703
703
  success: (res: { eid: string }) => {
704
704
  resolve(res);
705
705
  },
706
706
  fail: (err: any) => {
707
707
  reject(err);
708
708
  },
709
709
  });
710
710
  });
711
711
  } else {
712
712
  return Promise.resolve(false);
713
713
  }
714
714
  }
715
715
 
716
716
  toLogin(options = {}): Promise<any> {
717
717
  return this.wxAppLoginInstance
718
718
  .getLoginPromise({
719
719
  mode: 'silent',
720
720
  loginColor: {
721
721
  biz: WXAPP_BIZ_KEY,
722
722
  dpin: 0,
723
723
  },
724
724
  ...options,
725
725
  })
726
726
  .then((res) => {
727
727
  console.log('微信app登录返回信息,微信侧返回code为0表示成功', res);
728
728
  setTimeout(() => {
729
729
  console.log(
730
730
  '微信app登录返回成功后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie',
731
731
  );
732
732
  this.getLoginCookie(`${Date.now()}`);
733
733
  }, 500);
734
734
  })
735
735
  .catch((err) => {
736
736
  console.log('微信app登录异常返回信息,也获取cookie', err);
737
737
  this.getLoginCookie(`${Date.now()}`);
738
738
  });
739
739
  }
740
740
 
741
741
  doLogin(options) {
742
742
  console.log('触发松果小程序 doLogin() new new');
743
743
  return new Promise((resolve, reject) => {
744
744
  jd.login({
745
745
  success: (res) => {
746
746
  if (res.code) {
747
747
  console.log('[common]松果小程序登录成功', res.code);
748
748
  jd.redirectTo({
749
749
  url: `/pages/shopx/pages/index/index?${objectToUrlEncode({
750
750
  ...this.info.originQueryInfo,
751
751
  })}`,
752
752
  });
753
753
  resolve(res);
754
754
  } else {
755
755
  console.error('[common]松果小程序登录失败', res.errMsg);
756
756
  reject();
757
757
  }
758
758
  },
759
759
  fail: (res) => {
760
760
  console.error('[common]松果小程序登录失败', res.errMsg);
761
761
  reject();
762
762
  },
763
763
  });
764
764
  });
765
765
  }
766
766
 
767
767
  getLoginCookie(updateKey = 'wxapp') {
768
768
  return new Promise((resolve) => {
769
769
  console.log('开始获取更新wxapp中的cookie信息', updateKey);
770
770
  if (
771
771
  this.config.wqCookie &&
772
772
  this.config.wqCookieStr &&
773
773
  this.config.getWqCookieKey === updateKey
774
774
  ) {
775
775
  console.log('已有存储wxapp中的cookie信息,直接返回', this.config);
776
776
  resolve({
777
777
  wqCookie: this.config.wqCookie,
778
778
  wqCookieStr: this.config.wqCookieStr,
779
779
  });
780
780
  } else {
781
781
  if (isPublishToWxapp) {
782
782
  const getWxappCookieObj = getTaroStorageKeyValue('cookies') || null;
783
783
  if (getWxappCookieObj) {
784
784
  const getCookieObj = getWxappCookieObj['_data'];
785
785
  const { wqCookie, wqCookieStr } = getWxAppCookieStr(getCookieObj);
786
786
  const { pin = '', visitkey = '-1', wq_unionid = '', wxapp_openid = '' } = wqCookie;
787
787
  this.info.loginState = true;
788
788
  this.info.userInfo.wqCookie = wqCookieStr;
789
789
  this.info.userInfo.wqVisitkey = visitkey;
790
790
  console.log('获取用户完整cookie信息', getCookieObj);
791
791
  const getUserAddress = this.wxAppUserInfoInstance.getAddress();
792
792
  console.log('获取微信用户地址信息', getUserAddress);
793
793
  if (getUserAddress) {
794
794
  this.info.pageInfo.address = getUserAddress?.areaId;
795
795
  this.info.pageInfo.addressCommaStr = this.info.pageInfo.address
796
796
  ? this.info.pageInfo.address.replace(/_/g, ',')
797
797
  : '';
798
798
  this.info.pageInfo.un_area = this.info.pageInfo.address;
799
799
  Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, {
800
800
  area: this.info.pageInfo.address,
801
801
  });
802
802
  }
803
803
  if (this.miniAppLogInstance) {
804
804
  this.miniAppLogInstance.set({
805
805
  account: pin,
806
806
  unionid: wq_unionid,
807
807
  openid: wxapp_openid,
808
808
  });
809
809
  }
810
810
  this.config.wqCookie = wqCookie;
811
811
  this.config.wqCookieStr = wqCookieStr;
812
812
  this.config.getWqCookieKey = updateKey;
813
813
  console.log('解析wxapp中的cookie信息成功,返回后存储', this.config);
814
814
  resolve({
815
815
  wqCookie,
816
816
  wqCookieStr,
817
817
  });
818
818
  } else {
819
819
  console.log('解析wxapp中的cookie信息异常,返回异常结果', this.config);
820
820
  resolve({
821
821
  wqCookie: false,
822
822
  wqCookieStr: false,
823
823
  });
824
824
  }
825
825
  } else {
826
826
  resolve({
827
827
  wqCookie: false,
828
828
  wqCookieStr: false,
829
829
  });
830
830
  }
831
831
  }
832
832
  });
833
833
  }
834
834
 
835
835
 
836
836
  checkLoginStatus() {
837
837
  return this.getLoginCookie();
838
838
  }
839
839
 
840
840
  getAddressCachePromise() {
841
841
  return Promise.reject('该方法只在APP内适用');
842
842
  }
843
843
 
844
844
  getLbsAddressCachePromise() {
845
845
  return Promise.resolve({
846
846
  status: '-1005',
847
847
  msg: '暂未实现,获取失败',
848
848
  });
849
849
  }
850
850
 
851
851
  getDynamicConfig(key: string) {
852
852
  console.warn('调用松果小程序的 getDynamicConfig(),注意,此方法还未实现!');
853
853
  return null;
854
854
  }
855
855
 
856
856
  updatePageAndLogInfo(updateQuery = {}) {
857
857
  const createUpdateQueryInfo: {
858
858
  query: {
859
859
  shopId?: string | number;
860
860
  venderId?: string | number;
861
861
  };
862
862
  updateShopInfoState: boolean;
863
863
  } = Object.assign(
864
864
  {},
865
865
  {
866
866
  query: {},
867
867
  updateShopInfoState: false,
868
868
  },
869
869
  updateQuery,
870
870
  );
871
871
  console.log(
872
872
  '获取当前下发的店铺查询参数',
873
873
  updateQuery,
874
874
  '获取之前保存的shopInfo店铺查询参数',
875
875
  this.info?.shopInfo,
876
876
  );
877
877
  const { query, updateShopInfoState } = createUpdateQueryInfo;
878
878
  const { shopId, venderId } = query;
879
879
  if (updateShopInfoState) {
880
880
  this.info.queryInfo = {
881
881
  ...this.info.queryInfo,
882
882
  ...query,
883
883
  };
884
884
  if (shopId && venderId) {
885
885
  this.info.shopInfo = {
886
886
  shopId: `${shopId}`,
887
887
  venderId: `${venderId}`,
888
888
  };
889
889
  }
890
890
  } else {
891
891
  this.info.queryInfo = {
892
892
  ...query,
893
893
  };
894
894
  this.info.originQueryInfo = {
895
895
  ...query,
896
896
  };
897
897
  if (
898
898
  this.info.shopInfo?.shopId &&
899
899
  this.info.shopInfo?.venderId &&
900
900
  (this.info.shopInfo.shopId == shopId || this.info.shopInfo.venderId == venderId)
901
901
  ) {
902
902
  this.info.queryInfo.shopId = this.info.shopInfo.shopId;
903
903
  this.info.queryInfo.venderId = this.info.shopInfo.venderId;
904
904
  console.log(
905
905
  '当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数',
906
906
  this.info.queryInfo,
907
907
  );
908
908
  }
909
909
  }
910
910
  this.info.queryInfo['shopId'] &&
911
911
  (this.info.queryInfo['shopId'] = `${this.info.queryInfo['shopId']}`);
912
912
  this.info.queryInfo['venderId'] &&
913
913
  (this.info.queryInfo['venderId'] = `${this.info.queryInfo['venderId']}`);
914
914
  console.log(
915
915
  'weapp===获取店铺下发查询参数\n',
916
916
  query,
917
917
  '\n获取店铺最后查询参数\n',
918
918
  this.info.queryInfo,
919
919
  '\n是否为更新店铺状态\n',
920
920
  updateShopInfoState,
921
921
  );
922
922
  }
923
923
  renderNextTickLoadSdk() {
924
924
  console.warn('暂未实现 index.jd.ts');
925
925
  }
926
926
  loadOtherSdk() {
927
927
  console.warn('暂未实现 index.jd.ts');
928
928
  }
929
929
  loadItemSdkPromise(jsInfo = {}) {
930
930
  console.warn('暂未实现 index.jd.ts');
931
931
  }