@fonixtree/magic-design 1.0.98 → 1.0.100

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.
@@ -79,8 +79,8 @@
79
79
  border-radius: 0;
80
80
  }
81
81
  .m-group-buy-mobile .group-buy-list .m-product-item-wrap .product-img {
82
- height: 2.8rem;
83
- width: 2.8rem;
82
+ height: 3.4rem;
83
+ width: 3.4rem;
84
84
  }
85
85
  .m-group-buy-mobile .group-buy-list .m-product-item-wrap .content-wrap {
86
86
  padding: 0.24rem;
@@ -44,7 +44,8 @@ var __assign = void 0 && (void 0).__assign || function () {
44
44
  var setDesignConfig = function setDesignConfig(props) {
45
45
  var config = props.config,
46
46
  device = props.device,
47
- isPreview = props.isPreview;
47
+ isPreview = props.isPreview,
48
+ projectCode = props.projectCode;
48
49
  window.magicDesign = __assign(__assign({
49
50
  pageBackground: '#f2f2f2',
50
51
  mode: 'renderer',
@@ -52,6 +53,7 @@ var setDesignConfig = function setDesignConfig(props) {
52
53
  designMode: isPreview,
53
54
  navigatePreUrl: ''
54
55
  }, config), {
56
+ projectCode: projectCode,
55
57
  compSpacing: Number(config.compSpacing),
56
58
  compWidth: Number(config.compWidth)
57
59
  });
@@ -286,35 +286,61 @@ var getCoupon = function getCoupon(couponId) {
286
286
  });
287
287
  };
288
288
 
289
- var clickUrl = function clickUrl(url) {
289
+ function isUrl(string) {
290
+ // var pattern = new RegExp('^(https?:\\/\\/)?' + // 协议
291
+ // '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // 域名
292
+ // '((\\d{1,3}\\.){3}\\d{1,3}))' + // 或者 IP (v4) 地址
293
+ // '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // 端口和路径
294
+ // '(\\?[;&a-z\\d%_.~+=-]*)?' + // 查询字符串
295
+ // '(\\#[-a-z\\d_]*)?$', 'i'); // fragment locator
296
+ // return !!pattern.test(string);
297
+ try {
298
+ new URL(string);
299
+ return true;
300
+ } catch (_) {
301
+ return false;
302
+ }
303
+ }
304
+
305
+ var clickUrl = function clickUrl(url, state) {
306
+ var _a;
307
+
290
308
  if (url === void 0) {
291
309
  url = '';
292
310
  }
293
311
 
294
- console.log('clickUrl...', url); // 只读模式,设计模式,url为空,邮箱模版
312
+ console.log('clickUrl...', url, state); // 只读模式,设计模式,url为空,邮箱模版
295
313
 
296
314
  if (window.magicDesign.readOnly || window.magicDesign.mode !== 'renderer' || !url || window.magicDesign.outputType == 'html') {
297
315
  return;
298
316
  }
299
317
 
300
- var _a = _typeof(url) === 'object' ? (0, _businessUtil.newParseUrl)(url) : (0, _businessUtil.parseUrl)(url),
301
- link = _a.link,
302
- data = _a.data;
318
+ var _b = _typeof(url) === 'object' ? (0, _businessUtil.newParseUrl)(url) : (0, _businessUtil.parseUrl)(url),
319
+ link = _b.link,
320
+ data = _b.data;
303
321
 
304
- var _b = data.params,
305
- params = _b === void 0 ? {} : _b; // console.log('clicked data:', data);
322
+ var _c = data.params,
323
+ params = _c === void 0 ? {} : _c; // console.log('clicked data:', data);
306
324
  // console.log({ type: 'jumpBrowser', params: { url: params.link } });
307
325
 
326
+ /** 锚点跳转 */
327
+
328
+ if (params.type === 'ANCHOR') {
329
+ ensure(function () {
330
+ var nodeId = isPc() ? params.data.pcNodeId : params.data.mobileNodeId;
331
+ document.querySelector("#node-" + nodeId).scrollIntoView({
332
+ behavior: 'smooth'
333
+ });
334
+ });
335
+ return;
336
+ }
337
+
308
338
  if ((0, _androidUtil.browserVersion)().isAshitaApp) {
309
339
  (0, _androidUtil.sendToApp)(data);
310
- } else if ((0, _androidUtil.browserVersion)().isApp && params.link && params.link.startsWith('http')) {
311
- // 兼容Nuri的 绝对路径跳转
312
- (0, _androidUtil.sendToAndroid)({
313
- type: 'jumpBrowser',
314
- params: {
315
- url: params.link
316
- }
317
- });
340
+ } else if ((0, _androidUtil.browserVersion)().isDitoApp && params.link && params.link.startsWith('http')) {
341
+ // pto 抽奖系统对接
342
+ var urlTemp = "" + params.link + (params.link.includes('?') ? '&' : '?') + "token=" + (localStorage.getItem('h5Token') || '');
343
+ window.location.href = urlTemp;
318
344
  } else {
319
345
  // 视频
320
346
  if (params.type === 'VIDEO') {
@@ -336,9 +362,32 @@ var clickUrl = function clickUrl(url) {
336
362
  }
337
363
 
338
364
  return;
365
+ } // 判断是否是pto, pto跳外链需要带token
366
+
367
+
368
+ if (((_a = window === null || window === void 0 ? void 0 : window.magicDesign) === null || _a === void 0 ? void 0 : _a.projectCode) === 'pto') {
369
+ // 输入的是完整的跳转地址
370
+ if (isUrl(link)) {
371
+ if (!link.includes(window.location.host)) {
372
+ // 跳转外链 需要把token带上
373
+ if (link.includes('?')) {
374
+ var a = link + "&token=" + (localStorage.getItem('h5Token') || '');
375
+ console.log('wai lian: ', a);
376
+ window.location.href = a;
377
+ } else {
378
+ var a = link + "?token=" + (localStorage.getItem('h5Token') || '');
379
+ console.log('wai lian: ', a);
380
+ window.location.href = a;
381
+ }
382
+ } else {
383
+ window.open(link);
384
+ }
385
+ } else {
386
+ (0, _commonUtil.navigateTo)(link, state);
387
+ }
388
+ } else {
389
+ (0, _commonUtil.navigateTo)(link, state);
339
390
  }
340
-
341
- (0, _commonUtil.navigateTo)(link);
342
391
  }
343
392
  };
344
393
 
@@ -79,8 +79,8 @@
79
79
  border-radius: 0;
80
80
  }
81
81
  .m-group-buy-mobile .group-buy-list .m-product-item-wrap .product-img {
82
- height: 2.8rem;
83
- width: 2.8rem;
82
+ height: 3.4rem;
83
+ width: 3.4rem;
84
84
  }
85
85
  .m-group-buy-mobile .group-buy-list .m-product-item-wrap .content-wrap {
86
86
  padding: 0.24rem;
@@ -44,7 +44,8 @@ var __assign = void 0 && (void 0).__assign || function () {
44
44
  var setDesignConfig = function setDesignConfig(props) {
45
45
  var config = props.config,
46
46
  device = props.device,
47
- isPreview = props.isPreview;
47
+ isPreview = props.isPreview,
48
+ projectCode = props.projectCode;
48
49
  window.magicDesign = __assign(__assign({
49
50
  pageBackground: '#f2f2f2',
50
51
  mode: 'renderer',
@@ -52,6 +53,7 @@ var setDesignConfig = function setDesignConfig(props) {
52
53
  designMode: isPreview,
53
54
  navigatePreUrl: ''
54
55
  }, config), {
56
+ projectCode: projectCode,
55
57
  compSpacing: Number(config.compSpacing),
56
58
  compWidth: Number(config.compWidth)
57
59
  });
@@ -286,35 +286,61 @@ var getCoupon = function getCoupon(couponId) {
286
286
  });
287
287
  };
288
288
 
289
- var clickUrl = function clickUrl(url) {
289
+ function isUrl(string) {
290
+ // var pattern = new RegExp('^(https?:\\/\\/)?' + // 协议
291
+ // '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // 域名
292
+ // '((\\d{1,3}\\.){3}\\d{1,3}))' + // 或者 IP (v4) 地址
293
+ // '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // 端口和路径
294
+ // '(\\?[;&a-z\\d%_.~+=-]*)?' + // 查询字符串
295
+ // '(\\#[-a-z\\d_]*)?$', 'i'); // fragment locator
296
+ // return !!pattern.test(string);
297
+ try {
298
+ new URL(string);
299
+ return true;
300
+ } catch (_) {
301
+ return false;
302
+ }
303
+ }
304
+
305
+ var clickUrl = function clickUrl(url, state) {
306
+ var _a;
307
+
290
308
  if (url === void 0) {
291
309
  url = '';
292
310
  }
293
311
 
294
- console.log('clickUrl...', url); // 只读模式,设计模式,url为空,邮箱模版
312
+ console.log('clickUrl...', url, state); // 只读模式,设计模式,url为空,邮箱模版
295
313
 
296
314
  if (window.magicDesign.readOnly || window.magicDesign.mode !== 'renderer' || !url || window.magicDesign.outputType == 'html') {
297
315
  return;
298
316
  }
299
317
 
300
- var _a = _typeof(url) === 'object' ? (0, _businessUtil.newParseUrl)(url) : (0, _businessUtil.parseUrl)(url),
301
- link = _a.link,
302
- data = _a.data;
318
+ var _b = _typeof(url) === 'object' ? (0, _businessUtil.newParseUrl)(url) : (0, _businessUtil.parseUrl)(url),
319
+ link = _b.link,
320
+ data = _b.data;
303
321
 
304
- var _b = data.params,
305
- params = _b === void 0 ? {} : _b; // console.log('clicked data:', data);
322
+ var _c = data.params,
323
+ params = _c === void 0 ? {} : _c; // console.log('clicked data:', data);
306
324
  // console.log({ type: 'jumpBrowser', params: { url: params.link } });
307
325
 
326
+ /** 锚点跳转 */
327
+
328
+ if (params.type === 'ANCHOR') {
329
+ ensure(function () {
330
+ var nodeId = isPc() ? params.data.pcNodeId : params.data.mobileNodeId;
331
+ document.querySelector("#node-" + nodeId).scrollIntoView({
332
+ behavior: 'smooth'
333
+ });
334
+ });
335
+ return;
336
+ }
337
+
308
338
  if ((0, _androidUtil.browserVersion)().isAshitaApp) {
309
339
  (0, _androidUtil.sendToApp)(data);
310
- } else if ((0, _androidUtil.browserVersion)().isApp && params.link && params.link.startsWith('http')) {
311
- // 兼容Nuri的 绝对路径跳转
312
- (0, _androidUtil.sendToAndroid)({
313
- type: 'jumpBrowser',
314
- params: {
315
- url: params.link
316
- }
317
- });
340
+ } else if ((0, _androidUtil.browserVersion)().isDitoApp && params.link && params.link.startsWith('http')) {
341
+ // pto 抽奖系统对接
342
+ var urlTemp = "" + params.link + (params.link.includes('?') ? '&' : '?') + "token=" + (localStorage.getItem('h5Token') || '');
343
+ window.location.href = urlTemp;
318
344
  } else {
319
345
  // 视频
320
346
  if (params.type === 'VIDEO') {
@@ -336,9 +362,32 @@ var clickUrl = function clickUrl(url) {
336
362
  }
337
363
 
338
364
  return;
365
+ } // 判断是否是pto, pto跳外链需要带token
366
+
367
+
368
+ if (((_a = window === null || window === void 0 ? void 0 : window.magicDesign) === null || _a === void 0 ? void 0 : _a.projectCode) === 'pto') {
369
+ // 输入的是完整的跳转地址
370
+ if (isUrl(link)) {
371
+ if (!link.includes(window.location.host)) {
372
+ // 跳转外链 需要把token带上
373
+ if (link.includes('?')) {
374
+ var a = link + "&token=" + (localStorage.getItem('h5Token') || '');
375
+ console.log('wai lian: ', a);
376
+ window.location.href = a;
377
+ } else {
378
+ var a = link + "?token=" + (localStorage.getItem('h5Token') || '');
379
+ console.log('wai lian: ', a);
380
+ window.location.href = a;
381
+ }
382
+ } else {
383
+ window.open(link);
384
+ }
385
+ } else {
386
+ (0, _commonUtil.navigateTo)(link, state);
387
+ }
388
+ } else {
389
+ (0, _commonUtil.navigateTo)(link, state);
339
390
  }
340
-
341
- (0, _commonUtil.navigateTo)(link);
342
391
  }
343
392
  };
344
393
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fonixtree/magic-design",
3
3
  "author": "Cylon Team",
4
- "version": "1.0.98",
4
+ "version": "1.0.100",
5
5
  "description": "Magic Design",
6
6
  "license": "MIT",
7
7
  "module": "es/index.js",