index.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999
  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:['mch_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: "mch"
  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. // dd($diyPath, $stylePath, $components, $styleComponents);
  344. ComponentHelper::loadComponentView('diy/diy-preview');
  345. ComponentHelper::loadComponentView('diy/diy-style-preview');
  346. foreach ($components as $item) {
  347. ComponentHelper::loadComponentView("diy/common/{$item}");
  348. }
  349. foreach ($styleComponents as $item) {
  350. ComponentHelper::loadComponentView("diy/style-components/{$item}");
  351. }
  352. $currentRoute = Yii::$app->controller->route;
  353. ?>
  354. <div id="app">
  355. <div style="padding-bottom: 10px;padding-right: 20px;background: #F4F6F8;" @click="save" flex="main:right">
  356. <el-button type="primary">保存</el-button>
  357. </div>
  358. <div class="diy-contain flex" v-loading="loading">
  359. <diy-preview :active-index="activeIndex" :list="previewList" @select-item="selectItme" @change-move="changeMove"></diy-preview>
  360. <transition name="fade">
  361. <diy-style-preview :active-item="activeItem" :active-index="activeIndex" :permission="permission" @update="changeDiyItem" v-if="showUpdate"></diy-style-preview>
  362. </transition>
  363. </div>
  364. <!-- 预览弹窗 -->
  365. <el-dialog title="预览弹窗" :modal-append-to-body="false" :visible.sync="dialogFormVisible">
  366. <div class="flex flex-x-center" style="height: 600px;overflow:auto">
  367. <img id="diy-test-preview" :src="previewSrc"></img>
  368. </div>
  369. <div slot="footer" class="dialog-footer">
  370. <el-button @click="dialogFormVisible = false">取 消</el-button>
  371. <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>
  372. </div>
  373. </el-dialog>
  374. </div>
  375. <script>
  376. Vue.prototype.$capitals = []; // 用户信息对象
  377. Vue.prototype.$eventBus = new Vue();
  378. var PageShareData = {
  379. pageIndex: false // 点击页面设置标识 => nav/style
  380. }; // 全局共享数据 - 没有响应式
  381. new Vue({
  382. el: '#app',
  383. data() {
  384. return {
  385. capital: [],
  386. dialogFormVisible: false,
  387. /**
  388. * @descriptions 浮动()、普通()、置顶(isTop)、弹窗(alert)四种显示组件
  389. * @param {string} type // diy组件类型
  390. * @param {string} title // 二级标题
  391. * @param {string} img // diy组件图片
  392. * @param {number} count // 可添加diy组件数量
  393. * @param {boolean} is_top // diy组件是否置顶组件 - 待添加 - 分添加等级 1 2 3 数字靠前权限越高
  394. * @param {object} permission // 组件的不可操作权限 {"is_delete": false,"is_drag": false,"disabled": true, // 禁用操作}
  395. */
  396. pageComponentsList: [],
  397. /**
  398. * @param {boolean} is_show_permission // 显示权限
  399. * @param {boolean} is_delete // 是否可删除
  400. * @param {boolean} is_up // 是否可上移
  401. * @param {boolean} is_down // 是否可下移
  402. * @param {boolean} is_drag // 是否可拖拽
  403. * @param {boolean} is_copy // 是否可复制
  404. * @param {boolean} disabled // 全部禁用操作
  405. */
  406. previewList: [], // 预览数组对象
  407. activeIndex: -1, // 预览激活索引
  408. activeItem: null, // 预览激活对象
  409. type: "add", // add新增 - edit编辑
  410. test: ["a", "b", "c"],
  411. showUpdate: true,
  412. responentData: null, // 详情响应的总数据
  413. permission: [], // 权限数组
  414. isClickPage: false, // 是否点击分页设置
  415. loading: false, // 数据加载
  416. saveLoading: false, // 保存数据
  417. fields: {
  418. upload_type: 'images'
  419. },
  420. previewSrc: "",
  421. }
  422. },
  423. provide() {
  424. return {
  425. capitals: this.capital
  426. }
  427. },
  428. watch: {
  429. activeIndex() {
  430. this.showUpdate = false
  431. setTimeout(() => {
  432. this.showUpdate = true
  433. }, 0)
  434. },
  435. },
  436. created() {
  437. // console.log(this.dynamicImgSrc('/abc/ss'));
  438. // 添加不同的模板nav
  439. this.previewList.push(...getNavData())
  440. this.init()
  441. this.detail()
  442. },
  443. methods: {
  444. savePreview() {
  445. this.activeIndex = -1
  446. this.activeItem = null
  447. this.$nextTick(() => {
  448. const contain = document.getElementById("diy-preview-contain");
  449. this.deepNode(contain);
  450. setTimeout(() => {
  451. this.dialogFormVisible = true
  452. html2canvas(contain, {
  453. useCORS: true
  454. }).then(canvas => {
  455. const src = canvas.toDataURL("image/png")
  456. this.upload(this.dataURLtoFile(src)).then(res => {
  457. if (res.code == 0) {
  458. this.previewSrc = res.data.url
  459. this.save(false)
  460. } else {
  461. this.$message({
  462. message: res.msg,
  463. type: 'warning'
  464. });
  465. }
  466. })
  467. })
  468. }, 0)
  469. })
  470. },
  471. dataURLtoFile(dataurl) { // 生成Blob
  472. var arr = dataurl.split(',');
  473. var mime = arr[0].match(/:(.*?);/)[1];
  474. var bstr = atob(arr[1]);
  475. var n = bstr.length;
  476. var u8arr = new Uint8Array(n);
  477. while (n--) {
  478. u8arr[n] = bstr.charCodeAt(n);
  479. }
  480. return new Blob([u8arr], {
  481. type: mime
  482. });
  483. },
  484. upload(file) {
  485. let formData = new FormData();
  486. const params = {
  487. upload_type: 'images'
  488. };
  489. params['r'] = 'common/file/upload';
  490. for (let i in this.fields) {
  491. formData.append(i, this.fields[i]);
  492. }
  493. formData.append('file', file, "image.png");
  494. return new Promise(successCallback => {
  495. this.$request({
  496. headers: {
  497. 'Content-Type': 'multipart/form-data'
  498. },
  499. params: params,
  500. method: 'post',
  501. data: formData,
  502. }).then(e => {
  503. successCallback(e.data)
  504. }).catch(e => {
  505. file._complete = true;
  506. });
  507. })
  508. },
  509. deepNode(contain) {
  510. if (contain.tagName === "IMG") {
  511. contain.src = contain.src + '?t=' + Date.now()
  512. contain.setAttribute('crossorigin', 'anonymous')
  513. }
  514. if (contain.children && contain.children.length) {
  515. [].forEach.call(contain.children, (item => {
  516. this.deepNode(item)
  517. }))
  518. }
  519. },
  520. pageSet() {
  521. PageShareData.pageIndex = true
  522. this.$eventBus.$emit("onPageClick")
  523. var index = 0;
  524. this.activeIndex = index
  525. this.activeItem = this.previewList[index]
  526. // this.changeDiyItem()
  527. },
  528. detail() {
  529. // 详情
  530. this.loading = true
  531. request({
  532. params: {
  533. r: 'mch/diy/index'
  534. },
  535. method: 'get',
  536. }).then(res => {
  537. if(res.data.code == 0){
  538. let previewList = [];
  539. if (res.data.data.content) {
  540. previewList = JSON.parse(res.data.data.content)
  541. }
  542. console.log(previewList, '---------------')
  543. if(!previewList.length) return
  544. this.previewList = previewList
  545. } else {
  546. this.$message({
  547. message: res.data.msg,
  548. type: 'error'
  549. });
  550. }
  551. }).finally(res => {
  552. this.loading = false
  553. })
  554. },
  555. save: debounce(function(isLoading = true) {
  556. // 对接保存数据接口
  557. if (this.saveFlag) {
  558. console.log("重复提交");
  559. return
  560. }
  561. const title = this.previewList[0].data.name
  562. // if (!title) {
  563. // this.$message({
  564. // message: '请输入标题',
  565. // type: 'warning'
  566. // });
  567. // return
  568. // }
  569. isLoading && (this.saveLoading = true)
  570. this.saveFlag = true // 防止重复提交限制
  571. request({
  572. params: {
  573. r: 'mch/diy/index'
  574. },
  575. method: 'post',
  576. data: {
  577. content: JSON.stringify(this.previewList),
  578. }
  579. }).then(res => {
  580. if (res.data.code != 0) {
  581. this.$message({
  582. message: res.data.msg,
  583. type: 'error'
  584. });
  585. } else {
  586. this.$message({
  587. message: res.data.msg,
  588. type: 'success'
  589. });
  590. }
  591. }).finally(res => {
  592. this.saveFlag = false
  593. this.saveLoading = false
  594. })
  595. },400),
  596. init() {
  597. this.$eventBus.$on("diy-preview-copy", (item = {}) => {
  598. this.copy(item)
  599. })
  600. this.$eventBus.$on("diy-preview-operateFn", (item = {}) => {
  601. this.operateFn(item)
  602. })
  603. this.$eventBus.$on("diy-back-set", () => {
  604. this.updateView(null, -1)
  605. })
  606. },
  607. validateCount(e) {
  608. // 校验组件能添加几个
  609. var msg = "";
  610. var list = this.previewList.filter(item => {
  611. return item.funcListItem.type === e.type
  612. });
  613. if (e && e.count && list.length >= e.count) {
  614. msg = `该组件只能添加${e.count}个哦`
  615. }
  616. if (msg) {
  617. this.$message({
  618. message: msg,
  619. type: 'warning'
  620. });
  621. }
  622. return msg
  623. },
  624. getIsTopArrLength() {
  625. return this.previewList.filter(item => {
  626. const e1 = item.funcListItem || {}
  627. return e1.is_top
  628. }).length
  629. },
  630. changeDiyItem(item, index, params = {}) {
  631. var {
  632. type
  633. } = params
  634. var list = deepClone(this.previewList) // 克隆一下
  635. if (type !== "isShow") {
  636. // 显示问题 -- 样式组件不让修改
  637. item.isShow = list[this.activeIndex].isShow;
  638. }
  639. // 直接全部覆盖
  640. list[this.activeIndex] = deepClone(item)
  641. this.activeItem = deepClone(item)
  642. this.previewList = list
  643. },
  644. selectItme(item, index) {
  645. console.info(item);
  646. if (this.activeIndex == index) {
  647. this.activeIndex = -1
  648. this.activeItem = null
  649. } else {
  650. this.activeIndex = index
  651. this.activeItem = item
  652. }
  653. console.info();
  654. this.$forceUpdate()
  655. },
  656. pushItem(list = [], target = {}) {
  657. var result = deepClone(list)
  658. result.push(target)
  659. return result
  660. },
  661. /**
  662. * 两种形式,一种push,追加index
  663. */
  664. addIndexItem(list = [], target = {}, index) { // 往指定的index添加item
  665. var result = deepClone(list)
  666. if (this.activeIndex < 0) {
  667. result.push(target)
  668. } else {
  669. var handleArr = [deepClone(result[index]), target]
  670. result.splice(index, 1, ...handleArr)
  671. }
  672. return result
  673. },
  674. // 操作相关
  675. copy() {
  676. if (!this.activeItem || this.activeItem.disabled || this.activeItem.is_copy === false) {
  677. return
  678. }
  679. var item = deepClone(this.activeItem)
  680. item.id = getRandomId()
  681. this.previewList = this.addIndexItem(this.previewList, item, this.activeIndex)
  682. },
  683. /**
  684. * @params {string} obj.type up - down - show
  685. */
  686. operateFn(obj) {
  687. const methods = {
  688. show: 'showItem',
  689. up: 'upItem',
  690. down: 'downItem',
  691. delete: 'deleteItem'
  692. }
  693. this[methods[obj.type]](obj.index)
  694. },
  695. showItem(index) {
  696. var item = deepClone(this.activeItem);
  697. item.isShow = !item.isShow
  698. this.changeDiyItem(item, index, {
  699. type: "isShow"
  700. })
  701. },
  702. updateView(item, index) {
  703. this.activeItem = item
  704. this.activeIndex = index
  705. },
  706. deleteItem(index) {
  707. if (this.activeItem.disabled || this.activeItem.is_delete === false) {
  708. return false
  709. }
  710. this.previewList.splice(index, 1);
  711. // 删除后失去焦点
  712. this.activeIndex = -1;
  713. this.activeItem = null;
  714. },
  715. upItem(index) {
  716. const topArr = this.previewList.filter(item => {
  717. const e1 = item.funcListItem || {}
  718. return e1.is_top
  719. }) // 操作上限
  720. const topIndex = Math.max(0, topArr.length)
  721. if (index <= 0 || this.activeItem.disabled || this.activeItem.is_up === false) {
  722. return false
  723. } else if (index <= topIndex) {
  724. alert("不可以再操作了噢");
  725. return false
  726. }
  727. var previewList = deepClone(this.previewList);
  728. this.previewList = this.swapItems(previewList, index, index - 1);
  729. this.updateView(this.previewList[index - 1], index - 1);
  730. },
  731. downItem(index) {
  732. if (this.activeItem.disabled || this.activeItem.is_down === false) {
  733. return false
  734. } else if (index === this.previewList.length - 1) {
  735. alert("不可以再操作了噢");
  736. return false
  737. }
  738. var previewList = deepClone(this.previewList);
  739. this.previewList = this.swapItems(previewList, index, index + 1);
  740. this.updateView(this.previewList[index + 1], index + 1);
  741. },
  742. swapItems(arr, index1, index2) {
  743. var item = deepClone(arr[index1]);
  744. arr[index1] = arr[index2]
  745. arr[index2] = item
  746. return arr
  747. },
  748. changeMove(e) {
  749. const {
  750. newIndex,
  751. list
  752. } = e
  753. // 移动拖拽改变索引
  754. this.previewList = deepClone(list);
  755. this.updateView(this.previewList[newIndex], newIndex);
  756. },
  757. // 更新主页面
  758. updateMainPage(item) {
  759. this.mainPage = deepClone(item);
  760. },
  761. // 处理兼容老数据
  762. addIsTop(list, type) {
  763. const obj = {
  764. ['nav']: 1,
  765. ['member-info']: 2
  766. }
  767. const top = obj[type]
  768. list.forEach(item => {
  769. if (item.funcListItem.type === type && !item.funcListItem.is_top) {
  770. item.funcListItem.is_top = top
  771. }
  772. });
  773. return list
  774. }
  775. }
  776. })
  777. // 拦截页面卸载
  778. /* window.onbeforeunload = function(e) {
  779. var e = window.event || e;
  780. e.returnValue = ("确定离开当前页面吗?");
  781. } */
  782. </script>
  783. <style>
  784. #app {
  785. display: flex;
  786. flex-direction: column;
  787. min-width: 1250px;
  788. }
  789. #diy-test-preview {
  790. margin: auto;
  791. }
  792. .diy-header-backs {
  793. cursor: pointer;
  794. }
  795. .fixed {
  796. position: fixed;
  797. left: 0;
  798. top: 0;
  799. width: 100%;
  800. height: 100%;
  801. z-index: 999;
  802. }
  803. .diy-header {
  804. height: 60px;
  805. background: #313131;
  806. opacity: 1;
  807. border-radius: 0px;
  808. justify-content: space-between;
  809. font-size: 13px;
  810. font-family: PingFang SC;
  811. font-weight: bold;
  812. color: #FFFFFF;
  813. padding: 0 30px;
  814. }
  815. .diy-contain {
  816. flex: 1;
  817. overflow: auto;
  818. background: #F4F6F8;
  819. justify-content: space-between;
  820. }
  821. .diy-func-list {
  822. box-sizing: border-box;
  823. width: 354px;
  824. background: #FFFFFF;
  825. border-radius: 0px;
  826. }
  827. .diy-preview {
  828. flex: 1;
  829. background: #F4F6F8;
  830. justify-content: space-around;
  831. }
  832. .fill-box {
  833. position: relative;
  834. width: 467px;
  835. height: 100%;
  836. }
  837. .flex {
  838. display: flex;
  839. }
  840. .flex-x-center {
  841. justify-content: center;
  842. }
  843. .flex-y-center {
  844. align-items: center;
  845. }
  846. /* */
  847. .fade-enter-active,
  848. .fade-leave-active {
  849. transition: opacity 1s;
  850. }
  851. .fade-enter,
  852. .fade-leave-to {
  853. opacity: 0;
  854. }
  855. .diy-text-font {
  856. font-size: 13px;
  857. font-weight: 700;
  858. color: #999999;
  859. }
  860. .fill-border-top {
  861. border-top: 10px solid #F4F6F8;
  862. }
  863. .fill-border-bottom {
  864. border-bottom: 10px solid #F4F6F8;
  865. }
  866. /* 导航栏 */
  867. .custom-page {
  868. width: 181px;
  869. height: 60px;
  870. line-height: 60px;
  871. background: var(--diy-theme);
  872. font-weight: 700;
  873. border-radius: 0px;
  874. text-align: center;
  875. }
  876. .save {
  877. font-size: 24px;
  878. vertical-align: middle;
  879. }
  880. .save+span {
  881. vertical-align: middle;
  882. }
  883. .sava_btn .el-button--primary {
  884. background: var(--diy-theme);
  885. border-color: var(--diy-theme);
  886. padding: 8px 14px;
  887. }
  888. .diy_nav_right>div {
  889. padding: 8px 14px;
  890. }
  891. .diy_nav_right .sava_btn {
  892. padding: 0;
  893. }
  894. .page_set>i {
  895. font-size: 24px;
  896. vertical-align: middle;
  897. }
  898. .page_set>span {
  899. vertical-align: middle;
  900. }
  901. .xiaoshou {
  902. cursor: pointer;
  903. }
  904. :root {
  905. /* 主题色 */
  906. --diy-theme: #F10009;
  907. /* 主要字体颜色 */
  908. --diy-color: #F10009;
  909. }
  910. /* 修改ele默认样式 */
  911. /* slider组件 */
  912. .el-slider__bar {
  913. background-color: var(--diy-theme);
  914. }
  915. .el-slider__button {
  916. border-color: var(--diy-theme);
  917. }
  918. /* input组件 */
  919. .el-input .el-input__inner:focus {
  920. border: 1px solid var(--diy-theme);
  921. }
  922. /* textarea */
  923. .el-textarea .el-textarea__inner:focus {
  924. border: 1px solid var(--diy-theme);
  925. }
  926. /* radio单选组件 */
  927. .el-radio__input.is-checked+.el-radio__label {
  928. color: var(--diy-color);
  929. }
  930. .el-radio__input.is-checked .el-radio__inner {
  931. border-color: var(--diy-theme);
  932. background: var(--diy-theme);
  933. }
  934. .el-radio-button__orig-radio:checked+.el-radio-button__inner {
  935. border-color: var(--diy-theme);
  936. box-shadow: -1px 0 0 0 var(--diy-theme);
  937. }
  938. /* 多选 */
  939. .el-checkbox__input.is-checked+.el-checkbox__label {
  940. color: var(--diy-color);
  941. }
  942. .el-checkbox__input.is-checked .el-checkbox__inner,
  943. .el-checkbox__input.is-indeterminate .el-checkbox__inner {
  944. border-color: var(--diy-theme);
  945. background: var(--diy-theme);
  946. }
  947. </style>