@fonixtree/magic-design 2.0.32 → 2.0.35

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 (69) hide show
  1. package/es/common/AffiliateProductModal/index.js +582 -0
  2. package/es/common/AffiliateProductModal/index.less +146 -0
  3. package/es/common/ProductModal/index.js +1 -2
  4. package/es/common/ProductSource/index.js +42 -10
  5. package/es/composite-comp/common/components/AffiliateProductItem/imgs/icon-Balance2.svg +9 -0
  6. package/es/composite-comp/common/components/AffiliateProductItem/imgs/icon-Koin.svg +40 -0
  7. package/es/composite-comp/common/components/AffiliateProductItem/index.js +175 -0
  8. package/es/composite-comp/common/components/AffiliateProductItem/index.less +107 -0
  9. package/es/composite-comp/common/components/ProductItem/index.js +8 -6
  10. package/es/composite-comp/common/components/ProductItem/index.less +28 -22
  11. package/es/composite-comp/dito/components/AffiliateRecommend/defaultJSON.js +243 -0
  12. package/es/composite-comp/dito/components/AffiliateRecommend/index.js +90 -0
  13. package/es/composite-comp/dito/components/AffiliateRecommend/mobile/index.js +656 -0
  14. package/es/composite-comp/dito/components/AffiliateRecommend/mobile/index.less +76 -0
  15. package/es/composite-comp/dito/components/AffiliateRecommend/pc/index.js +725 -0
  16. package/es/composite-comp/dito/components/AffiliateRecommend/pc/index.less +124 -0
  17. package/es/composite-comp/dito/components/SignBoard/mobile/index.js +1 -1
  18. package/es/composite-comp/dito/config-panels/AffiliateRecommendConfig/RecommendConfigContent/index.js +102 -0
  19. package/es/composite-comp/dito/config-panels/AffiliateRecommendConfig/RecommendConfigContent/index.less +0 -0
  20. package/es/composite-comp/dito/config-panels/AffiliateRecommendConfig/RecommendConfigGroup/index.js +145 -0
  21. package/es/composite-comp/dito/config-panels/AffiliateRecommendConfig/RecommendConfigGroup/index.less +16 -0
  22. package/es/composite-comp/dito/config-panels/AffiliateRecommendConfig/imgs/defaultImg.png +0 -0
  23. package/es/composite-comp/dito/config-panels/AffiliateRecommendConfig/index.js +141 -0
  24. package/es/composite-comp/dito/config-panels/RecommendConfig/RecommendConfigGroup/index.js +10 -9
  25. package/es/composite-comp/dito/second-config-panels/AffiliateRecommendSecondConfig/AIRecommendation/index.js +431 -0
  26. package/es/composite-comp/dito/second-config-panels/AffiliateRecommendSecondConfig/index.js +214 -0
  27. package/es/composite-comp/dito/second-config-panels/AffiliateRecommendSecondConfig/index.less +15 -0
  28. package/es/constants/component-types.js +9 -3
  29. package/es/constants/index.js +4 -0
  30. package/es/core/Designer/ConfigPanel/index.js +7 -2
  31. package/es/core/Designer/LeftTitle/index.js +1 -1
  32. package/es/core/Renderer/index.js +20 -21
  33. package/es/meta-comp/components/Text/index.js +16 -0
  34. package/es/utils/businessUtil.js +6 -1
  35. package/lib/common/AffiliateProductModal/index.js +582 -0
  36. package/lib/common/AffiliateProductModal/index.less +146 -0
  37. package/lib/common/ProductModal/index.js +1 -2
  38. package/lib/common/ProductSource/index.js +42 -10
  39. package/lib/composite-comp/common/components/AffiliateProductItem/imgs/icon-Balance2.svg +9 -0
  40. package/lib/composite-comp/common/components/AffiliateProductItem/imgs/icon-Koin.svg +40 -0
  41. package/lib/composite-comp/common/components/AffiliateProductItem/index.js +175 -0
  42. package/lib/composite-comp/common/components/AffiliateProductItem/index.less +107 -0
  43. package/lib/composite-comp/common/components/ProductItem/index.js +8 -6
  44. package/lib/composite-comp/common/components/ProductItem/index.less +28 -22
  45. package/lib/composite-comp/dito/components/AffiliateRecommend/defaultJSON.js +243 -0
  46. package/lib/composite-comp/dito/components/AffiliateRecommend/index.js +90 -0
  47. package/lib/composite-comp/dito/components/AffiliateRecommend/mobile/index.js +656 -0
  48. package/lib/composite-comp/dito/components/AffiliateRecommend/mobile/index.less +76 -0
  49. package/lib/composite-comp/dito/components/AffiliateRecommend/pc/index.js +725 -0
  50. package/lib/composite-comp/dito/components/AffiliateRecommend/pc/index.less +124 -0
  51. package/lib/composite-comp/dito/components/SignBoard/mobile/index.js +1 -1
  52. package/lib/composite-comp/dito/config-panels/AffiliateRecommendConfig/RecommendConfigContent/index.js +102 -0
  53. package/lib/composite-comp/dito/config-panels/AffiliateRecommendConfig/RecommendConfigContent/index.less +0 -0
  54. package/lib/composite-comp/dito/config-panels/AffiliateRecommendConfig/RecommendConfigGroup/index.js +145 -0
  55. package/lib/composite-comp/dito/config-panels/AffiliateRecommendConfig/RecommendConfigGroup/index.less +16 -0
  56. package/lib/composite-comp/dito/config-panels/AffiliateRecommendConfig/imgs/defaultImg.png +0 -0
  57. package/lib/composite-comp/dito/config-panels/AffiliateRecommendConfig/index.js +141 -0
  58. package/lib/composite-comp/dito/config-panels/RecommendConfig/RecommendConfigGroup/index.js +10 -9
  59. package/lib/composite-comp/dito/second-config-panels/AffiliateRecommendSecondConfig/AIRecommendation/index.js +431 -0
  60. package/lib/composite-comp/dito/second-config-panels/AffiliateRecommendSecondConfig/index.js +214 -0
  61. package/lib/composite-comp/dito/second-config-panels/AffiliateRecommendSecondConfig/index.less +15 -0
  62. package/lib/constants/component-types.js +9 -3
  63. package/lib/constants/index.js +4 -0
  64. package/lib/core/Designer/ConfigPanel/index.js +7 -2
  65. package/lib/core/Designer/LeftTitle/index.js +1 -1
  66. package/lib/core/Renderer/index.js +20 -21
  67. package/lib/meta-comp/components/Text/index.js +16 -0
  68. package/lib/utils/businessUtil.js +6 -1
  69. package/package.json +1 -1
@@ -0,0 +1,725 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _macy = _interopRequireDefault(require("macy"));
11
+
12
+ require("./index.less");
13
+
14
+ var _classnames = _interopRequireDefault(require("classnames"));
15
+
16
+ var _lodash = require("lodash");
17
+
18
+ var _lodash2 = _interopRequireDefault(require("lodash.throttle"));
19
+
20
+ var _mobx = require("../../../../../mobx");
21
+
22
+ var _AffiliateProductItem = _interopRequireDefault(require("../../../../common/components/AffiliateProductItem"));
23
+
24
+ var _components = require("../../../../../meta-comp/components");
25
+
26
+ var _storeUtil = require("../../../../../utils/storeUtil");
27
+
28
+ var _commonUtil = require("../../../../../utils/commonUtil");
29
+
30
+ var _coreUtil = require("../../../../../utils/coreUtil");
31
+
32
+ var _Iconfont = _interopRequireDefault(require("../../../../../common/Iconfont"));
33
+
34
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
35
+
36
+ var __extends = void 0 && (void 0).__extends || function () {
37
+ var _extendStatics = function extendStatics(d, b) {
38
+ _extendStatics = Object.setPrototypeOf || {
39
+ __proto__: []
40
+ } instanceof Array && function (d, b) {
41
+ d.__proto__ = b;
42
+ } || function (d, b) {
43
+ for (var p in b) {
44
+ if (b.hasOwnProperty(p)) d[p] = b[p];
45
+ }
46
+ };
47
+
48
+ return _extendStatics(d, b);
49
+ };
50
+
51
+ return function (d, b) {
52
+ _extendStatics(d, b);
53
+
54
+ function __() {
55
+ this.constructor = d;
56
+ }
57
+
58
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
59
+ };
60
+ }();
61
+
62
+ var __assign = void 0 && (void 0).__assign || function () {
63
+ __assign = Object.assign || function (t) {
64
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
65
+ s = arguments[i];
66
+
67
+ for (var p in s) {
68
+ if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
69
+ }
70
+ }
71
+
72
+ return t;
73
+ };
74
+
75
+ return __assign.apply(this, arguments);
76
+ };
77
+
78
+ var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
79
+ function adopt(value) {
80
+ return value instanceof P ? value : new P(function (resolve) {
81
+ resolve(value);
82
+ });
83
+ }
84
+
85
+ return new (P || (P = Promise))(function (resolve, reject) {
86
+ function fulfilled(value) {
87
+ try {
88
+ step(generator.next(value));
89
+ } catch (e) {
90
+ reject(e);
91
+ }
92
+ }
93
+
94
+ function rejected(value) {
95
+ try {
96
+ step(generator["throw"](value));
97
+ } catch (e) {
98
+ reject(e);
99
+ }
100
+ }
101
+
102
+ function step(result) {
103
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
104
+ }
105
+
106
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
107
+ });
108
+ };
109
+
110
+ var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
111
+ var _ = {
112
+ label: 0,
113
+ sent: function sent() {
114
+ if (t[0] & 1) throw t[1];
115
+ return t[1];
116
+ },
117
+ trys: [],
118
+ ops: []
119
+ },
120
+ f,
121
+ y,
122
+ t,
123
+ g;
124
+ return g = {
125
+ next: verb(0),
126
+ "throw": verb(1),
127
+ "return": verb(2)
128
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
129
+ return this;
130
+ }), g;
131
+
132
+ function verb(n) {
133
+ return function (v) {
134
+ return step([n, v]);
135
+ };
136
+ }
137
+
138
+ function step(op) {
139
+ if (f) throw new TypeError("Generator is already executing.");
140
+
141
+ while (_) {
142
+ try {
143
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
144
+ if (y = 0, t) op = [op[0] & 2, t.value];
145
+
146
+ switch (op[0]) {
147
+ case 0:
148
+ case 1:
149
+ t = op;
150
+ break;
151
+
152
+ case 4:
153
+ _.label++;
154
+ return {
155
+ value: op[1],
156
+ done: false
157
+ };
158
+
159
+ case 5:
160
+ _.label++;
161
+ y = op[1];
162
+ op = [0];
163
+ continue;
164
+
165
+ case 7:
166
+ op = _.ops.pop();
167
+
168
+ _.trys.pop();
169
+
170
+ continue;
171
+
172
+ default:
173
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
174
+ _ = 0;
175
+ continue;
176
+ }
177
+
178
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
179
+ _.label = op[1];
180
+ break;
181
+ }
182
+
183
+ if (op[0] === 6 && _.label < t[1]) {
184
+ _.label = t[1];
185
+ t = op;
186
+ break;
187
+ }
188
+
189
+ if (t && _.label < t[2]) {
190
+ _.label = t[2];
191
+
192
+ _.ops.push(op);
193
+
194
+ break;
195
+ }
196
+
197
+ if (t[2]) _.ops.pop();
198
+
199
+ _.trys.pop();
200
+
201
+ continue;
202
+ }
203
+
204
+ op = body.call(thisArg, _);
205
+ } catch (e) {
206
+ op = [6, e];
207
+ y = 0;
208
+ } finally {
209
+ f = t = 0;
210
+ }
211
+ }
212
+
213
+ if (op[0] & 5) throw op[1];
214
+ return {
215
+ value: op[0] ? op[1] : void 0,
216
+ done: true
217
+ };
218
+ }
219
+ };
220
+
221
+ var __spreadArrays = void 0 && (void 0).__spreadArrays || function () {
222
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) {
223
+ s += arguments[i].length;
224
+ }
225
+
226
+ for (var r = Array(s), k = 0, i = 0; i < il; i++) {
227
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) {
228
+ r[k] = a[j];
229
+ }
230
+ }
231
+
232
+ return r;
233
+ };
234
+
235
+ var RecommendPc =
236
+ /** @class */
237
+ function (_super) {
238
+ __extends(RecommendPc, _super);
239
+
240
+ function RecommendPc() {
241
+ var _this = _super !== null && _super.apply(this, arguments) || this;
242
+
243
+ _this.preData = {};
244
+ _this.preLayout = '';
245
+ _this.preContent = '';
246
+ _this.preSpacing = '';
247
+ _this._cache = (0, _coreUtil.isDesignMode)() ? {} : (0, _commonUtil.ensure)(function () {
248
+ return (0, _storeUtil.getMagicStore)("recommend_" + _this.props.panelProps.id);
249
+ }, {});
250
+ _this.scrollRef = /*#__PURE__*/_react["default"].createRef();
251
+ _this.state = __assign({
252
+ contentWidth: 0,
253
+ tabIndex: 0,
254
+ tabLeft: 0,
255
+ tabWidth: 0,
256
+ groupSource: [],
257
+ hideTabs: false,
258
+ scrollToLeftDisabled: true,
259
+ scrollToRightDisabled: true
260
+ }, _this._cache);
261
+
262
+ _this.listenWidth = function () {
263
+ setTimeout(function () {
264
+ var renderContainer = document.querySelector(".macyContainer_" + _this.props.panelProps.id) || document.querySelector(".scrollContainer_" + _this.props.panelProps.id);
265
+ if (renderContainer) _this.setState({
266
+ contentWidth: renderContainer.offsetWidth
267
+ });
268
+ });
269
+ };
270
+
271
+ _this.setScrollDisabled = function (scrollDom) {
272
+ var scrollToLeftDisabled = scrollDom.scrollLeft === 0;
273
+ var scrollToRightDisabled = scrollDom.clientWidth + scrollDom.scrollLeft >= scrollDom.scrollWidth;
274
+
275
+ _this.setState({
276
+ scrollToLeftDisabled: scrollToLeftDisabled,
277
+ scrollToRightDisabled: scrollToRightDisabled
278
+ });
279
+ };
280
+
281
+ _this.initTab = function (index, hideTabs) {
282
+ var selectedTabDom = document.querySelector(".tab-select-wrap .tabTitle:nth-child(" + (index + 1) + ")");
283
+ var tabLeft = 0;
284
+ var tabWidth = 0;
285
+
286
+ if (selectedTabDom && !hideTabs) {
287
+ tabLeft = selectedTabDom.offsetLeft;
288
+ tabWidth = selectedTabDom.offsetWidth;
289
+ }
290
+
291
+ _this.setState({
292
+ tabLeft: tabLeft,
293
+ tabWidth: tabWidth
294
+ });
295
+ };
296
+
297
+ _this.getTabBarActiveColor = function (_panelProps) {
298
+ var tabIndex = _this.state.tabIndex;
299
+ return (0, _commonUtil.ensure)(function () {
300
+ return _panelProps.groupSource[tabIndex].hover.groupName.content.color;
301
+ }, '#1890ff');
302
+ };
303
+
304
+ _this.getProductList = function (index) {
305
+ return __awaiter(_this, void 0, void 0, function () {
306
+ var panelProps, groupSource, recommendId, cache, _a, prodIds, newData, res, e_1, _cache;
307
+
308
+ var _b, _c, _d;
309
+
310
+ var _this = this;
311
+
312
+ return __generator(this, function (_e) {
313
+ switch (_e.label) {
314
+ case 0:
315
+ panelProps = this.props.panelProps;
316
+ groupSource = this.state.groupSource;
317
+ recommendId = panelProps.id;
318
+
319
+ if (!(0, _coreUtil.isDesignMode)()) {
320
+ cache = (0, _storeUtil.getMagicStore)("recommend_" + recommendId);
321
+
322
+ if (cache) {
323
+ if ("products" + index in cache) {
324
+ this.setState((_b = {}, _b["products" + index] = cache["products" + index], _b), function () {
325
+ _this.resetLayout();
326
+ });
327
+ /** 如果数据未过期 */
328
+
329
+ if (cache.endTime > Date.now()) return [2
330
+ /*return*/
331
+ ];
332
+ }
333
+ }
334
+ }
335
+
336
+ _a = (groupSource[index] || {}).prodIds, prodIds = _a === void 0 ? '' : _a;
337
+ newData = [];
338
+ _e.label = 1;
339
+
340
+ case 1:
341
+ _e.trys.push([1, 5,, 6]);
342
+
343
+ if (!(groupSource.length > 0)) return [3
344
+ /*break*/
345
+ , 3];
346
+
347
+ if (!prodIds) {
348
+ return [2
349
+ /*return*/
350
+ ];
351
+ }
352
+
353
+ return [4
354
+ /*yield*/
355
+ , (0, _commonUtil.commonFetch)('/designer/v1/h5/nuri/distribute/product', {
356
+ affiliateProductIds: prodIds
357
+ }, 'GET')];
358
+
359
+ case 2:
360
+ res = _e.sent();
361
+ newData = __spreadArrays(res.list);
362
+ return [3
363
+ /*break*/
364
+ , 4];
365
+
366
+ case 3:
367
+ newData = [];
368
+ _e.label = 4;
369
+
370
+ case 4:
371
+ return [3
372
+ /*break*/
373
+ , 6];
374
+
375
+ case 5:
376
+ e_1 = _e.sent();
377
+ newData = [];
378
+ return [3
379
+ /*break*/
380
+ , 6];
381
+
382
+ case 6:
383
+ if (!(0, _coreUtil.isDesignMode)()) {
384
+ _cache = (0, _storeUtil.getMagicStore)("recommend_" + recommendId);
385
+ (0, _storeUtil.setMagicStore)("recommend_" + recommendId, __assign(__assign({}, _cache), (_c = {}, _c["products" + index] = newData, _c.endTime = Date.now() + 3 * 60 * 1000, _c)));
386
+ }
387
+
388
+ this.setState((_d = {}, _d["products" + index] = newData, _d), function () {
389
+ _this.resetLayout();
390
+ });
391
+ return [2
392
+ /*return*/
393
+ ];
394
+ }
395
+ });
396
+ });
397
+ };
398
+
399
+ _this.resetLayout = function () {
400
+ var customize = _this.props.panelProps.customize;
401
+ if (customize.layout.pcLayout !== 'layout1') return;
402
+ setTimeout(function () {
403
+ if (document.querySelector(".macyContainer_" + _this.props.panelProps.id)) {
404
+ _this.getMacy(".macyContainer_" + _this.props.panelProps.id, customize.pcRowNum);
405
+ }
406
+ }, 10);
407
+ };
408
+
409
+ _this.getMacy = function (container, columns) {
410
+ var masonryNew = new _macy["default"]({
411
+ container: container,
412
+ trueOrder: false,
413
+ waitForImages: false,
414
+ useOwnImageLoader: false,
415
+ margin: {
416
+ x: 24,
417
+ y: 24
418
+ },
419
+ columns: columns
420
+ });
421
+ masonryNew.runOnImageLoad(function () {
422
+ masonryNew.recalculate(true);
423
+ }, true);
424
+ };
425
+
426
+ _this.onTabClick = function (e, index) {
427
+ var tabIndex = _this.state.tabIndex;
428
+ if (tabIndex === index) return; // e.currentTarget.scrollIntoView(false);
429
+
430
+ _this.setState({
431
+ tabIndex: index
432
+ }, function () {
433
+ _this.resetLayout();
434
+
435
+ _this.initTab(index);
436
+ });
437
+
438
+ _this.getProductList(index);
439
+
440
+ setTimeout(function () {
441
+ var scrollDom = _this.scrollRef.current;
442
+
443
+ if (scrollDom) {
444
+ _this.setScrollDisabled(scrollDom);
445
+
446
+ scrollDom.onscroll = (0, _lodash2["default"])(function () {
447
+ _this.setScrollDisabled(scrollDom);
448
+ }, 500);
449
+ }
450
+ }, 0);
451
+ };
452
+
453
+ _this.scrollToRight = function () {
454
+ var scrollDom = _this.scrollRef.current;
455
+
456
+ if (scrollDom.clientWidth + scrollDom.scrollLeft < scrollDom.scrollWidth) {
457
+ scrollDom.scrollTo(scrollDom.scrollLeft + scrollDom.clientWidth, 0);
458
+ }
459
+ };
460
+
461
+ _this.scrollToLeft = function () {
462
+ var scrollDom = _this.scrollRef.current;
463
+
464
+ if (scrollDom.scrollLeft > 0) {
465
+ scrollDom.scrollTo(scrollDom.scrollLeft - scrollDom.clientWidth, 0);
466
+ }
467
+ };
468
+
469
+ return _this;
470
+ }
471
+
472
+ RecommendPc.prototype.componentDidMount = function () {
473
+ var _this = this;
474
+
475
+ var panelProps = this.props.panelProps;
476
+ var source = [];
477
+ panelProps.groupSource.map(function (m) {
478
+ var show = m.image.open || m.groupName.open;
479
+ if (show) source.push(m);
480
+ });
481
+ this.setState({
482
+ groupSource: source
483
+ }, function () {
484
+ _this.initTab(0);
485
+
486
+ _this.getProductList(0);
487
+ });
488
+ setTimeout(function () {
489
+ var scrollDom = _this.scrollRef.current;
490
+
491
+ if (scrollDom) {
492
+ _this.setScrollDisabled(scrollDom);
493
+
494
+ scrollDom.onscroll = (0, _lodash2["default"])(function () {
495
+ _this.setScrollDisabled(scrollDom);
496
+ }, 500);
497
+ }
498
+ }, 0);
499
+ this.listenWidth();
500
+ window.addEventListener('resize', (0, _lodash.debounce)(this.listenWidth));
501
+ };
502
+
503
+ RecommendPc.prototype.componentWillUnmount = function () {
504
+ window.removeEventListener('resize', this.listenWidth);
505
+ };
506
+
507
+ RecommendPc.prototype.componentWillReceiveProps = function (nextProps) {
508
+ var _this = this;
509
+
510
+ var tabIndex = this.state.tabIndex;
511
+ var panelProps = nextProps.panelProps;
512
+ var source = [];
513
+ var hideTabs = false;
514
+ panelProps.groupSource.map(function (m) {
515
+ var show = m.image.open || m.groupName.open;
516
+ if (show) source.push(m);
517
+ });
518
+
519
+ if (source.length === 0) {
520
+ if (panelProps.groupSource.length > 0) source.push(panelProps.groupSource[0]);
521
+ hideTabs = true;
522
+ }
523
+
524
+ this.setState({
525
+ groupSource: source
526
+ }, function () {
527
+ var groupSource = _this.state.groupSource;
528
+
529
+ if (JSON.stringify(groupSource) === _this.preData) {
530
+ return;
531
+ }
532
+
533
+ _this.preData = JSON.stringify(groupSource);
534
+ var newTabIndex = tabIndex;
535
+ if (tabIndex >= source.length) newTabIndex = 0;
536
+
537
+ _this.initTab(newTabIndex, hideTabs);
538
+
539
+ _this.getProductList(newTabIndex);
540
+
541
+ _this.setState({
542
+ tabIndex: newTabIndex,
543
+ hideTabs: hideTabs
544
+ });
545
+ });
546
+ var curLayout = JSON.stringify(panelProps.customize);
547
+
548
+ if (curLayout !== this.preLayout) {
549
+ this.resetLayout();
550
+ setTimeout(function () {
551
+ var scrollDom = _this.scrollRef.current;
552
+
553
+ if (scrollDom) {
554
+ _this.setScrollDisabled(scrollDom);
555
+
556
+ scrollDom.onscroll = (0, _lodash2["default"])(function () {
557
+ _this.setScrollDisabled(scrollDom);
558
+ }, 500);
559
+ }
560
+ }, 0);
561
+ }
562
+
563
+ var curContent = JSON.stringify(panelProps.content);
564
+ var curSpacing = JSON.stringify(panelProps.spacing);
565
+
566
+ if (curLayout !== this.preLayout || curSpacing !== this.preSpacing) {
567
+ this.listenWidth();
568
+ }
569
+
570
+ if (curContent !== this.preContent || curSpacing !== this.preSpacing) {
571
+ this.resetLayout();
572
+ }
573
+
574
+ this.preLayout = curLayout;
575
+ this.preContent = curContent;
576
+ this.preSpacing = curSpacing;
577
+ };
578
+
579
+ RecommendPc.prototype.render = function () {
580
+ var _this = this;
581
+
582
+ var panelProps = this.props.panelProps;
583
+ var _a = this.state,
584
+ tabIndex = _a.tabIndex,
585
+ tabLeft = _a.tabLeft,
586
+ tabWidth = _a.tabWidth,
587
+ groupSource = _a.groupSource,
588
+ hideTabs = _a.hideTabs,
589
+ scrollToLeftDisabled = _a.scrollToLeftDisabled,
590
+ scrollToRightDisabled = _a.scrollToRightDisabled,
591
+ contentWidth = _a.contentWidth;
592
+ var products = this.state["products" + tabIndex] || [];
593
+ var isDivide = false;
594
+ var layout = panelProps.customize.layout.pcLayout;
595
+
596
+ var _seeAll = (0, _commonUtil.ensure)(function () {
597
+ return groupSource[tabIndex].seeAll;
598
+ }, '');
599
+
600
+ var imgSize = 140;
601
+ var otherWidth = layout === 'layout3' ? 100 : 0;
602
+ var colNumber = layout === 'layout1' ? panelProps.customize.pcRowNum : panelProps.customize.pcRowNum + 0.5;
603
+ var spaceNumber = layout === 'layout1' ? panelProps.customize.pcRowNum - 1 : panelProps.customize.pcRowNum;
604
+ if (contentWidth) imgSize = (contentWidth - 24 * spaceNumber - otherWidth) / colNumber;
605
+ return /*#__PURE__*/_react["default"].createElement("div", {
606
+ className: "m-recommend-pc"
607
+ }, !hideTabs && /*#__PURE__*/_react["default"].createElement("div", {
608
+ className: "tab-select-wrap"
609
+ }, groupSource.map(function (tab, index) {
610
+ var _image = index == tabIndex && tab.hover.open && tab.hover.image.open ? tab.hover.image : tab.image;
611
+
612
+ var _groupName = index == tabIndex && tab.hover.open && tab.hover.groupName.open ? tab.hover.groupName : tab.groupName;
613
+
614
+ return /*#__PURE__*/_react["default"].createElement("div", {
615
+ key: tab.id,
616
+ className: "tabTitle",
617
+ onClick: function onClick(e) {
618
+ _this.onTabClick(e, index);
619
+
620
+ _mobx.store.setState({
621
+ clickedGroup: tab.id,
622
+ clickedFloor: _mobx.store.getFloorIdByGroupId(tab.id)
623
+ });
624
+ },
625
+ style: {
626
+ flex: ~~isDivide
627
+ }
628
+ }, tab.image.open && _image && /*#__PURE__*/_react["default"].createElement(_components.MetaImage, {
629
+ data: _image
630
+ }), tab.groupName.open && /*#__PURE__*/_react["default"].createElement(_components.MetaText, {
631
+ data: _groupName,
632
+ onTextInput: function onTextInput(text) {
633
+ tab.hover.groupName.text = text;
634
+ tab.groupName.text = text;
635
+ }
636
+ }));
637
+ }), /*#__PURE__*/_react["default"].createElement("div", {
638
+ className: "active-line",
639
+ style: {
640
+ width: tabWidth,
641
+ transform: "translateX(" + tabLeft + "px)",
642
+ background: this.getTabBarActiveColor(panelProps)
643
+ }
644
+ })), /*#__PURE__*/_react["default"].createElement("div", {
645
+ className: "tab-content"
646
+ }, layout !== 'layout1' && /*#__PURE__*/_react["default"].createElement("div", {
647
+ className: "arrow-icon left",
648
+ onClick: function onClick() {
649
+ return _this.scrollToLeft();
650
+ }
651
+ }, /*#__PURE__*/_react["default"].createElement(_Iconfont["default"], {
652
+ color: scrollToLeftDisabled ? '#BDC1C8' : '#232F46',
653
+ size: (0, _commonUtil.convertToRem)(20),
654
+ type: "icon-outlined-left"
655
+ })), layout === 'layout1' ? /*#__PURE__*/_react["default"].createElement("div", {
656
+ className: "tab-list"
657
+ }, /*#__PURE__*/_react["default"].createElement("div", {
658
+ key: "macyContainer",
659
+ ref: this.scrollRef,
660
+ className: "macyContainer macyContainer_" + panelProps.id
661
+ }, products.map(function (item) {
662
+ return /*#__PURE__*/_react["default"].createElement(_AffiliateProductItem["default"], {
663
+ key: item.productId,
664
+ data: item,
665
+ fixHeight: true,
666
+ imgHeight: imgSize,
667
+ imgWidth: "100%" // onItemClick={() => clickUrl(`/product/detail/${item.offerId}`)}
668
+ ,
669
+ onItemClick: function onItemClick() {
670
+ return (0, _coreUtil.clickUrl)("proDetail-" + item.offerId);
671
+ },
672
+ panelProps: panelProps.content
673
+ });
674
+ })), _seeAll.open && products.length > 0 && /*#__PURE__*/_react["default"].createElement(_components.MetaButton, {
675
+ className: (0, _classnames["default"])('btnSeeAll', {
676
+ line: layout === 'layout1'
677
+ }),
678
+ data: _seeAll
679
+ })) : /*#__PURE__*/_react["default"].createElement("div", {
680
+ key: "scrollContainer",
681
+ ref: this.scrollRef,
682
+ className: (0, _classnames["default"])("scrollContainer scrollContainer_" + panelProps.id, {
683
+ pl_100: layout === 'layout3'
684
+ })
685
+ }, /*#__PURE__*/_react["default"].createElement("div", {
686
+ className: "scrollProductList"
687
+ }, products.map(function (item) {
688
+ return /*#__PURE__*/_react["default"].createElement("div", {
689
+ className: "productCard"
690
+ }, /*#__PURE__*/_react["default"].createElement(_AffiliateProductItem["default"], {
691
+ key: "scroll_" + item.productId,
692
+ data: item,
693
+ fixHeight: true,
694
+ imgHeight: imgSize,
695
+ imgWidth: imgSize // onItemClick={() => clickUrl(`/product/detail/${item.offerId}`)}
696
+ ,
697
+ onItemClick: function onItemClick() {
698
+ return (0, _coreUtil.clickUrl)("proDetail-" + item.offerId);
699
+ },
700
+ panelProps: panelProps.content,
701
+ showProgress: false
702
+ }));
703
+ })), _seeAll.open && products.length > 0 && /*#__PURE__*/_react["default"].createElement(_components.MetaButton, {
704
+ className: "btnSeeAll",
705
+ data: _seeAll
706
+ })), layout !== 'layout1' && /*#__PURE__*/_react["default"].createElement("div", {
707
+ className: "arrow-icon right",
708
+ onClick: function onClick() {
709
+ return _this.scrollToRight();
710
+ }
711
+ }, /*#__PURE__*/_react["default"].createElement(_Iconfont["default"], {
712
+ color: scrollToRightDisabled ? '#BDC1C8' : '#232F46',
713
+ size: (0, _commonUtil.convertToRem)(20),
714
+ type: "icon-outlined-right"
715
+ }))));
716
+ };
717
+
718
+ RecommendPc.defaultProps = {
719
+ panelProps: {}
720
+ };
721
+ return RecommendPc;
722
+ }(_react["default"].Component);
723
+
724
+ var _default = RecommendPc;
725
+ exports["default"] = _default;