diy.php 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543
  1. <script src="/resources/js/html2canvas.min.js"></script>
  2. <script>
  3. function getRandomId(list = []) {
  4. var initArr = [] // getInitArr(); // 拿到已有的id -- 一般不会冲突
  5. // 随机id不能和以前编辑冲突
  6. function generateId() {
  7. const s = [];
  8. const hexDigits = '0123456789abcdef';
  9. for (let i = 0; i < 36; i++) {
  10. s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
  11. }
  12. s[14] = '4';
  13. s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);
  14. s[8] = s[13] = s[18] = s[23] = '-';
  15. const uuid = s.join('');
  16. if (initArr.some(str => (str === uuid))) { // 存在已有数据
  17. return generateId()
  18. }
  19. return uuid;
  20. }
  21. function getInitArr() {
  22. return list.map(item => {
  23. return item.id
  24. })
  25. }
  26. var id = generateId()
  27. return id
  28. }
  29. function deepClone(obj) {
  30. var o, i, j, k;
  31. if (typeof(obj) != "object" || obj === null) return obj;
  32. if (obj instanceof(Array)) {
  33. o = [];
  34. i = 0;
  35. j = obj.length;
  36. for (; i < j; i++) {
  37. if (typeof(obj[i]) == "object" && obj[i] != null) {
  38. o[i] = arguments.callee(obj[i]);
  39. } else {
  40. o[i] = obj[i];
  41. }
  42. }
  43. } else {
  44. o = {};
  45. for (i in obj) {
  46. if (typeof(obj[i]) == "object" && obj[i] != null) {
  47. o[i] = arguments.callee(obj[i]);
  48. } else {
  49. o[i] = obj[i];
  50. }
  51. }
  52. }
  53. return o;
  54. }
  55. function getObjValue(target = {}, keys = [], def) {
  56. let obj = deepClone(target)
  57. try {
  58. value = keys.reduce((prev, key) => {
  59. return prev[key]
  60. }, target)
  61. } catch (error) {
  62. value = def
  63. }
  64. return value || def
  65. }
  66. function deepEqual(x, y) {
  67. // 指向同一内存时
  68. if (x === y) {
  69. return true;
  70. } else if ((typeof x == "object" && x != null) && (typeof y == "object" && y != null)) {
  71. if (Object.keys(x).length !== Object.keys(y).length) {
  72. return false;
  73. }
  74. for (var prop in x) {
  75. if (y.hasOwnProperty(prop)) {
  76. if (!deepEqual(x[prop], y[prop])) return false;
  77. } else {
  78. return false;
  79. }
  80. }
  81. return true;
  82. } else {
  83. return false;
  84. }
  85. }
  86. var basicMixins = {
  87. data() {
  88. return {
  89. defaultForm: {
  90. // default_color: "transparer",
  91. colorInfos: ['底部背景'],
  92. sizeInfos: ['上边距', '下边距', '左右边距'],
  93. radiusInfos: ['上圆角', '下圆角'],
  94. defColor: "transparent",
  95. tabItem: null
  96. },
  97. result: {},
  98. searchIpts: {},
  99. diy_img_prefix: '<?= Yii::getAlias('@attachurl') ?>',
  100. }
  101. },
  102. created() {
  103. this.init()
  104. },
  105. // 这里是基础的修改 - 需要其他自行添加对应方法-数据
  106. methods: {
  107. init() {
  108. // 设置默认值
  109. this.result = deepClone(this.activeItem)
  110. this.searchIpts = this.result.computedStyle.searchIpts || {}
  111. // 描边颜色默认值
  112. let arr = ['computedStyle', 'tabItem']
  113. this.defaultForm.tabItem = getObjValue(this.result, arr, this.defaultForm.tabItem)
  114. // 选择颜色样式
  115. let arr1 = ['computedStyle', 'searchBox']
  116. var colorArr = [{
  117. name: '底部背景', //名字
  118. color: getObjValue(this.result, arr1, "transparent"), //颜色
  119. showAlpha: false, //是否开启透明度
  120. }, ]
  121. this.defaultForm.colorInfos = colorArr
  122. // 边距
  123. let arr2 = ['computedStyle', 'searchIpts', 'marginBottom']
  124. let arr3 = ['computedStyle', 'searchIpts', 'marginLeft']
  125. let arr4 = ['computedStyle', 'searchIpts', 'marginTop']
  126. var marginArr = [{
  127. name: '上边距', //名字
  128. value: parseFloat(getObjValue(this.result, arr4, 0)), //值
  129. unit: "px", //单位
  130. disabled: false, //是否禁用
  131. maxValue: 50,
  132. }, {
  133. name: '下边距', //名字
  134. value: parseFloat(getObjValue(this.result, arr2, 0)), //值
  135. unit: "px", //单位
  136. disabled: false, //是否禁用
  137. maxValue: 50,
  138. }, {
  139. name: '左右边距', //名字
  140. value: parseFloat(getObjValue(this.result, arr3, 0)), //值
  141. unit: "px", //单位
  142. disabled: false, //是否禁用
  143. maxValue: 20,
  144. }]
  145. this.defaultForm.sizeInfos = marginArr
  146. // 圆角
  147. let arr5 = ['computedStyle', 'searchIpts', 'border-top-left-radius']
  148. let arr6 = ['computedStyle', 'searchIpts', 'border-bottom-right-radius']
  149. var radiusArr = [{
  150. name: '上圆角', //名字
  151. value: parseFloat(getObjValue(this.result, arr5, 0)), //值
  152. unit: "px", //单位
  153. disabled: false, //是否禁用
  154. maxValue: 20,
  155. }, {
  156. name: '下圆角', //名字
  157. value: parseFloat(getObjValue(this.result, arr6, 0)), //值
  158. unit: "px", //单位
  159. disabled: false, //是否禁用
  160. maxValue: 20,
  161. }]
  162. this.defaultForm.radiusInfos = radiusArr
  163. },
  164. // 基础逻辑
  165. colorSelect(e) { // 样式
  166. console.log(e)
  167. let tabItem = this.defaultForm.tabItem || {}
  168. this.defaultForm.tabItem = Object.assign(tabItem, e.item)
  169. console.log('this.defaultForm.tabItem');
  170. console.log(this.defaultForm.tabItem);
  171. this.updataResult(this.defaultForm.tabItem, 'tabItem')
  172. },
  173. sliderChange(arr, type, showUnit = true) { // 边距
  174. let top = arr[0] && (showUnit ? (arr[0].value + arr[0].unit) : arr[0].value)
  175. let bottom = arr[1] && (showUnit ? (arr[1].value + arr[1].unit) : arr[1].value)
  176. let lr = arr[2] && (showUnit ? (arr[2].value + arr[2].unit) : arr[2].value)
  177. const style = {
  178. marginTop: top,
  179. marginBottom: bottom,
  180. marginLeft: lr,
  181. marginRight: lr
  182. }
  183. this.searchIpts = Object.assign(this.searchIpts, style)
  184. this.updataResult(this.searchIpts, 'searchIpts')
  185. },
  186. RadiusChange(arr) {
  187. let top = arr[0].value + arr[0].unit
  188. let bottom = arr[1].value + arr[1].unit
  189. const style = {
  190. 'border-top-left-radius': top,
  191. 'border-top-right-radius': top,
  192. 'border-bottom-right-radius': bottom,
  193. 'border-bottom-left-radius': bottom
  194. }
  195. this.searchIpts = Object.assign(this.searchIpts, style)
  196. this.updataResult(this.searchIpts, 'searchIpts')
  197. },
  198. updateColor(e) { // 选择颜色
  199. this.result.computedStyle.searchBox = e[0].color
  200. this.$emit("update", this.result)
  201. },
  202. updataResult(style, name) {
  203. var result = deepClone(style)
  204. this.result.computedStyle[name] = result
  205. this.$emit("update", this.result)
  206. },
  207. iptSelect(e) {
  208. e.currentTarget.select();
  209. },
  210. }
  211. }
  212. //16进制颜色转化为RGB颜色
  213. function colorRgb(str) {
  214. var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
  215. var sColor = str.toLowerCase();
  216. if (sColor && reg.test(sColor)) {
  217. if (sColor.length === 4) {
  218. var sColorNew = "#";
  219. for (var i = 1; i < 4; i += 1) {
  220. sColorNew += sColor.slice(i, i + 1).concat(sColor.slice(i, i + 1));
  221. }
  222. sColor = sColorNew;
  223. }
  224. //处理六位的颜色值
  225. var sColorChange = [];
  226. for (var i = 1; i < 7; i += 2) {
  227. sColorChange.push(parseInt("0x" + sColor.slice(i, i + 2)));
  228. }
  229. return "rgb(" + sColorChange.join(",") + ")";
  230. } else {
  231. return sColor;
  232. }
  233. }
  234. //判断是否为亮色
  235. function getContrastYIQ(hexcolor) {
  236. try {
  237. var colorrgb = colorRgb(hexcolor);
  238. var colors = colorrgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
  239. var red = colors[1];
  240. var green = colors[2];
  241. var blue = colors[3];
  242. var brightness;
  243. brightness = (red * 299) + (green * 587) + (blue * 114);
  244. brightness = brightness / 255000;
  245. if (brightness >= 0.5) {
  246. return "light";
  247. } else {
  248. return "dark";
  249. }
  250. } catch (e) {
  251. return "light";
  252. }
  253. }
  254. // 获取链接选择其他链接类型中文
  255. function getOtherUrlName(type) {
  256. let text = "";
  257. if (type == "call") {
  258. text = "拨打电话"
  259. } else if (type == "web") {
  260. text = "自定义链接"
  261. } else if (type == "applet") {
  262. text = "小程序"
  263. }
  264. return text;
  265. }
  266. // dom生成canvas
  267. function domToCanvas(contain) {
  268. var canvas2 = document.createElement("canvas");
  269. var w = $(contain).outerWidth();
  270. var h = $(contain).outerHeight();
  271. //先放大2倍,后期缩小,处理模糊问题
  272. canvas2.width = w * 2;
  273. canvas2.height = h * 2;
  274. canvas2.style.width = w + "px";
  275. canvas2.style.height = h + "px";
  276. var context = canvas2.getContext("2d");
  277. // 进行缩放
  278. context.scale(2, 2);
  279. return new Promise((resolve, reject) => {
  280. html2canvas(document.querySelector(contain), {
  281. canvas: canvas2,
  282. allowTaint: true, //允许污染
  283. taintTest: true, //在渲染前测试图片
  284. useCORS: true //使用跨域
  285. }).then(function(canvas) {
  286. resolve(canvas)
  287. });
  288. })
  289. }
  290. function getNavData() {
  291. const result = {
  292. "id": getRandomId(),
  293. "data": {
  294. "logoSrc": "",
  295. "backSrc": "",
  296. "isShowName": "1",
  297. "isShowSearch": "0",
  298. "mainPage": { // 主页面设置
  299. "defColor": "#fff",
  300. "imageUrl": [],
  301. "name": "标题",
  302. "type": "纯色"
  303. },
  304. "positionChoose": "1",
  305. "name": "商品详情"
  306. },
  307. "computedStyle": {
  308. "mode": 1,
  309. "style": 1,
  310. "titleSwitch": true,
  311. "titleMode": 1,
  312. "imageUrl": [],
  313. "position": 1,
  314. "searchSwitch": true,
  315. "searchBgColor": "",
  316. "defaultForm": {
  317. "defColor": "transparer"
  318. },
  319. "titleDistance": {
  320. "fontSize": 16,
  321. "height": 30,
  322. "width": 57,
  323. "marginLeft": 20
  324. },
  325. "statusBar": "1",
  326. "searchMarPad": {
  327. "marginLeft": 20,
  328. "paddingLeft": 14
  329. }
  330. },
  331. "permission": [],
  332. "funcListItem": {
  333. "type": "nav",
  334. "title": "顶部导航",
  335. "is_top": 1
  336. },
  337. "isShow": true,
  338. "is_show_permission": false,
  339. "is_drag": false,
  340. "disabled": true,
  341. }
  342. return result
  343. }
  344. function getGoodsParse() {
  345. const result = {
  346. "id": getRandomId(),
  347. "data": {
  348. "sizeInfos": [{
  349. "disabled": false,
  350. "hidden": false,
  351. "maxValue": 50,
  352. "name": "上边距",
  353. "unit": "px",
  354. "value": 0
  355. },
  356. {
  357. "disabled": false,
  358. "hidden": false,
  359. "maxValue": 50,
  360. "name": "下边距",
  361. "unit": "px",
  362. "value": 0
  363. },
  364. {
  365. "disabled": false,
  366. "hidden": false,
  367. "maxValue": 20,
  368. "name": "左右边距",
  369. "unit": "px",
  370. "value": 0
  371. }
  372. ]
  373. },
  374. "computedStyle": {
  375. "aroundMargin": "0px",
  376. "marginBottom": "0px",
  377. "marginTop": "0px"
  378. },
  379. "permission": [],
  380. "funcListItem": {
  381. "count": 1,
  382. "img": "resources/img/decorate/func/goods-info.png",
  383. "type": "goods-parse",
  384. "title": "商品详情",
  385. "permission": {
  386. "is_copy": false,
  387. "is_delete": false,
  388. "is_show": false
  389. }
  390. },
  391. "isShow": true,
  392. "is_copy": false,
  393. "is_delete": false,
  394. "is_show": false,
  395. "is_show_permission": true,
  396. "visible": false,
  397. }
  398. return result
  399. }
  400. function debounce(func, wait) {
  401. let timer;
  402. return function() {
  403. let context = this; // 注意 this 指向
  404. let args = arguments; // arguments中存着e
  405. if (timer) clearTimeout(timer);
  406. timer = setTimeout(() => {
  407. func.apply(this, args)
  408. }, wait)
  409. }
  410. }
  411. </script>
  412. <?php
  413. use common\helpers\ComponentHelper;
  414. use common\models\diy\DiyComponents;
  415. $diyPath = Yii::$app->viewPath . '/components/common/diy/common';
  416. $stylePath = Yii::$app->viewPath . '/components/common/diy/style-components';
  417. $components = DiyComponents::getDir($diyPath, $diyPath);
  418. $styleComponents = DiyComponents::getDir($stylePath, $stylePath);
  419. ComponentHelper::loadComponentView('diy/diy-func-list');
  420. ComponentHelper::loadComponentView('diy/diy-preview');
  421. ComponentHelper::loadComponentView('diy/diy-style-preview');
  422. ComponentHelper::loadComponentView('diy/popup-advertisement');
  423. if (!empty($addons_components)) {
  424. // 组件ID
  425. $view_arr = ['preview', 'style'];
  426. foreach ($addons_components as $item) {
  427. $basc_path = Yii::getAlias('@addons') . "/{$item['source']}/backend/views/components/diy/{$item['code']}";
  428. // 加载组件
  429. foreach ($view_arr as $view) {
  430. // 文件
  431. $file_path = $basc_path . DIRECTORY_SEPARATOR . $view . '.php';
  432. if (is_file($file_path)) {
  433. ComponentHelper::loadComponentView($view, $basc_path);
  434. }
  435. }
  436. }
  437. }
  438. foreach ($components as $item) {
  439. ComponentHelper::loadComponentView("diy/common/{$item}");
  440. }
  441. foreach ($styleComponents as $item) {
  442. ComponentHelper::loadComponentView("diy/style-components/{$item}");
  443. }
  444. $currentRoute = Yii::$app->controller->route;
  445. ?>
  446. <div id="app" class="fixed">
  447. <div class="diy-header flex">
  448. <div class="flex flex-y-center">
  449. <div @click="goBack" class="diy-header-backs">
  450. <i class="el-icon-arrow-left"></i>
  451. <span>返回</span>
  452. </div>
  453. <div class="custom-page" style="margin-left:70px;">自定义页面装修</div>
  454. <div class="temp-select" v-if="pageType == 2">
  455. <el-select size="small" v-model="cate_id" placeholder="请选择">
  456. <el-option v-for="item in cate_arr" :key="item.label" :label="item.label" :value="item.value">
  457. </el-option>
  458. </el-select>
  459. <div class="cate">所属分类:</div>
  460. </div>
  461. </div>
  462. <div class="flex flex-y-center diy_nav_right">
  463. <div class="page_set xiaoshou" @click="pageSet">
  464. <i class="el-icon-setting "></i>
  465. <span>页面设置</span>
  466. </div>
  467. <!-- <div class="save_as_template xiaoshou" @click="popupVisible = true">
  468. 另存为模板
  469. </div> -->
  470. <div class="save_preview xiaoshou" @click="savePreview">
  471. 保存并预览
  472. </div>
  473. <div style=" margin: -5px 0" class="sava_btn">
  474. <el-button type="primary" size="mini" @click="save" :loading="saveLoading">
  475. <i class="el-icon-s-promotion save"></i>
  476. <span>保存设置</span>
  477. </el-button>
  478. </div>
  479. </div>
  480. </div>
  481. <div class="diy-contain flex" v-loading="loading">
  482. <div class="diy-func-list">
  483. <diy-func-list @end="onEnd" :test-data="onClick" :list="pageComponentsList" @add-prev-item="onClick"></diy-func-list>
  484. </div>
  485. <diy-preview :active-index="activeIndex" :list="previewList" @select-item="selectItme" @change-move="changeMove"></diy-preview>
  486. <transition name="fade">
  487. <diy-style-preview :active-item="activeItem" :active-index="activeIndex" :permission="permission" @update="changeDiyItem" v-if="showUpdate"></diy-style-preview>
  488. </transition>
  489. </div>
  490. <!-- 弹窗广告弹窗 -->
  491. <el-dialog :close-on-click-modal="false" title="弹窗广告设置" :width="'634px'" append-to-body :visible.sync="popupVisible">
  492. <popup-advertisement :data="initAlearData" @change="onAlertChange"></popup-advertisement>
  493. <span slot="footer" class="dialog-footer">
  494. <el-button @click="popupVisible = false">取 消</el-button>
  495. <el-button type="primary" @click="popupVisible = false">确 定</el-button>
  496. </span>
  497. </el-dialog>
  498. <!-- 预览弹窗 -->
  499. <el-dialog :close-on-click-modal="false" title="预览弹窗" :modal-append-to-body="false" :visible.sync="dialogFormVisible">
  500. <div v-loading="previewloading" class="flex flex-x-center" style="height: 600px;overflow:auto">
  501. <img id="diy-test-preview" :src="previewSrc"></img>
  502. </div>
  503. <div slot="footer" class="dialog-footer">
  504. <el-button @click="dialogFormVisible = false">取 消</el-button>
  505. <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>
  506. </div>
  507. </el-dialog>
  508. </div>
  509. <script>
  510. Vue.prototype.$vailComm = false; // 是否开启校验组件
  511. Vue.prototype.$capitals = []; // 用户信息对象 - member-info
  512. Vue.prototype.$eventBus = new Vue();
  513. var PageShareData = {
  514. pageIndex: false // 点击页面设置标识 => nav/style
  515. }; // 全局共享数据 - 没有响应式
  516. new Vue({
  517. el: '#app',
  518. data() {
  519. return {
  520. capital: [],
  521. dialogFormVisible: false,
  522. /**
  523. * @descriptions 浮动()、普通()、置顶(isTop)、弹窗(alert)四种显示组件
  524. * @param {string} type // diy组件类型
  525. * @param {string} title // 二级标题
  526. * @param {string} img // diy组件图片
  527. * @param {number} count // 可添加diy组件数量
  528. * @param {boolean} is_top // diy组件是否置顶组件 - 待添加 - 分添加等级 1 2 3 数字靠前权限越高
  529. * @param {object} permission // 组件的不可操作权限 {"is_delete": false,"is_drag": false,"disabled": true, // 禁用操作}
  530. */
  531. pageComponentsList: [{
  532. title: '一级标题', // 一级标题
  533. list: [{
  534. type: 'search', // diy组件类型
  535. title: '搜索', // 二级标题
  536. img: 'resources/img/decorate/func/search.png',
  537. }, {
  538. type: 'button-group', // diy组件类型
  539. title: '按钮组', // 二级标题
  540. img: 'resources/img/decorate/func/button-group.png',
  541. }, {
  542. type: 'placard', // diy组件类型
  543. title: '公告', // 二级标题
  544. img: 'resources/img/decorate/func/placard.png',
  545. }, {
  546. type: 'video', // diy组件类型
  547. title: '视频', // 二级标题
  548. img: 'resources/img/decorate/func/video.png',
  549. },
  550. {
  551. type: 'graphic-details', // diy组件类型
  552. title: '图文详情', // 二级标题
  553. img: 'resources/img/decorate/func/graphic-details.png',
  554. },
  555. {
  556. type: 'auxiliary-blank', // diy组件类型
  557. title: '辅助空白', // 二级标题
  558. img: 'resources/img/decorate/func/auxiliary-blank.png',
  559. },
  560. {
  561. type: 'auxiliary-line', // diy组件类型
  562. title: '辅助线', // 二级标题
  563. img: 'resources/img/decorate/func/auxiliary-line.png',
  564. },
  565. {
  566. type: "title-block",
  567. title: "标签栏",
  568. img: 'resources/img/decorate/func/title-block.png',
  569. },
  570. {
  571. type: 'rubik-cube', // diy组件类型
  572. title: '魔方', // 二级标题
  573. img: 'resources/img/decorate/func/rubik-cube.png',
  574. },
  575. {
  576. type: 'img-ad', // diy组件类型
  577. title: '图片广告', // 二级标题
  578. img: 'resources/img/decorate/func/img-ad.png',
  579. },
  580. {
  581. type: 'micro-theme', // diy组件类型
  582. title: '微主题', // 二级标题
  583. img: 'resources/img/decorate/func/micro-theme.png',
  584. },
  585. {
  586. type: 'carousel-img', // diy组件类型
  587. title: '轮播广告', // 二级标题
  588. img: 'resources/img/decorate/func/carousel-img.png',
  589. },
  590. {
  591. type: 'graphic-details', // diy组件类型
  592. title: '模板', // 二级标题
  593. img: 'resources/img/decorate/func/search.png',
  594. },
  595. {
  596. type: 'goods-info', // diy组件类型
  597. title: '商品信息', // 二级标题
  598. count: 1,
  599. is_top: 2,
  600. img: 'resources/img/decorate/func/goods-info.png',
  601. permission: {
  602. "is_drag": false,
  603. "is_up": false,
  604. "is_down": false,
  605. "is_copy": false
  606. } // 禁用操作
  607. },
  608. {
  609. type: 'goods-comment', // diy组件类型
  610. title: '商品评价', // 二级标题
  611. img: 'resources/img/decorate/func/goods-comment.png'
  612. }
  613. ]
  614. }, {
  615. title: '二级标题', // 一级标题
  616. list: [{
  617. type: 'commodity-strategy-group', // diy组件类型
  618. title: '商品组', // 二级标题
  619. img: 'resources/img/decorate/func/commodity-group.png',
  620. },
  621. {
  622. type: 'order-broadcast', // diy组件类型
  623. title: '订单播报', // 二级标题
  624. img: 'resources/img/decorate/func/order-broadcast.png',
  625. count: 1,
  626. },
  627. {
  628. type: 'commodity-group-tab', // diy组件类型
  629. title: '选项卡', // 二级标题
  630. img: 'resources/img/decorate/func/commodity-group-tab.png',
  631. },
  632. /* {
  633. type: 'goods-comment', // diy组件类型
  634. title: '商品评论', // 二级标题
  635. img: '', // icon图片
  636. }, */
  637. ]
  638. }, {
  639. title: '营销类', // 一级标题
  640. list: [{
  641. type: 'merchant-info', // diy组件类型
  642. title: '商户信息', // 二级标题
  643. img: 'resources/img/decorate/func/merchant-info.png',
  644. },
  645. {
  646. type: 'member-info', // diy组件类型
  647. title: '会员信息', // 二级标题
  648. img: 'resources/img/decorate/func/member-info.png',
  649. count: 1,
  650. is_top: 2,
  651. permission: {
  652. "is_drag": false,
  653. "is_up": false,
  654. "is_down": false,
  655. "is_copy": false
  656. } // 禁用操作
  657. },
  658. {
  659. type: 'order-icon-group', // diy组件类型
  660. title: '订单图标组', // 二级标题
  661. img: 'resources/img/decorate/func/order-icon-group.png',
  662. count: 1,
  663. },
  664. {
  665. type: 'commonly-icon-group', // diy组件类型
  666. title: '常用图标组', // 二级标题
  667. img: 'resources/img/decorate/func/commonly-icon-group.png',
  668. },
  669. {
  670. type: 'group-goods', // diy组件类型
  671. title: '拼团', // 二级标题
  672. img: 'resources/img/decorate/func/commonly-icon-group.png',
  673. },
  674. {
  675. type: 'notes-articles', // diy组件类型
  676. title: '运营笔记', // 二级标题
  677. img: 'resources/img/decorate/func/commonly-icon-group.png',
  678. },
  679. ]
  680. },
  681. {
  682. title: '其他', // 一级标题
  683. list: [{
  684. type: 'position', // diy组件类型
  685. title: '定位', // 二级标题
  686. img: 'resources/img/decorate/func/merchant-info.png',
  687. }, {
  688. type: 'follow-official', // diy组件类型
  689. title: '关注公众号', // 二级标题
  690. img: 'resources/img/decorate/func/follow-official.png',
  691. }, {
  692. type: 'popup-advertisement', // diy组件类型
  693. title: '弹窗广告', // 二级标题
  694. img: 'resources/img/decorate/func/popup-advertisement.png'
  695. }, {
  696. type: 'smart-form', // diy组件类型
  697. title: '表单', // 二级标题
  698. img: "<?= Yii::getAlias('@attachurl') ?>/static/addons/smartform/smartform.png"
  699. }
  700. ]
  701. }
  702. ],
  703. /**
  704. * @param {boolean} is_show_permission // 显示权限
  705. * @param {boolean} is_delete // 是否可删除
  706. * @param {boolean} is_up // 是否可上移
  707. * @param {boolean} is_down // 是否可下移
  708. * @param {boolean} is_drag // 是否可拖拽
  709. * @param {boolean} is_copy // 是否可复制
  710. * @param {boolean} disabled // 全部禁用操作
  711. */
  712. previewList: [], // 预览数组对象
  713. activeIndex: -1, // 预览激活索引
  714. activeItem: null, // 预览激活对象
  715. type: "add", // add新增 - edit编辑
  716. test: ["a", "b", "c"],
  717. showUpdate: true,
  718. responentData: null, // 详情响应的总数据
  719. permission: [], // 权限数组
  720. isClickPage: false, // 是否点击分页设置
  721. loading: false, // 数据加载
  722. saveLoading: false, // 保存数据
  723. previewloading: false, // 预览
  724. fields: {
  725. upload_type: 'images'
  726. },
  727. previewSrc: "",
  728. popupVisible: false,
  729. initAlearData: null,
  730. currentRoute: "<?= $currentRoute; ?>",
  731. pageType: 1, // 1 普通页面,2 模板市场
  732. cate_arr: [],
  733. cate_id: ''
  734. }
  735. },
  736. watch: {
  737. activeIndex() {
  738. this.showUpdate = false
  739. setTimeout(() => {
  740. this.showUpdate = true
  741. }, 0)
  742. },
  743. },
  744. created() {
  745. // 添加不同的模板nav
  746. this.previewList.push(getNavData())
  747. this.init()
  748. // this.initPageType()
  749. this.type = getQuery('id') ? "edit" : "add"
  750. const id = getQuery('id')
  751. this.detail(id)
  752. },
  753. methods: {
  754. initPageType() {
  755. const obj = {
  756. 'admin/template/edit': 2
  757. }
  758. let type = obj[this.currentRoute] || 1
  759. this.pageType = type
  760. },
  761. initAlertComData(list) {
  762. const item = list.find(item => {
  763. return item.funcListItem.type === "popup-advertisement"
  764. })
  765. item && (this.initAlearData = deepClone(item.data))
  766. },
  767. onAlertChange(data) {
  768. const index = this.previewList.findIndex(item => {
  769. return item.funcListItem.type === "popup-advertisement"
  770. })
  771. let item = this.previewList[index]
  772. item.data = data
  773. this.previewList[index] = item
  774. },
  775. savePreview() {
  776. this.activeIndex = -1
  777. this.activeItem = null
  778. this.previewloading = true
  779. console.log(this.previewloading, "======> this.previewloading ");
  780. this.$nextTick(() => {
  781. const contain = document.getElementById("diy-preview-contain");
  782. this.deepNode(contain);
  783. setTimeout(() => {
  784. this.dialogFormVisible = true
  785. html2canvas(contain, {
  786. useCORS: true
  787. }).then(canvas => {
  788. const src = canvas.toDataURL("image/png")
  789. this.upload(this.dataURLtoFile(src)).then(res => {
  790. if (res.code == 0) {
  791. this.previewSrc = res.data.url
  792. this.save(false, 'preview')
  793. } else {
  794. this.$message({
  795. message: res.msg,
  796. type: 'warning'
  797. });
  798. }
  799. }).finally(res => {
  800. this.previewloading = false
  801. })
  802. })
  803. }, 0)
  804. })
  805. },
  806. dataURLtoFile(dataurl) { // 生成Blob
  807. var arr = dataurl.split(',');
  808. var mime = arr[0].match(/:(.*?);/)[1];
  809. var bstr = atob(arr[1]);
  810. var n = bstr.length;
  811. var u8arr = new Uint8Array(n);
  812. while (n--) {
  813. u8arr[n] = bstr.charCodeAt(n);
  814. }
  815. return new Blob([u8arr], {
  816. type: mime
  817. });
  818. },
  819. upload(file) {
  820. let formData = new FormData();
  821. const params = {
  822. upload_type: 'images'
  823. };
  824. params['r'] = 'common/file/upload';
  825. for (let i in this.fields) {
  826. formData.append(i, this.fields[i]);
  827. }
  828. formData.append('file', file, "image.png");
  829. return new Promise(successCallback => {
  830. this.$request({
  831. headers: {
  832. 'Content-Type': 'multipart/form-data'
  833. },
  834. params: params,
  835. method: 'post',
  836. data: formData,
  837. }).then(e => {
  838. successCallback(e.data)
  839. }).catch(e => {
  840. file._complete = true;
  841. });
  842. })
  843. },
  844. deepNode(contain) {
  845. if (contain.tagName === "IMG") {
  846. contain.src = contain.src + '?t=' + Date.now()
  847. contain.setAttribute('crossorigin', 'anonymous')
  848. }
  849. if (contain.children && contain.children.length) {
  850. [].forEach.call(contain.children, (item => {
  851. this.deepNode(item)
  852. }))
  853. }
  854. },
  855. pageSet() {
  856. PageShareData.pageIndex = true
  857. this.$eventBus.$emit("onPageClick")
  858. var index = 0;
  859. this.activeIndex = index
  860. this.activeItem = this.previewList[index]
  861. // this.changeDiyItem()
  862. },
  863. detail(id) {
  864. // 详情
  865. this.loading = true
  866. request({
  867. params: {
  868. r: this.currentRoute,
  869. id
  870. },
  871. method: 'get',
  872. }).then(res => {
  873. const {
  874. data
  875. } = res.data
  876. if (res.data.code != 0) {
  877. this.$message({
  878. message: res.data.msg,
  879. type: 'error'
  880. });
  881. return false
  882. }
  883. this.responentData = data;
  884. if (data.diypage.content) {
  885. const previewList = JSON.parse(data.diypage.content);
  886. // 兼容以前数据
  887. const memberInfo = this.addIsTop(previewList, "nav")
  888. this.previewList = this.addIsTop(memberInfo, "member-info")
  889. this.initAlertComData(this.previewList)
  890. }
  891. if (data.components && data.components.length) {
  892. this.pageComponentsList = data.components;
  893. Vue.prototype.$capitals = data.capital
  894. }
  895. this.permission = data.auth
  896. // 模板市场分类
  897. // if (this.pageType == 2) {
  898. // let obj = res.data.data
  899. // for (const key in obj.cate_arr) {
  900. // let value = obj.cate_arr[key]
  901. // this.cate_arr.push({
  902. // value: key * 1,
  903. // label: value
  904. // })
  905. // }
  906. // this.cate_id = obj.diypage.cate_id
  907. // }
  908. }).finally(res => {
  909. this.loading = false
  910. })
  911. },
  912. updateTips() { // 对应组件上绑定该事件
  913. Vue.prototype.$vailComm = true
  914. this.$eventBus.$emit("updateTips")
  915. },
  916. CommVail() { // 组件校验目前只是单个nav
  917. const item = this.previewList[0]
  918. const title = item.data.name
  919. const type = item.data.contentType
  920. if ((type != 2) && !title) {
  921. // 目前只是标题校验后续需要,在拓展出来
  922. if (this.activeIndex != 0) {
  923. const index = 0
  924. this.selectItme(this.previewList[index], index)
  925. }
  926. this.$nextTick(() => {
  927. this.updateTips()
  928. })
  929. return '请输入标题'
  930. }
  931. },
  932. /**
  933. * @params { string } type // save(保存) preview(预览)
  934. */
  935. save: debounce(function(isLoading = true, type = 'save') {
  936. // 对接保存数据接口
  937. if (this.saveFlag) {
  938. console.log("重复提交");
  939. return
  940. }
  941. const item = this.previewList[0]
  942. const title = item.data.name
  943. let msg = this.CommVail()
  944. if (msg) {
  945. this.$message({
  946. message: msg,
  947. type: 'warning'
  948. });
  949. return msg
  950. }
  951. this.saveFlag = true // 防止重复提交限制
  952. isLoading && (this.saveLoading = true)
  953. let data = {
  954. id: getQuery('id') || null,
  955. title,
  956. content: JSON.stringify(this.previewList),
  957. cover: this.previewSrc,
  958. }
  959. if (this.cate_id) {
  960. data.cate_id = this.cate_id
  961. }
  962. request({
  963. params: {
  964. r: this.currentRoute
  965. },
  966. method: 'post',
  967. data
  968. }).then(res => {
  969. if (res.data.code != 0) {
  970. this.$message({
  971. message: res.data.msg,
  972. type: 'error'
  973. });
  974. } else {
  975. this.$message({
  976. message: res.data.msg,
  977. type: 'success'
  978. });
  979. if (type === 'save') {
  980. this.leavePage(res.data.data);
  981. // let urlObJ = {
  982. // 1: 'mall/diy/index',
  983. // 2: 'admin/template/mall',
  984. // }
  985. // navigateTo({
  986. // r: urlObJ[this.pageType]
  987. // })
  988. }
  989. }
  990. }).finally(res => {
  991. this.saveFlag = false
  992. this.saveLoading = false
  993. })
  994. },
  995. 400),
  996. init() {
  997. this.$eventBus.$on("diy-preview-copy", (item = {}) => {
  998. this.copy(item)
  999. })
  1000. this.$eventBus.$on("diy-preview-operateFn", (item = {}) => {
  1001. this.operateFn(item)
  1002. })
  1003. this.$eventBus.$on("diy-back-set", () => {
  1004. this.updateView(null, -1)
  1005. })
  1006. },
  1007. validateCount(e) {
  1008. // 校验组件能添加几个
  1009. var msg = "";
  1010. var list = this.previewList.filter(item => {
  1011. return item.funcListItem.type === e.type
  1012. });
  1013. if (e && e.count && list.length >= e.count) {
  1014. msg = `该组件只能添加${e.count}个哦`
  1015. }
  1016. if (msg) {
  1017. this.$message({
  1018. message: msg,
  1019. type: 'warning'
  1020. });
  1021. }
  1022. return msg
  1023. },
  1024. setInitObj(data, e) {
  1025. if (!e.permission) {
  1026. return false
  1027. }
  1028. const target = typeof e.permission === "object" ? e.permission : JSON.parse(e.permission)
  1029. for (const key in target) {
  1030. data[key] = e.permission[key]
  1031. }
  1032. },
  1033. isAlearComponents(e) {
  1034. const isAlertArr = ['popup-advertisement'] // 弹窗组件
  1035. return isAlertArr.some(item => {
  1036. return item === e.type
  1037. })
  1038. },
  1039. handleAlertComponent(initObj) {
  1040. if (!this.previewList.some(item => {
  1041. return this.isAlearComponents(item.funcListItem)
  1042. })) { // 判断是否有alert组件 - 只能单个
  1043. console.log("添加特殊组件");
  1044. this.previewList.push(initObj)
  1045. }
  1046. this.popupVisible = true
  1047. },
  1048. onEnd(e, index) { // 左侧拖拽结束手动添加进去
  1049. this.activeIndex = index - 1
  1050. console.log(this.activeIndex, "=======> activeIndex");
  1051. this.onClick(e)
  1052. },
  1053. onClick(e) {
  1054. const flag = this.validateCount(e) // 校验组件可添加个数
  1055. if (flag) return // 不通过
  1056. var initObj = {
  1057. id: getRandomId(this.previewList),
  1058. data: {}, // 对应数据
  1059. computedStyle: {}, // 对应组件样式-尺寸
  1060. permission: [], // 展示权限列表 ==> 对应用户等级or其他
  1061. funcListItem: e,
  1062. isShow: true, // 前端是否显示
  1063. is_show_permission: true, // 是否显示权限
  1064. } // 创建的初始数据
  1065. this.setInitObj(initObj, e) // 设置可操作方法
  1066. // 弹窗组件
  1067. if (e.type === "popup-advertisement") {
  1068. this.handleAlertComponent(initObj) // 单独处理全局弹窗组件
  1069. return false
  1070. }
  1071. if (e.is_top) { // 置顶组件操作 - 不操作以前
  1072. const index = this.previewList.findIndex(item => {
  1073. const e1 = item.funcListItem || {}
  1074. return e1.is_top === undefined || (e1.is_top >= e.is_top)
  1075. })
  1076. this.activeItem = initObj
  1077. if (index < 0) {
  1078. this.previewList.push(initObj)
  1079. this.activeIndex = Math.max(0, this.previewList.length - 1)
  1080. } else {
  1081. this.previewList.splice(index, 0, initObj)
  1082. this.activeIndex = index
  1083. }
  1084. return false
  1085. }
  1086. // 不置顶组件添加
  1087. this.activeIndex = Math.max(this.getIsTopArrLength() - 1, this.activeIndex) // 限制普通组件到istop前面
  1088. var length = this.previewList.length;
  1089. var isLast = length - 1 === this.activeIndex;
  1090. this.previewList = this.addIndexItem(this.previewList, initObj, this.activeIndex)
  1091. if (length && (isLast || this.activeIndex == -1)) {
  1092. // 有值是否最后一项
  1093. this.activeIndex = length - 1
  1094. }
  1095. this.activeItem = initObj
  1096. this.activeIndex += 1
  1097. },
  1098. getIsTopArrLength() {
  1099. return this.previewList.filter(item => {
  1100. const e1 = item.funcListItem || {}
  1101. return e1.is_top
  1102. }).length
  1103. },
  1104. changeDiyItem(item, index, params = {}) {
  1105. var {
  1106. type
  1107. } = params
  1108. var list = deepClone(this.previewList) // 克隆一下
  1109. if (type !== "isShow") {
  1110. // 显示问题 -- 样式组件不让修改
  1111. item.isShow = list[this.activeIndex].isShow;
  1112. }
  1113. // 直接全部覆盖
  1114. list[this.activeIndex] = deepClone(item)
  1115. this.activeItem = deepClone(item)
  1116. this.previewList = list
  1117. },
  1118. selectItme(item, index) {
  1119. if (this.activeIndex == index) {
  1120. this.activeIndex = -1
  1121. this.activeItem = null
  1122. } else {
  1123. this.activeIndex = index
  1124. this.activeItem = item
  1125. }
  1126. this.$forceUpdate()
  1127. },
  1128. pushItem(list = [], target = {}) {
  1129. var result = deepClone(list)
  1130. result.push(target)
  1131. return result
  1132. },
  1133. /**
  1134. * 两种形式,一种push,追加index
  1135. */
  1136. addIndexItem(list = [], target = {}, index) { // 往指定的index添加item
  1137. var result = deepClone(list)
  1138. if (this.activeIndex < 0) {
  1139. result.push(target)
  1140. } else {
  1141. var handleArr = [deepClone(result[index]), target]
  1142. result.splice(index, 1, ...handleArr)
  1143. }
  1144. return result
  1145. },
  1146. // 操作相关
  1147. copy() {
  1148. if (!this.activeItem || this.activeItem.disabled || this.activeItem.is_copy === false) {
  1149. return
  1150. }
  1151. var item = deepClone(this.activeItem)
  1152. item.id = getRandomId()
  1153. this.previewList = this.addIndexItem(this.previewList, item, this.activeIndex)
  1154. },
  1155. /**
  1156. * @params {string} obj.type up - down - show
  1157. */
  1158. operateFn(obj) {
  1159. const methods = {
  1160. show: 'showItem',
  1161. up: 'upItem',
  1162. down: 'downItem',
  1163. delete: 'deleteItem'
  1164. }
  1165. this[methods[obj.type]](obj.index)
  1166. },
  1167. showItem(index) {
  1168. var item = deepClone(this.activeItem);
  1169. item.isShow = !item.isShow
  1170. this.changeDiyItem(item, index, {
  1171. type: "isShow"
  1172. })
  1173. },
  1174. updateView(item, index) {
  1175. this.activeItem = item
  1176. this.activeIndex = index
  1177. },
  1178. deleteItem(index) {
  1179. if (this.activeItem.disabled || this.activeItem.is_delete === false) {
  1180. return false
  1181. }
  1182. this.previewList.splice(index, 1);
  1183. // 删除后失去焦点
  1184. this.activeIndex = -1;
  1185. this.activeItem = null;
  1186. },
  1187. upItem(index) {
  1188. const topArr = this.previewList.filter(item => {
  1189. const e1 = item.funcListItem || {}
  1190. return e1.is_top
  1191. }) // 操作上限
  1192. const topIndex = Math.max(0, topArr.length)
  1193. if (index <= 0 || this.activeItem.disabled || this.activeItem.is_up === false) {
  1194. return false
  1195. } else if (index <= topIndex) {
  1196. alert("不可以再操作了噢");
  1197. return false
  1198. }
  1199. var previewList = deepClone(this.previewList);
  1200. this.previewList = this.swapItems(previewList, index, index - 1);
  1201. this.updateView(this.previewList[index - 1], index - 1);
  1202. },
  1203. downItem(index) {
  1204. if (this.activeItem.disabled || this.activeItem.is_down === false) {
  1205. return false
  1206. } else if (index === this.previewList.length - 1) {
  1207. alert("不可以再操作了噢");
  1208. return false
  1209. }
  1210. var previewList = deepClone(this.previewList);
  1211. this.previewList = this.swapItems(previewList, index, index + 1);
  1212. this.updateView(this.previewList[index + 1], index + 1);
  1213. },
  1214. swapItems(arr, index1, index2) {
  1215. var item = deepClone(arr[index1]);
  1216. arr[index1] = arr[index2]
  1217. arr[index2] = item
  1218. return arr
  1219. },
  1220. changeMove(e) {
  1221. const {
  1222. newIndex,
  1223. list
  1224. } = e
  1225. // 移动拖拽改变索引
  1226. this.previewList = deepClone(list);
  1227. this.updateView(this.previewList[newIndex], newIndex);
  1228. },
  1229. // 更新主页面
  1230. updateMainPage(item) {
  1231. this.mainPage = deepClone(item);
  1232. },
  1233. // 处理兼容老数据
  1234. addIsTop(list, type) {
  1235. const obj = {
  1236. ['nav']: 1,
  1237. ['member-info']: 2
  1238. }
  1239. const top = obj[type]
  1240. list.forEach(item => {
  1241. if (item.funcListItem.type === type && !item.funcListItem.is_top) {
  1242. item.funcListItem.is_top = top
  1243. }
  1244. });
  1245. return list
  1246. },
  1247. leavePage(data) {
  1248. window.parent.postMessage(JSON.stringify(data), '*');
  1249. },
  1250. goBack() {
  1251. this.leavePage({});
  1252. }
  1253. }
  1254. })
  1255. // 拦截页面卸载
  1256. // window.onbeforeunload = function(e) {
  1257. // var e = window.event || e;
  1258. // e.returnValue = ("确定离开当前页面吗?");
  1259. // }
  1260. </script>
  1261. <style>
  1262. #app {
  1263. display: flex;
  1264. flex-direction: column;
  1265. min-width: 1250px;
  1266. }
  1267. #diy-test-preview {
  1268. margin: auto;
  1269. }
  1270. .diy-header-backs {
  1271. cursor: pointer;
  1272. }
  1273. .fixed {
  1274. position: fixed;
  1275. left: 0;
  1276. top: 0;
  1277. width: 100%;
  1278. height: 100%;
  1279. z-index: 999;
  1280. }
  1281. .temp-select {
  1282. position: relative;
  1283. margin-left: 20px;
  1284. }
  1285. .temp-select .cate {
  1286. position: absolute;
  1287. top: 0;
  1288. bottom: 0;
  1289. left: 6px;
  1290. color: #fff;
  1291. display: inline-block;
  1292. font-size: inherit;
  1293. height: 30px;
  1294. line-height: 30px;
  1295. cursor: pointer;
  1296. pointer-events: none;
  1297. font-weight: 400;
  1298. }
  1299. .temp-select .el-input__inner {
  1300. background: hsla(0, 0%, 100%, .2);
  1301. color: #FFFFFF;
  1302. }
  1303. .temp-select .el-input.is-focus .el-input__inner,
  1304. .temp-select .el-input .el-input__inner:focus,
  1305. .temp-select .el-input__inner {
  1306. border-color: transparent !important;
  1307. border: none;
  1308. text-indent: 54px;
  1309. }
  1310. .diy-header {
  1311. height: 55px;
  1312. background: #313131;
  1313. opacity: 1;
  1314. border-radius: 0px;
  1315. justify-content: space-between;
  1316. font-size: 13px;
  1317. font-family: PingFang SC;
  1318. /*font-weight: bold;*/
  1319. color: #FFFFFF;
  1320. padding: 0 30px;
  1321. }
  1322. .diy-contain {
  1323. flex: 1;
  1324. overflow: auto;
  1325. background: #F4F6F8;
  1326. justify-content: space-between;
  1327. }
  1328. .diy-func-list {
  1329. box-sizing: border-box;
  1330. width: 300px;
  1331. background: #FFFFFF;
  1332. border-radius: 0px;
  1333. }
  1334. .diy-preview {
  1335. flex: 1;
  1336. background: #F4F6F8;
  1337. justify-content: space-around;
  1338. }
  1339. .fill-box {
  1340. position: relative;
  1341. width: 467px;
  1342. height: 100%;
  1343. }
  1344. .flex {
  1345. display: flex;
  1346. }
  1347. .flex-x-center {
  1348. justify-content: center;
  1349. }
  1350. .flex-y-center {
  1351. align-items: center;
  1352. }
  1353. /* */
  1354. .fade-enter-active,
  1355. .fade-leave-active {
  1356. transition: opacity 1s;
  1357. }
  1358. .fade-enter,
  1359. .fade-leave-to {
  1360. opacity: 0;
  1361. }
  1362. .diy-text-font {
  1363. font-size: 13px;
  1364. font-weight: 700;
  1365. color: #999999;
  1366. }
  1367. .fill-border-top {
  1368. border-top: 10px solid #F4F6F8;
  1369. }
  1370. .fill-border-bottom {
  1371. border-bottom: 10px solid #F4F6F8;
  1372. }
  1373. /* 导航栏 */
  1374. .custom-page {
  1375. width: 181px;
  1376. height: 60px;
  1377. line-height: 60px;
  1378. background: var(--diy-theme);
  1379. /*font-weight: 700;*/
  1380. border-radius: 0px;
  1381. text-align: center;
  1382. }
  1383. .save {
  1384. font-size: 18px;
  1385. vertical-align: middle;
  1386. }
  1387. .save+span {
  1388. vertical-align: middle;
  1389. }
  1390. .sava_btn .el-button--primary {
  1391. background: var(--diy-theme);
  1392. border-color: var(--diy-theme);
  1393. /*padding: 8px 14px;*/
  1394. }
  1395. .diy_nav_right>div {
  1396. padding: 8px 14px;
  1397. }
  1398. .diy_nav_right .sava_btn {
  1399. padding: 0;
  1400. }
  1401. .page_set>i {
  1402. font-size: 24px;
  1403. vertical-align: middle;
  1404. }
  1405. .page_set>span {
  1406. vertical-align: middle;
  1407. }
  1408. .xiaoshou {
  1409. cursor: pointer;
  1410. }
  1411. :root {
  1412. /* 主题色 */
  1413. --diy-theme: #F10009;
  1414. /* 主要字体颜色 */
  1415. --diy-color: #F10009;
  1416. }
  1417. /* 修改ele默认样式 */
  1418. /* slider组件 */
  1419. .el-slider__bar {
  1420. background-color: var(--diy-theme);
  1421. }
  1422. .el-slider__button {
  1423. border-color: var(--diy-theme);
  1424. }
  1425. /* input组件 */
  1426. .el-input .el-input__inner:focus {
  1427. border: 1px solid var(--diy-theme);
  1428. }
  1429. /* textarea */
  1430. .el-textarea .el-textarea__inner:focus {
  1431. border: 1px solid var(--diy-theme);
  1432. }
  1433. /* radio单选组件 */
  1434. .el-radio__input.is-checked+.el-radio__label {
  1435. color: var(--diy-color);
  1436. }
  1437. .el-radio__input.is-checked .el-radio__inner {
  1438. border-color: var(--diy-theme);
  1439. background: var(--diy-theme);
  1440. }
  1441. .el-radio-button__orig-radio:checked+.el-radio-button__inner {
  1442. border-color: var(--diy-theme);
  1443. box-shadow: -1px 0 0 0 var(--diy-theme);
  1444. }
  1445. /* 多选 */
  1446. .el-checkbox__input.is-checked+.el-checkbox__label {
  1447. color: var(--diy-color);
  1448. }
  1449. .el-checkbox__input.is-checked .el-checkbox__inner,
  1450. .el-checkbox__input.is-indeterminate .el-checkbox__inner {
  1451. border-color: var(--diy-theme);
  1452. background: var(--diy-theme);
  1453. }
  1454. </style>