@fonixtree/magic-design 1.0.149 → 1.0.151

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 (25) hide show
  1. package/es/common/ProductCardModal/index.js +10 -0
  2. package/es/common/ProductCardModal/index.less +21 -2
  3. package/es/composite-comp/dito/components/SearchDITO/pc/index.js +47 -3
  4. package/es/composite-comp/dito/components/SearchDITO/pc/index.less +15 -0
  5. package/es/composite-comp/dito/components/SlideImage/pc/components/CardItem/index.js +5 -5
  6. package/es/composite-comp/dito/components/SlideImage/pc/components/CardItem/index.less +4 -1
  7. package/es/composite-comp/dito/components/SlideImage/pc/components/VideoItem/index.js +113 -13
  8. package/es/composite-comp/dito/components/SlideImage/pc/components/VideoItem/index.less +74 -12
  9. package/es/composite-comp/dito/components/SlideImage/pc/index.js +462 -12
  10. package/es/composite-comp/dito/components/SlideImage/pc/index.less +12 -1
  11. package/es/constants/index.js +4 -1
  12. package/es/utils/businessUtil.js +13 -2
  13. package/lib/common/ProductCardModal/index.js +10 -0
  14. package/lib/common/ProductCardModal/index.less +21 -2
  15. package/lib/composite-comp/dito/components/SearchDITO/pc/index.js +47 -3
  16. package/lib/composite-comp/dito/components/SearchDITO/pc/index.less +15 -0
  17. package/lib/composite-comp/dito/components/SlideImage/pc/components/CardItem/index.js +5 -5
  18. package/lib/composite-comp/dito/components/SlideImage/pc/components/CardItem/index.less +4 -1
  19. package/lib/composite-comp/dito/components/SlideImage/pc/components/VideoItem/index.js +113 -13
  20. package/lib/composite-comp/dito/components/SlideImage/pc/components/VideoItem/index.less +74 -12
  21. package/lib/composite-comp/dito/components/SlideImage/pc/index.js +462 -12
  22. package/lib/composite-comp/dito/components/SlideImage/pc/index.less +12 -1
  23. package/lib/constants/index.js +4 -1
  24. package/lib/utils/businessUtil.js +13 -2
  25. package/package.json +2 -1
@@ -160,6 +160,16 @@ function ProductCardModal(_a) {
160
160
  alt: "",
161
161
  className: "dotIcon",
162
162
  src: _dotIcon["default"]
163
+ }), index === active && /*#__PURE__*/_react["default"].createElement("div", {
164
+ className: "cardLeft",
165
+ onClick: function onClick(e) {
166
+ return handlePrev(e);
167
+ }
168
+ }), index === active && /*#__PURE__*/_react["default"].createElement("div", {
169
+ className: "cardRight",
170
+ onClick: function onClick(e) {
171
+ return handleNext(e);
172
+ }
163
173
  })));
164
174
  }))), /*#__PURE__*/_react["default"].createElement(_Iconfont["default"], {
165
175
  className: "iconLeft",
@@ -25,6 +25,25 @@
25
25
  top: 0;
26
26
  bottom: 0;
27
27
  margin: auto;
28
+ cursor: pointer;
29
+
30
+ .cardLeft {
31
+ width: 50%;
32
+ height: 100%;
33
+ position: absolute;
34
+ top: 0;
35
+ left: 0;
36
+ z-index: 2;
37
+ }
38
+
39
+ .cardRight {
40
+ width: 50%;
41
+ height: 100%;
42
+ position: absolute;
43
+ top: 0;
44
+ right: 0;
45
+ z-index: 2;
46
+ }
28
47
 
29
48
  .bgImg {
30
49
  display: block;
@@ -86,7 +105,7 @@
86
105
  transform: rotate(90deg);
87
106
  cursor: pointer;
88
107
  position: absolute;
89
- left: 8%;
108
+ left: 20%;
90
109
  top: 0;
91
110
  bottom: 0;
92
111
  margin: auto;
@@ -97,7 +116,7 @@
97
116
  transform: rotate(-90deg);
98
117
  cursor: pointer;
99
118
  position: absolute;
100
- right: 8%;
119
+ right: 20%;
101
120
  top: 0;
102
121
  bottom: 0;
103
122
  margin: auto;
@@ -21,6 +21,8 @@ var _common = require("../../../../../common");
21
21
 
22
22
  var _commonUtil = require("../../../../../utils/commonUtil");
23
23
 
24
+ var _businessUtil = require("../../../../../utils/businessUtil");
25
+
24
26
  var _components = require("../../../../../meta-comp/components");
25
27
 
26
28
  require("slick-carousel/slick/slick.css");
@@ -234,7 +236,8 @@ function (_super) {
234
236
  visible: false,
235
237
  relativeLeft: 0,
236
238
  logVisible: false,
237
- userInfo: {}
239
+ userInfo: {},
240
+ cartNum: 0
238
241
  };
239
242
  _this.carouselRef = /*#__PURE__*/_react["default"].createRef();
240
243
  _this.destroy = null;
@@ -468,6 +471,43 @@ function (_super) {
468
471
  });
469
472
  };
470
473
 
474
+ _this.getCartCount = function () {
475
+ return __awaiter(_this, void 0, void 0, function () {
476
+ var num, res;
477
+ return __generator(this, function (_a) {
478
+ switch (_a.label) {
479
+ case 0:
480
+ num = 0;
481
+ if (!(0, _commonUtil.isLogin)()) return [3
482
+ /*break*/
483
+ , 2];
484
+ return [4
485
+ /*yield*/
486
+ , (0, _commonUtil.commonFetch)('/designer/v1/h5/carts/num', {}, 'GET')];
487
+
488
+ case 1:
489
+ res = _a.sent();
490
+ num = res.num;
491
+ return [3
492
+ /*break*/
493
+ , 3];
494
+
495
+ case 2:
496
+ num = (0, _businessUtil.getTempCartCount)();
497
+ _a.label = 3;
498
+
499
+ case 3:
500
+ this.setState({
501
+ cartNum: num
502
+ });
503
+ return [2
504
+ /*return*/
505
+ ];
506
+ }
507
+ });
508
+ });
509
+ };
510
+
471
511
  return _this;
472
512
  }
473
513
 
@@ -478,6 +518,7 @@ function (_super) {
478
518
  this.getUserInfo();
479
519
  }
480
520
 
521
+ this.getCartCount();
481
522
  this.getCategory();
482
523
  this.destroy = (0, _mobx.autorun)(function () {
483
524
  _this.bannerGoto(_this.props.data.groupSource);
@@ -517,7 +558,8 @@ function (_super) {
517
558
  relativeLeft = _s.relativeLeft,
518
559
  catgImg = _s.catgImg,
519
560
  logVisible = _s.logVisible,
520
- userInfo = _s.userInfo;
561
+ userInfo = _s.userInfo,
562
+ cartNum = _s.cartNum;
521
563
  var autoplay = data.setting.autoplay.open;
522
564
  /** 设计器模式下 如果选中特定group 自动播放关闭 */
523
565
 
@@ -602,7 +644,9 @@ function (_super) {
602
644
  },
603
645
  size: 24,
604
646
  type: "icon-ShoppingCartSimple1"
605
- })), ((_q = (_p = data.content) === null || _p === void 0 ? void 0 : _p.login) === null || _q === void 0 ? void 0 : _q.open) && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, (0, _commonUtil.isLogin)() ? /*#__PURE__*/_react["default"].createElement("div", {
647
+ }), cartNum > 0 && /*#__PURE__*/_react["default"].createElement("span", {
648
+ className: "cart-num"
649
+ }, cartNum)), ((_q = (_p = data.content) === null || _p === void 0 ? void 0 : _p.login) === null || _q === void 0 ? void 0 : _q.open) && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, (0, _commonUtil.isLogin)() ? /*#__PURE__*/_react["default"].createElement("div", {
606
650
  className: (0, _classnames["default"])('personal-info', {
607
651
  showLogOut: logVisible
608
652
  }),
@@ -124,6 +124,21 @@
124
124
 
125
125
  .icon-wrap {
126
126
  cursor: pointer;
127
+ position: relative;
128
+
129
+ .cart-num {
130
+ position: absolute;
131
+ top: -8px;
132
+ right: -8px;
133
+ width: 20px;
134
+ height: 20px;
135
+ background-color: #ce1126;
136
+ color: #fff;
137
+ border-radius: 50%;
138
+ font-size: 11px;
139
+ line-height: 20px;
140
+ text-align: center;
141
+ }
127
142
  }
128
143
 
129
144
  .personal-info {
@@ -69,8 +69,6 @@ function (_super) {
69
69
  return _super !== null && _super.apply(this, arguments) || this;
70
70
  }
71
71
 
72
- CardItem.prototype.componentDidMount = function () {};
73
-
74
72
  CardItem.prototype.render = function () {
75
73
  var _a = this.props,
76
74
  data = _a.data,
@@ -83,13 +81,15 @@ function (_super) {
83
81
  }
84
82
  }, rest), /*#__PURE__*/_react["default"].createElement(_VideoItem["default"], {
85
83
  data: data
86
- }), data.groupName.open && /*#__PURE__*/_react["default"].createElement(_components.MetaText, {
87
- className: "img-text",
84
+ }), data.groupName.open && /*#__PURE__*/_react["default"].createElement("div", {
85
+ className: "text-perch"
86
+ }, /*#__PURE__*/_react["default"].createElement(_components.MetaText, {
87
+ className: "canvas-ignore",
88
88
  data: data.groupName,
89
89
  style: {
90
90
  pointerEvents: (0, _coreUtil.isDesignMode)() ? 'unset' : 'none'
91
91
  }
92
- })));
92
+ }))));
93
93
  };
94
94
 
95
95
  CardItem.defaultProps = {
@@ -1,7 +1,10 @@
1
1
  .slide-image-card-item-wrap {
2
2
  cursor: pointer;
3
3
 
4
- .img-text {
4
+ .video-wrap {}
5
+
6
+ .text-perch {
5
7
  margin-top: 20px;
8
+ height: 30px;
6
9
  }
7
10
  }
@@ -11,6 +11,8 @@ var _classnames = _interopRequireDefault(require("classnames"));
11
11
 
12
12
  require("./index.less");
13
13
 
14
+ var _lodash = _interopRequireDefault(require("lodash.throttle"));
15
+
14
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
17
 
16
18
  var __extends = void 0 && (void 0).__extends || function () {
@@ -48,9 +50,14 @@ function (_super) {
48
50
  var _this = _super !== null && _super.apply(this, arguments) || this;
49
51
 
50
52
  _this.state = {
51
- playing: false
53
+ playing: false,
54
+ inside: false,
55
+ isNearCenter: false,
56
+ flag: false,
57
+ corner: ''
52
58
  };
53
59
  _this.videoRef = /*#__PURE__*/_react["default"].createRef();
60
+ _this.cardRef = /*#__PURE__*/_react["default"].createRef();
54
61
 
55
62
  _this.onMouseEnter = function () {
56
63
  var _a;
@@ -74,36 +81,129 @@ function (_super) {
74
81
  _this.setState({
75
82
  playing: false
76
83
  });
84
+ }; // 获取元素中心坐标
85
+
86
+
87
+ _this.getCenter = function (element) {
88
+ var rect = element.getBoundingClientRect();
89
+ return {
90
+ x: rect.left + rect.width / 2,
91
+ y: rect.top + rect.height / 2
92
+ };
93
+ }; // 判断是否在中心区域
94
+
95
+
96
+ _this.checkMouseNearCenter = function (e, radius) {
97
+ if (radius === void 0) {
98
+ radius = 20;
99
+ }
100
+
101
+ var center = _this.getCenter(e.target); // 计算鼠标与中心的距离
102
+
103
+
104
+ var distance = Math.sqrt(Math.pow(e.clientX - center.x, 2) + Math.pow(e.clientY - center.y, 2));
105
+ return distance <= radius;
106
+ }; // 判断鼠标方位
107
+
108
+
109
+ _this.getMousePos = function (e) {
110
+ var rect = e.target.getBoundingClientRect();
111
+ var x = e.clientX - rect.left; // 鼠标相对于元素的 X 坐标
112
+
113
+ var y = e.clientY - rect.top; // 鼠标相对于元素的 Y 坐标
114
+ // 判断区域
115
+
116
+ var isLeft = x < rect.width / 2;
117
+ var isTop = y < rect.height / 2;
118
+ var corner = '';
119
+ if (isLeft && isTop) corner = 'topLeft';else if (!isLeft && isTop) corner = 'topRight';else if (isLeft && !isTop) corner = 'bottomLeft';else corner = 'bottomRight';
120
+ return corner;
121
+ };
122
+
123
+ _this.handleMouseMove = (0, _lodash["default"])(function (e) {
124
+ var dom = _this.cardRef.current;
125
+ var size = parseInt(getComputedStyle(dom).width);
126
+ var x = size * 0.5 + e.offsetX * 0.5; // 提升灵敏度
127
+
128
+ var y = size * 0.5 + e.offsetY * 0.5;
129
+ dom.style.setProperty('--x', x);
130
+ dom.style.setProperty('--y', y);
131
+ dom.style.setProperty('--size', size);
132
+
133
+ var isNear = _this.checkMouseNearCenter(e);
134
+
135
+ var corner = _this.getMousePos(e);
136
+
137
+ if (isNear) _this.setState({
138
+ flag: true
139
+ });
140
+
141
+ _this.setState({
142
+ isNearCenter: isNear,
143
+ inside: true,
144
+ corner: corner
145
+ });
146
+ });
147
+
148
+ _this.handleMouseLeave = function () {
149
+ _this.setState({
150
+ inside: false,
151
+ flag: false,
152
+ corner: ''
153
+ });
77
154
  };
78
155
 
79
156
  return _this;
80
157
  }
81
158
 
159
+ VideoItem.prototype.componentDidMount = function () {
160
+ var dom = this.cardRef.current;
161
+ dom.addEventListener('mousemove', this.handleMouseMove);
162
+ dom.addEventListener('mouseleave', this.handleMouseLeave);
163
+ };
164
+
165
+ VideoItem.prototype.componentWillUnmount = function () {
166
+ var dom = this.cardRef.current;
167
+ dom.removeEventListener('mousemove', this.handleMouseMove);
168
+ dom.removeEventListener('mouseleave', this.handleMouseLeave);
169
+ };
170
+
82
171
  VideoItem.prototype.render = function () {
83
- var _a, _b, _c, _d, _e, _f;
172
+ var _a, _b;
173
+
174
+ var _c, _d, _e, _f, _g, _h, _j;
84
175
 
85
176
  var data = this.props.data;
86
- var playing = this.state.playing;
177
+ var _k = this.state,
178
+ playing = _k.playing,
179
+ inside = _k.inside,
180
+ isNearCenter = _k.isNearCenter,
181
+ flag = _k.flag,
182
+ corner = _k.corner;
87
183
  return /*#__PURE__*/_react["default"].createElement("div", {
88
- className: "slide-image-video-wrap",
184
+ ref: this.cardRef,
185
+ className: (0, _classnames["default"])('slide-image-video-wrap', (_a = {}, _a[corner] = inside && !isNearCenter && !flag, _a)),
89
186
  onMouseEnter: this.onMouseEnter,
90
187
  onMouseLeave: this.onMouseLeave
91
- }, ((_a = data.video) === null || _a === void 0 ? void 0 : _a.sourceUrl) && /*#__PURE__*/_react["default"].createElement("video", {
188
+ }, ((_c = data.video) === null || _c === void 0 ? void 0 : _c.sourceUrl) && /*#__PURE__*/_react["default"].createElement("video", {
92
189
  ref: this.videoRef,
190
+ className: "canvas-ignore",
93
191
  loop: true,
94
192
  muted: true,
95
- playsinline: true
193
+ playsinline: true,
194
+ style: {
195
+ visibility: playing ? 'visible' : 'hidden'
196
+ }
96
197
  }, /*#__PURE__*/_react["default"].createElement("source", {
97
- src: (_b = data.video) === null || _b === void 0 ? void 0 : _b.sourceUrl,
198
+ src: (_d = data.video) === null || _d === void 0 ? void 0 : _d.sourceUrl,
98
199
  type: "video/mp4"
99
- })), ((_c = data.overilay) === null || _c === void 0 ? void 0 : _c.open) && /*#__PURE__*/_react["default"].createElement("img", {
200
+ })), ((_e = data.overilay) === null || _e === void 0 ? void 0 : _e.open) && /*#__PURE__*/_react["default"].createElement("img", {
100
201
  alt: "",
101
- className: (0, _classnames["default"])('video-img', {
102
- cover: (_d = data.video) === null || _d === void 0 ? void 0 : _d.sourceUrl
103
- }),
104
- src: (_f = (_e = data.overilay) === null || _e === void 0 ? void 0 : _e.content) === null || _f === void 0 ? void 0 : _f.pcImgSrc,
202
+ className: (0, _classnames["default"])('video-img', (_b = {}, _b['canvas-ignore'] = (_f = data.video) === null || _f === void 0 ? void 0 : _f.sourceUrl, _b)),
203
+ src: (_h = (_g = data.overilay) === null || _g === void 0 ? void 0 : _g.content) === null || _h === void 0 ? void 0 : _h.pcImgSrc,
105
204
  style: {
106
- visibility: playing ? 'hidden' : 'visible'
205
+ visibility: playing ? 'hidden' : 'visible',
206
+ zIndex: ((_j = data.video) === null || _j === void 0 ? void 0 : _j.sourceUrl) ? 3 : 0
107
207
  }
108
208
  }));
109
209
  };
@@ -1,24 +1,86 @@
1
1
  .slide-image-video-wrap {
2
2
  position: relative;
3
+ transition: border-radius 0.2s ease;
4
+ overflow: hidden;
3
5
  cursor: pointer;
6
+ --dx: calc(var(--size) - var(--x));
7
+ --dy: calc(var(--size) - var(--y));
8
+
9
+ // &.hover {
10
+ // border-radius:
11
+ // ~"calc(var(--x)/var(--size)*100%)"
12
+ // ~"calc(var(--dx)/var(--size)*100%)"
13
+ // ~"calc(var(--dx)/var(--size)*100%)"
14
+ // ~"calc(var(--x)/var(--size)*100%) /"
15
+ // ~"calc(var(--y)/var(--size)*100%)"
16
+ // ~"calc(var(--y)/var(--size)*100%)"
17
+ // ~"calc(var(--dy)/var(--size)*100%)"
18
+ // ~"calc(var(--dy)/var(--size)*100%)";
19
+ // }
20
+
21
+ &.topLeft {
22
+ border-radius:
23
+ ~"calc(var(--x)/var(--size)*100%)"
24
+ ~"0"
25
+ ~"0"
26
+ ~"0 /"
27
+ ~"calc(var(--y)/var(--size)*100%)"
28
+ ~"0"
29
+ ~"0"
30
+ ~"0";
31
+ }
32
+
33
+ &.topRight {
34
+ border-radius:
35
+ ~"0"
36
+ ~"calc(var(--x)/var(--size)*100%)"
37
+ ~"0"
38
+ ~"0 /"
39
+ ~"0"
40
+ ~"calc(var(--y)/var(--size)*100%)"
41
+ ~"0"
42
+ ~"0";
43
+ }
44
+
45
+ &.bottomRight {
46
+ border-radius:
47
+ ~"0"
48
+ ~"0"
49
+ ~"calc(var(--x)/var(--size)*100%)"
50
+ ~"0 /"
51
+ ~"0"
52
+ ~"0"
53
+ ~"calc(var(--y)/var(--size)*100%)"
54
+ ~"0";
55
+ }
56
+
57
+ &.bottomLeft {
58
+ border-radius:
59
+ ~"0"
60
+ ~"0"
61
+ ~"0"
62
+ ~"calc(var(--x)/var(--size)*100%) /"
63
+ ~"0"
64
+ ~"0"
65
+ ~"0"
66
+ ~"calc(var(--y)/var(--size)*100%)";
67
+ }
4
68
 
5
69
  video {
70
+ position: absolute;
71
+ top: 0;
72
+ right: 0;
73
+ left: 0;
74
+ bottom: 0;
75
+ object-fit: cover;
6
76
  width: 100%;
77
+ height: 100%;
78
+ z-index: 2;
7
79
  }
8
80
 
9
81
  .video-img {
10
82
  width: 100%;
11
-
12
- &.cover {
13
- position: absolute;
14
- top: 0;
15
- right: 0;
16
- left: 0;
17
- bottom: 0;
18
- object-fit: cover;
19
- width: 100%;
20
- height: 100%;
21
- z-index: 0;
22
- }
83
+ position: relative;
84
+ z-index: 0;
23
85
  }
24
86
  }