pb-sxp-ui 1.2.10 → 1.3.1
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.
- package/dist/index.cjs +700 -284
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +62 -2
- package/dist/index.js +700 -284
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +3 -3
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +3 -3
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +700 -284
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +3 -3
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/SxpPageRender/FormatImage.js +1 -1
- package/es/core/components/SxpPageRender/Modal/index.js +34 -20
- package/es/core/components/SxpPageRender/Popup/index.js +2 -2
- package/es/core/components/SxpPageRender/ToggleButton/index.js +4 -1
- package/es/core/components/SxpPageRender/WaterFall/List.js +13 -18
- package/es/core/components/SxpPageRender/WaterFall/WaterfallList.js +12 -17
- package/es/core/components/SxpPageRender/index.d.ts +6 -1
- package/es/core/components/SxpPageRender/index.js +73 -42
- package/es/core/components/SxpPageRender/typing.d.ts +2 -0
- package/es/core/context/EditorContext.js +2 -0
- package/es/core/context/SxpDataSourceProvider.d.ts +3 -2
- package/es/core/context/SxpDataSourceProvider.js +53 -33
- package/es/core/hooks/useEventReport.d.ts +1 -1
- package/es/core/hooks/useEventReport.js +10 -9
- package/es/core/utils/tool.d.ts +5 -1
- package/es/core/utils/tool.js +69 -1
- package/es/materials/sxp/popup/AppointForm/settingRender.js +15 -0
- package/es/materials/sxp/popup/CommodityDetail/index.d.ts +13 -2
- package/es/materials/sxp/popup/CommodityDetail/index.js +60 -34
- package/es/materials/sxp/popup/CommodityDetail/material.js +4 -0
- package/es/materials/sxp/popup/CommodityDetail/settingRender.d.ts +28 -2
- package/es/materials/sxp/popup/CommodityDetail/settingRender.js +52 -0
- package/es/materials/sxp/popup/CommodityDetailDiroNew/index.d.ts +13 -2
- package/es/materials/sxp/popup/CommodityDetailDiroNew/index.js +85 -51
- package/es/materials/sxp/popup/CommodityDetailDiroNew/material.js +4 -0
- package/es/materials/sxp/popup/CommodityDetailDiroNew/settingRender.d.ts +28 -2
- package/es/materials/sxp/popup/CommodityDetailDiroNew/settingRender.js +52 -0
- package/es/materials/sxp/popup/CommodityList/settingRender.js +15 -0
- package/es/materials/sxp/popup/Iframe/index.d.ts +16 -0
- package/es/materials/sxp/popup/Iframe/index.js +18 -0
- package/es/materials/sxp/popup/Iframe/material.d.ts +2 -0
- package/es/materials/sxp/popup/Iframe/material.js +21 -0
- package/es/materials/sxp/popup/Iframe/settingRender.d.ts +9 -0
- package/es/materials/sxp/popup/Iframe/settingRender.js +12 -0
- package/es/materials/sxp/popup/Prompt/settingRender.js +16 -1
- package/es/materials/sxp/popup/index.d.ts +1 -0
- package/es/materials/sxp/popup/index.js +1 -0
- package/es/materials/sxp/template/Link/index.js +5 -11
- package/es/materials/sxp/template/Link/interactionRender.d.ts +8 -0
- package/es/materials/sxp/template/Link/interactionRender.js +11 -0
- package/es/materials/sxp/template/Link/material.js +3 -1
- package/es/materials/sxp/template/components/EventProvider.d.ts +3 -2
- package/es/materials/sxp/template/components/EventProvider.js +3 -3
- package/lib/core/components/SxpPageRender/FormatImage.js +1 -1
- package/lib/core/components/SxpPageRender/Modal/index.js +34 -20
- package/lib/core/components/SxpPageRender/Popup/index.js +2 -2
- package/lib/core/components/SxpPageRender/ToggleButton/index.js +3 -0
- package/lib/core/components/SxpPageRender/WaterFall/List.js +13 -18
- package/lib/core/components/SxpPageRender/WaterFall/WaterfallList.js +12 -17
- package/lib/core/components/SxpPageRender/index.d.ts +6 -1
- package/lib/core/components/SxpPageRender/index.js +72 -41
- package/lib/core/components/SxpPageRender/typing.d.ts +2 -0
- package/lib/core/context/EditorContext.js +2 -0
- package/lib/core/context/SxpDataSourceProvider.d.ts +3 -2
- package/lib/core/context/SxpDataSourceProvider.js +53 -33
- package/lib/core/hooks/useEventReport.d.ts +1 -1
- package/lib/core/hooks/useEventReport.js +10 -9
- package/lib/core/utils/tool.d.ts +5 -1
- package/lib/core/utils/tool.js +73 -1
- package/lib/materials/sxp/popup/AppointForm/settingRender.js +15 -0
- package/lib/materials/sxp/popup/CommodityDetail/index.d.ts +13 -2
- package/lib/materials/sxp/popup/CommodityDetail/index.js +60 -34
- package/lib/materials/sxp/popup/CommodityDetail/material.js +4 -0
- package/lib/materials/sxp/popup/CommodityDetail/settingRender.d.ts +28 -2
- package/lib/materials/sxp/popup/CommodityDetail/settingRender.js +52 -0
- package/lib/materials/sxp/popup/CommodityDetailDiroNew/index.d.ts +13 -2
- package/lib/materials/sxp/popup/CommodityDetailDiroNew/index.js +85 -51
- package/lib/materials/sxp/popup/CommodityDetailDiroNew/material.js +4 -0
- package/lib/materials/sxp/popup/CommodityDetailDiroNew/settingRender.d.ts +28 -2
- package/lib/materials/sxp/popup/CommodityDetailDiroNew/settingRender.js +52 -0
- package/lib/materials/sxp/popup/CommodityList/settingRender.js +15 -0
- package/lib/materials/sxp/popup/Iframe/index.d.ts +16 -0
- package/lib/materials/sxp/popup/Iframe/index.js +20 -0
- package/lib/materials/sxp/popup/Iframe/material.d.ts +2 -0
- package/lib/materials/sxp/popup/Iframe/material.js +25 -0
- package/lib/materials/sxp/popup/Iframe/settingRender.d.ts +9 -0
- package/lib/materials/sxp/popup/Iframe/settingRender.js +14 -0
- package/lib/materials/sxp/popup/Prompt/settingRender.js +16 -1
- package/lib/materials/sxp/popup/index.d.ts +1 -0
- package/lib/materials/sxp/popup/index.js +1 -0
- package/lib/materials/sxp/template/Link/index.js +5 -11
- package/lib/materials/sxp/template/Link/interactionRender.d.ts +8 -0
- package/lib/materials/sxp/template/Link/interactionRender.js +13 -0
- package/lib/materials/sxp/template/Link/material.js +3 -1
- package/lib/materials/sxp/template/components/EventProvider.d.ts +3 -2
- package/lib/materials/sxp/template/components/EventProvider.js +3 -3
- package/package.json +1 -1
@@ -6,6 +6,7 @@ import { storeAndLoadFeUserId, AGREE_POLICY } from '../utils/localStore';
|
|
6
6
|
import { useIconLink } from '../components/SxpPageRender/useIconLink';
|
7
7
|
import SXP_EVENT_BUS, { SXP_EVENT_TYPE } from '../utils/event';
|
8
8
|
import Consent from '../components/Consent';
|
9
|
+
import { getBrowserInfo, getCookie, getDevice, getSystem } from '../utils/tool';
|
9
10
|
export const SxpDataSourceContext = createContext({
|
10
11
|
rtcList: [],
|
11
12
|
tagList: []
|
@@ -15,7 +16,7 @@ var DataSourceType;
|
|
15
16
|
DataSourceType[DataSourceType["BFF"] = 5] = "BFF";
|
16
17
|
})(DataSourceType || (DataSourceType = {}));
|
17
18
|
export const DEFAULT_TAG = 'FOR U';
|
18
|
-
const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent = true, maxSize, defaultSize, isPreview = false, sxpParameter, appDomain, hashTagSize, loadingImage, isOpenHashTag = false, enabledMetaConversionApi = false, consentHeight, consentWidth, isShowTag = true, isOpenConsent = false, globalConfig, isEditor = false, utmParameter }) => {
|
19
|
+
const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent = true, maxSize, defaultSize, isPreview = false, sxpParameter, appDomain, hashTagSize, loadingImage, isOpenHashTag = false, enabledMetaConversionApi = false, consentHeight, consentWidth, isShowTag = true, isOpenConsent = false, globalConfig, isEditor = false, utmParameter, channelQueryList }) => {
|
19
20
|
var _a, _b, _c;
|
20
21
|
const [rtcList, setRtcList] = useState([]);
|
21
22
|
const [tagList, setTagList] = useState([]);
|
@@ -92,16 +93,8 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
92
93
|
.catch((err) => Promise.reject(err));
|
93
94
|
}, [bffDataSource]);
|
94
95
|
const getRecommendVideos = useCallback((query) => __awaiter(void 0, void 0, void 0, function* () {
|
95
|
-
var _d, _e, _f, _g, _h;
|
96
|
-
query = {
|
97
|
-
maxSize: (_d = query === null || query === void 0 ? void 0 : query.maxSize) !== null && _d !== void 0 ? _d : maxSize,
|
98
|
-
defaultSize: (_e = query === null || query === void 0 ? void 0 : query.defaultSize) !== null && _e !== void 0 ? _e : defaultSize,
|
99
|
-
'itemFilter.itemId': query === null || query === void 0 ? void 0 : query['itemFilter.itemId'],
|
100
|
-
'itemFilter.itemType': query === null || query === void 0 ? void 0 : query['itemFilter.itemType'],
|
101
|
-
hashTag: query === null || query === void 0 ? void 0 : query.hashTag,
|
102
|
-
traceInfo: query === null || query === void 0 ? void 0 : query.traceInfo,
|
103
|
-
themeTag: query === null || query === void 0 ? void 0 : query.themeTag
|
104
|
-
};
|
96
|
+
var _d, _e, _f, _g, _h, _j, _k;
|
97
|
+
query = Object.assign(Object.assign({ maxSize: (_d = query === null || query === void 0 ? void 0 : query.maxSize) !== null && _d !== void 0 ? _d : maxSize, defaultSize: (_e = query === null || query === void 0 ? void 0 : query.defaultSize) !== null && _e !== void 0 ? _e : defaultSize, hashTag: query === null || query === void 0 ? void 0 : query.hashTag, traceInfo: query === null || query === void 0 ? void 0 : query.traceInfo, themeTag: query === null || query === void 0 ? void 0 : query.themeTag }, ((query === null || query === void 0 ? void 0 : query.contentFilter) && { contentFilter: `[${query === null || query === void 0 ? void 0 : query.contentFilter}]` })), ((query === null || query === void 0 ? void 0 : query.productFilter) && { productFilter: `[${query === null || query === void 0 ? void 0 : query.productFilter}]` }));
|
105
98
|
if (utmVal) {
|
106
99
|
const val = (_h = (_g = (_f = utmVal === null || utmVal === void 0 ? void 0 : utmVal.split('&')) === null || _f === void 0 ? void 0 : _f.filter((val) => {
|
107
100
|
var _a, _b;
|
@@ -110,6 +103,32 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
110
103
|
})) === null || _g === void 0 ? void 0 : _g.join('&')) !== null && _h !== void 0 ? _h : '';
|
111
104
|
query = Object.assign(Object.assign({}, query), { channel: decodeURIComponent(val) });
|
112
105
|
}
|
106
|
+
if ((globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview) || isEditor) {
|
107
|
+
query = Object.assign(Object.assign(Object.assign({}, query), { directPage: true, level: 1 }), (!utmVal && channelQueryList && (channelQueryList === null || channelQueryList === void 0 ? void 0 : channelQueryList.length) > 0 && { channel: channelQueryList === null || channelQueryList === void 0 ? void 0 : channelQueryList[0] }));
|
108
|
+
if (!(query === null || query === void 0 ? void 0 : query.channel))
|
109
|
+
return;
|
110
|
+
let list = [];
|
111
|
+
let result = null;
|
112
|
+
let pageNum = 1;
|
113
|
+
const recurveRecList = (query) => __awaiter(void 0, void 0, void 0, function* () {
|
114
|
+
var _l, _m, _o, _p;
|
115
|
+
query.pageNum = pageNum;
|
116
|
+
result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/recommend/list', { method: 'GET', query }));
|
117
|
+
if (!(result === null || result === void 0 ? void 0 : result.success)) {
|
118
|
+
return undefined;
|
119
|
+
}
|
120
|
+
const rec = (_m = (_l = result === null || result === void 0 ? void 0 : result.data) === null || _l === void 0 ? void 0 : _l.recList) === null || _m === void 0 ? void 0 : _m[0];
|
121
|
+
list = list.concat((_p = (_o = result === null || result === void 0 ? void 0 : result.data) === null || _o === void 0 ? void 0 : _o.recList) !== null && _p !== void 0 ? _p : []);
|
122
|
+
if ((rec === null || rec === void 0 ? void 0 : rec.product) || (rec === null || rec === void 0 ? void 0 : rec.video)) {
|
123
|
+
pageNum = pageNum + 1;
|
124
|
+
yield recurveRecList(query);
|
125
|
+
}
|
126
|
+
});
|
127
|
+
yield recurveRecList(query);
|
128
|
+
if (!(query === null || query === void 0 ? void 0 : query.hashTag) && result)
|
129
|
+
setCurReqInfo({ rtc: (_j = result === null || result === void 0 ? void 0 : result.data) === null || _j === void 0 ? void 0 : _j.rtc, requestId: (_k = result === null || result === void 0 ? void 0 : result.data) === null || _k === void 0 ? void 0 : _k.requestId });
|
130
|
+
return Object.assign(Object.assign({}, result.data), { recList: list });
|
131
|
+
}
|
113
132
|
const result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/recommend/list', { method: 'GET', query }));
|
114
133
|
if (!(result === null || result === void 0 ? void 0 : result.success)) {
|
115
134
|
return undefined;
|
@@ -117,29 +136,26 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
117
136
|
if (!(query === null || query === void 0 ? void 0 : query.hashTag))
|
118
137
|
setCurReqInfo({ rtc: result.data.rtc, requestId: result.data.requestId });
|
119
138
|
return result === null || result === void 0 ? void 0 : result.data;
|
120
|
-
}), [bffFetch, utmVal, maxSize, defaultSize]);
|
139
|
+
}), [bffFetch, utmVal, maxSize, defaultSize, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview, channelQueryList, isEditor]);
|
121
140
|
const loadVideos = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
141
|
+
var _q, _r, _s, _t;
|
122
142
|
if (rtcList.length <= 0) {
|
123
143
|
return;
|
124
144
|
}
|
125
|
-
const
|
126
|
-
|
127
|
-
'itemFilter.itemId': waterFallData === null || waterFallData === void 0 ? void 0 : waterFallData.itemId,
|
128
|
-
'itemFilter.itemType': waterFallData === null || waterFallData === void 0 ? void 0 : waterFallData.itemType,
|
129
|
-
themeTag: themeTag.current
|
130
|
-
});
|
145
|
+
const lastItem = rtcList === null || rtcList === void 0 ? void 0 : rtcList[(rtcList === null || rtcList === void 0 ? void 0 : rtcList.length) - 1];
|
146
|
+
const data = yield getRecommendVideos(Object.assign(Object.assign(Object.assign({ hashTag: waterFallData === null || waterFallData === void 0 ? void 0 : waterFallData.hashTag }, (((_q = lastItem === null || lastItem === void 0 ? void 0 : lastItem.product) === null || _q === void 0 ? void 0 : _q.itemId) && { productFilter: (_r = lastItem === null || lastItem === void 0 ? void 0 : lastItem.product) === null || _r === void 0 ? void 0 : _r.itemId })), (((_s = lastItem === null || lastItem === void 0 ? void 0 : lastItem.video) === null || _s === void 0 ? void 0 : _s.itemId) && { contentFilter: (_t = lastItem === null || lastItem === void 0 ? void 0 : lastItem.video) === null || _t === void 0 ? void 0 : _t.itemId })), { themeTag: themeTag.current }));
|
131
147
|
setRtcList(rtcList.concat(getFilterRecList(data)));
|
132
148
|
setCacheRtcList(cacheRtcList.concat(getFilterRecList(data)));
|
133
149
|
}), [getRecommendVideos, rtcList, waterFallData, cacheRtcList]);
|
134
150
|
const bffEventReport = useCallback(({ userInfo, eventInfo }) => {
|
135
|
-
if (!enableReportEvent) {
|
151
|
+
if (!enableReportEvent || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview)) {
|
136
152
|
return;
|
137
153
|
}
|
138
154
|
if (!userInfo) {
|
139
155
|
userInfo = {};
|
140
156
|
}
|
141
157
|
const sessionID = storeAndLoadFeSessionId();
|
142
|
-
const ef = Object.assign({ sessionID, rtc: curReqInfo.rtc, requestId: curReqInfo.requestId }, eventInfo);
|
158
|
+
const ef = Object.assign(Object.assign({ sessionID, rtc: curReqInfo.rtc, requestId: curReqInfo.requestId }, eventInfo), { sxpDevice: getDevice(), sxpSystem: getSystem(), sxpBrowser: getBrowserInfo() });
|
143
159
|
const realUserInfo = Object.entries(userInfo).map(([k, v]) => ({ name: k, value: v }));
|
144
160
|
const realEventInfo = Object.entries(ef)
|
145
161
|
.map(([k, v]) => v && { name: k, value: v })
|
@@ -153,11 +169,11 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
153
169
|
body: { userInfo: realUserInfo, eventInfo: realEventInfo },
|
154
170
|
type: 'beacon'
|
155
171
|
});
|
156
|
-
}, [bffFetch, curReqInfo, enableReportEvent]);
|
172
|
+
}, [bffFetch, curReqInfo, enableReportEvent, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview]);
|
157
173
|
const bffFbReport = useCallback((_a) => {
|
158
|
-
var _b;
|
174
|
+
var _b, _c;
|
159
175
|
var { eventName, actionSource = 'website', eventSourceUrl = (_b = window === null || window === void 0 ? void 0 : window.location) === null || _b === void 0 ? void 0 : _b.href, externalId } = _a;
|
160
|
-
if (!enableReportEvent || !enabledMetaConversionApi) {
|
176
|
+
if (!enableReportEvent || !enabledMetaConversionApi || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview)) {
|
161
177
|
return;
|
162
178
|
}
|
163
179
|
const fakeUserId = storeAndLoadFeUserId();
|
@@ -168,12 +184,15 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
168
184
|
actionSource,
|
169
185
|
eventSourceUrl,
|
170
186
|
userData: {
|
171
|
-
externalId: fakeUserId
|
187
|
+
externalId: fakeUserId,
|
188
|
+
fbc: `fb.2.${new Date().getTime()}.${getCookie('_fbc')}`,
|
189
|
+
fbp: `fb.2.${new Date().getTime()}.${getCookie('_fbp')}`,
|
190
|
+
client_user_agent: (_c = window === null || window === void 0 ? void 0 : window.navigator) === null || _c === void 0 ? void 0 : _c.userAgent
|
172
191
|
}
|
173
192
|
},
|
174
193
|
type: 'beacon'
|
175
194
|
});
|
176
|
-
}, [bffFetch, enableReportEvent, enabledMetaConversionApi]);
|
195
|
+
}, [bffFetch, enableReportEvent, enabledMetaConversionApi, globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.enablePreview]);
|
177
196
|
const bffMutateLike = useCallback((body) => __awaiter(void 0, void 0, void 0, function* () {
|
178
197
|
const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/recommend/like', { method: 'POST', body }));
|
179
198
|
return res === null || res === void 0 ? void 0 : res.success;
|
@@ -187,24 +206,24 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
187
206
|
return res === null || res === void 0 ? void 0 : res.success;
|
188
207
|
}), [bffFetch]);
|
189
208
|
const bffGetTagList = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
190
|
-
var
|
209
|
+
var _u, _v, _w, _x, _y;
|
191
210
|
if (!utmVal || !isShowTag)
|
192
211
|
return;
|
193
212
|
try {
|
194
|
-
const val = (
|
213
|
+
const val = (_w = (_v = (_u = utmVal === null || utmVal === void 0 ? void 0 : utmVal.split('&')) === null || _u === void 0 ? void 0 : _u.filter((val) => {
|
195
214
|
var _a, _b;
|
196
215
|
const key = val.split('=')[0];
|
197
216
|
return (_b = ((_a = utmParameter === null || utmParameter === void 0 ? void 0 : utmParameter.channels) !== null && _a !== void 0 ? _a : [])) === null || _b === void 0 ? void 0 : _b.includes(key);
|
198
|
-
})) === null ||
|
217
|
+
})) === null || _v === void 0 ? void 0 : _v.join('&')) !== null && _w !== void 0 ? _w : '';
|
199
218
|
const result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/tag/list', { method: 'GET', query: { channel: decodeURIComponent(val) } }));
|
200
|
-
setTagList((
|
219
|
+
setTagList((_y = (_x = result === null || result === void 0 ? void 0 : result.data) === null || _x === void 0 ? void 0 : _x.tags) !== null && _y !== void 0 ? _y : []);
|
201
220
|
}
|
202
221
|
catch (e) {
|
203
222
|
console.log('e', e);
|
204
223
|
}
|
205
224
|
}), [bffFetch, utmVal, isShowTag]);
|
206
225
|
const ctaEvent = useCallback((eventInfo, rec, product, position) => {
|
207
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
|
226
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11;
|
208
227
|
const cta = product === null || product === void 0 ? void 0 : product.bindCta;
|
209
228
|
const isProd = ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.bindProduct) || (((_b = rec === null || rec === void 0 ? void 0 : rec.video) === null || _b === void 0 ? void 0 : _b.bindProducts) && ((_d = (_c = rec === null || rec === void 0 ? void 0 : rec.video) === null || _c === void 0 ? void 0 : _c.bindProducts) === null || _d === void 0 ? void 0 : _d.length) > 0);
|
210
229
|
let fromKName = '';
|
@@ -217,8 +236,9 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
217
236
|
else if ((_g = (_f = rec === null || rec === void 0 ? void 0 : rec.video) === null || _f === void 0 ? void 0 : _f.imgUrls) === null || _g === void 0 ? void 0 : _g.length) {
|
218
237
|
fromKName = 'imagePage';
|
219
238
|
}
|
239
|
+
const contentTags = (_p = (_m = (_h = product === null || product === void 0 ? void 0 : product.tags) !== null && _h !== void 0 ? _h : (_l = (_k = (_j = rec === null || rec === void 0 ? void 0 : rec.video) === null || _j === void 0 ? void 0 : _j.bindProducts) === null || _k === void 0 ? void 0 : _k[0]) === null || _l === void 0 ? void 0 : _l.tags) !== null && _m !== void 0 ? _m : (_o = rec === null || rec === void 0 ? void 0 : rec.video) === null || _o === void 0 ? void 0 : _o.tags) !== null && _p !== void 0 ? _p : (_q = rec === null || rec === void 0 ? void 0 : rec.product) === null || _q === void 0 ? void 0 : _q.tags;
|
220
240
|
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
221
|
-
eventInfo: Object.assign(Object.assign({}, eventInfo), { ctaId: (
|
241
|
+
eventInfo: Object.assign(Object.assign({}, eventInfo), { ctaId: (_r = cta === null || cta === void 0 ? void 0 : cta.itemId) !== null && _r !== void 0 ? _r : '', ctaName: (_s = cta === null || cta === void 0 ? void 0 : cta.title) !== null && _s !== void 0 ? _s : '', contentTags: contentTags ? JSON.stringify(contentTags) : '', position: position + '', contentId: (_u = (_t = rec === null || rec === void 0 ? void 0 : rec.video) === null || _t === void 0 ? void 0 : _t.itemId) !== null && _u !== void 0 ? _u : '', productId: isProd ? product === null || product === void 0 ? void 0 : product.itemId : '', traceInfo: (_10 = (_7 = (_2 = (_y = (_v = cta === null || cta === void 0 ? void 0 : cta.traceInfo) !== null && _v !== void 0 ? _v : (_x = (_w = rec === null || rec === void 0 ? void 0 : rec.video) === null || _w === void 0 ? void 0 : _w.bindCta) === null || _x === void 0 ? void 0 : _x.traceInfo) !== null && _y !== void 0 ? _y : (_1 = (_0 = (_z = rec === null || rec === void 0 ? void 0 : rec.video) === null || _z === void 0 ? void 0 : _z.bindProduct) === null || _0 === void 0 ? void 0 : _0.bindCta) === null || _1 === void 0 ? void 0 : _1.traceInfo) !== null && _2 !== void 0 ? _2 : (_6 = (_5 = (_4 = (_3 = rec === null || rec === void 0 ? void 0 : rec.video) === null || _3 === void 0 ? void 0 : _3.bindProducts) === null || _4 === void 0 ? void 0 : _4[0]) === null || _5 === void 0 ? void 0 : _5.bindCta) === null || _6 === void 0 ? void 0 : _6.traceInfo) !== null && _7 !== void 0 ? _7 : (_9 = (_8 = rec === null || rec === void 0 ? void 0 : rec.product) === null || _8 === void 0 ? void 0 : _8.bindCta) === null || _9 === void 0 ? void 0 : _9.traceInfo) !== null && _10 !== void 0 ? _10 : '', fromKName, fromKPage: (_11 = location === null || location === void 0 ? void 0 : location.href) !== null && _11 !== void 0 ? _11 : '' })
|
222
242
|
});
|
223
243
|
}, [bffEventReport, isFromHashtag]);
|
224
244
|
const h5EnterLink = useCallback(() => {
|
@@ -273,7 +293,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
273
293
|
});
|
274
294
|
}, [isShowConsent]);
|
275
295
|
useEffect(() => {
|
276
|
-
if (!isInit.current)
|
296
|
+
if (!isInit.current && !isEditor)
|
277
297
|
return;
|
278
298
|
setLoading(true);
|
279
299
|
bffGetTagList();
|
@@ -285,7 +305,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
285
305
|
.finally(() => {
|
286
306
|
setLoading(false);
|
287
307
|
});
|
288
|
-
}, [
|
308
|
+
}, [bffGetTagList, isEditor, getRecommendVideos]);
|
289
309
|
const defaultLoadingImage = useIconLink('/pb_static/a65d23c5893c49d7aaaa81681d3179e2.gif', appDomain);
|
290
310
|
return (React.createElement(SxpDataSourceContext.Provider, { value: {
|
291
311
|
rtcList,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { RecItemType } from '../components/SxpPageRender/typing';
|
2
2
|
export declare function useEventReport(): {
|
3
|
-
jumpToWeb: (data?: RecItemType, product?: RecItemType['product'], cta?: RecItemType['cta'], position?: number) => void;
|
3
|
+
jumpToWeb: (data?: RecItemType, product?: RecItemType['product'], cta?: RecItemType['cta'], position?: number, traceInfo?: string) => void;
|
4
4
|
productView: (data?: RecItemType, product?: RecItemType['product'], cta?: RecItemType['cta'], viewTime?: any, position?: number) => void;
|
5
5
|
backMainFeed: (lastFeed: 'theme' | 'branch' | 'external', selectTag?: string, themeTag?: string, hashTag?: string) => void;
|
6
6
|
};
|
@@ -3,8 +3,8 @@ import { useSxpDataSource } from './useSxpDataSource';
|
|
3
3
|
import { DEFAULT_TAG } from '../context/SxpDataSourceProvider';
|
4
4
|
export function useEventReport() {
|
5
5
|
const { bffEventReport, popupDetailData, waterFallData, isFromHashtag } = useSxpDataSource();
|
6
|
-
const jumpToWeb = useCallback((data, product, cta, position) => {
|
7
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
|
6
|
+
const jumpToWeb = useCallback((data, product, cta, position, traceInfo) => {
|
7
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9;
|
8
8
|
let fromKName = '';
|
9
9
|
if (popupDetailData && (((_b = (_a = data === null || data === void 0 ? void 0 : data.video) === null || _a === void 0 ? void 0 : _a.bindProducts) === null || _b === void 0 ? void 0 : _b.length) || ((_c = data === null || data === void 0 ? void 0 : data.video) === null || _c === void 0 ? void 0 : _c.bindProduct))) {
|
10
10
|
fromKName = 'pdpPage';
|
@@ -21,21 +21,22 @@ export function useEventReport() {
|
|
21
21
|
else if (data === null || data === void 0 ? void 0 : data.product) {
|
22
22
|
fromKName = 'productPage';
|
23
23
|
}
|
24
|
+
const contentTags = (_p = (_m = (_h = product === null || product === void 0 ? void 0 : product.tags) !== null && _h !== void 0 ? _h : (_l = (_k = (_j = data === null || data === void 0 ? void 0 : data.video) === null || _j === void 0 ? void 0 : _j.bindProducts) === null || _k === void 0 ? void 0 : _k[0]) === null || _l === void 0 ? void 0 : _l.tags) !== null && _m !== void 0 ? _m : (_o = data === null || data === void 0 ? void 0 : data.video) === null || _o === void 0 ? void 0 : _o.tags) !== null && _p !== void 0 ? _p : (_q = data === null || data === void 0 ? void 0 : data.product) === null || _q === void 0 ? void 0 : _q.tags;
|
24
25
|
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
25
26
|
eventInfo: {
|
26
27
|
eventSubject: 'jumpToWeb',
|
27
28
|
eventDescription: 'User jumped to website',
|
28
|
-
productId: (
|
29
|
-
productName: (
|
29
|
+
productId: (_r = product === null || product === void 0 ? void 0 : product.itemId) !== null && _r !== void 0 ? _r : '',
|
30
|
+
productName: (_s = product === null || product === void 0 ? void 0 : product.title) !== null && _s !== void 0 ? _s : '',
|
30
31
|
price: (product === null || product === void 0 ? void 0 : product.price) ? (product === null || product === void 0 ? void 0 : product.price) + '' : '0',
|
31
|
-
productCollection: (
|
32
|
+
productCollection: (_t = product === null || product === void 0 ? void 0 : product.collection) !== null && _t !== void 0 ? _t : '',
|
32
33
|
fromKName,
|
33
34
|
fromKPage: location === null || location === void 0 ? void 0 : location.href,
|
34
|
-
contentTags:
|
35
|
+
contentTags: contentTags ? JSON.stringify(contentTags) : '',
|
35
36
|
position: position + '',
|
36
|
-
contentId: (
|
37
|
-
ctatId: (
|
38
|
-
traceInfo: (
|
37
|
+
contentId: (_v = (_u = data === null || data === void 0 ? void 0 : data.video) === null || _u === void 0 ? void 0 : _u.itemId) !== null && _v !== void 0 ? _v : '',
|
38
|
+
ctatId: (_w = cta === null || cta === void 0 ? void 0 : cta.itemId) !== null && _w !== void 0 ? _w : '',
|
39
|
+
traceInfo: (_9 = (_6 = (_4 = (_0 = (_x = traceInfo !== null && traceInfo !== void 0 ? traceInfo : product === null || product === void 0 ? void 0 : product.traceInfo) !== null && _x !== void 0 ? _x : (_z = (_y = data === null || data === void 0 ? void 0 : data.video) === null || _y === void 0 ? void 0 : _y.bindProduct) === null || _z === void 0 ? void 0 : _z.traceInfo) !== null && _0 !== void 0 ? _0 : (_3 = (_2 = (_1 = data === null || data === void 0 ? void 0 : data.video) === null || _1 === void 0 ? void 0 : _1.bindProducts) === null || _2 === void 0 ? void 0 : _2[0]) === null || _3 === void 0 ? void 0 : _3.traceInfo) !== null && _4 !== void 0 ? _4 : (_5 = data === null || data === void 0 ? void 0 : data.product) === null || _5 === void 0 ? void 0 : _5.traceInfo) !== null && _6 !== void 0 ? _6 : (_8 = (_7 = data === null || data === void 0 ? void 0 : data.video) === null || _7 === void 0 ? void 0 : _7.bindCta) === null || _8 === void 0 ? void 0 : _8.traceInfo) !== null && _9 !== void 0 ? _9 : ''
|
39
40
|
}
|
40
41
|
});
|
41
42
|
}, [bffEventReport, popupDetailData, isFromHashtag]);
|
package/es/core/utils/tool.d.ts
CHANGED
@@ -7,4 +7,8 @@ interface IfontType {
|
|
7
7
|
'fontFamily-en': string;
|
8
8
|
}
|
9
9
|
export declare const setFontForText: (textContent?: string | null, style?: IfontType | any) => string;
|
10
|
-
|
10
|
+
declare function getBrowserInfo(): string;
|
11
|
+
declare function getSystem(): string;
|
12
|
+
declare function getDevice(): string;
|
13
|
+
declare function getCookie(val: string): string;
|
14
|
+
export { uuid, getIndexByblockType, getBrowserInfo, getDevice, getSystem, getCookie };
|
package/es/core/utils/tool.js
CHANGED
@@ -88,4 +88,72 @@ export const setFontForText = (textContent, style) => {
|
|
88
88
|
}
|
89
89
|
return content;
|
90
90
|
};
|
91
|
-
|
91
|
+
function getBrowserInfo() {
|
92
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
93
|
+
let userAgent = self.navigator.userAgent;
|
94
|
+
if (!userAgent)
|
95
|
+
return 'Unknown';
|
96
|
+
if (/edge\/([\d\.]+)/i.exec(userAgent))
|
97
|
+
return `Edge ${(_a = /edge\/([\d\.]+)/i.exec(userAgent)) === null || _a === void 0 ? void 0 : _a[1]}`;
|
98
|
+
if (/edg\/([\d\.]+)/i.exec(userAgent))
|
99
|
+
return `Edge(Chromium) ${(_b = /edge\/([\d\.]+)/i.exec(userAgent)) === null || _b === void 0 ? void 0 : _b[1]}`;
|
100
|
+
if (/msie/i.test(userAgent))
|
101
|
+
return `Internet Explorer ${(_c = /msie ([\d\.]+)/i.exec(userAgent)) === null || _c === void 0 ? void 0 : _c[1]}`;
|
102
|
+
if (/Trident/i.test(userAgent))
|
103
|
+
return `Internet Explorer ${(_d = /rv:([\d\.]+)/i.exec(userAgent)) === null || _d === void 0 ? void 0 : _d[1]}`;
|
104
|
+
if (/chrome/i.test(userAgent))
|
105
|
+
return `Chrome ${(_e = /chrome\/([\d\.]+)/i.exec(userAgent)) === null || _e === void 0 ? void 0 : _e[1]}`;
|
106
|
+
if (/firefox/i.test(userAgent))
|
107
|
+
return `Firefox ${(_f = /firefox\/([\d\.]+)/i.exec(userAgent)) === null || _f === void 0 ? void 0 : _f[1]}`;
|
108
|
+
if (/safari/i.test(userAgent))
|
109
|
+
return `Safari ${(_g = /version\/([\d\.]+)/i.exec(userAgent)) === null || _g === void 0 ? void 0 : _g[1]}`;
|
110
|
+
return 'Unknown';
|
111
|
+
}
|
112
|
+
function getSystem() {
|
113
|
+
var _a, _b, _c;
|
114
|
+
let userAgent = self.navigator.userAgent;
|
115
|
+
if (!userAgent)
|
116
|
+
return 'Unknown';
|
117
|
+
if (/iphone/i.test(userAgent))
|
118
|
+
return `IOS ${(_a = userAgent.match(/OS\s(.*?)\slike/)) === null || _a === void 0 ? void 0 : _a[1]}`;
|
119
|
+
if (/android/i.test(userAgent))
|
120
|
+
return `Android ${(_b = userAgent.match(/Android\s(.*?)\;/)) === null || _b === void 0 ? void 0 : _b[1]}`;
|
121
|
+
if (/windows/i.test(userAgent))
|
122
|
+
return `Windows ${(_c = userAgent.match(/Windows\s(.*?)\;/)) === null || _c === void 0 ? void 0 : _c[1]}`;
|
123
|
+
if (/mac/i.test(userAgent))
|
124
|
+
return `Mac OS`;
|
125
|
+
return 'Unknown';
|
126
|
+
}
|
127
|
+
function getDevice() {
|
128
|
+
let userAgent = self.navigator.userAgent;
|
129
|
+
if (!userAgent)
|
130
|
+
return 'Unknown';
|
131
|
+
if (/iphone/i.test(userAgent))
|
132
|
+
return `iPhone`;
|
133
|
+
if (/android/i.test(userAgent)) {
|
134
|
+
var index1 = userAgent.indexOf('(');
|
135
|
+
var index2 = userAgent.indexOf(')');
|
136
|
+
if (index1 !== -1 && index2 !== -1) {
|
137
|
+
var value = userAgent.substring(index1 + 1, index2);
|
138
|
+
return `${value}`;
|
139
|
+
}
|
140
|
+
}
|
141
|
+
if (/windows/i.test(userAgent))
|
142
|
+
return `Windows`;
|
143
|
+
if (/mac/i.test(userAgent))
|
144
|
+
return `Mac`;
|
145
|
+
return 'Unknown';
|
146
|
+
}
|
147
|
+
function getCookie(val) {
|
148
|
+
const cookies = document.cookie;
|
149
|
+
const cookieArray = cookies.split(';');
|
150
|
+
let value = null;
|
151
|
+
cookieArray.forEach((cookie) => {
|
152
|
+
const [cookieName, cookieValue] = cookie.trim().split('=');
|
153
|
+
if (cookieName === val) {
|
154
|
+
value = cookieValue;
|
155
|
+
}
|
156
|
+
});
|
157
|
+
return value !== null && value !== void 0 ? value : '';
|
158
|
+
}
|
159
|
+
export { uuid, getIndexByblockType, getBrowserInfo, getDevice, getSystem, getCookie };
|
@@ -1,4 +1,19 @@
|
|
1
1
|
export default [
|
2
|
+
{
|
3
|
+
title: '弹窗背景',
|
4
|
+
child: [
|
5
|
+
{
|
6
|
+
type: 'Number',
|
7
|
+
label: '左右边距',
|
8
|
+
name: ['props', 'popupBg', 'horizontalMargin']
|
9
|
+
},
|
10
|
+
{
|
11
|
+
type: 'Number',
|
12
|
+
label: '下边距',
|
13
|
+
name: ['props', 'popupBg', 'bottomMargin']
|
14
|
+
}
|
15
|
+
]
|
16
|
+
},
|
2
17
|
{
|
3
18
|
type: 'Text',
|
4
19
|
label: '组件名称',
|
@@ -18,14 +18,16 @@ export interface ICommodityDetailProps {
|
|
18
18
|
viewTime?: any;
|
19
19
|
rec?: RecItemType;
|
20
20
|
swiper: {
|
21
|
-
dotsAlign: 'left' | 'center';
|
21
|
+
dotsAlign: 'left' | 'center' | 'right';
|
22
22
|
delay: number;
|
23
23
|
translateY?: number;
|
24
24
|
};
|
25
25
|
commodityStyles?: {
|
26
26
|
title: CSSProperties;
|
27
27
|
collection: CSSProperties;
|
28
|
-
price: CSSProperties
|
28
|
+
price: CSSProperties & {
|
29
|
+
enableFormattedPrice?: boolean;
|
30
|
+
};
|
29
31
|
info: CSSProperties;
|
30
32
|
taxInfo: CSSProperties;
|
31
33
|
};
|
@@ -36,6 +38,15 @@ export interface ICommodityDetailProps {
|
|
36
38
|
translateY?: number;
|
37
39
|
style?: CSSProperties;
|
38
40
|
};
|
41
|
+
popupBg?: {
|
42
|
+
horizontalMargin?: number;
|
43
|
+
bottomMargin?: number;
|
44
|
+
};
|
45
|
+
iframeIcon?: string;
|
46
|
+
commodityImgRatio?: {
|
47
|
+
w: number;
|
48
|
+
h: number;
|
49
|
+
};
|
39
50
|
}
|
40
51
|
declare const _default: React.NamedExoticComponent<ICommodityDetailProps>;
|
41
52
|
export default _default;
|
@@ -12,14 +12,15 @@ import FormatImage from '../../../../core/components/SxpPageRender/FormatImage';
|
|
12
12
|
import { setFontForText } from '../../../../core/utils/tool';
|
13
13
|
import CommodityGroup from '../../template/components/CommodityGroup';
|
14
14
|
const CommodityDetail = (_a) => {
|
15
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
16
|
-
var { content, style, bgImg, onClick, schema, isDefault, bottom_image, tipText, isPost, viewTime, rec, swiper, commodityStyles, buttonStyle, index, commodityGroup } = _a, props = __rest(_a, ["content", "style", "bgImg", "onClick", "schema", "isDefault", "bottom_image", "tipText", "isPost", "viewTime", "rec", "swiper", "commodityStyles", "buttonStyle", "index", "commodityGroup"]);
|
15
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5;
|
16
|
+
var { content, style, bgImg, onClick, schema, isDefault, bottom_image, tipText, isPost, viewTime, rec, swiper, commodityStyles, buttonStyle, index, commodityGroup, popupBg, iframeIcon, commodityImgRatio } = _a, props = __rest(_a, ["content", "style", "bgImg", "onClick", "schema", "isDefault", "bottom_image", "tipText", "isPost", "viewTime", "rec", "swiper", "commodityStyles", "buttonStyle", "index", "commodityGroup", "popupBg", "iframeIcon", "commodityImgRatio"]);
|
17
17
|
const { sxpParameter, popupDetailData, isPreview, bffFbReport, popupCurTimeRef, checkCommodityIndexRef } = useSxpDataSource();
|
18
18
|
const { jumpToWeb, productView } = useEventReport();
|
19
19
|
const curTimeRef = useRef(null);
|
20
20
|
const [showModal, setShowModal] = useState(false);
|
21
21
|
const [show3DModal, setShow3DModal] = useState(false);
|
22
22
|
const [checkCommodityIndex, setCheckCommodityIndex] = useState((_b = popupDetailData === null || popupDetailData === void 0 ? void 0 : popupDetailData.multiCheckIndex) !== null && _b !== void 0 ? _b : 0);
|
23
|
+
const ref = useRef();
|
23
24
|
const data = isPost ? rec : popupDetailData;
|
24
25
|
let product = isPost ? data === null || data === void 0 ? void 0 : data.product : (_d = (_c = data === null || data === void 0 ? void 0 : data.video) === null || _c === void 0 ? void 0 : _c.bindProduct) !== null && _d !== void 0 ? _d : (_f = (_e = data === null || data === void 0 ? void 0 : data.video) === null || _e === void 0 ? void 0 : _e.bindProducts) === null || _f === void 0 ? void 0 : _f[0];
|
25
26
|
let cta = isPost
|
@@ -59,17 +60,21 @@ const CommodityDetail = (_a) => {
|
|
59
60
|
};
|
60
61
|
}, []);
|
61
62
|
const priceText = useMemo(() => {
|
62
|
-
var _a, _b, _c, _d, _e;
|
63
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
64
|
+
const isToLocStr = ((_a = commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.price) === null || _a === void 0 ? void 0 : _a.enableFormattedPrice) === undefined || ((_b = commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.price) === null || _b === void 0 ? void 0 : _b.enableFormattedPrice);
|
63
65
|
if ((product === null || product === void 0 ? void 0 : product.currency) && (product === null || product === void 0 ? void 0 : product.price)) {
|
64
|
-
return `${(
|
65
|
-
|
66
|
-
|
66
|
+
return `${(_e = (_d = (_c = product === null || product === void 0 ? void 0 : product.currency) === null || _c === void 0 ? void 0 : _c.split('-')[1]) === null || _d === void 0 ? void 0 : _d.toUpperCase()) !== null && _e !== void 0 ? _e : ''}${isToLocStr
|
67
|
+
? (_g = (_f = product === null || product === void 0 ? void 0 : product.price) === null || _f === void 0 ? void 0 : _f.toLocaleString('zh', {
|
68
|
+
minimumFractionDigits: 0
|
69
|
+
})) !== null && _g !== void 0 ? _g : ''
|
70
|
+
: product === null || product === void 0 ? void 0 : product.price}`;
|
67
71
|
}
|
68
72
|
else {
|
69
73
|
return '$7,000';
|
70
74
|
}
|
71
|
-
}, [product === null || product === void 0 ? void 0 : product.price, product === null || product === void 0 ? void 0 : product.currency]);
|
72
|
-
const width = isPreview ? 375 : (
|
75
|
+
}, [product === null || product === void 0 ? void 0 : product.price, product === null || product === void 0 ? void 0 : product.currency, (_t = commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.price) === null || _t === void 0 ? void 0 : _t.enableFormattedPrice]);
|
76
|
+
const width = (isPreview ? 375 : (_u = style === null || style === void 0 ? void 0 : style.width) !== null && _u !== void 0 ? _u : window.innerWidth) - ((_v = popupBg === null || popupBg === void 0 ? void 0 : popupBg.horizontalMargin) !== null && _v !== void 0 ? _v : 0) * 2;
|
77
|
+
const height = commodityImgRatio ? width * (commodityImgRatio.h / commodityImgRatio.w) : width;
|
73
78
|
const renderContent = ({ isPost }) => {
|
74
79
|
var _a, _b, _c, _d;
|
75
80
|
return (React.createElement("div", null,
|
@@ -109,6 +114,10 @@ const CommodityDetail = (_a) => {
|
|
109
114
|
popupCurTimeRef.current = new Date();
|
110
115
|
setCheckCommodityIndex(index);
|
111
116
|
checkCommodityIndexRef.current = index;
|
117
|
+
if (ref === null || ref === void 0 ? void 0 : ref.current) {
|
118
|
+
ref.current.swiper.slideTo(0);
|
119
|
+
ref.current.swiper.autoplay.start();
|
120
|
+
}
|
112
121
|
}, []);
|
113
122
|
const renderCommodityGroup = useCallback(() => {
|
114
123
|
var _a, _b, _c;
|
@@ -116,25 +125,32 @@ const CommodityDetail = (_a) => {
|
|
116
125
|
return;
|
117
126
|
return (React.createElement(CommodityGroup, { products: (_a = data === null || data === void 0 ? void 0 : data.video) === null || _a === void 0 ? void 0 : _a.bindProducts, data: commodityGroup, defImg: (_c = (_b = sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.bottom_image) !== null && _b !== void 0 ? _b : bottom_image) !== null && _c !== void 0 ? _c : '', style: { padding: '0 19px' }, onCLick: handleClick, popupDetailData: popupDetailData, check: checkCommodityIndex }));
|
118
127
|
}, [checkCommodityIndex]);
|
128
|
+
const getDotsAlign = useMemo(() => {
|
129
|
+
const dotsAlignClass = {
|
130
|
+
left: 'commondityDetail-swiper-clickable-left',
|
131
|
+
center: 'commondityDetail-swiper-clickable-center',
|
132
|
+
right: 'commondityDetail-swiper-clickable-right'
|
133
|
+
};
|
134
|
+
return dotsAlignClass === null || dotsAlignClass === void 0 ? void 0 : dotsAlignClass[swiper === null || swiper === void 0 ? void 0 : swiper.dotsAlign];
|
135
|
+
}, [swiper === null || swiper === void 0 ? void 0 : swiper.dotsAlign]);
|
136
|
+
const iframeUrl = ((_x = (_w = data === null || data === void 0 ? void 0 : data.video) === null || _w === void 0 ? void 0 : _w.bindProduct) === null || _x === void 0 ? void 0 : _x.remark) || ((_0 = (_z = (_y = data === null || data === void 0 ? void 0 : data.video) === null || _y === void 0 ? void 0 : _y.bindProducts) === null || _z === void 0 ? void 0 : _z[0]) === null || _0 === void 0 ? void 0 : _0.remark) || ((_1 = data === null || data === void 0 ? void 0 : data.product) === null || _1 === void 0 ? void 0 : _1.remark);
|
119
137
|
return (React.createElement(React.Fragment, null,
|
120
138
|
React.createElement("div", Object.assign({ className: css(Object.assign({}, style)) }, props),
|
121
|
-
|
122
|
-
React.createElement(Swiper, { height:
|
139
|
+
React.createElement("div", { style: { position: 'relative' } },
|
140
|
+
product && ((_2 = product === null || product === void 0 ? void 0 : product.homePage) === null || _2 === void 0 ? void 0 : _2.length) > 0 && (React.createElement(Swiper, { height: height, modules: [Pagination, Autoplay], pagination: {
|
123
141
|
clickable: true,
|
124
142
|
bulletActiveClass: 'swipe-item-active-bullet',
|
125
|
-
clickableClass:
|
126
|
-
? 'commondityDetail-swiper-clickable-left'
|
127
|
-
: 'commondityDetail-swiper-clickable-center'
|
143
|
+
clickableClass: getDotsAlign
|
128
144
|
}, loop: true, autoplay: {
|
129
145
|
delay: (swiper === null || swiper === void 0 ? void 0 : swiper.delay) * 1000
|
130
|
-
} },
|
131
|
-
React.createElement(React.Fragment, null, (
|
146
|
+
}, ref: ref },
|
147
|
+
React.createElement(React.Fragment, null, (_3 = product === null || product === void 0 ? void 0 : product.homePage) === null || _3 === void 0 ? void 0 : _3.map((src) => {
|
132
148
|
var _a;
|
133
149
|
return (React.createElement(SwiperSlide, { key: src },
|
134
150
|
React.createElement("div", { style: {
|
135
151
|
overflow: 'hidden',
|
136
152
|
width,
|
137
|
-
height
|
153
|
+
height
|
138
154
|
} },
|
139
155
|
React.createElement(FormatImage, { style: {
|
140
156
|
height: '100%',
|
@@ -143,21 +159,30 @@ const CommodityDetail = (_a) => {
|
|
143
159
|
display: 'block',
|
144
160
|
objectPosition: `50% ${(swiper === null || swiper === void 0 ? void 0 : swiper.translateY) ? (swiper === null || swiper === void 0 ? void 0 : swiper.translateY) + 50 : 50}%`
|
145
161
|
}, src: (_a = src !== null && src !== void 0 ? src : sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.bottom_image) !== null && _a !== void 0 ? _a : bottom_image }))));
|
146
|
-
}))))
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
162
|
+
})))),
|
163
|
+
!((_4 = product === null || product === void 0 ? void 0 : product.homePage) === null || _4 === void 0 ? void 0 : _4.length) && (React.createElement("div", { className: css({
|
164
|
+
height,
|
165
|
+
width
|
166
|
+
}) },
|
167
|
+
React.createElement("img", { className: css({
|
168
|
+
objectFit: 'cover',
|
169
|
+
width: '100%',
|
170
|
+
height: '100%'
|
171
|
+
}), src: (_5 = sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.bottom_image) !== null && _5 !== void 0 ? _5 : bottom_image, alt: 'pdp image' }))),
|
172
|
+
(iframeUrl && iframeIcon) ||
|
173
|
+
(!product && iframeIcon && (React.createElement("div", { style: {
|
174
|
+
padding: '5px 10px',
|
175
|
+
display: 'flex',
|
176
|
+
alignItems: 'center',
|
177
|
+
position: 'absolute',
|
178
|
+
right: '10px',
|
179
|
+
bottom: '10px',
|
180
|
+
zIndex: 1,
|
181
|
+
background: '#fff',
|
182
|
+
borderRadius: '3px'
|
183
|
+
}, onClick: () => setShow3DModal(true) },
|
184
|
+
React.createElement("img", { src: iframeIcon, alt: '3d', width: '20px', height: '20px', style: { marginRight: '5px' } }),
|
185
|
+
React.createElement("span", { style: { fontSize: '12px' } }, "Try in 3D"))))),
|
161
186
|
renderCommodityGroup(),
|
162
187
|
React.createElement("div", { className: 'pb-commondity-content' }, renderContent({ isPost }))),
|
163
188
|
renderBtn(),
|
@@ -165,10 +190,11 @@ const CommodityDetail = (_a) => {
|
|
165
190
|
React.createElement("div", { style: { paddingBottom: '80px' } }, renderContent({ isPost: false })),
|
166
191
|
renderBtn()),
|
167
192
|
React.createElement(Modal, { visible: show3DModal, padding: 0, isFullScreen: true, onClose: () => setShow3DModal(false) },
|
168
|
-
React.createElement("iframe", { src:
|
193
|
+
React.createElement("iframe", { src: iframeUrl, style: {
|
169
194
|
width: '100%',
|
170
|
-
height: 'calc(100% -
|
171
|
-
marginTop: '40px'
|
195
|
+
height: 'calc(100% - 50px)',
|
196
|
+
marginTop: '40px',
|
197
|
+
border: 'none'
|
172
198
|
} }))));
|
173
199
|
};
|
174
200
|
export default memo(CommodityDetail);
|