@conecli/cone-render 0.10.1-shop3.97 → 0.10.1-shop3.98

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 React, { useEffect, useMemo, useState } from 'react';
2
1
  const getThisLeGaoTagKey = `${tagId}-${tagText}}`;
3
2
  const getLeGaoTagCacheNode = shopLeGaoTagNodeMap.get(getThisLeGaoTagKey) || false;
4
3
  return getLeGaoTagCacheNode
5
4
  ? getLeGaoTagCacheNode
6
5
  : useMemo(() => {
7
6
  const createCanVasTag = (
8
7
  <canvas-tag
9
8
  className={classNames(shopTagStyle['d-tag-item-canvas'])}
10
9
  tagId={tagId}
11
10
  text={tagText}
12
11
  appVersion={getJdAppVersionStr}
13
12
  lang={languageNowType}
14
13
  />
15
14
  );
16
15
  shopLeGaoTagNodeMap.set(getThisLeGaoTagKey, createCanVasTag);
17
16
  return createCanVasTag;
18
17
  }, [tagId, tagText]);
19
18
  const {
20
19
  tagInfoList = [],
21
20
  className,
22
21
  itemClassName,
23
22
  isSkuBaseTag = false,
24
23
  itemClickCallback,
25
24
  } = props;
26
25
  const getTagInfoList = Array.isArray(tagInfoList) ? tagInfoList : [];
27
26
  const getTagInfoListNum = getTagInfoList.length;
28
27
  const isCallBackFn = typeof itemClickCallback === 'function';
29
28
  const needAsyncLoad = useMemo(() => {
30
29
  if (window.CanvasTag) return false;
31
30
  const h5TagJs = taroJdBaseInfo.loadJsSdkList.find((e) => e.fileName === 'h5TagJs');
32
31
  return !!(h5TagJs && h5TagJs.initTriggerType === LoadJsInitTriggerType.NRXT_TICK);
33
32
  }, []);
34
33
  const [loadOver, setLoadOver] = useState(!needAsyncLoad);
35
34
  useEffect(() => {
36
35
  async function loadTagSdk() {
37
36
  try {
38
37
  await taroJdBaseInfo.loadH5tagReayPromise();
39
38
  } catch (error) {}
40
39
  setLoadOver(true);
41
40
  }
42
41
  needAsyncLoad && loadTagSdk();
43
42
  }, []);
44
43
  if (!loadOver) return null;
45
44
  return getTagInfoListNum > 0 ? (
46
45
  <View
47
46
  className={classNames(
48
47
  shopTagStyle['d-shop-tag-list'],
49
48
  {
50
49
  [shopTagStyle['d-shop-sku-tag-list']]: isSkuBaseTag,
51
50
  },
52
51
  className,
53
52
  )}
54
53
  >
55
54
  {}
56
55
  <View style={{ width: '1px', height: '100%' }} />
57
56
  {getTagInfoList.map((item, index) => {
58
57
  const { tagId, tabIconId, tagText, type, tabIconType, tabText } = item;
59
58
  const getTagId = tagId || tabIconId;
60
59
  const getTagType = type || tabIconType;
61
60
  const getTagText = tagText || tabText;
62
61
  return getTagId ? (
63
62
  <View
64
63
  key={getTagId + getTagType + index}
65
64
  className={classNames(shopTagStyle['d-tag-item'], itemClassName)}
66
65
  onClick={isCallBackFn && itemClickCallback.bind(this, item, index)}
67
66
  >
68
67
  <LeGaoTagComponent tagId={getTagId} tagText={getTagText} />
69
68
  </View>
70
69
  ) : null;
71
70
  })}
72
71
  </View>
73
72
  ) : null;
73
+ import React, { useEffect, useMemo, useState } from 'react';
74
74
  const getThisLeGaoTagKey = `${tagId}-${tagText}}`;
75
75
  const getLeGaoTagCacheNode = shopLeGaoTagNodeMap.get(getThisLeGaoTagKey) || false;
76
76
  return getLeGaoTagCacheNode
77
77
  ? getLeGaoTagCacheNode
78
78
  : useMemo(() => {
79
79
  const createCanVasTag = (
80
80
  <canvas-tag
81
81
  className={classNames(shopTagStyle['d-tag-item-canvas'])}
82
82
  tagId={tagId}
83
83
  text={tagText}
84
84
  appVersion={getJdAppVersionStr}
85
85
  lang={languageNowType}
86
86
  />
87
87
  );
88
88
  shopLeGaoTagNodeMap.set(getThisLeGaoTagKey, createCanVasTag);
89
89
  return createCanVasTag;
90
90
  }, [tagId, tagText]);
91
91
  const {
92
92
  tagInfoList = [],
93
93
  className,
94
94
  itemClassName,
95
95
  isSkuBaseTag = false,
96
96
  itemClickCallback,
97
97
  } = props;
98
98
  const getTagInfoList = Array.isArray(tagInfoList) ? tagInfoList : [];
99
99
  const getTagInfoListNum = getTagInfoList.length;
100
100
  const isCallBackFn = typeof itemClickCallback === 'function';
101
101
  const needAsyncLoad = useMemo(() => {
102
102
  if (window.CanvasTag) return false;
103
103
  const h5TagJs = taroJdBaseInfo.loadJsSdkList.find((e) => e.fileName === 'h5TagJs');
104
104
  return !!(h5TagJs && h5TagJs.initTriggerType === LoadJsInitTriggerType.NRXT_TICK);
105
105
  }, []);
106
106
  const [loadOver, setLoadOver] = useState(!needAsyncLoad);
107
107
  useEffect(() => {
108
108
  async function loadTagSdk() {
109
109
  try {
110
110
  await taroJdBaseInfo.loadH5tagReayPromise();
111
111
  } catch (error) {}
112
112
  setLoadOver(true);
113
113
  }
114
114
  needAsyncLoad && loadTagSdk();
115
115
  }, []);
116
116
  if (!loadOver) return null;
117
117
  return getTagInfoListNum > 0 ? (
118
118
  <View
119
119
  className={classNames(
120
120
  shopTagStyle['d-shop-tag-list'],
121
121
  {
122
122
  [shopTagStyle['d-shop-sku-tag-list']]: isSkuBaseTag,
123
123
  },
124
124
  className,
125
125
  )}
126
126
  >
127
127
  {}
128
128
  <View style={{ width: '1px', height: '100%' }} />
129
129
  {getTagInfoList.map((item, index) => {
130
130
  const { tagId, tabIconId, tagText, type, tabIconType, tabText } = item;
131
131
  const getTagId = tagId || tabIconId;
132
132
  const getTagType = type || tabIconType;
133
133
  const getTagText = tagText || tabText;
134
134
  return getTagId ? (
135
135
  <View
136
136
  role="text"
137
137
  tabindex="0"
138
138
  aria-label={getTagText}
139
139
  key={getTagId + getTagType + index}
140
140
  className={classNames(shopTagStyle['d-tag-item'], itemClassName)}
141
141
  onClick={isCallBackFn && itemClickCallback.bind(this, item, index)}
142
142
  >
143
143
  <LeGaoTagComponent tagId={getTagId} tagText={getTagText} />
144
144
  </View>
145
145
  ) : null;
146
146
  })}
147
147
  </View>
148
148
  ) : null;