index.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996
  1. <script src="/resources/js/html2canvas.min.js"></script>
  2. <!-- 装修所需的数据 -->
  3. <script type="text/javascript" src="/resources/js/diy-util.js"></script>
  4. <script type="text/javascript" src="/resources/js/hotzone.js"></script>
  5. <script>
  6. function getNavData() {
  7. const result = [{
  8. // 顶部导航
  9. "id": getRandomId(),
  10. "data": {
  11. backSrc: "",
  12. contentType: "1",
  13. isShowName: "1",
  14. logoSrc: "",
  15. mainPage: { // 主页面设置
  16. defColor: "#fff",
  17. name: "幸运拼团",
  18. type: "纯色",
  19. imgUrl: ""
  20. },
  21. name: "幸运拼团",
  22. positionChoose: "1",
  23. hideSearch: false,
  24. },
  25. "computedStyle": {
  26. "mode": 1,
  27. "style": 1,
  28. "titleSwitch": true,
  29. "titleMode": 1,
  30. "imageUrl": [],
  31. "position": 1,
  32. "searchSwitch": true,
  33. "searchBgColor": "",
  34. "statusBarColor": "#FFF",
  35. "defaultForm": {
  36. "defColor": "transparent"
  37. },
  38. "titleDistance": {
  39. "fontSize": 16,
  40. "height": 30,
  41. "width": 57,
  42. "marginLeft": 20
  43. },
  44. "statusBar": "1",
  45. "searchMarPad": {
  46. "marginLeft": 20,
  47. "paddingLeft": 14
  48. }
  49. },
  50. "funcListItem": {
  51. "type": "nav",
  52. "title": "顶部导航",
  53. "is_top": 1
  54. },
  55. "isShow": true,
  56. "is_show_permission": false,
  57. "is_drag": false,
  58. "disabled": true,
  59. "is_delete": false,
  60. "is_up": false,
  61. "is_down": false,
  62. "is_copy": false
  63. }, {
  64. // 轮播图
  65. "id": getRandomId(),
  66. "data": {
  67. buttonData: {
  68. typeIndex: 0,
  69. typeItem: null
  70. },
  71. buttonPointData: {
  72. open: true,
  73. pointIndex: 1,
  74. pointItem: {
  75. label: "resources/img/decorate/point-two.png",
  76. value: "two"
  77. },
  78. position: 1
  79. },
  80. carouselImgArr: [{
  81. hotZone: [],
  82. imgUrl: "resources/img/decorate/group-goods/banner.png",
  83. url: "",
  84. urlName: "",
  85. urlType: "",
  86. visible: false
  87. }],
  88. spaceInfo: [{
  89. disabled: false,
  90. hidden: true,
  91. maxValue: 20,
  92. name: "图片间距",
  93. unit: "px",
  94. value: 5
  95. },
  96. {
  97. disabled: false,
  98. hidden: false,
  99. maxValue: 50,
  100. name: "上边距",
  101. unit: "px",
  102. value: 0,
  103. },
  104. {
  105. disabled: false,
  106. hidden: false,
  107. maxValue: 50,
  108. name: "下边距",
  109. unit: "px",
  110. value: 0
  111. },
  112. {
  113. disabled: false,
  114. hidden: false,
  115. maxValue: 50,
  116. name: "左右边距",
  117. unit: "px",
  118. value: 12
  119. }
  120. ]
  121. },
  122. "computedStyle": {
  123. "searchBox": "",
  124. "spaceStyle": {
  125. marginBottom: "0px",
  126. marginLeft: "12px",
  127. marginRight: "12px",
  128. marginTop: "0px",
  129. height: '160px',
  130. },
  131. "searchIpts": {
  132. 'border-bottom-left-radius': "10px",
  133. 'border-bottom-right-radius': "10px",
  134. 'border-top-left-radius': "10px",
  135. 'border-top-right-radius': "10px"
  136. }
  137. },
  138. "permission": [],
  139. "funcListItem": {
  140. is_top: 0,
  141. title: "轮播广告",
  142. type: "carousel-img"
  143. },
  144. "isShow": true,
  145. "is_show_permission": false,
  146. "is_drag": false,
  147. "disabled": true,
  148. "is_delete": false,
  149. "is_up": false,
  150. "is_down": false,
  151. "is_copy": false
  152. }, {
  153. // 按钮组
  154. "id": getRandomId(),
  155. "data": {
  156. "buttonData": {
  157. "line_num": 1,
  158. "pattern": "fixed",
  159. "patternItem": null,
  160. "shape": "square",
  161. "single_line": 3,
  162. "style": 1,
  163. "type": 1,
  164. },
  165. "colorInfos": [{
  166. color: "",
  167. name: "底部背景",
  168. showAlpha: false,
  169. value: "transparent"
  170. },
  171. {
  172. color: "",
  173. name: "组件背景",
  174. showAlpha: false,
  175. value: "transparent"
  176. },
  177. {
  178. color: "#333333",
  179. name: "文字颜色",
  180. showAlpha: false,
  181. value: "#333333",
  182. }
  183. ],
  184. "iconList": [
  185. {
  186. img: 'resources/img/decorate/default_btn1.png',
  187. icon: 'el-icon-setting',
  188. is_show_tag: true,
  189. tags: '热门',
  190. tagsBgColor: '#f83287',
  191. tagsTextColor: '#ffffff',
  192. btnText: '按钮文字',
  193. link_params: null,
  194. },
  195. ],
  196. "sizeInfos": [{
  197. disabled: false,
  198. hidden: false,
  199. maxValue: 50,
  200. name: "上边距",
  201. unit: "px",
  202. value: 8
  203. },
  204. {
  205. disabled: false,
  206. hidden: false,
  207. maxValue: 50,
  208. name: "下边距",
  209. unit: "px",
  210. value: 8
  211. },
  212. {
  213. disabled: false,
  214. hidden: false,
  215. maxValue: 50,
  216. name: "左右边距",
  217. unit: "px",
  218. value: 0
  219. }
  220. ],
  221. defaultTabs: [{name: 'marketing',children:['lucky_group_cate']}],
  222. },
  223. "computedStyle": {
  224. "iptBg": "",
  225. "searchBox": "",
  226. "searchIpts": {
  227. "marginBottom": "8px",
  228. "marginLeft": "0px",
  229. "marginRight": "0px",
  230. "marginTop": "8px",
  231. },
  232. "textStyle": "#333333"
  233. },
  234. "permission": [],
  235. "funcListItem": {
  236. is_top: 0,
  237. title: "按钮组",
  238. type: "button-group"
  239. },
  240. "isShow": true,
  241. "is_show_permission": false,
  242. "is_drag": false,
  243. "disabled": true,
  244. "is_delete": false,
  245. "is_up": false,
  246. "is_down": false,
  247. "is_copy": false
  248. }, {
  249. // 商品列表
  250. "id": getRandomId(),
  251. "data": {
  252. titleRadio: 1,
  253. listType: 1,
  254. listShow: true,
  255. dataType: 0,
  256. btnData: {
  257. style: 0,
  258. name: '立即拼团'
  259. },
  260. colorInfos: [
  261. {
  262. name: "底部颜色", //名字
  263. color: "#FAFAFA", //颜色
  264. showAlpha: false, //是否开启透明度
  265. value: "#FAFAFA", //展示的值
  266. },
  267. {
  268. name: "组件颜色", //名字
  269. color: "#FFFFFF", //颜色
  270. showAlpha: false, //是否开启透明度
  271. value: "#FFFFFF", //展示的值
  272. }
  273. ],
  274. sizeInfos: [
  275. {
  276. disabled: false,
  277. hidden: false,
  278. maxValue: 20,
  279. name: "商品间距",
  280. unit: "px",
  281. value: 0,
  282. },
  283. {
  284. disabled: false,
  285. hidden: false,
  286. maxValue: 50,
  287. name: "上边距",
  288. unit: "px",
  289. value: 0,
  290. },
  291. {
  292. disabled: false,
  293. hidden: false,
  294. maxValue: 50,
  295. name: "下边距",
  296. unit: "px",
  297. value: 0,
  298. },
  299. {
  300. disabled: false,
  301. hidden: false,
  302. maxValue: 50,
  303. name: "左右边距",
  304. unit: "px",
  305. value: 0,
  306. }
  307. ],
  308. },
  309. "computedStyle": {
  310. aroundMargin: "0px",
  311. boxBg: "#FAFAFA",
  312. goodsBg: "#FFFFFF",
  313. marginBottom: "0px",
  314. marginTop: "0px",
  315. spacing: "0px"
  316. },
  317. "permission": [],
  318. "funcListItem": {
  319. is_top: 0,
  320. title: "幸运拼团",
  321. type: "lucky-group"
  322. },
  323. "isShow": true,
  324. "is_show_permission": false,
  325. "is_drag": false,
  326. "disabled": true,
  327. "is_delete": false,
  328. "is_up": false,
  329. "is_down": false,
  330. "is_copy": false
  331. }]
  332. return result
  333. }
  334. </script>
  335. <?php
  336. use common\helpers\ComponentHelper;
  337. use common\models\diy\DiyComponents;
  338. use common\helpers\AddonHelper;
  339. $diyPath = Yii::$app->viewPath . '/components/common/diy/common';
  340. $stylePath = Yii::$app->viewPath . '/components/common/diy/style-components';
  341. $components = DiyComponents::getDir($diyPath, $diyPath);
  342. $styleComponents = DiyComponents::getDir($stylePath, $stylePath);
  343. ComponentHelper::loadComponentView('diy/diy-preview');
  344. ComponentHelper::loadComponentView('diy/diy-style-preview');
  345. foreach ($components as $item) {
  346. ComponentHelper::loadComponentView("diy/common/{$item}");
  347. }
  348. foreach ($styleComponents as $item) {
  349. ComponentHelper::loadComponentView("diy/style-components/{$item}");
  350. }
  351. $currentRoute = Yii::$app->controller->route;
  352. ?>
  353. <div id="app">
  354. <div style="padding-bottom: 10px;padding-right: 20px;background: #F4F6F8;" @click="save" flex="main:right">
  355. <el-button type="primary">保存</el-button>
  356. </div>
  357. <div class="diy-contain flex" v-loading="loading">
  358. <diy-preview :active-index="activeIndex" :list="previewList" @select-item="selectItme" @change-move="changeMove"></diy-preview>
  359. <transition name="fade">
  360. <diy-style-preview :active-item="activeItem" :active-index="activeIndex" :permission="permission" @update="changeDiyItem" v-if="showUpdate"></diy-style-preview>
  361. </transition>
  362. </div>
  363. <!-- 预览弹窗 -->
  364. <el-dialog title="预览弹窗" :modal-append-to-body="false" :visible.sync="dialogFormVisible">
  365. <div class="flex flex-x-center" style="height: 600px;overflow:auto">
  366. <img id="diy-test-preview" :src="previewSrc"></img>
  367. </div>
  368. <div slot="footer" class="dialog-footer">
  369. <el-button @click="dialogFormVisible = false">取 消</el-button>
  370. <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>
  371. </div>
  372. </el-dialog>
  373. </div>
  374. <script>
  375. Vue.prototype.$capitals = []; // 用户信息对象
  376. Vue.prototype.$eventBus = new Vue();
  377. var PageShareData = {
  378. pageIndex: false // 点击页面设置标识 => nav/style
  379. }; // 全局共享数据 - 没有响应式
  380. new Vue({
  381. el: '#app',
  382. data() {
  383. return {
  384. capital: [],
  385. dialogFormVisible: false,
  386. /**
  387. * @descriptions 浮动()、普通()、置顶(isTop)、弹窗(alert)四种显示组件
  388. * @param {string} type // diy组件类型
  389. * @param {string} title // 二级标题
  390. * @param {string} img // diy组件图片
  391. * @param {number} count // 可添加diy组件数量
  392. * @param {boolean} is_top // diy组件是否置顶组件 - 待添加 - 分添加等级 1 2 3 数字靠前权限越高
  393. * @param {object} permission // 组件的不可操作权限 {"is_delete": false,"is_drag": false,"disabled": true, // 禁用操作}
  394. */
  395. pageComponentsList: [],
  396. /**
  397. * @param {boolean} is_show_permission // 显示权限
  398. * @param {boolean} is_delete // 是否可删除
  399. * @param {boolean} is_up // 是否可上移
  400. * @param {boolean} is_down // 是否可下移
  401. * @param {boolean} is_drag // 是否可拖拽
  402. * @param {boolean} is_copy // 是否可复制
  403. * @param {boolean} disabled // 全部禁用操作
  404. */
  405. previewList: [], // 预览数组对象
  406. activeIndex: -1, // 预览激活索引
  407. activeItem: null, // 预览激活对象
  408. type: "add", // add新增 - edit编辑
  409. test: ["a", "b", "c"],
  410. showUpdate: true,
  411. responentData: null, // 详情响应的总数据
  412. permission: [], // 权限数组
  413. isClickPage: false, // 是否点击分页设置
  414. loading: false, // 数据加载
  415. saveLoading: false, // 保存数据
  416. fields: {
  417. upload_type: 'images'
  418. },
  419. previewSrc: "",
  420. }
  421. },
  422. provide() {
  423. return {
  424. capitals: this.capital
  425. }
  426. },
  427. watch: {
  428. activeIndex() {
  429. this.showUpdate = false
  430. setTimeout(() => {
  431. this.showUpdate = true
  432. }, 0)
  433. },
  434. },
  435. created() {
  436. // console.log(this.dynamicImgSrc('/abc/ss'));
  437. // 添加不同的模板nav
  438. this.previewList.push(...getNavData())
  439. this.init()
  440. this.detail()
  441. },
  442. methods: {
  443. savePreview() {
  444. this.activeIndex = -1
  445. this.activeItem = null
  446. this.$nextTick(() => {
  447. const contain = document.getElementById("diy-preview-contain");
  448. this.deepNode(contain);
  449. setTimeout(() => {
  450. this.dialogFormVisible = true
  451. html2canvas(contain, {
  452. useCORS: true
  453. }).then(canvas => {
  454. const src = canvas.toDataURL("image/png")
  455. this.upload(this.dataURLtoFile(src)).then(res => {
  456. if (res.code == 0) {
  457. this.previewSrc = res.data.url
  458. this.save(false)
  459. } else {
  460. this.$message({
  461. message: res.msg,
  462. type: 'warning'
  463. });
  464. }
  465. })
  466. })
  467. }, 0)
  468. })
  469. },
  470. dataURLtoFile(dataurl) { // 生成Blob
  471. var arr = dataurl.split(',');
  472. var mime = arr[0].match(/:(.*?);/)[1];
  473. var bstr = atob(arr[1]);
  474. var n = bstr.length;
  475. var u8arr = new Uint8Array(n);
  476. while (n--) {
  477. u8arr[n] = bstr.charCodeAt(n);
  478. }
  479. return new Blob([u8arr], {
  480. type: mime
  481. });
  482. },
  483. upload(file) {
  484. let formData = new FormData();
  485. const params = {
  486. upload_type: 'images'
  487. };
  488. params['r'] = 'common/file/upload';
  489. for (let i in this.fields) {
  490. formData.append(i, this.fields[i]);
  491. }
  492. formData.append('file', file, "image.png");
  493. return new Promise(successCallback => {
  494. this.$request({
  495. headers: {
  496. 'Content-Type': 'multipart/form-data'
  497. },
  498. params: params,
  499. method: 'post',
  500. data: formData,
  501. }).then(e => {
  502. successCallback(e.data)
  503. }).catch(e => {
  504. file._complete = true;
  505. });
  506. })
  507. },
  508. deepNode(contain) {
  509. if (contain.tagName === "IMG") {
  510. contain.src = contain.src + '?t=' + Date.now()
  511. contain.setAttribute('crossorigin', 'anonymous')
  512. }
  513. if (contain.children && contain.children.length) {
  514. [].forEach.call(contain.children, (item => {
  515. this.deepNode(item)
  516. }))
  517. }
  518. },
  519. pageSet() {
  520. PageShareData.pageIndex = true
  521. this.$eventBus.$emit("onPageClick")
  522. var index = 0;
  523. this.activeIndex = index
  524. this.activeItem = this.previewList[index]
  525. // this.changeDiyItem()
  526. },
  527. detail() {
  528. // 详情
  529. this.loading = true
  530. request({
  531. params: {
  532. r: 'lucky-group/diy/index'
  533. },
  534. method: 'get',
  535. }).then(res => {
  536. if(res.data.code == 0){
  537. const previewList = JSON.parse(res.data.data.content)
  538. console.log(previewList, '---------------')
  539. if(!previewList.length) return
  540. this.previewList = previewList
  541. } else {
  542. this.$message({
  543. message: res.data.msg,
  544. type: 'error'
  545. });
  546. }
  547. }).finally(res => {
  548. this.loading = false
  549. })
  550. },
  551. save: debounce(function(isLoading = true) {
  552. // 对接保存数据接口
  553. if (this.saveFlag) {
  554. console.log("重复提交");
  555. return
  556. }
  557. const title = this.previewList[0].data.name
  558. if (!title) {
  559. this.$message({
  560. message: '请输入标题',
  561. type: 'warning'
  562. });
  563. return
  564. }
  565. isLoading && (this.saveLoading = true)
  566. this.saveFlag = true // 防止重复提交限制
  567. request({
  568. params: {
  569. r: 'lucky-group/diy/index'
  570. },
  571. method: 'post',
  572. data: {
  573. content: JSON.stringify(this.previewList),
  574. }
  575. }).then(res => {
  576. if (res.data.code != 0) {
  577. this.$message({
  578. message: res.data.msg,
  579. type: 'error'
  580. });
  581. } else {
  582. this.$message({
  583. message: res.data.msg,
  584. type: 'success'
  585. });
  586. }
  587. }).finally(res => {
  588. this.saveFlag = false
  589. this.saveLoading = false
  590. })
  591. },400),
  592. init() {
  593. this.$eventBus.$on("diy-preview-copy", (item = {}) => {
  594. this.copy(item)
  595. })
  596. this.$eventBus.$on("diy-preview-operateFn", (item = {}) => {
  597. this.operateFn(item)
  598. })
  599. this.$eventBus.$on("diy-back-set", () => {
  600. this.updateView(null, -1)
  601. })
  602. },
  603. validateCount(e) {
  604. // 校验组件能添加几个
  605. var msg = "";
  606. var list = this.previewList.filter(item => {
  607. return item.funcListItem.type === e.type
  608. });
  609. if (e && e.count && list.length >= e.count) {
  610. msg = `该组件只能添加${e.count}个哦`
  611. }
  612. if (msg) {
  613. this.$message({
  614. message: msg,
  615. type: 'warning'
  616. });
  617. }
  618. return msg
  619. },
  620. getIsTopArrLength() {
  621. return this.previewList.filter(item => {
  622. const e1 = item.funcListItem || {}
  623. return e1.is_top
  624. }).length
  625. },
  626. changeDiyItem(item, index, params = {}) {
  627. var {
  628. type
  629. } = params
  630. var list = deepClone(this.previewList) // 克隆一下
  631. if (type !== "isShow") {
  632. // 显示问题 -- 样式组件不让修改
  633. item.isShow = list[this.activeIndex].isShow;
  634. }
  635. // 直接全部覆盖
  636. list[this.activeIndex] = deepClone(item)
  637. this.activeItem = deepClone(item)
  638. this.previewList = list
  639. },
  640. selectItme(item, index) {
  641. console.info(item);
  642. if (this.activeIndex == index) {
  643. this.activeIndex = -1
  644. this.activeItem = null
  645. } else {
  646. this.activeIndex = index
  647. this.activeItem = item
  648. }
  649. console.info();
  650. this.$forceUpdate()
  651. },
  652. pushItem(list = [], target = {}) {
  653. var result = deepClone(list)
  654. result.push(target)
  655. return result
  656. },
  657. /**
  658. * 两种形式,一种push,追加index
  659. */
  660. addIndexItem(list = [], target = {}, index) { // 往指定的index添加item
  661. var result = deepClone(list)
  662. if (this.activeIndex < 0) {
  663. result.push(target)
  664. } else {
  665. var handleArr = [deepClone(result[index]), target]
  666. result.splice(index, 1, ...handleArr)
  667. }
  668. return result
  669. },
  670. // 操作相关
  671. copy() {
  672. if (!this.activeItem || this.activeItem.disabled || this.activeItem.is_copy === false) {
  673. return
  674. }
  675. var item = deepClone(this.activeItem)
  676. item.id = getRandomId()
  677. this.previewList = this.addIndexItem(this.previewList, item, this.activeIndex)
  678. },
  679. /**
  680. * @params {string} obj.type up - down - show
  681. */
  682. operateFn(obj) {
  683. const methods = {
  684. show: 'showItem',
  685. up: 'upItem',
  686. down: 'downItem',
  687. delete: 'deleteItem'
  688. }
  689. this[methods[obj.type]](obj.index)
  690. },
  691. showItem(index) {
  692. var item = deepClone(this.activeItem);
  693. item.isShow = !item.isShow
  694. this.changeDiyItem(item, index, {
  695. type: "isShow"
  696. })
  697. },
  698. updateView(item, index) {
  699. this.activeItem = item
  700. this.activeIndex = index
  701. },
  702. deleteItem(index) {
  703. if (this.activeItem.disabled || this.activeItem.is_delete === false) {
  704. return false
  705. }
  706. this.previewList.splice(index, 1);
  707. // 删除后失去焦点
  708. this.activeIndex = -1;
  709. this.activeItem = null;
  710. },
  711. upItem(index) {
  712. const topArr = this.previewList.filter(item => {
  713. const e1 = item.funcListItem || {}
  714. return e1.is_top
  715. }) // 操作上限
  716. const topIndex = Math.max(0, topArr.length)
  717. if (index <= 0 || this.activeItem.disabled || this.activeItem.is_up === false) {
  718. return false
  719. } else if (index <= topIndex) {
  720. alert("不可以再操作了噢");
  721. return false
  722. }
  723. var previewList = deepClone(this.previewList);
  724. this.previewList = this.swapItems(previewList, index, index - 1);
  725. this.updateView(this.previewList[index - 1], index - 1);
  726. },
  727. downItem(index) {
  728. if (this.activeItem.disabled || this.activeItem.is_down === false) {
  729. return false
  730. } else if (index === this.previewList.length - 1) {
  731. alert("不可以再操作了噢");
  732. return false
  733. }
  734. var previewList = deepClone(this.previewList);
  735. this.previewList = this.swapItems(previewList, index, index + 1);
  736. this.updateView(this.previewList[index + 1], index + 1);
  737. },
  738. swapItems(arr, index1, index2) {
  739. var item = deepClone(arr[index1]);
  740. arr[index1] = arr[index2]
  741. arr[index2] = item
  742. return arr
  743. },
  744. changeMove(e) {
  745. const {
  746. newIndex,
  747. list
  748. } = e
  749. // 移动拖拽改变索引
  750. this.previewList = deepClone(list);
  751. this.updateView(this.previewList[newIndex], newIndex);
  752. },
  753. // 更新主页面
  754. updateMainPage(item) {
  755. this.mainPage = deepClone(item);
  756. },
  757. // 处理兼容老数据
  758. addIsTop(list, type) {
  759. const obj = {
  760. ['nav']: 1,
  761. ['member-info']: 2
  762. }
  763. const top = obj[type]
  764. list.forEach(item => {
  765. if (item.funcListItem.type === type && !item.funcListItem.is_top) {
  766. item.funcListItem.is_top = top
  767. }
  768. });
  769. return list
  770. }
  771. }
  772. })
  773. // 拦截页面卸载
  774. /* window.onbeforeunload = function(e) {
  775. var e = window.event || e;
  776. e.returnValue = ("确定离开当前页面吗?");
  777. } */
  778. </script>
  779. <style>
  780. #app {
  781. display: flex;
  782. flex-direction: column;
  783. min-width: 1250px;
  784. }
  785. #diy-test-preview {
  786. margin: auto;
  787. }
  788. .diy-header-backs {
  789. cursor: pointer;
  790. }
  791. .fixed {
  792. position: fixed;
  793. left: 0;
  794. top: 0;
  795. width: 100%;
  796. height: 100%;
  797. z-index: 999;
  798. }
  799. .diy-header {
  800. height: 60px;
  801. background: #313131;
  802. opacity: 1;
  803. border-radius: 0px;
  804. justify-content: space-between;
  805. font-size: 13px;
  806. font-family: PingFang SC;
  807. font-weight: bold;
  808. color: #FFFFFF;
  809. padding: 0 30px;
  810. }
  811. .diy-contain {
  812. flex: 1;
  813. overflow: auto;
  814. background: #F4F6F8;
  815. justify-content: space-between;
  816. }
  817. .diy-func-list {
  818. box-sizing: border-box;
  819. width: 354px;
  820. background: #FFFFFF;
  821. border-radius: 0px;
  822. }
  823. .diy-preview {
  824. flex: 1;
  825. background: #F4F6F8;
  826. justify-content: space-around;
  827. }
  828. .fill-box {
  829. position: relative;
  830. width: 467px;
  831. height: 100%;
  832. }
  833. .flex {
  834. display: flex;
  835. }
  836. .flex-x-center {
  837. justify-content: center;
  838. }
  839. .flex-y-center {
  840. align-items: center;
  841. }
  842. /* */
  843. .fade-enter-active,
  844. .fade-leave-active {
  845. transition: opacity 1s;
  846. }
  847. .fade-enter,
  848. .fade-leave-to {
  849. opacity: 0;
  850. }
  851. .diy-text-font {
  852. font-size: 13px;
  853. font-weight: 700;
  854. color: #999999;
  855. }
  856. .fill-border-top {
  857. border-top: 10px solid #F4F6F8;
  858. }
  859. .fill-border-bottom {
  860. border-bottom: 10px solid #F4F6F8;
  861. }
  862. /* 导航栏 */
  863. .custom-page {
  864. width: 181px;
  865. height: 60px;
  866. line-height: 60px;
  867. background: var(--diy-theme);
  868. font-weight: 700;
  869. border-radius: 0px;
  870. text-align: center;
  871. }
  872. .save {
  873. font-size: 24px;
  874. vertical-align: middle;
  875. }
  876. .save+span {
  877. vertical-align: middle;
  878. }
  879. .sava_btn .el-button--primary {
  880. background: var(--diy-theme);
  881. border-color: var(--diy-theme);
  882. padding: 8px 14px;
  883. }
  884. .diy_nav_right>div {
  885. padding: 8px 14px;
  886. }
  887. .diy_nav_right .sava_btn {
  888. padding: 0;
  889. }
  890. .page_set>i {
  891. font-size: 24px;
  892. vertical-align: middle;
  893. }
  894. .page_set>span {
  895. vertical-align: middle;
  896. }
  897. .xiaoshou {
  898. cursor: pointer;
  899. }
  900. :root {
  901. /* 主题色 */
  902. --diy-theme: #F10009;
  903. /* 主要字体颜色 */
  904. --diy-color: #F10009;
  905. }
  906. /* 修改ele默认样式 */
  907. /* slider组件 */
  908. .el-slider__bar {
  909. background-color: var(--diy-theme);
  910. }
  911. .el-slider__button {
  912. border-color: var(--diy-theme);
  913. }
  914. /* input组件 */
  915. .el-input .el-input__inner:focus {
  916. border: 1px solid var(--diy-theme);
  917. }
  918. /* textarea */
  919. .el-textarea .el-textarea__inner:focus {
  920. border: 1px solid var(--diy-theme);
  921. }
  922. /* radio单选组件 */
  923. .el-radio__input.is-checked+.el-radio__label {
  924. color: var(--diy-color);
  925. }
  926. .el-radio__input.is-checked .el-radio__inner {
  927. border-color: var(--diy-theme);
  928. background: var(--diy-theme);
  929. }
  930. .el-radio-button__orig-radio:checked+.el-radio-button__inner {
  931. border-color: var(--diy-theme);
  932. box-shadow: -1px 0 0 0 var(--diy-theme);
  933. }
  934. /* 多选 */
  935. .el-checkbox__input.is-checked+.el-checkbox__label {
  936. color: var(--diy-color);
  937. }
  938. .el-checkbox__input.is-checked .el-checkbox__inner,
  939. .el-checkbox__input.is-indeterminate .el-checkbox__inner {
  940. border-color: var(--diy-theme);
  941. background: var(--diy-theme);
  942. }
  943. </style>