@fonixtree/magic-design 0.0.167 → 0.0.169

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.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = void 0;
6
+ exports["default"] = exports.createVideoModal = void 0;
7
7
 
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
 
@@ -204,6 +204,61 @@ var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
204
204
  }
205
205
  };
206
206
 
207
+ /** 检查youtube依赖包 */
208
+ var checkYoutuVIdeo = function checkYoutuVIdeo() {
209
+ return __awaiter(void 0, void 0, void 0, function () {
210
+ return __generator(this, function (_a) {
211
+ switch (_a.label) {
212
+ case 0:
213
+ if (!!window.YT) return [3
214
+ /*break*/
215
+ , 2];
216
+ return [4
217
+ /*yield*/
218
+ , Promise.all([(0, _commonUtil.importAsync)('https://www.youtube.com/iframe_api', 'js')])];
219
+
220
+ case 1:
221
+ _a.sent();
222
+
223
+ _a.label = 2;
224
+
225
+ case 2:
226
+ return [2
227
+ /*return*/
228
+ ];
229
+ }
230
+ });
231
+ });
232
+ };
233
+ /** 检查Ali依赖包 */
234
+
235
+
236
+ var checkAliVIdeo = function checkAliVIdeo() {
237
+ return __awaiter(void 0, void 0, void 0, function () {
238
+ return __generator(this, function (_a) {
239
+ switch (_a.label) {
240
+ case 0:
241
+ if (!!window.Aliplayer) return [3
242
+ /*break*/
243
+ , 2];
244
+ return [4
245
+ /*yield*/
246
+ , Promise.all([(0, _commonUtil.importAsync)('https://g.alicdn.com/de/prismplayer/2.13.2/aliplayer-min.js'), (0, _commonUtil.importAsync)('https://g.alicdn.com/de/prismplayer/2.13.2/skins/default/aliplayer-min.css')])];
247
+
248
+ case 1:
249
+ _a.sent();
250
+
251
+ _a.label = 2;
252
+
253
+ case 2:
254
+ return [2
255
+ /*return*/
256
+ ];
257
+ }
258
+ });
259
+ });
260
+ };
261
+
207
262
  var createAliVideo = function createAliVideo(domId, opts) {
208
263
  if (opts === void 0) {
209
264
  opts = {};
@@ -328,6 +383,10 @@ var createYoutuVideo = function createYoutuVideo(domId, opts) {
328
383
  player.mute();
329
384
  }
330
385
 
386
+ if (opts.videoSound) {
387
+ player.unMute();
388
+ }
389
+
331
390
  if (opts.speed) {
332
391
  player.setPlaybackRate(opts.speed);
333
392
  }
@@ -413,6 +472,83 @@ var getVideoType = function getVideoType(opts) {
413
472
 
414
473
  return 'ali';
415
474
  };
475
+ /** 创建视频弹框显示 */
476
+
477
+
478
+ var createVideoModal = function createVideoModal(videoId, opts) {
479
+ return __awaiter(void 0, void 0, void 0, function () {
480
+ var modelWrap, shadowWrap, contentWrap, videoDom, closeImgDom, type;
481
+ return __generator(this, function (_a) {
482
+ switch (_a.label) {
483
+ case 0:
484
+ modelWrap = document.createElement('div');
485
+ modelWrap.className = 'pc-video-modal-wrap';
486
+ modelWrap.setAttribute('video-id', videoId);
487
+ shadowWrap = document.createElement('div');
488
+ shadowWrap.className = 'video-shadow-wrap';
489
+
490
+ shadowWrap.onclick = function () {
491
+ var _a;
492
+
493
+ (_a = document.querySelector("[video-id=\"" + videoId + "\"]")) === null || _a === void 0 ? void 0 : _a.remove();
494
+ };
495
+
496
+ contentWrap = document.createElement('div');
497
+ contentWrap.className = 'content-wrap';
498
+ videoDom = document.createElement('div');
499
+ videoDom.id = 'video-modal-' + videoId;
500
+ contentWrap.appendChild(videoDom);
501
+ closeImgDom = document.createElement('img');
502
+ closeImgDom.src = _closeImg["default"];
503
+ closeImgDom.className = 'close-img-wrap';
504
+
505
+ closeImgDom.onclick = function () {
506
+ var _a;
507
+
508
+ (_a = document.querySelector("[video-id=\"" + videoId + "\"]")) === null || _a === void 0 ? void 0 : _a.remove();
509
+ };
510
+
511
+ contentWrap.appendChild(closeImgDom);
512
+ modelWrap.appendChild(shadowWrap);
513
+ modelWrap.appendChild(contentWrap);
514
+ (document.querySelector('[magic_design]') || document.body).appendChild(modelWrap);
515
+ type = getVideoType(opts);
516
+ if (!(type == 'youtu')) return [3
517
+ /*break*/
518
+ , 2];
519
+ return [4
520
+ /*yield*/
521
+ , checkYoutuVIdeo()];
522
+
523
+ case 1:
524
+ _a.sent();
525
+
526
+ _a.label = 2;
527
+
528
+ case 2:
529
+ if (!(type == 'ali')) return [3
530
+ /*break*/
531
+ , 4];
532
+ return [4
533
+ /*yield*/
534
+ , checkAliVIdeo()];
535
+
536
+ case 3:
537
+ _a.sent();
538
+
539
+ _a.label = 4;
540
+
541
+ case 4:
542
+ createVideo(type, '-modal-' + videoId, opts);
543
+ return [2
544
+ /*return*/
545
+ ];
546
+ }
547
+ });
548
+ });
549
+ };
550
+
551
+ exports.createVideoModal = createVideoModal;
416
552
 
417
553
  var Video =
418
554
  /** @class */
@@ -500,30 +636,24 @@ function (_super) {
500
636
  case 0:
501
637
  if (!this.props.opts.source) return [3
502
638
  /*break*/
503
- , 8];
639
+ , 6];
504
640
  videoType = getVideoType(this.props.opts);
505
641
  if (!(videoType == 'youtu')) return [3
506
642
  /*break*/
507
- , 4];
508
- if (!!window.YT) return [3
509
- /*break*/
510
- , 2];
643
+ , 3];
511
644
  return [4
512
645
  /*yield*/
513
- , Promise.all([(0, _commonUtil.importAsync)('https://www.youtube.com/iframe_api', 'js')])];
646
+ , checkYoutuVIdeo()];
514
647
 
515
648
  case 1:
516
649
  _c.sent();
517
650
 
518
- _c.label = 2;
519
-
520
- case 2:
521
651
  _a = this;
522
652
  return [4
523
653
  /*yield*/
524
654
  , createVideo('youtu', this.props.videoId, this.props.opts)];
525
655
 
526
- case 3:
656
+ case 2:
527
657
  _a.ytPlayer = _c.sent();
528
658
  this.ytPlayer.addEventListener('onStateChange', function (event) {
529
659
  if (!_this.props.opts.loop) {
@@ -534,31 +664,25 @@ function (_super) {
534
664
  }
535
665
  }
536
666
  });
537
- _c.label = 4;
667
+ _c.label = 3;
538
668
 
539
- case 4:
669
+ case 3:
540
670
  if (!(videoType == 'ali')) return [3
541
671
  /*break*/
542
- , 8];
543
- if (!!window.Aliplayer) return [3
544
- /*break*/
545
672
  , 6];
546
673
  return [4
547
674
  /*yield*/
548
- , Promise.all([(0, _commonUtil.importAsync)('https://g.alicdn.com/de/prismplayer/2.13.2/aliplayer-min.js'), (0, _commonUtil.importAsync)('https://g.alicdn.com/de/prismplayer/2.13.2/skins/default/aliplayer-min.css')])];
675
+ , checkAliVIdeo()];
549
676
 
550
- case 5:
677
+ case 4:
551
678
  _c.sent();
552
679
 
553
- _c.label = 6;
554
-
555
- case 6:
556
680
  _b = this;
557
681
  return [4
558
682
  /*yield*/
559
683
  , createVideo('ali', this.props.videoId, this.props.opts)];
560
684
 
561
- case 7:
685
+ case 5:
562
686
  _b.aliPlayer = _c.sent();
563
687
  this.aliPlayer.on('ended', function () {
564
688
  if (!_this.props.opts.loop) {
@@ -567,9 +691,9 @@ function (_super) {
567
691
  _this.props.onEnd();
568
692
  }
569
693
  });
570
- _c.label = 8;
694
+ _c.label = 6;
571
695
 
572
- case 8:
696
+ case 6:
573
697
  return [2
574
698
  /*return*/
575
699
  ];
@@ -579,7 +703,9 @@ function (_super) {
579
703
  };
580
704
 
581
705
  _this.fullPlay = function () {
582
- _this.createVideoModal(_this.props.videoId);
706
+ createVideoModal(_this.props.videoId, __assign(__assign({}, _this.props.opts), {
707
+ autoplay: true
708
+ }));
583
709
  };
584
710
 
585
711
  return _this;
@@ -77,8 +77,7 @@ function (_super) {
77
77
  VideoUpload.prototype.render = function () {
78
78
  var _this = this;
79
79
 
80
- var _a = this.props.value,
81
- value = _a === void 0 ? '/get/resource/20220615/video/haha1536909657474453504.mp4' : _a;
80
+ var value = this.props.value;
82
81
  var visible = this.state.visible;
83
82
  return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
84
83
  className: "video-upload-container",
@@ -145,7 +144,7 @@ function (_super) {
145
144
  };
146
145
 
147
146
  VideoUpload.defaultProps = {
148
- value: '/get/resource/20220615/video/haha1536909657474453504.mp4',
147
+ value: '',
149
148
  onChange: function onChange(v) {
150
149
  console.log(v);
151
150
  }
@@ -166,7 +166,7 @@ function (_super) {
166
166
  }, /*#__PURE__*/_react["default"].createElement(_NewImg["default"], {
167
167
  className: "product-img",
168
168
  lazy: true,
169
- src: (0, _commonUtil.convertImageUrl)(data.imgUrlContent || data.productImageUrlContent),
169
+ src: (0, _commonUtil.convertImageUrl)(data.productImg || data.imgUrlContent || data.productImageUrlContent),
170
170
  style: imgStyle
171
171
  }), /*#__PURE__*/_react["default"].createElement(_ImageLabel["default"], {
172
172
  labels: imgLabels,
@@ -41,7 +41,8 @@ var urlType = {
41
41
  CUSTOMIZED: 'customized',
42
42
  PROD_FILTER: 'filter',
43
43
  ANCHOR: 'anchor',
44
- GET_COUPON: 'coupons'
44
+ GET_COUPON: 'coupons',
45
+ VIDEO: 'video'
45
46
  };
46
47
  exports.urlType = urlType;
47
48
  var respCodeMap = {
@@ -9,6 +9,8 @@ var _qs = _interopRequireDefault(require("qs"));
9
9
 
10
10
  var _lodash = require("lodash");
11
11
 
12
+ var _commonUtil = require("./commonUtil");
13
+
12
14
  var _constants = require("../constants");
13
15
 
14
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -56,7 +58,7 @@ var parseUrl = function parseUrl(url) {
56
58
  action: 'jump',
57
59
  data: {
58
60
  type: 'NAVIGATE',
59
- url: h5Link
61
+ url: link
60
62
  }
61
63
  };
62
64
  break;
@@ -97,6 +99,19 @@ var parseUrl = function parseUrl(url) {
97
99
  };
98
100
  break;
99
101
 
102
+ case _constants.urlType.VIDEO:
103
+ // 播放视频
104
+ params = {
105
+ type: 'operation',
106
+ params: {
107
+ type: 'VIDEO',
108
+ data: (0, _commonUtil.ensure)(function () {
109
+ return JSON.parse(url.slice('video-'.length));
110
+ }, {})
111
+ }
112
+ };
113
+ break;
114
+
100
115
  default:
101
116
  var map = {
102
117
  '/main/cart': 'CART',
@@ -119,7 +134,8 @@ var parseUrl = function parseUrl(url) {
119
134
  params = {
120
135
  action: 'jump',
121
136
  params: {
122
- type: map[url]
137
+ type: map[url],
138
+ link: link
123
139
  }
124
140
  };
125
141
  }
@@ -281,7 +281,11 @@ var navigateTo = function navigateTo(url) {
281
281
  return;
282
282
  }
283
283
 
284
- window.magicDesign.history.push(url);
284
+ if (url.startsWith('/')) {
285
+ window.magicDesign.history.push(url);
286
+ } else {
287
+ window.location.href = link;
288
+ }
285
289
  };
286
290
 
287
291
  exports.navigateTo = navigateTo;
@@ -19,6 +19,8 @@ var _MessageModal = _interopRequireDefault(require("../common/MessageModal"));
19
19
 
20
20
  var _locale = require("../locale");
21
21
 
22
+ var _Video = require("../common/Video");
23
+
22
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
23
25
 
24
26
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
@@ -292,27 +294,34 @@ var clickUrl = function clickUrl(url) {
292
294
  data = _a.data;
293
295
 
294
296
  var params = data.params;
295
- console.log('data', data);
296
- console.log('link', link);
297
297
 
298
- if (window.magicDesign.readOnly || window.magicDesign.mode !== 'renderer' || !url || window.magicDesign.outputType == 'html') {
298
+ if (window.magicDesign.mode !== 'renderer' || !url || window.magicDesign.outputType == 'html') {
299
+ return;
300
+ } // 如果是video 放开return
301
+
302
+
303
+ if (params.type !== 'VIDEO' && window.magicDesign.readOnly) {
299
304
  return;
300
305
  }
301
306
 
302
307
  if ((0, _androidUtil.browserVersion)().isApp) {
303
308
  (0, _androidUtil.sendToApp)(params);
304
309
  } else {
305
- // 领取优惠券
310
+ // 视频
311
+ if (params.type === 'VIDEO') {
312
+ (0, _Video.createVideoModal)((0, _uuid.v4)(), __assign(__assign({}, params.data), {
313
+ source: params.data.sourceUrl
314
+ }));
315
+ return;
316
+ } // 领取优惠券
317
+
318
+
306
319
  if (params.type === 'GET_COUPON') {
307
320
  getCoupon(params.couponId);
308
321
  return;
309
322
  }
310
323
 
311
- if (link.startsWith('/')) {
312
- (0, _commonUtil.navigateTo)(newUrl);
313
- } else {
314
- window.location.href = newUrl;
315
- }
324
+ (0, _commonUtil.navigateTo)(link);
316
325
  }
317
326
  };
318
327
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fonixtree/magic-design",
3
3
  "author": "Cylon Team",
4
- "version": "0.0.167",
4
+ "version": "0.0.169",
5
5
  "description": "Magic Design",
6
6
  "license": "MIT",
7
7
  "module": "es/index.js",