@fonixtree/magic-design 0.0.7 → 0.0.10

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 (262) hide show
  1. package/_virtual/__node-resolve_empty.js +6 -0
  2. package/_virtual/_cloneBuffer.js +3 -0
  3. package/_virtual/_commonjsHelpers.js +24 -0
  4. package/_virtual/_node-resolve_empty.js +3 -0
  5. package/_virtual/_nodeUtil.js +3 -0
  6. package/_virtual/_rollupPluginBabelHelpers.js +18 -0
  7. package/_virtual/index.js +3 -0
  8. package/_virtual/index2.js +3 -0
  9. package/_virtual/index3.js +3 -0
  10. package/_virtual/index4.js +3 -0
  11. package/_virtual/index5.js +5 -0
  12. package/_virtual/interopRequireDefault.js +3 -0
  13. package/_virtual/isBuffer.js +3 -0
  14. package/_virtual/react-is.development.js +3 -0
  15. package/_virtual/react-is.production.min.js +3 -0
  16. package/_virtual/rng-browser.js +3 -0
  17. package/_virtual/toArray.js +3 -0
  18. package/package.json +22 -3
  19. package/src/components/assets/images/layout-icon/carouselLayout1.png.js +3 -0
  20. package/src/components/assets/images/layout-icon/carouselLayout2.png.js +3 -0
  21. package/src/components/assets/images/layout-icon/dividerLayout.svg.js +3 -0
  22. package/src/components/assets/images/layout-icon/imageGalleryLayout1.png.js +3 -0
  23. package/src/components/assets/images/layout-icon/imageGalleryLayout2.png.js +3 -0
  24. package/src/components/assets/images/layout-icon/imageGalleryLayout3.png.js +3 -0
  25. package/src/components/assets/images/layout-icon/layout-imagetext-m1-1.png.js +3 -0
  26. package/src/components/assets/images/layout-icon/layout-imagetext-m1-2.png.js +3 -0
  27. package/src/components/assets/images/layout-icon/layout-imagetext-m1-3.png.js +3 -0
  28. package/src/components/assets/images/layout-icon/layout-imagetext-m2.png.js +3 -0
  29. package/src/components/assets/images/layout-icon/layout-imagetext-m3.png.js +3 -0
  30. package/src/components/assets/images/layout-icon/layout-imagetext-p1.png.js +3 -0
  31. package/src/components/assets/images/layout-icon/layout-imagetext-p2.png.js +3 -0
  32. package/src/components/assets/images/layout-icon/layout-imagetext-p4.png.js +3 -0
  33. package/src/components/assets/images/layout-icon/layout-search.png.js +3 -0
  34. package/src/components/assets/images/layout-icon/newsletter.svg.js +3 -0
  35. package/src/components/assets/less/cylon-antd.less.js +3 -0
  36. package/src/components/assets/less/index.less.js +4 -0
  37. package/src/components/common/AlignSelector/index.js +65 -0
  38. package/src/components/common/AlignSelector/index.less.js +4 -0
  39. package/src/components/common/Button/index.js +75 -0
  40. package/src/components/common/Button/index.less.js +4 -0
  41. package/src/components/common/ButtonIconLayout/index.js +66 -0
  42. package/src/components/common/ButtonIconLayout/index.less.js +4 -0
  43. package/src/components/common/Collapse/index.js +323 -0
  44. package/src/components/common/Collapse/index.less.js +4 -0
  45. package/src/components/common/ColorPicker/index.js +94 -0
  46. package/src/components/common/ColorPicker/index.less.js +4 -0
  47. package/src/components/common/ColorPickerInput/index.js +76 -0
  48. package/src/components/common/ColorPickerInput/index.less.js +4 -0
  49. package/src/components/common/CountDown/index.js +110 -0
  50. package/src/components/common/CountDown/index.less.js +4 -0
  51. package/src/components/common/Field/index.js +43 -0
  52. package/src/components/common/Field/index.less.js +4 -0
  53. package/src/components/common/FontStyles/index.js +124 -0
  54. package/src/components/common/FontStyles/index.less.js +4 -0
  55. package/src/components/common/GroupList/defaultImg.png.js +3 -0
  56. package/src/components/common/GroupList/index.js +170 -0
  57. package/src/components/common/GroupList/index.less.js +4 -0
  58. package/src/components/common/IconPicker/index.js +93 -0
  59. package/src/components/common/IconPicker/index.less.js +4 -0
  60. package/src/components/common/Iconfont/index.js +74 -0
  61. package/src/components/common/Iconfont/index.less.js +4 -0
  62. package/src/components/common/ImageModal/CommonModal/const.js +16 -0
  63. package/src/components/common/ImageModal/CommonModal/index.js +33 -0
  64. package/src/components/common/ImageModal/CommonSelPicCard/index.js +66 -0
  65. package/src/components/common/ImageModal/CommonSelPicCard/index.less.js +4 -0
  66. package/src/components/common/ImageModal/const.js +18 -0
  67. package/src/components/common/ImageModal/index.js +547 -0
  68. package/src/components/common/ImageModal/index.less.js +4 -0
  69. package/src/components/common/ImagePicker/index.js +124 -0
  70. package/src/components/common/ImagePicker/index.less.js +4 -0
  71. package/src/components/common/InputNumber/index.js +54 -0
  72. package/src/components/common/InputNumber/index.less.js +4 -0
  73. package/src/components/common/LayoutSelector/imgs/center.png.js +3 -0
  74. package/src/components/common/LayoutSelector/imgs/left.png.js +3 -0
  75. package/src/components/common/LayoutSelector/imgs/right.png.js +3 -0
  76. package/src/components/common/LayoutSelector/index.js +70 -0
  77. package/src/components/common/LayoutSelector/index.less.js +4 -0
  78. package/src/components/common/LinkModal/CatgTable/index.js +78 -0
  79. package/src/components/common/LinkModal/CouponTable/index.js +111 -0
  80. package/src/components/common/LinkModal/CustomTable/index.js +72 -0
  81. package/src/components/common/LinkModal/FilteredProductModal/index.js +463 -0
  82. package/src/components/common/LinkModal/FilteredProductModal/index.less.js +4 -0
  83. package/src/components/common/LinkModal/FunctionTable/index.js +66 -0
  84. package/src/components/common/LinkModal/ProductDetailPage/index.js +241 -0
  85. package/src/components/common/LinkModal/ProductDetailPage/index.less.js +4 -0
  86. package/src/components/common/LinkModal/index.js +112 -0
  87. package/src/components/common/LinkModal/index.less.js +4 -0
  88. package/src/components/common/NewImg/index.js +91 -0
  89. package/src/components/common/ProductModal/index.js +556 -0
  90. package/src/components/common/ProductModal/index.less.js +4 -0
  91. package/src/components/common/ProductSource/index.js +91 -0
  92. package/src/components/common/ProductSource/index.less.js +4 -0
  93. package/src/components/common/RcCollapse/Collapse.js +176 -0
  94. package/src/components/common/RcCollapse/Panel.js +146 -0
  95. package/src/components/common/RcCollapse/PanelContent.js +41 -0
  96. package/src/components/common/RcCollapse/index.js +6 -0
  97. package/src/components/common/RcCollapse/index.less.js +4 -0
  98. package/src/components/common/RcCollapse/motionUtil.js +37 -0
  99. package/src/components/common/Slider/index.js +95 -0
  100. package/src/components/common/Slider/index.less.js +4 -0
  101. package/src/components/common/SwitchCollapse/index.js +162 -0
  102. package/src/components/common/SwitchCollapse/index.less.js +4 -0
  103. package/src/components/common/UrlPicker/index.js +81 -0
  104. package/src/components/common/UrlPicker/index.less.js +4 -0
  105. package/src/components/composite-comp/bol/components/Banner/defaultJSON.js +258 -0
  106. package/src/components/composite-comp/bol/components/Banner/imgs/banner.png.js +3 -0
  107. package/src/components/composite-comp/bol/components/Banner/index.js +34 -0
  108. package/src/components/composite-comp/bol/components/Banner/mobile/index.js +176 -0
  109. package/src/components/composite-comp/bol/components/Banner/mobile/index.less.js +4 -0
  110. package/src/components/composite-comp/bol/components/Banner/pc/index.js +254 -0
  111. package/src/components/composite-comp/bol/components/Banner/pc/index.less.js +4 -0
  112. package/src/components/composite-comp/bol/components/Button/defaultJSON.js +93 -0
  113. package/src/components/composite-comp/bol/components/Button/index.js +48 -0
  114. package/src/components/composite-comp/bol/components/Button/index.less.js +4 -0
  115. package/src/components/composite-comp/bol/components/Carousel/defaultJSON.js +286 -0
  116. package/src/components/composite-comp/bol/components/Carousel/imgs/defaultImg.png.js +3 -0
  117. package/src/components/composite-comp/bol/components/Carousel/index.js +37 -0
  118. package/src/components/composite-comp/bol/components/Carousel/mobile/index.js +217 -0
  119. package/src/components/composite-comp/bol/components/Carousel/mobile/index.less.js +4 -0
  120. package/src/components/composite-comp/bol/components/Carousel/pc/index.js +208 -0
  121. package/src/components/composite-comp/bol/components/Carousel/pc/index.less.js +4 -0
  122. package/src/components/composite-comp/bol/components/Divider/defaultJSON.js +40 -0
  123. package/src/components/composite-comp/bol/components/Divider/index.js +48 -0
  124. package/src/components/composite-comp/bol/components/ImageGallery/defaultJSON.js +64 -0
  125. package/src/components/composite-comp/bol/components/ImageGallery/index.js +30 -0
  126. package/src/components/composite-comp/bol/components/ImageGallery/mobile/index.js +47 -0
  127. package/src/components/composite-comp/bol/components/ImageGallery/mobile/index.less.js +4 -0
  128. package/src/components/composite-comp/bol/components/ImageText/defaultJSON.js +535 -0
  129. package/src/components/composite-comp/bol/components/ImageText/index.js +33 -0
  130. package/src/components/composite-comp/bol/components/ImageText/mobile/index.js +143 -0
  131. package/src/components/composite-comp/bol/components/ImageText/mobile/index.less.js +4 -0
  132. package/src/components/composite-comp/bol/components/ImageText/pc/index.js +112 -0
  133. package/src/components/composite-comp/bol/components/ImageText/pc/index.less.js +4 -0
  134. package/src/components/composite-comp/bol/components/Newsletter/defaultJSON.js +114 -0
  135. package/src/components/composite-comp/bol/components/Newsletter/index.js +65 -0
  136. package/src/components/composite-comp/bol/components/Newsletter/index.less.js +4 -0
  137. package/src/components/composite-comp/bol/components/Tag/defaultJSON.js +91 -0
  138. package/src/components/composite-comp/bol/components/Tag/index.js +52 -0
  139. package/src/components/composite-comp/bol/components/Tag/index.less.js +4 -0
  140. package/src/components/composite-comp/bol/components/Text/defaultJSON.js +125 -0
  141. package/src/components/composite-comp/bol/components/Text/index.js +68 -0
  142. package/src/components/composite-comp/bol/components/Text/index.less.js +4 -0
  143. package/src/components/composite-comp/bol/config-panels/BannerConfig/BannerConfigGroup/index.js +73 -0
  144. package/src/components/composite-comp/bol/config-panels/BannerConfig/BannerConfigGroup/index.less.js +4 -0
  145. package/src/components/composite-comp/bol/config-panels/BannerConfig/BannerConfigSetting/index.js +200 -0
  146. package/src/components/composite-comp/bol/config-panels/BannerConfig/BannerConfigSetting/index.less.js +4 -0
  147. package/src/components/composite-comp/bol/config-panels/BannerConfig/index.js +35 -0
  148. package/src/components/composite-comp/bol/config-panels/ButtonCompConfig/ButtonConfigContent/index.js +79 -0
  149. package/src/components/composite-comp/bol/config-panels/ButtonCompConfig/imgs/layout1.png.js +3 -0
  150. package/src/components/composite-comp/bol/config-panels/ButtonCompConfig/imgs/layout2.png.js +3 -0
  151. package/src/components/composite-comp/bol/config-panels/ButtonCompConfig/index.js +53 -0
  152. package/src/components/composite-comp/bol/config-panels/CarouselConfig/CarouselConfigImageGroup/index.js +91 -0
  153. package/src/components/composite-comp/bol/config-panels/CarouselConfig/CarouselConfigSetting/index.js +175 -0
  154. package/src/components/composite-comp/bol/config-panels/CarouselConfig/CarouselConfigSetting/index.less.js +4 -0
  155. package/src/components/composite-comp/bol/config-panels/CarouselConfig/imgs/defaultImg.png.js +3 -0
  156. package/src/components/composite-comp/bol/config-panels/CarouselConfig/index.js +54 -0
  157. package/src/components/composite-comp/bol/config-panels/DividerConfig/DividerContentSetting/index.js +153 -0
  158. package/src/components/composite-comp/bol/config-panels/DividerConfig/DividerSpacingSetting/index.js +66 -0
  159. package/src/components/composite-comp/bol/config-panels/DividerConfig/index.js +44 -0
  160. package/src/components/composite-comp/bol/config-panels/ImageGalleryConfig/ImageGalleryConfigImageGroup/index.js +91 -0
  161. package/src/components/composite-comp/bol/config-panels/ImageGalleryConfig/imgs/defaultImg.png.js +3 -0
  162. package/src/components/composite-comp/bol/config-panels/ImageGalleryConfig/index.js +44 -0
  163. package/src/components/composite-comp/bol/config-panels/ImageTextConfig/ImageTextConfigGroup/index.js +74 -0
  164. package/src/components/composite-comp/bol/config-panels/ImageTextConfig/index.js +170 -0
  165. package/src/components/composite-comp/bol/config-panels/NewsletterConfig/InputField/index.js +143 -0
  166. package/src/components/composite-comp/bol/config-panels/NewsletterConfig/NewsletterContentSetting/index.js +89 -0
  167. package/src/components/composite-comp/bol/config-panels/NewsletterConfig/index.js +44 -0
  168. package/src/components/composite-comp/bol/config-panels/TagCompConfig/TagConfigContent/index.js +88 -0
  169. package/src/components/composite-comp/bol/config-panels/TagCompConfig/imgs/layout1.png.js +3 -0
  170. package/src/components/composite-comp/bol/config-panels/TagCompConfig/index.js +48 -0
  171. package/src/components/composite-comp/bol/config-panels/TextCompConfig/TextConfigContent/index.js +79 -0
  172. package/src/components/composite-comp/bol/config-panels/TextCompConfig/TextConfigGroup/index.js +85 -0
  173. package/src/components/composite-comp/bol/config-panels/TextCompConfig/TextConfigGroup/index.less.js +4 -0
  174. package/src/components/composite-comp/bol/config-panels/TextCompConfig/imgs/layout1.png.js +3 -0
  175. package/src/components/composite-comp/bol/config-panels/TextCompConfig/index.js +55 -0
  176. package/src/components/composite-comp/bol/second-config-panels/BannerSecondConfig/index.js +109 -0
  177. package/src/components/composite-comp/bol/second-config-panels/CarouselSecondConfig/index.js +107 -0
  178. package/src/components/composite-comp/bol/second-config-panels/ImageTextSecondConfig/index.js +116 -0
  179. package/src/components/composite-comp/bol/second-config-panels/TextSecondConfig/TextContentConfigContent/index.js +79 -0
  180. package/src/components/composite-comp/bol/second-config-panels/TextSecondConfig/index.js +70 -0
  181. package/src/components/composite-comp/common/components/ImageLabel/index.js +47 -0
  182. package/src/components/composite-comp/common/components/ImageLabel/index.less.js +4 -0
  183. package/src/components/composite-comp/common/components/ProductItem/index.js +121 -0
  184. package/src/components/composite-comp/common/components/ProductItem/index.less.js +4 -0
  185. package/src/components/composite-comp/common/config-panels/BackgroundConfig/index.js +89 -0
  186. package/src/components/composite-comp/common/config-panels/CustomizeConfig/index.js +182 -0
  187. package/src/components/composite-comp/common/config-panels/CustomizeConfig/index.less.js +4 -0
  188. package/src/components/composite-comp/common/config-panels/SpacingConfig/index.js +133 -0
  189. package/src/components/composite-comp/common/config-panels/SpacingConfig/index.less.js +4 -0
  190. package/src/components/composite-comp/dito/components/FlashDeal/defaultJSON.js +176 -0
  191. package/src/components/composite-comp/dito/components/FlashDeal/index.js +31 -0
  192. package/src/components/composite-comp/dito/components/FlashDeal/mobile/imgs/defImg1.png.js +3 -0
  193. package/src/components/composite-comp/dito/components/FlashDeal/mobile/imgs/defImg2.png.js +3 -0
  194. package/src/components/composite-comp/dito/components/FlashDeal/mobile/imgs/defImg3.png.js +3 -0
  195. package/src/components/composite-comp/dito/components/FlashDeal/mobile/index.js +233 -0
  196. package/src/components/composite-comp/dito/components/FlashDeal/mobile/index.less.js +4 -0
  197. package/src/components/composite-comp/dito/components/Recommend/defaultJSON.js +210 -0
  198. package/src/components/composite-comp/dito/components/Recommend/index.js +31 -0
  199. package/src/components/composite-comp/dito/components/Recommend/mobile/index.js +317 -0
  200. package/src/components/composite-comp/dito/components/Recommend/mobile/index.less.js +4 -0
  201. package/src/components/composite-comp/dito/components/SearchBar/defaultJSON.js +44 -0
  202. package/src/components/composite-comp/dito/components/SearchBar/imgs/dito-logo.svg.js +3 -0
  203. package/src/components/composite-comp/dito/components/SearchBar/index.js +31 -0
  204. package/src/components/composite-comp/dito/components/SearchBar/mobile/index.js +89 -0
  205. package/src/components/composite-comp/dito/components/SearchBar/mobile/index.less.js +4 -0
  206. package/src/components/composite-comp/dito/config-panels/FlashDealConfig/FlashDealConfigContent/index.js +121 -0
  207. package/src/components/composite-comp/dito/config-panels/FlashDealConfig/FlashDealConfigTitle/index.js +102 -0
  208. package/src/components/composite-comp/dito/config-panels/FlashDealConfig/imgs/layout1.png.js +3 -0
  209. package/src/components/composite-comp/dito/config-panels/FlashDealConfig/index.js +49 -0
  210. package/src/components/composite-comp/dito/config-panels/RecommendConfig/RecommendConfigContent/index.js +97 -0
  211. package/src/components/composite-comp/dito/config-panels/RecommendConfig/RecommendConfigGroup/index.js +89 -0
  212. package/src/components/composite-comp/dito/config-panels/RecommendConfig/RecommendConfigGroup/index.less.js +4 -0
  213. package/src/components/composite-comp/dito/config-panels/RecommendConfig/imgs/defaultImg.png.js +3 -0
  214. package/src/components/composite-comp/dito/config-panels/RecommendConfig/imgs/layout1.png.js +3 -0
  215. package/src/components/composite-comp/dito/config-panels/RecommendConfig/index.js +49 -0
  216. package/src/components/composite-comp/dito/config-panels/SearchBarConfig/index.js +115 -0
  217. package/src/components/composite-comp/dito/second-config-panels/RecommendSecondConfig/index.js +156 -0
  218. package/src/components/constants/component-types.js +48 -0
  219. package/src/components/constants/index.js +74 -0
  220. package/src/components/constants/layout.js +90 -0
  221. package/src/components/core/Designer/CompListPanel/CompCard/index.js +33 -0
  222. package/src/components/core/Designer/CompListPanel/CompCard/index.less.js +4 -0
  223. package/src/components/core/Designer/CompListPanel/index.js +109 -0
  224. package/src/components/core/Designer/CompListPanel/index.less.js +4 -0
  225. package/src/components/core/Designer/ConfigPanel/index.js +246 -0
  226. package/src/components/core/Designer/ConfigPanel/index.less.js +4 -0
  227. package/src/components/core/Designer/History/index.js +82 -0
  228. package/src/components/core/Designer/PageCompList/index.js +248 -0
  229. package/src/components/core/Designer/PageCompList/index.less.js +4 -0
  230. package/src/components/core/Designer/QuickMenuBar/index.js +130 -0
  231. package/src/components/core/Designer/QuickMenuBar/index.less.js +4 -0
  232. package/src/components/core/Designer/ViewArea/index.js +86 -0
  233. package/src/components/core/Designer/ViewArea/index.less.js +4 -0
  234. package/src/components/core/Designer/index.js +364 -0
  235. package/src/components/core/Designer/index.less.js +4 -0
  236. package/src/components/core/Renderer/index.js +55 -0
  237. package/src/components/decorator/compositeDecorator.js +94 -0
  238. package/src/components/decorator/metaDecorator.js +150 -0
  239. package/src/components/index.js +4 -0
  240. package/src/components/meta-comp/components/Button/index.js +113 -0
  241. package/src/components/meta-comp/components/Button/index.less.js +4 -0
  242. package/src/components/meta-comp/components/Image/index.js +121 -0
  243. package/src/components/meta-comp/components/Image/index.less.js +4 -0
  244. package/src/components/meta-comp/components/Text/index.js +385 -0
  245. package/src/components/meta-comp/components/Text/index.less.js +4 -0
  246. package/src/components/meta-comp/config-panels/BaseConfig.js +47 -0
  247. package/src/components/meta-comp/config-panels/ButtonConfig/index.js +308 -0
  248. package/src/components/meta-comp/config-panels/ButtonConfig/index.less.js +4 -0
  249. package/src/components/meta-comp/config-panels/ImageConfig/index.js +179 -0
  250. package/src/components/meta-comp/config-panels/ImageConfig/index.less.js +4 -0
  251. package/src/components/meta-comp/config-panels/TextConfig/index.js +310 -0
  252. package/src/components/meta-comp/config-panels/TextConfig/index.less.js +4 -0
  253. package/src/components/mobx/Store.js +88 -0
  254. package/src/components/mobx/index.js +12 -0
  255. package/src/components/utils/androidUtil.js +22 -0
  256. package/src/components/utils/businessUtil.js +214 -0
  257. package/src/components/utils/commonUtil.js +223 -0
  258. package/src/components/utils/coreUtil.js +108 -0
  259. package/src/components/utils/currencyUtil.js +110 -0
  260. package/src/components/utils/dataTreeUtils.js +93 -0
  261. package/src/components/utils/dateUtil.js +30 -0
  262. package/src/components/utils/storeUtil.js +113 -0
@@ -0,0 +1,223 @@
1
+ import axios from 'axios';
2
+ import lib from '../../../node_modules/qs/lib/index.js';
3
+
4
+ /**
5
+ * 安全获取数据
6
+ * @param {function} func 获取函数
7
+ * @param {any} defaults 默认值
8
+ */
9
+
10
+ function ensure(func, defaults) {
11
+ try {
12
+ return func() || defaults;
13
+ } catch (error) {
14
+ return defaults;
15
+ }
16
+ }
17
+ /**
18
+ * fish fetch
19
+ * @param {*} url 请求地址
20
+ * @param {*} data 入参
21
+ * @param {*} method 请求方法
22
+ */
23
+
24
+ function commonFetch(url, data, method) {
25
+ if (data === void 0) {
26
+ data = {};
27
+ }
28
+
29
+ if (method === void 0) {
30
+ method = 'GET';
31
+ }
32
+
33
+ var _method = method.toUpperCase();
34
+
35
+ return new Promise(function (resolve) {
36
+ var _a, _b;
37
+
38
+ var isLoginUrl = url.includes('portal/login');
39
+ var headers = {
40
+ 'Content-Type': isLoginUrl ? 'application/x-www-form-urlencoded' : 'application/json; charset=UTF-8'
41
+ };
42
+
43
+ if (_method === 'GET') {
44
+ if ((_a = window.magicDesign) === null || _a === void 0 ? void 0 : _a.fetch) {
45
+ window.magicDesign.fetch(url, {
46
+ method: 'GET',
47
+ params: data
48
+ }).then(function (res) {
49
+ resolve(res);
50
+ });
51
+ return;
52
+ }
53
+
54
+ axios.get(url, {
55
+ params: data,
56
+ headers: headers
57
+ }).then(function (res) {
58
+ resolve(res.data);
59
+ });
60
+ }
61
+
62
+ if (_method === 'POST') {
63
+ if ((_b = window.magicDesign) === null || _b === void 0 ? void 0 : _b.fetch) {
64
+ window.magicDesign.fetch(url, {
65
+ method: 'POST',
66
+ data: data
67
+ }).then(function (res) {
68
+ resolve(res);
69
+ });
70
+ return;
71
+ }
72
+
73
+ axios.post(url, isLoginUrl ? lib.stringify(data) : data, {
74
+ headers: headers
75
+ }).then(function (res) {
76
+ resolve(res.data);
77
+ });
78
+ }
79
+ });
80
+ }
81
+ var navigateTo = function (url) {
82
+ if (!window.magicDesign || !window.magicDesign.history) {
83
+ window.location.href = url;
84
+ return;
85
+ }
86
+
87
+ window.magicDesign.history.push(url);
88
+ };
89
+ var dragSource = function (source, from, to) {
90
+ var out = source.splice(from, 1);
91
+
92
+ if (from > to) {
93
+ source.splice(to, 0, out[0]);
94
+ } else {
95
+ source.splice(to, 0, out[0]);
96
+ }
97
+
98
+ return source;
99
+ }; // 校验文件名称,不能存在 / \ ,
100
+
101
+ var checkFileName = function (fileName) {
102
+ if (fileName === undefined || fileName === null || fileName === '') {
103
+ return false;
104
+ }
105
+
106
+ var reg = /[\\,/]+/;
107
+
108
+ if (reg.test(fileName)) {
109
+ return false;
110
+ }
111
+
112
+ return true;
113
+ }; // 获取浏览器参数
114
+ /**
115
+ * 补0 函数
116
+ * @param {*} num 数字
117
+ */
118
+
119
+ var addZero = function (num) {
120
+ return String(num).length === 1 ? "0".concat(String(num)) : String(num);
121
+ };
122
+ /**
123
+ * 计算倒计时
124
+ * @param {number} lastTime 剩余时间 单位:毫秒
125
+ * @param {string?} type 'day' 以日为单位
126
+ * @returns
127
+ */
128
+
129
+ var calcLastTime = function (lastTime, type) {
130
+ if (lastTime <= 0) {
131
+ return 0;
132
+ }
133
+
134
+ var day = ~~(lastTime / 1000 / 60 / 60 / 24);
135
+ var hours = ~~(lastTime / 1000 / 60 / 60);
136
+ var mines = ~~(lastTime / 1000 / 60 % 60);
137
+ var second = ~~(lastTime / 1000 % 60);
138
+
139
+ if (type === 'day') {
140
+ hours = ~~(lastTime / 1000 / 60 / 60 % 24);
141
+ return "".concat(day, "DAYS ").concat(addZero(hours), ":").concat(addZero(mines), ":").concat(addZero(second));
142
+ }
143
+
144
+ if (type === '_hour') {
145
+ return hours;
146
+ }
147
+
148
+ if (type === '_mines') {
149
+ return mines;
150
+ }
151
+
152
+ return "".concat(addZero(hours), ":").concat(addZero(mines), ":").concat(addZero(second));
153
+ };
154
+ /**
155
+ * 获取图片URL
156
+ * @param {object} imageObj 图片对象
157
+ * @param {string?} type small | big
158
+ */
159
+
160
+ function convertImageUrl(imageObj, type) {
161
+ if (imageObj === void 0) {
162
+ imageObj = {};
163
+ }
164
+
165
+ if (!imageObj) return '';
166
+ var typeMap = {
167
+ small: 'smallImgUrl',
168
+ big: 'bigImgUrl'
169
+ }[type];
170
+ return ensure(function () {
171
+ return encodeURI(imageObj[typeMap] || imageObj.url);
172
+ }, '');
173
+ }
174
+ /** 序列化 style对象 */
175
+
176
+ var styleStringify = function (style, _a) {
177
+ var _b = _a === void 0 ? {} : _a,
178
+ _c = _b.suffix,
179
+ suffix = _c === void 0 ? 'px' : _c;
180
+
181
+ var numericProperties = ['height', 'width', 'top', 'left', 'right', 'bottom', 'fontSize', 'maxHeight', 'maxWidth', 'lineHeight', 'margin', 'marginTop', 'marginLeft', 'marginRight', 'marginBottom', 'padding', 'paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom'];
182
+ return Object.keys(style).reduce(function (styleStr, key) {
183
+ var value = style[key];
184
+ if (value == null) return styleStr;
185
+ var needSuffix = numericProperties.includes(key) && typeof value === 'number';
186
+ var newName = key.replace(/([A-Z])/g, '-$1').toLowerCase();
187
+ return "".concat(styleStr).concat(newName, ": ").concat(value).concat(needSuffix ? suffix : '', "; ");
188
+ }, '');
189
+ };
190
+ /** 十六进制色值转换成rgba */
191
+
192
+ var getColorRgba = function (sHex, alpha) {
193
+ if (alpha === void 0) {
194
+ alpha = 1;
195
+ }
196
+
197
+ var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
198
+ var sColor = sHex.toLowerCase();
199
+
200
+ if (sColor && reg.test(sColor)) {
201
+ if (sColor.length === 4) {
202
+ var sColorNew = '#';
203
+
204
+ for (var i = 1; i < 4; i += 1) {
205
+ sColorNew += sColor.slice(i, i + 1).concat(sColor.slice(i, i + 1));
206
+ }
207
+
208
+ sColor = sColorNew;
209
+ }
210
+
211
+ var sColorChange = [];
212
+
213
+ for (var i = 1; i < 7; i += 2) {
214
+ sColorChange.push(parseInt('0x' + sColor.slice(i, i + 2)));
215
+ }
216
+
217
+ return 'rgba(' + sColorChange.join(',') + ',' + alpha + ')';
218
+ } else {
219
+ return sColor;
220
+ }
221
+ };
222
+
223
+ export { addZero, calcLastTime, checkFileName, commonFetch, convertImageUrl, dragSource, ensure, getColorRgba, navigateTo, styleStringify };
@@ -0,0 +1,108 @@
1
+ import uuid_1 from '../../../node_modules/uuid/index.js';
2
+ import { parseUrl } from './businessUtil.js';
3
+ import { navigateTo } from './commonUtil.js';
4
+ import { browserVersion } from './androidUtil.js';
5
+
6
+ var _this = undefined;
7
+ var isDesignMode = function () {
8
+ return window.magicDesign.mode === 'designer';
9
+ };
10
+ var isPc = function () {
11
+ return window.magicDesign.device === 'pc';
12
+ };
13
+ /** 刷新预览区域 */
14
+
15
+ var renderPreview = function () {
16
+ var evt = new Event('render-view', {
17
+ bubbles: false
18
+ });
19
+ window.document.dispatchEvent(evt);
20
+ };
21
+ var clickUrl = function (url) {
22
+ console.log('url', url);
23
+
24
+ if (window.magicDesign.readOnly || window.magicDesign.mode !== 'renderer' || !url) {
25
+ return;
26
+ }
27
+
28
+ var _a = parseUrl(url),
29
+ h5Link = _a.h5Link,
30
+ params = _a.params;
31
+
32
+ var type = params.type,
33
+ data = params.data; // 领取优惠券
34
+
35
+ if (type === 'GET_COUPON') {
36
+ _this.getCoupon(data.couponId);
37
+
38
+ return;
39
+ }
40
+
41
+ if (!browserVersion().isApp) {
42
+ if (url.startsWith('/')) {
43
+ navigateTo(url);
44
+ } else {
45
+ location.href = url;
46
+ }
47
+
48
+ return;
49
+ }
50
+
51
+ if (browserVersion().android) {
52
+ sendToAndroid({
53
+ type: 'jump',
54
+ params: {
55
+ url: h5Link
56
+ }
57
+ });
58
+ } else if (browserVersion().ios) {
59
+ if (type === 'CUSTOMIZED') {
60
+ // 适配ios 从首页跳转自定义页面
61
+ _this.goH5Page(h5Link);
62
+ }
63
+
64
+ sendToIos(params);
65
+ }
66
+ };
67
+
68
+ function isObject(value) {
69
+ var type = typeof value;
70
+ return value != null && (type === 'object' || type === 'function');
71
+ } // 拷贝节点方法,重新生成节点中的id和parentId字段
72
+
73
+
74
+ var copyNode = function (value, parentId) {
75
+ if (!isObject(value)) {
76
+ return value;
77
+ }
78
+
79
+ var isArr = Array.isArray(value);
80
+
81
+ if (isArr) {
82
+ var newArray_1 = [];
83
+ value.forEach(function (data) {
84
+ newArray_1.push(copyNode(data));
85
+ });
86
+ return newArray_1;
87
+ }
88
+
89
+ var newNode = {};
90
+
91
+ if (value.id) {
92
+ newNode.id = uuid_1.v4();
93
+ }
94
+
95
+ var names = Object.getOwnPropertyNames(value);
96
+ names.forEach(function (name) {
97
+ if (name === 'id') return;
98
+
99
+ if (name === 'parentId') {
100
+ newNode.parentId = parentId;
101
+ } else {
102
+ newNode[name] = copyNode(value[name], newNode.id);
103
+ }
104
+ });
105
+ return newNode;
106
+ };
107
+
108
+ export { clickUrl, copyNode, isDesignMode, isPc, renderPreview };
@@ -0,0 +1,110 @@
1
+ import divide_1 from '../../../node_modules/lodash/divide.js';
2
+ import isEmpty_1 from '../../../node_modules/lodash/isEmpty.js';
3
+ import { ensure } from './commonUtil.js';
4
+
5
+ /* eslint-disable */
6
+ ensure(function () {
7
+ return window.ecommerce.precision;
8
+ }, '0'); // 千分位展示
9
+
10
+ var addSeparators = function (nStr, thousandsSep, decimalSep) {
11
+ if (!Number(nStr)) {
12
+ return nStr;
13
+ }
14
+
15
+ var x1;
16
+ var x2;
17
+ nStr += '';
18
+ var x = nStr.split('.');
19
+ x1 = x[0];
20
+ x2 = x.length > 1 ? decimalSep + x[1] : '';
21
+ var rgx = /(\d+)(\d{3})/;
22
+
23
+ while (rgx.test(x1)) {
24
+ x1 = x1.replace(rgx, "$1".concat(thousandsSep, "$2"));
25
+ }
26
+
27
+ return x1 + x2;
28
+ };
29
+ var getPricePrefix = function () {
30
+ var pricePrefix = ensure(function () {
31
+ return window.ecommerce.prefix;
32
+ }, 'Rp');
33
+ return pricePrefix;
34
+ };
35
+ var getPrecision = function () {
36
+ var ret = ensure(function () {
37
+ return window.ecommerce.precision;
38
+ }, '0');
39
+ return Number(ret);
40
+ }; // 格式化金额
41
+
42
+ var formatCurrency = function (num) {
43
+ var displayPrecision = ensure(function () {
44
+ return window.ecommerce.displayCurrencyPrecision;
45
+ }, '0');
46
+ var precision = ensure(function () {
47
+ return window.ecommerce.precision;
48
+ }, '0');
49
+ var pricePrefix = ensure(function () {
50
+ return window.ecommerce.prefix;
51
+ }, 'Rp');
52
+ var numVal = num;
53
+
54
+ if (Number.isNaN(num) || !Number.isFinite(num)) {
55
+ numVal = 0;
56
+ }
57
+
58
+ var displayNum = displayPrecision != null && displayPrecision !== '' ? displayPrecision : precision;
59
+ var ret = numVal / Math.pow(10, precision);
60
+ return addSeparators(ret.toFixed(displayNum), pricePrefix === "IDR" || pricePrefix === "Rp" ? '.' : ',', '.');
61
+ };
62
+ var formatCurrencyWithSymbol = function (num) {
63
+ var ret = formatCurrency(num);
64
+ return "".concat(getPricePrefix(), " ").concat(ret);
65
+ };
66
+ /**
67
+ * 格式化数值,不加前缀 (前台使用) 例如:缩小100倍
68
+ * @param {*} value 数值
69
+ * @param {*} customPrecision 精度转换,默认读配置项
70
+ * @param {*} customDisplayPrecision 保留小数位数,默认读配置项(传null,表示不作处理只转换精度)
71
+ * @returns 格式化后的数值字符串
72
+ */
73
+
74
+ var currencyToFont = function (value, customPrecision, customDisplayPrecision) {
75
+ if (value === null || value === undefined || value === '' || Number.isNaN(Number(value))) {
76
+ return value;
77
+ }
78
+
79
+ var precision; // 优先使用参数上的精度
80
+
81
+ if (!isEmpty_1(customPrecision) && !Number.isNaN(Number(customPrecision))) {
82
+ precision = Number(customPrecision);
83
+ } else {
84
+ precision = ensure(function () {
85
+ return window.ecommerce.precision;
86
+ }, '0');
87
+ }
88
+
89
+ var number = Number(value);
90
+ var temp = divide_1(number, Math.pow(10, precision)); // 特殊处理,不需要格式化小数位
91
+
92
+ if (customDisplayPrecision === null) {
93
+ return "".concat(temp);
94
+ } // 精度格式化
95
+
96
+
97
+ var displayPrecision; // 优先使用参数上的精度
98
+
99
+ if (!isEmpty_1(customDisplayPrecision) && !Number.isNaN(Number(customDisplayPrecision))) {
100
+ displayPrecision = Number(customDisplayPrecision);
101
+ } else {
102
+ displayPrecision = ensure(function () {
103
+ return window.ecommerce.displayCurrencyPrecision;
104
+ }, 'Rp');
105
+ }
106
+
107
+ return temp.toFixed(Number(displayPrecision));
108
+ };
109
+
110
+ export { addSeparators, currencyToFont, formatCurrency, formatCurrencyWithSymbol, getPrecision, getPricePrefix };
@@ -0,0 +1,93 @@
1
+ import isEmpty_1 from '../../../node_modules/lodash/isEmpty.js';
2
+ import isObject_1 from '../../../node_modules/lodash/isObject.js';
3
+ import mapKeys_1 from '../../../node_modules/lodash/mapKeys.js';
4
+ import cloneDeep_1 from '../../../node_modules/lodash/cloneDeep.js';
5
+
6
+ /**
7
+ * 处理树相关的工具
8
+ */
9
+
10
+ var treeUtils = {
11
+ /** 将一维数组转换为树结构 */
12
+ translateDataToTree: function (jsonData, id, pid, mapProps) {
13
+ var newData = cloneDeep_1(jsonData);
14
+ var result = [];
15
+ var temp = {};
16
+
17
+ for (var i = 0; i < newData.length; i += 1) {
18
+ temp[newData[i][id]] = newData[i]; // 以id作为索引存储元素,可以无需遍历直接定位元素
19
+ }
20
+
21
+ var _loop_1 = function (j) {
22
+ var currentElement = newData[j]; // 添加需要的属性
23
+
24
+ if (mapProps && isObject_1(mapProps) && !isEmpty_1(mapProps)) {
25
+ mapKeys_1(mapProps, function (value, key) {
26
+ currentElement[key] = currentElement[value];
27
+ });
28
+ }
29
+
30
+ var tempCurrentElementParent = temp[currentElement[pid]]; // 临时变量里面的当前元素的父元素
31
+
32
+ if (tempCurrentElementParent) {
33
+ // 如果存在父元素
34
+ if (!tempCurrentElementParent.children) {
35
+ // 如果父元素没有chindren键
36
+ tempCurrentElementParent.children = []; // 设上父元素的children键
37
+ }
38
+
39
+ tempCurrentElementParent.children.push(currentElement); // 给父元素加上当前元素作为子元素
40
+ } else {
41
+ // 不存在父元素,意味着当前元素是一级元素
42
+ result.push(currentElement);
43
+ }
44
+ };
45
+
46
+ for (var j = 0; j < newData.length; j += 1) {
47
+ _loop_1(j);
48
+ }
49
+
50
+ return result;
51
+ },
52
+
53
+ /**
54
+ * jsonData 输入数据
55
+ * 需要查找的id
56
+ * pk 主键的名称
57
+ * childKeys返回值
58
+ */
59
+ findChildKeys: function (jsonData, id, pk, childKeys) {
60
+ var target = {};
61
+ this.dsFilter(jsonData, id, pk, target);
62
+
63
+ if (target && JSON.stringify(target) !== '{}') {
64
+ childKeys.push(target[pk]);
65
+
66
+ if (target.children && target.children.length) {
67
+ this.getChildKey(target.children, pk, childKeys);
68
+ }
69
+ }
70
+ },
71
+ dsFilter: function (dealData, id, pk, target) {
72
+ for (var i = 0; i < dealData.length; i += 1) {
73
+ if (dealData[i].children && dealData[i].children.length) {
74
+ this.dsFilter(dealData[i].children, id, pk, target);
75
+ }
76
+
77
+ if (dealData[i][pk] === id) {
78
+ Object.assign(target, dealData[i]);
79
+ }
80
+ }
81
+ },
82
+ getChildKey: function (dealData, pk, childKeys) {
83
+ for (var i = 0; i < dealData.length; i += 1) {
84
+ if (dealData[i].children && dealData[i].children.length) {
85
+ this.getChildKey(dealData[i].children, pk, childKeys);
86
+ }
87
+
88
+ childKeys.push(dealData[i][pk]);
89
+ }
90
+ }
91
+ };
92
+
93
+ export { treeUtils as default };
@@ -0,0 +1,30 @@
1
+ import moment from 'moment';
2
+
3
+ var dateFmt = 'YYYY-MM-DD';
4
+ /**
5
+ * new Date 解决ios 安卓兼容问题
6
+ * @param {*} date 时间
7
+ */
8
+
9
+ var newDate = function (date) {
10
+ if (date instanceof Date) {
11
+ return date;
12
+ }
13
+
14
+ if (date) {
15
+ var reg = /^[0-9]+.?[0-9]*$/;
16
+
17
+ if (reg.test(date)) {
18
+ return new Date(Number(date));
19
+ }
20
+
21
+ return new Date(date.replace(/-/g, '/'));
22
+ }
23
+
24
+ return new Date();
25
+ };
26
+ var formatDate = function (date) {
27
+ return moment(date).format(dateFmt);
28
+ };
29
+
30
+ export { formatDate, newDate };
@@ -0,0 +1,113 @@
1
+ import { ensure } from './commonUtil.js';
2
+ import { formatDate } from './dateUtil.js';
3
+
4
+ var debug = require('debug')('worker:store');
5
+ /** 持久化渠道 */
6
+
7
+
8
+ var CHANNEL = window.localStorage;
9
+ /**
10
+ * 获取缓存数据 localStorage
11
+ * @param {*} key
12
+ * @param {*} isJson 是否是json 默认是
13
+ */
14
+
15
+ var getStore = function (key, channel) {
16
+ if (channel === void 0) {
17
+ channel = CHANNEL;
18
+ }
19
+
20
+ return ensure(function () {
21
+ return JSON.parse(channel.getItem(key));
22
+ }, channel.getItem(key));
23
+ };
24
+ /**
25
+ * 设置缓存 localStorage
26
+ * @param {string} key 键
27
+ * @param {any} data 值
28
+ */
29
+
30
+ var setStore = function (key, data, channel) {
31
+ if (channel === void 0) {
32
+ channel = CHANNEL;
33
+ }
34
+
35
+ if (data instanceof Object) {
36
+ channel.setItem(key, JSON.stringify(data));
37
+ } else {
38
+ channel.setItem(key, data);
39
+ }
40
+ };
41
+ /**
42
+ * 清空 localStorage
43
+ * @param {string} key 键
44
+ */
45
+
46
+ var clearStore = function (key, channel) {
47
+ if (channel === void 0) {
48
+ channel = CHANNEL;
49
+ }
50
+
51
+ if (key) {
52
+ channel.removeItem(key);
53
+ } else {
54
+ channel.clear();
55
+ }
56
+ };
57
+ /** 设计器定制的 一套缓存机制 */
58
+
59
+ /**
60
+ * 获取缓存数据 localStorage
61
+ * @param {*} key
62
+ * @param {*} isJson 是否是json 默认是
63
+ */
64
+ // export const getStore = key => ensure(() => JSON.parse(CHANNEL.getItem(key)), CHANNEL.getItem(key));
65
+
66
+ var localStorageKey = 'magicBoxCache';
67
+ /** 清楚缓存 */
68
+
69
+ var clearMagicStore = function () {
70
+ clearStore(localStorageKey);
71
+ };
72
+ /**
73
+ * 设置缓存 localStorage
74
+ * @param {string} key 键
75
+ * @param {any} data 值
76
+ */
77
+
78
+ var setMagicStore = function (key, data) {
79
+ try {
80
+ var localStore = getStore(localStorageKey) || {
81
+ date: formatDate(),
82
+ data: {}
83
+ };
84
+ localStore.data[key] = data;
85
+ setStore(localStorageKey, localStore);
86
+ } catch (error) {
87
+ debug(error);
88
+ clearMagicStore();
89
+ }
90
+ };
91
+ /** 获取设计器缓存 */
92
+
93
+ var getMagicStore = function (key) {
94
+ try {
95
+ var localStore = getStore(localStorageKey) || {
96
+ date: formatDate(),
97
+ data: {}
98
+ };
99
+
100
+ if (localStore.date !== formatDate()) {
101
+ throw new Error('清除设计器缓存');
102
+ }
103
+
104
+ return localStore.data[key];
105
+ } catch (error) {
106
+ debug(error);
107
+ clearMagicStore();
108
+ }
109
+
110
+ return null;
111
+ };
112
+
113
+ export { clearMagicStore, clearStore, getMagicStore, getStore, setMagicStore, setStore };