@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.
- package/es/common/AffiliateProductModal/index.js +582 -0
- package/es/common/AffiliateProductModal/index.less +146 -0
- package/es/common/ProductModal/index.js +1 -2
- package/es/common/ProductSource/index.js +42 -10
- package/es/composite-comp/common/components/AffiliateProductItem/imgs/icon-Balance2.svg +9 -0
- package/es/composite-comp/common/components/AffiliateProductItem/imgs/icon-Koin.svg +40 -0
- package/es/composite-comp/common/components/AffiliateProductItem/index.js +175 -0
- package/es/composite-comp/common/components/AffiliateProductItem/index.less +107 -0
- package/es/composite-comp/common/components/ProductItem/index.js +8 -6
- package/es/composite-comp/common/components/ProductItem/index.less +28 -22
- package/es/composite-comp/dito/components/AffiliateRecommend/defaultJSON.js +243 -0
- package/es/composite-comp/dito/components/AffiliateRecommend/index.js +90 -0
- package/es/composite-comp/dito/components/AffiliateRecommend/mobile/index.js +656 -0
- package/es/composite-comp/dito/components/AffiliateRecommend/mobile/index.less +76 -0
- package/es/composite-comp/dito/components/AffiliateRecommend/pc/index.js +725 -0
- package/es/composite-comp/dito/components/AffiliateRecommend/pc/index.less +124 -0
- package/es/composite-comp/dito/components/SignBoard/mobile/index.js +1 -1
- package/es/composite-comp/dito/config-panels/AffiliateRecommendConfig/RecommendConfigContent/index.js +102 -0
- package/es/composite-comp/dito/config-panels/AffiliateRecommendConfig/RecommendConfigContent/index.less +0 -0
- package/es/composite-comp/dito/config-panels/AffiliateRecommendConfig/RecommendConfigGroup/index.js +145 -0
- package/es/composite-comp/dito/config-panels/AffiliateRecommendConfig/RecommendConfigGroup/index.less +16 -0
- package/es/composite-comp/dito/config-panels/AffiliateRecommendConfig/imgs/defaultImg.png +0 -0
- package/es/composite-comp/dito/config-panels/AffiliateRecommendConfig/index.js +141 -0
- package/es/composite-comp/dito/config-panels/RecommendConfig/RecommendConfigGroup/index.js +10 -9
- package/es/composite-comp/dito/second-config-panels/AffiliateRecommendSecondConfig/AIRecommendation/index.js +431 -0
- package/es/composite-comp/dito/second-config-panels/AffiliateRecommendSecondConfig/index.js +214 -0
- package/es/composite-comp/dito/second-config-panels/AffiliateRecommendSecondConfig/index.less +15 -0
- package/es/constants/component-types.js +9 -3
- package/es/constants/index.js +4 -0
- package/es/core/Designer/ConfigPanel/index.js +7 -2
- package/es/core/Designer/LeftTitle/index.js +1 -1
- package/es/core/Renderer/index.js +20 -21
- package/es/meta-comp/components/Text/index.js +16 -0
- package/es/utils/businessUtil.js +6 -1
- package/lib/common/AffiliateProductModal/index.js +582 -0
- package/lib/common/AffiliateProductModal/index.less +146 -0
- package/lib/common/ProductModal/index.js +1 -2
- package/lib/common/ProductSource/index.js +42 -10
- package/lib/composite-comp/common/components/AffiliateProductItem/imgs/icon-Balance2.svg +9 -0
- package/lib/composite-comp/common/components/AffiliateProductItem/imgs/icon-Koin.svg +40 -0
- package/lib/composite-comp/common/components/AffiliateProductItem/index.js +175 -0
- package/lib/composite-comp/common/components/AffiliateProductItem/index.less +107 -0
- package/lib/composite-comp/common/components/ProductItem/index.js +8 -6
- package/lib/composite-comp/common/components/ProductItem/index.less +28 -22
- package/lib/composite-comp/dito/components/AffiliateRecommend/defaultJSON.js +243 -0
- package/lib/composite-comp/dito/components/AffiliateRecommend/index.js +90 -0
- package/lib/composite-comp/dito/components/AffiliateRecommend/mobile/index.js +656 -0
- package/lib/composite-comp/dito/components/AffiliateRecommend/mobile/index.less +76 -0
- package/lib/composite-comp/dito/components/AffiliateRecommend/pc/index.js +725 -0
- package/lib/composite-comp/dito/components/AffiliateRecommend/pc/index.less +124 -0
- package/lib/composite-comp/dito/components/SignBoard/mobile/index.js +1 -1
- package/lib/composite-comp/dito/config-panels/AffiliateRecommendConfig/RecommendConfigContent/index.js +102 -0
- package/lib/composite-comp/dito/config-panels/AffiliateRecommendConfig/RecommendConfigContent/index.less +0 -0
- package/lib/composite-comp/dito/config-panels/AffiliateRecommendConfig/RecommendConfigGroup/index.js +145 -0
- package/lib/composite-comp/dito/config-panels/AffiliateRecommendConfig/RecommendConfigGroup/index.less +16 -0
- package/lib/composite-comp/dito/config-panels/AffiliateRecommendConfig/imgs/defaultImg.png +0 -0
- package/lib/composite-comp/dito/config-panels/AffiliateRecommendConfig/index.js +141 -0
- package/lib/composite-comp/dito/config-panels/RecommendConfig/RecommendConfigGroup/index.js +10 -9
- package/lib/composite-comp/dito/second-config-panels/AffiliateRecommendSecondConfig/AIRecommendation/index.js +431 -0
- package/lib/composite-comp/dito/second-config-panels/AffiliateRecommendSecondConfig/index.js +214 -0
- package/lib/composite-comp/dito/second-config-panels/AffiliateRecommendSecondConfig/index.less +15 -0
- package/lib/constants/component-types.js +9 -3
- package/lib/constants/index.js +4 -0
- package/lib/core/Designer/ConfigPanel/index.js +7 -2
- package/lib/core/Designer/LeftTitle/index.js +1 -1
- package/lib/core/Renderer/index.js +20 -21
- package/lib/meta-comp/components/Text/index.js +16 -0
- package/lib/utils/businessUtil.js +6 -1
- package/package.json +1 -1
|
@@ -0,0 +1,656 @@
|
|
|
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 _AffiliateProductItem = _interopRequireDefault(require("../../../../common/components/AffiliateProductItem"));
|
|
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: ''
|
|
233
|
+
},
|
|
234
|
+
layout2: {
|
|
235
|
+
w: 100,
|
|
236
|
+
h: 100
|
|
237
|
+
},
|
|
238
|
+
layout3: {
|
|
239
|
+
w: '100%',
|
|
240
|
+
h: ''
|
|
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.preContent = '';
|
|
263
|
+
_this.preSpacing = '';
|
|
264
|
+
_this._cache = (0, _coreUtil.isDesignMode)() ? {} : (0, _commonUtil.ensure)(function () {
|
|
265
|
+
return (0, _storeUtil.getMagicStore)("recommend_" + _this.props.panelProps.id);
|
|
266
|
+
}, {});
|
|
267
|
+
_this.state = __assign({
|
|
268
|
+
contentWidth: 0,
|
|
269
|
+
tabIndex: 0,
|
|
270
|
+
tabLeft: 0,
|
|
271
|
+
tabWidth: 0,
|
|
272
|
+
groupSource: [],
|
|
273
|
+
hideTabs: false
|
|
274
|
+
}, _this._cache);
|
|
275
|
+
|
|
276
|
+
_this.listenWidth = function () {
|
|
277
|
+
setTimeout(function () {
|
|
278
|
+
var renderContainer = document.querySelector(".macyContainer_" + _this.props.panelProps.id);
|
|
279
|
+
if (renderContainer) _this.setState({
|
|
280
|
+
contentWidth: renderContainer.offsetWidth
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
_this.initTab = function (index, hideTabs) {
|
|
286
|
+
var selectedTabDom = document.querySelector(".recommend_" + _this.props.panelProps.id + " .tab-select-wrap .tabTitle:nth-child(" + (index + 1) + ")");
|
|
287
|
+
var tabLeft = 0;
|
|
288
|
+
var tabWidth = 0;
|
|
289
|
+
|
|
290
|
+
if (selectedTabDom && !hideTabs) {
|
|
291
|
+
tabLeft = selectedTabDom.offsetLeft;
|
|
292
|
+
tabWidth = selectedTabDom.offsetWidth;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
_this.setState({
|
|
296
|
+
tabLeft: tabLeft,
|
|
297
|
+
tabWidth: tabWidth
|
|
298
|
+
});
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
_this.getTabBarActiveColor = function (_panelProps) {
|
|
302
|
+
var tabIndex = _this.state.tabIndex;
|
|
303
|
+
var activeHoverGroupName = _panelProps.groupSource[tabIndex].hover;
|
|
304
|
+
return activeHoverGroupName.open ? (0, _commonUtil.ensure)(function () {
|
|
305
|
+
return activeHoverGroupName.groupName.content.color;
|
|
306
|
+
}, '#CE1126') : '#CE1126';
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
_this.getProductList = function (index) {
|
|
310
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
311
|
+
var panelProps, groupSource, recommendId, cache, _a, prodIds, newData, res, e_1, _cache;
|
|
312
|
+
|
|
313
|
+
var _b, _c, _d;
|
|
314
|
+
|
|
315
|
+
var _this = this;
|
|
316
|
+
|
|
317
|
+
return __generator(this, function (_e) {
|
|
318
|
+
switch (_e.label) {
|
|
319
|
+
case 0:
|
|
320
|
+
panelProps = this.props.panelProps;
|
|
321
|
+
groupSource = this.state.groupSource;
|
|
322
|
+
recommendId = panelProps.id;
|
|
323
|
+
|
|
324
|
+
if (!(0, _coreUtil.isDesignMode)()) {
|
|
325
|
+
cache = (0, _storeUtil.getMagicStore)("recommend_" + recommendId);
|
|
326
|
+
|
|
327
|
+
if (cache) {
|
|
328
|
+
if ("products" + index in cache) {
|
|
329
|
+
this.setState((_b = {}, _b["products" + index] = cache["products" + index], _b), function () {
|
|
330
|
+
_this.resetLayout();
|
|
331
|
+
});
|
|
332
|
+
/** 如果数据未过期 */
|
|
333
|
+
|
|
334
|
+
if (cache.endTime > Date.now()) return [2
|
|
335
|
+
/*return*/
|
|
336
|
+
];
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
_a = (groupSource[index] || {}).prodIds, prodIds = _a === void 0 ? '' : _a;
|
|
342
|
+
newData = [];
|
|
343
|
+
_e.label = 1;
|
|
344
|
+
|
|
345
|
+
case 1:
|
|
346
|
+
_e.trys.push([1, 5,, 6]);
|
|
347
|
+
|
|
348
|
+
if (!(groupSource.length > 0)) return [3
|
|
349
|
+
/*break*/
|
|
350
|
+
, 3];
|
|
351
|
+
|
|
352
|
+
if (!prodIds) {
|
|
353
|
+
return [2
|
|
354
|
+
/*return*/
|
|
355
|
+
];
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
return [4
|
|
359
|
+
/*yield*/
|
|
360
|
+
, (0, _commonUtil.commonFetch)('/designer/v1/h5/nuri/distribute/product', {
|
|
361
|
+
affiliateProductIds: prodIds
|
|
362
|
+
}, 'GET')];
|
|
363
|
+
|
|
364
|
+
case 2:
|
|
365
|
+
res = _e.sent();
|
|
366
|
+
newData = __spreadArrays(res.list);
|
|
367
|
+
return [3
|
|
368
|
+
/*break*/
|
|
369
|
+
, 4];
|
|
370
|
+
|
|
371
|
+
case 3:
|
|
372
|
+
newData = [];
|
|
373
|
+
_e.label = 4;
|
|
374
|
+
|
|
375
|
+
case 4:
|
|
376
|
+
return [3
|
|
377
|
+
/*break*/
|
|
378
|
+
, 6];
|
|
379
|
+
|
|
380
|
+
case 5:
|
|
381
|
+
e_1 = _e.sent();
|
|
382
|
+
newData = [];
|
|
383
|
+
return [3
|
|
384
|
+
/*break*/
|
|
385
|
+
, 6];
|
|
386
|
+
|
|
387
|
+
case 6:
|
|
388
|
+
if (!(0, _coreUtil.isDesignMode)()) {
|
|
389
|
+
_cache = (0, _storeUtil.getMagicStore)("recommend_" + recommendId);
|
|
390
|
+
(0, _storeUtil.setMagicStore)("recommend_" + recommendId, __assign(__assign({}, _cache), (_c = {}, _c["products" + index] = newData, _c.endTime = Date.now() + 3 * 60 * 1000, _c)));
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
this.setState((_d = {}, _d["products" + index] = newData, _d), function () {
|
|
394
|
+
_this.resetLayout();
|
|
395
|
+
});
|
|
396
|
+
return [2
|
|
397
|
+
/*return*/
|
|
398
|
+
];
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
});
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
_this.resetLayout = function () {
|
|
405
|
+
var layout = _this.props.panelProps.customize.layout.h5Layout;
|
|
406
|
+
var LAYOUT_COLUMN = {
|
|
407
|
+
layout1: 2,
|
|
408
|
+
layout2: 1,
|
|
409
|
+
layout3: 3
|
|
410
|
+
};
|
|
411
|
+
if (!LAYOUT_COLUMN[layout]) return;
|
|
412
|
+
setTimeout(function () {
|
|
413
|
+
if (document.querySelector(".macyContainer_" + _this.props.panelProps.id)) {
|
|
414
|
+
_this.getMacy(".macyContainer_" + _this.props.panelProps.id, LAYOUT_COLUMN[layout]);
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
_this.getMacy = function (container, columns) {
|
|
420
|
+
var masonryNew = new _macy["default"]({
|
|
421
|
+
container: container,
|
|
422
|
+
trueOrder: false,
|
|
423
|
+
waitForImages: false,
|
|
424
|
+
useOwnImageLoader: false,
|
|
425
|
+
margin: {
|
|
426
|
+
x: 12,
|
|
427
|
+
y: 12
|
|
428
|
+
},
|
|
429
|
+
columns: columns
|
|
430
|
+
});
|
|
431
|
+
masonryNew.runOnImageLoad(function () {
|
|
432
|
+
masonryNew.recalculate(true);
|
|
433
|
+
}, true);
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
_this.onTabClick = function (e, index) {
|
|
437
|
+
var tabIndex = _this.state.tabIndex;
|
|
438
|
+
if (tabIndex === index) return; // e.currentTarget.scrollIntoView(false);
|
|
439
|
+
|
|
440
|
+
_this.setState({
|
|
441
|
+
tabIndex: index
|
|
442
|
+
}, function () {
|
|
443
|
+
_this.resetLayout();
|
|
444
|
+
|
|
445
|
+
_this.initTab(index);
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
_this.getProductList(index);
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
return _this;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
RecommendMobile.prototype.componentDidMount = function () {// const { panelProps } = this.props;
|
|
455
|
+
// const source = [];
|
|
456
|
+
// panelProps.groupSource.map(m => {
|
|
457
|
+
// const show = m.image.open || m.groupName.open;
|
|
458
|
+
// if (show) source.push(m);
|
|
459
|
+
// });
|
|
460
|
+
// this.setState({ groupSource: source }, () => {
|
|
461
|
+
// this.initTab(0);
|
|
462
|
+
// this.getProductList(0);
|
|
463
|
+
// });
|
|
464
|
+
// this.listenWidth();
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
RecommendMobile.prototype.componentWillReceiveProps = function (nextProps) {
|
|
468
|
+
var _this = this;
|
|
469
|
+
|
|
470
|
+
var tabIndex = this.state.tabIndex;
|
|
471
|
+
var panelProps = nextProps.panelProps;
|
|
472
|
+
var source = [];
|
|
473
|
+
var hideTabs = false;
|
|
474
|
+
panelProps.groupSource.map(function (m) {
|
|
475
|
+
var show = m.image.open || m.groupName.open;
|
|
476
|
+
if (show) source.push(m);
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
if (source.length === 0) {
|
|
480
|
+
if (panelProps.groupSource.length > 0) source.push(panelProps.groupSource[0]);
|
|
481
|
+
hideTabs = true;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
this.setState({
|
|
485
|
+
groupSource: source
|
|
486
|
+
}, function () {
|
|
487
|
+
var groupSource = _this.state.groupSource;
|
|
488
|
+
|
|
489
|
+
if (JSON.stringify(groupSource) === _this.preData) {
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
_this.preData = JSON.stringify(groupSource);
|
|
494
|
+
var newTabIndex = tabIndex;
|
|
495
|
+
if (tabIndex >= source.length) newTabIndex = 0;
|
|
496
|
+
|
|
497
|
+
_this.initTab(newTabIndex, hideTabs);
|
|
498
|
+
|
|
499
|
+
_this.getProductList(newTabIndex);
|
|
500
|
+
|
|
501
|
+
_this.setState({
|
|
502
|
+
tabIndex: newTabIndex,
|
|
503
|
+
hideTabs: hideTabs
|
|
504
|
+
});
|
|
505
|
+
});
|
|
506
|
+
var curLayout = panelProps.customize.layout.h5Layout;
|
|
507
|
+
var curContent = JSON.stringify(panelProps.content);
|
|
508
|
+
var curSpacing = JSON.stringify(panelProps.spacing);
|
|
509
|
+
|
|
510
|
+
if (curLayout !== this.preLayout || curSpacing !== this.preSpacing) {
|
|
511
|
+
this.listenWidth();
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
if (curLayout !== this.preLayout || curContent !== this.preContent || curSpacing !== this.preSpacing) {
|
|
515
|
+
this.resetLayout();
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
this.preLayout = curLayout;
|
|
519
|
+
this.preContent = curContent;
|
|
520
|
+
this.preSpacing = curSpacing;
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
RecommendMobile.prototype.render = function () {
|
|
524
|
+
var _this = this;
|
|
525
|
+
|
|
526
|
+
var panelProps = this.props.panelProps;
|
|
527
|
+
var _a = this.state,
|
|
528
|
+
tabIndex = _a.tabIndex,
|
|
529
|
+
tabLeft = _a.tabLeft,
|
|
530
|
+
tabWidth = _a.tabWidth,
|
|
531
|
+
groupSource = _a.groupSource,
|
|
532
|
+
hideTabs = _a.hideTabs,
|
|
533
|
+
contentWidth = _a.contentWidth;
|
|
534
|
+
var products = this.state["products" + tabIndex] || [];
|
|
535
|
+
var isDivide = groupSource.length <= 3;
|
|
536
|
+
var layout = panelProps.customize.layout.h5Layout;
|
|
537
|
+
|
|
538
|
+
var _seeAll = (0, _commonUtil.ensure)(function () {
|
|
539
|
+
return groupSource[tabIndex].seeAll;
|
|
540
|
+
}, '');
|
|
541
|
+
|
|
542
|
+
var imgWidth = (0, _commonUtil.ensure)(function () {
|
|
543
|
+
return LAYOUT_IMAGE_SIZE[layout].w;
|
|
544
|
+
}, 140);
|
|
545
|
+
var imgHeight = (0, _commonUtil.ensure)(function () {
|
|
546
|
+
return LAYOUT_IMAGE_SIZE[layout].h;
|
|
547
|
+
}, 140);
|
|
548
|
+
if (layout === 'layout1' && contentWidth) imgHeight = (contentWidth - 12) / 2;
|
|
549
|
+
if (layout === 'layout3' && contentWidth) imgHeight = (contentWidth - 12 * 2) / 3;
|
|
550
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
551
|
+
className: "m-recommend-mobile recommend_" + panelProps.id
|
|
552
|
+
}, !hideTabs && /*#__PURE__*/_react["default"].createElement("div", {
|
|
553
|
+
className: "tab-select-wrap"
|
|
554
|
+
}, groupSource.map(function (tab, index) {
|
|
555
|
+
var _image = index == tabIndex && tab.hover.open && tab.hover.image.open ? tab.hover.image : tab.image;
|
|
556
|
+
|
|
557
|
+
var _groupName = index == tabIndex && tab.hover.open && tab.hover.groupName.open ? tab.hover.groupName : tab.groupName;
|
|
558
|
+
|
|
559
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
560
|
+
key: tab.id,
|
|
561
|
+
className: "tabTitle",
|
|
562
|
+
onClick: function onClick(e) {
|
|
563
|
+
_this.onTabClick(e, index);
|
|
564
|
+
|
|
565
|
+
_mobx.store.setState({
|
|
566
|
+
clickedGroup: tab.id,
|
|
567
|
+
clickedFloor: _mobx.store.getFloorIdByGroupId(tab.id)
|
|
568
|
+
});
|
|
569
|
+
},
|
|
570
|
+
style: {
|
|
571
|
+
flex: ~~isDivide
|
|
572
|
+
}
|
|
573
|
+
}, tab.image.open && _image && /*#__PURE__*/_react["default"].createElement(_components.MetaImage, {
|
|
574
|
+
data: _image
|
|
575
|
+
}), tab.groupName.open && /*#__PURE__*/_react["default"].createElement(_components.MetaText, {
|
|
576
|
+
data: _groupName,
|
|
577
|
+
onTextInput: function onTextInput(text) {
|
|
578
|
+
tab.hover.groupName.text = text;
|
|
579
|
+
tab.groupName.text = text;
|
|
580
|
+
}
|
|
581
|
+
}));
|
|
582
|
+
}), groupSource.length > 0 && /*#__PURE__*/_react["default"].createElement("div", {
|
|
583
|
+
className: "active-line",
|
|
584
|
+
style: {
|
|
585
|
+
width: tabWidth,
|
|
586
|
+
transform: "translateX(" + tabLeft + "px)",
|
|
587
|
+
background: this.getTabBarActiveColor(panelProps)
|
|
588
|
+
}
|
|
589
|
+
})), ['layout1', 'layout2', 'layout3'].includes(layout) ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
|
|
590
|
+
key: "macyContainer",
|
|
591
|
+
className: "macyContainer macyContainer_" + panelProps.id
|
|
592
|
+
}, products.map(function (item) {
|
|
593
|
+
return /*#__PURE__*/_react["default"].createElement(_AffiliateProductItem["default"], {
|
|
594
|
+
key: item.affiliateProductId,
|
|
595
|
+
data: item,
|
|
596
|
+
fixHeight: layout === 'layout3',
|
|
597
|
+
imgHeight: imgHeight,
|
|
598
|
+
imgWidth: imgWidth,
|
|
599
|
+
layout: layout === 'layout2' ? 'horizontal' : 'vertical' // onItemClick={() => clickUrl(`/product/detail/${item.offerId}?productId=${item.sppProductId || item.productId || ''}`)}
|
|
600
|
+
,
|
|
601
|
+
onItemClick: function onItemClick() {
|
|
602
|
+
/** PTO 定制GA */
|
|
603
|
+
if (window.magicDesign.pushGA) {
|
|
604
|
+
window.magicDesign.pushGA(item, 'select_item', {
|
|
605
|
+
event_action: 'Select Item'
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
(0, _coreUtil.clickUrl)("proDetail-" + (item === null || item === void 0 ? void 0 : item.offerId) + "-" + (item.sppProductId || item.affiliateProductId || ''));
|
|
610
|
+
},
|
|
611
|
+
panelProps: panelProps.content
|
|
612
|
+
});
|
|
613
|
+
})), _seeAll.open && products.length > 0 && /*#__PURE__*/_react["default"].createElement(_components.MetaButton, {
|
|
614
|
+
className: "btnSeeAll",
|
|
615
|
+
data: _seeAll
|
|
616
|
+
})) : /*#__PURE__*/_react["default"].createElement("div", {
|
|
617
|
+
key: "scrollContainer",
|
|
618
|
+
className: (0, _classnames["default"])('scrollContainer', {
|
|
619
|
+
pl_100: layout === 'layout5'
|
|
620
|
+
})
|
|
621
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
622
|
+
className: "scrollProductList"
|
|
623
|
+
}, products.map(function (item) {
|
|
624
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
625
|
+
className: "productCard"
|
|
626
|
+
}, /*#__PURE__*/_react["default"].createElement(_AffiliateProductItem["default"], {
|
|
627
|
+
key: "scroll_" + item.productId,
|
|
628
|
+
data: item,
|
|
629
|
+
fixHeight: true,
|
|
630
|
+
imgHeight: imgHeight,
|
|
631
|
+
imgWidth: imgWidth // onItemClick={() => clickUrl(`/product/detail/${item.offerId}?productId=${item.sppProductId || item.productId || ''}`)}
|
|
632
|
+
,
|
|
633
|
+
onItemClick: function onItemClick() {
|
|
634
|
+
/** PTO 定制GA */
|
|
635
|
+
if (window.magicDesign.pushGA) {
|
|
636
|
+
window.magicDesign.pushGA({}, 'select_item', item);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
(0, _coreUtil.clickUrl)("proDetail-" + (item === null || item === void 0 ? void 0 : item.offerId) + "-" + (item.sppProductId || item.affiliateProductId || ''));
|
|
640
|
+
},
|
|
641
|
+
panelProps: panelProps.content
|
|
642
|
+
}));
|
|
643
|
+
})), _seeAll.open && products.length > 0 && /*#__PURE__*/_react["default"].createElement(_components.MetaButton, {
|
|
644
|
+
className: "btnSeeAll",
|
|
645
|
+
data: _seeAll
|
|
646
|
+
})));
|
|
647
|
+
};
|
|
648
|
+
|
|
649
|
+
RecommendMobile.defaultProps = {
|
|
650
|
+
panelProps: {}
|
|
651
|
+
};
|
|
652
|
+
return RecommendMobile;
|
|
653
|
+
}(_react["default"].Component);
|
|
654
|
+
|
|
655
|
+
var _default = RecommendMobile;
|
|
656
|
+
exports["default"] = _default;
|