@fonixtree/magic-design 0.0.36 → 0.0.38

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