@conecli/cone-render 0.8.33 → 0.8.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import Taro from '@tarojs/taro'
2
1
  className={classNames(
3
2
  id={`J_floor_${floorItem?.uid}`}
4
3
  key={floorItem.uid}
5
4
  data-floor-uid={floorItem?.uid}
6
5
  data-floor-type={floorItem?.floorExtInfo?.moduleFlag || ''}
7
6
  floorIndex={floorIndex}
8
7
  floorData={floorItem}
9
8
  layoutLeftRightMargin={containerLayoutLeftRightMargin}
10
9
  containerBorderRadius={item?.borderRadius || 0}
11
10
  updateShopFloorDataFn={updateShopFloorDataFn}
12
11
  loadingEndComponentFn={loadingEndComponentFn}
13
12
  key={floorItem.uid}
14
13
  changeScrollTopFn={changeContainerFloorListScrollTop}
15
14
  builtInComponents={builtInComponents}
16
15
  className={
17
16
  style={{
18
17
  netWorkShowType={NetWorkShowType.PART}
19
18
  netWorkDataType={NETWORK_DATA_TYPE.DATA_ERROR}
20
19
  refreshCallBackFn={updateShopFloorDataFn}
20
+ import Taro from '@tarojs/taro'
21
21
  NETWORK_DATA_TYPE,
22
22
  TaroEventType,
23
23
  MINI_APP_SHOP_HEADER_NAV_BAR_BOTTOM_MENU_HEIGHT,
24
24
  SHOP_TAB_CONTENT_BOTTOM,
25
25
  listData,
26
26
  num = LOAD_FLOOR_BATCH_NUM,
27
27
  let thisListData: ComponentInterFace.ContainerItemData[] | [] =
28
28
  listData.slice(0)
29
29
  const thisListDataLen = thisListData.length
30
30
  const res: any[] = []
31
31
  if (thisListDataLen) {
32
32
  if (thisListDataLen < num) {
33
33
  res.push(thisListData)
34
34
  } else {
35
35
  while (thisListData.length) {
36
36
  if (thisListData.length >= num) {
37
37
  res.push(thisListData.splice(0, num))
38
38
  } else {
39
39
  res.push(thisListData)
40
40
  thisListData = []
41
41
  }
42
42
  }
43
43
  }
44
44
  }
45
45
  return res
46
46
  containerFloorListData: ComponentInterFace.ContainerItemData[]
47
47
  className?: string
48
48
  sectionType?: string
49
49
  style?: object
50
50
  hasGoodsFeeds?: boolean
51
51
  miniScrollSelf?: boolean
52
52
  tabContentShowState?: boolean
53
53
  loadingEndComponentFn?: Function
54
54
  updateShopFloorDataFn?: Function
55
55
  builtInComponents?: Object
56
56
  changeScrollToLowerStateFn: Function | null
57
57
  changeLayoutScrollToTopFn?: Function
58
58
  triggerMiniLoadProductWithFilterFn?: Function
59
59
  const {
60
60
  className,
61
61
  style,
62
62
  loadingEndComponentFn,
63
63
  hasGoodsFeeds,
64
64
  sectionType,
65
65
  tabContentShowState,
66
66
  containerFloorListData,
67
67
  updateShopFloorDataFn,
68
68
  changeScrollToLowerStateFn,
69
69
  changeLayoutScrollToTopFn,
70
70
  triggerMiniLoadProductWithFilterFn,
71
71
  builtInComponents,
72
72
  miniScrollSelf = false,
73
73
  } = props
74
74
  const [containerFloorListScrollTop, setContainerFloorListScrollTop] =
75
75
  useState(0)
76
76
  const loadMoreContainerFloorListDataRef = useRef({
77
77
  needFirstLoadState: true,
78
78
  loadingState: false,
79
79
  })
80
80
  const isFuncForChangeScrollToLowerStateFn =
81
81
  typeof changeScrollToLowerStateFn == 'function'
82
82
  const loadSectionTypeContainerFloorListRef = useRef<{
83
83
  [key: string]: ComponentInterFace.MiniLoadFloorListRef
84
84
  }>({
85
85
  [`${sectionType}`]: {
86
86
  index: 1,
87
87
  itemNum: 0,
88
88
  list: [],
89
89
  loadList: [],
90
90
  max: 1,
91
91
  },
92
92
  })
93
93
  const [containerFloorList, setContainerFloorList] = useState<
94
94
  ComponentInterFace.ContainerItemData[]
95
95
  >(() => {
96
96
 
97
97
  const getLoadDataArr = containerFloorListDataSpliceToPromise(
98
98
  containerFloorListData,
99
99
  )
100
100
  const getThisSectionTypeListData =
101
101
  loadSectionTypeContainerFloorListRef.current[`${sectionType}`]
102
102
  getThisSectionTypeListData.list = getLoadDataArr
103
103
  getThisSectionTypeListData.itemNum = containerFloorListData.length
104
104
  getThisSectionTypeListData.max = getLoadDataArr.length
105
105
  console.log('获取加载数据总数据----' + sectionType, getLoadDataArr)
106
106
  const getThisLoadList = getLoadDataArr.shift()
107
107
  if (getThisLoadList) {
108
108
  getThisSectionTypeListData.loadList = getThisLoadList
109
109
  return getThisLoadList
110
110
  } else {
111
111
  return []
112
112
  }
113
113
  })
114
114
  useEffect(() => {
115
115
  if (containerFloorList.length > 0) {
116
116
  Taro.nextTick(() => {
117
117
  const getThisSectionTypeListData =
118
118
  loadSectionTypeContainerFloorListRef.current[`${sectionType}`]
119
119
  console.log(
120
120
  `加载${sectionType}中第${getThisSectionTypeListData.index}批次${LOAD_FLOOR_BATCH_NUM}个模块完毕,共计${getThisSectionTypeListData.max}轮,楼层总计${getThisSectionTypeListData.itemNum}`,
121
121
  )
122
122
  loadMoreContainerFloorListDataRef.current.needFirstLoadState &&
123
123
  checkLoadFloorListLoadState().then((needLoadState) => {
124
124
  console.log('检查是否需要继续加载状态', needLoadState)
125
125
  if (needLoadState) {
126
126
  const getThisLoadList = getThisSectionTypeListData.list.shift()
127
127
  if (getThisLoadList) {
128
128
  getThisSectionTypeListData.index++
129
129
  const changeContainerList: ComponentInterFace.ContainerItemData[] =
130
130
  [...getThisSectionTypeListData.loadList, ...getThisLoadList]
131
131
  getThisSectionTypeListData.loadList = changeContainerList
132
132
  setContainerFloorList(changeContainerList)
133
133
  } else {
134
134
  Taro.hideLoading()
135
135
  loadMoreContainerFloorListDataRef.current.needFirstLoadState =
136
136
  false
137
137
  }
138
138
  } else {
139
139
  Taro.hideLoading()
140
140
  loadMoreContainerFloorListDataRef.current.needFirstLoadState =
141
141
  false
142
142
  }
143
143
  })
144
144
  })
145
145
  }
146
146
  }, [containerFloorList])
147
147
 
148
148
  const checkLoadFloorListLoadState = () => {
149
149
  return new Promise((resolve) => {
150
150
  Taro.createSelectorQuery()
151
151
  .select('#J_shopContainerFloorList')
152
152
  .boundingClientRect(function (rect) {
153
153
  if (rect) {
154
154
  if (rect.height && rect.height < windowHeight + 100) {
155
155
  resolve(true)
156
156
  } else {
157
157
  resolve(false)
158
158
  }
159
159
  } else {
160
160
  resolve(true)
161
161
  }
162
162
  })
163
163
  .exec()
164
164
  })
165
165
  }
166
166
 
167
167
  const loadMoreContainerFloorList = (evt: any = false) => {
168
168
  const getThisSectionTypeListData =
169
169
  loadSectionTypeContainerFloorListRef.current[`${sectionType}`]
170
170
  if (
171
171
  !loadMoreContainerFloorListDataRef.current.loadingState &&
172
172
  getThisSectionTypeListData.list.length > 0
173
173
  ) {
174
174
  loadMoreContainerFloorListDataRef.current.loadingState = true
175
175
  getThisSectionTypeListData.index++
176
176
  console.log(
177
177
  `当前即将加载${sectionType}中第${getThisSectionTypeListData.index}轮`,
178
178
  )
179
179
  const getThisLoadList = getThisSectionTypeListData.list.shift()
180
180
  if (getThisLoadList) {
181
181
  const changeFloorList = [
182
182
  ...getThisSectionTypeListData.loadList,
183
183
  ...getThisLoadList,
184
184
  ]
185
185
  getThisSectionTypeListData.loadList = changeFloorList
186
186
  loadMoreContainerFloorListDataRef.current.loadingState = false
187
187
  isFuncForChangeScrollToLowerStateFn && changeScrollToLowerStateFn(false)
188
188
  setContainerFloorList(changeFloorList)
189
189
  Taro.nextTick(() => {
190
190
  if (getThisSectionTypeListData.list.length == 0) {
191
191
  typeof triggerMiniLoadProductWithFilterFn == 'function' &&
192
192
  triggerMiniLoadProductWithFilterFn()
193
193
  }
194
194
  })
195
195
  } else {
196
196
  isFuncForChangeScrollToLowerStateFn && changeScrollToLowerStateFn(false)
197
197
  }
198
198
  }
199
199
  if (
200
200
  miniScrollSelf &&
201
201
  evt &&
202
202
  !loadMoreContainerFloorListDataRef.current.loadingState &&
203
203
  getThisSectionTypeListData.index >= getThisSectionTypeListData.max
204
204
  ) {
205
205
  pageScrollToLower(evt)
206
206
  }
207
207
  }
208
208
  useEffect(() => {
209
209
  if (!miniScrollSelf) {
210
210
  Taro.eventCenter.on(TaroEventType.PAGE_SCROLL_END, (tabActiveType) => {
211
211
  if (tabActiveType == sectionType && tabContentShowState) {
212
212
  loadMoreContainerFloorList()
213
213
  }
214
214
  })
215
215
  }
216
216
  }, [])
217
217
  const pageScrollToLower = useCallback((evt) => {
218
218
  console.log('触发滚动底部位置', evt.detail)
219
219
  Taro.eventCenter.trigger(TaroEventType.PAGE_SCROLL_END)
220
220
  }, [])
221
221
 
222
222
  const onScrollRecord = (event) => {
223
223
  const { detail } = event
224
224
  if (detail) {
225
225
  taroJdBaseInfo.info.pageInfo.miniScrollInfo = detail
226
226
  }
227
227
  }
228
228
  const renderFloorItem = useCallback(
229
229
  (item, floorItem, floorIndex, containerLayoutLeftRightMargin) => {
230
230
  return (
231
231
  <View
232
232
  className={classNames(shopContainerListStyle['d-floor-item'])}
233
233
  id={`J_floor_${floorItem?.uid}`}
234
234
  key={floorItem.uid}
235
235
  data-floor-uid={floorItem?.uid}
236
236
  data-floor-type={floorItem?.floorExtInfo?.moduleFlag || ''}
237
237
  >
238
238
  <FloorListItem
239
239
  floorIndex={floorIndex}
240
240
  floorData={floorItem}
241
241
  layoutLeftRightMargin={containerLayoutLeftRightMargin}
242
242
  containerBorderRadius={item?.borderRadius || 0}
243
243
  updateShopFloorDataFn={updateShopFloorDataFn}
244
244
  loadingEndComponentFn={loadingEndComponentFn}
245
245
  changeScrollToLowerStateFn={changeScrollToLowerStateFn}
246
246
  key={floorItem.uid}
247
247
  changeScrollTopFn={changeContainerFloorListScrollTop}
248
248
  builtInComponents={builtInComponents}
249
249
  />
250
250
  </View>
251
251
  )
252
252
  },
253
253
  [],
254
254
  )
255
255
  const changeContainerFloorListScrollTop = (top) => {
256
256
  if (miniScrollSelf) {
257
257
  setContainerFloorListScrollTop(top)
258
258
  } else {
259
259
  typeof changeLayoutScrollToTopFn == 'function' &&
260
260
  changeLayoutScrollToTopFn(top)
261
261
  }
262
262
  }
263
263
  const renderContainerList = () => {
264
264
  const listNum = containerFloorList.length || 0
265
265
  const getThisSectionTypeListData =
266
266
  loadSectionTypeContainerFloorListRef.current[`${sectionType}`]
267
267
  return (
268
268
  <View id="J_shopContainerFloorList">
269
269
  {containerFloorListData && containerFloorListData.length > 0 ? (
270
270
  listNum > 0 && (
271
271
  <>
272
272
  {containerFloorList.map((item) => {
273
273
  const containerLayoutLeftRightMargin =
274
274
  (item.marginLeft || 0) + (item.marginRight || 0)
275
275
  const getContainerId = `J_container_${item.containerId}`
276
276
  const getContainerStyle = {
277
277
  marginBottom: item.marginBottom
278
278
  ? `${item.marginBottom}px`
279
279
  : 0,
280
280
  marginTop: item.marginTop ? `${item.marginTop}px` : 0,
281
281
  marginLeft: item.marginLeft ? `${item.marginLeft}px` : 0,
282
282
  marginRight: item.marginRight ? `${item.marginRight}px` : 0,
283
283
  borderRadius: item.borderRadius
284
284
  ? `${item.borderRadius}px`
285
285
  : 0,
286
286
  }
287
287
  item.borderTopLeftRadius &&
288
288
  (getContainerStyle['borderTopLeftRadius'] =
289
289
  `${item.borderTopLeftRadius}px`)
290
290
  item.borderTopRightRadius &&
291
291
  (getContainerStyle['borderTopRightRadius'] =
292
292
  `${item.borderTopRightRadius}px`)
293
293
  item.borderBottomLeftRadius &&
294
294
  (getContainerStyle['borderBottomLeftRadius'] =
295
295
  `${item.borderBottomLeftRadius}px`)
296
296
  item.borderBottomRightRadius &&
297
297
  (getContainerStyle['borderBottomRightRadius'] =
298
298
  `${item.borderBottomRightRadius}px`)
299
299
  return (
300
300
  <View
301
301
  className={shopContainerListStyle['d-container-item']}
302
302
  id={getContainerId}
303
303
  key={item.containerId + item.key}
304
304
  style={getContainerStyle}
305
305
  >
306
306
  {item.floors.length > 0 && (
307
307
  <>
308
308
  {item.floors?.map((floorItem, floorIndex) => {
309
309
  return renderFloorItem(
310
310
  item,
311
311
  floorItem,
312
312
  floorIndex,
313
313
  containerLayoutLeftRightMargin,
314
314
  )
315
315
  })}
316
316
  </>
317
317
  )}
318
318
  </View>
319
319
  )
320
320
  })}
321
321
  {getThisSectionTypeListData.index <
322
322
  getThisSectionTypeListData.max && (
323
323
  <JdLoading localState={true} text="加载中..." />
324
324
  )}
325
325
  {!hasGoodsFeeds &&
326
326
  getThisSectionTypeListData.index >=
327
327
  getThisSectionTypeListData.max &&
328
328
  loadingEndComponentFn &&
329
329
  loadingEndComponentFn()}
330
330
  </>
331
331
  )
332
332
  ) : (
333
333
  <View
334
334
  className={shopContainerListStyle['d-container-list-no-data']}
335
335
  style={{
336
336
  height: `${
337
337
  windowHeight -
338
338
  actualNavBarHeight -
339
339
  MINI_APP_SHOP_HEADER_NAV_BAR_BOTTOM_MENU_HEIGHT +
340
340
  SHOP_TAB_CONTENT_BOTTOM
341
341
  }px`,
342
342
  }}
343
343
  >
344
344
  <NetworkDataError
345
345
  netWorkShowType={NetWorkShowType.PART}
346
346
  netWorkDataType={NETWORK_DATA_TYPE.DATA_ERROR}
347
347
  refreshCallBackFn={updateShopFloorDataFn}
348
348
  />
349
349
  </View>
350
350
  )}
351
351
  </View>
352
352
  )
353
353
  }
354
354
  return miniScrollSelf ? (
355
355
  <ScrollView
356
356
  scrollY
357
357
  scrollTop={containerFloorListScrollTop}
358
358
  className={classNames(
359
359
  className,
360
360
  shopContainerListStyle['d-shop-container-list'],
361
361
  )}
362
362
  onScroll={onScrollRecord}
363
363
  lowerThreshold={windowHeight / 2}
364
364
  onScrollToLower={loadMoreContainerFloorList}
365
365
  style={style}
366
366
  >
367
367
  {tabContentShowState && renderContainerList()}
368
368
  </ScrollView>
369
369
  ) : (
370
370
  <View
371
371
  className={classNames(
372
372
  className,
373
373
  shopContainerListStyle['d-shop-container-list'],
374
374
  )}
375
375
  style={style}
376
376
  >
377
377
  {tabContentShowState && renderContainerList()}
378
378
  </View>
379
379
  )