pcdiy.ts 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880
  1. import { defineStore } from 'pinia';
  2. import { toRaw } from 'vue';
  3. import { ElMessage, ElMessageBox } from 'element-plus';
  4. import { cloneDeep } from 'lodash-es';
  5. import { fa } from 'element-plus/es/locale/index.mjs';
  6. const usePcdiyStore: any = defineStore('pcdiy', {
  7. state: () => {
  8. return {
  9. name: '',
  10. type: 1,
  11. backgroundColor: '#f2f2f2',
  12. hoverColor: '#E7000B',
  13. componentList: [],
  14. uniqueIdCounter: 0,
  15. currentIndex: -99, // 当前正在编辑的组件下标
  16. currentKey: '',
  17. editTab: 'content', // 编辑页面
  18. predefineColors: [
  19. '#F4391c',
  20. '#ff4500',
  21. '#ff8c00',
  22. '#FFD009',
  23. '#ffd700',
  24. '#19C650',
  25. '#90ee90',
  26. '#00ced1',
  27. '#1e90ff',
  28. '#c71585',
  29. '#FF407E',
  30. '#CFAF70',
  31. '#A253FF',
  32. 'rgba(255, 69, 0, 0.68)',
  33. 'rgb(255, 120, 0)',
  34. 'hsl(181, 100%, 37%)',
  35. 'hsla(209, 100%, 56%, 0.73)',
  36. '#c7158577'
  37. ],
  38. global: {
  39. title: '页面',
  40. // 公共模板属性,所有组件都继承,无需重复定义,组件内部根据业务自行调用
  41. template: {
  42. textColor: '#303133', // 文字颜色
  43. pageStartBgColor: '', // 组件底部背景颜色(开始)
  44. pageEndBgColor: '', // 组件底部背景颜色(结束)
  45. pageGradientAngle: 'to bottom', // 渐变角度,从上到下(to bottom)、从左到右(to right)
  46. componentStartBgColor: '', // 组件背景颜色(开始)
  47. componentEndBgColor: '', // 组件背景颜色(结束)
  48. componentGradientAngle: 'to bottom', // 渐变角度,从上到下(to bottom)、从左到右(to right)
  49. topRounded: 0, // 组件上圆角
  50. bottomRounded: 0, // 组件下圆角
  51. padding: {
  52. top: 0, // 上边距
  53. bottom: 0, // 下边距
  54. both: 0 // 左右边距
  55. },
  56. margin: {
  57. top: 0, // 上边距
  58. bottom: 10 // 下边距
  59. },
  60. isHidden: false // 是否隐藏该组件 true:是,false:否,增加问号说明:勾选后该组件将隐藏,适用于你不希望看到该组件字段又不希望删除的情况;
  61. }
  62. }
  63. };
  64. },
  65. getters: {
  66. editComponent: (state) => {
  67. if (state.currentIndex == -99) {
  68. return state.global;
  69. } else {
  70. return state.componentList[state.currentIndex];
  71. }
  72. }
  73. },
  74. actions: {
  75. // 添加组件
  76. addComponent(item: any, key: any) {
  77. if (this.componentList.length > 0 && item.id == 1) {
  78. const headBoo = this.componentList.some((item2) => item2.id == 1);
  79. if (headBoo) {
  80. ElMessage.error('头部组件只能添加一次~');
  81. return;
  82. }
  83. }
  84. if (this.componentList.length == 0) {
  85. this.uniqueIdCounter = 0;
  86. }
  87. this.uniqueIdCounter++;
  88. const template = cloneDeep(this.global.template);
  89. const newItem = {
  90. ...item,
  91. ...template,
  92. itemKey: this.uniqueIdCounter,
  93. ignore: []
  94. };
  95. // 头部组件
  96. if (item.id == 1) {
  97. newItem.ignore = ['pageBgColor', 'componentBgUrl', 'componentBgColor', 'componentBgColor', 'topRounded', 'bottomRounded', 'marginBoth'];
  98. newItem.settings = 1;
  99. newItem.carousel = 1;
  100. newItem.topStyle = 1;
  101. newItem.logo = '';
  102. newItem.code = '';
  103. newItem.classifyShow = true;
  104. newItem.topType = 1;
  105. newItem.topNav = [
  106. {
  107. title: '导航名称',
  108. url: '',
  109. id: Date.now()
  110. }
  111. ];
  112. newItem.toplabel = [
  113. {
  114. title: '标签名称',
  115. url: '',
  116. id: Date.now()
  117. }
  118. ];
  119. newItem.leftStyle = 1;
  120. newItem.leftBackground = '#ffffff';
  121. newItem.leftColor1 = '#101828';
  122. newItem.leftColor2 = '#364153';
  123. newItem.carouselStyle = false;
  124. newItem.carouselType = 1;
  125. newItem.carouselRadius = 10;
  126. newItem.carouselInterval = 3000;
  127. newItem.carouselPosition = 2;
  128. newItem.carouselStyleType = 1;
  129. newItem.carouselStyleColor = '#ffffff';
  130. newItem.centreType = 1;
  131. newItem.carouselList = [
  132. {
  133. imageUrl: '',
  134. url: '',
  135. imgType: 1,
  136. show: true,
  137. id: Date.now()
  138. }
  139. ];
  140. newItem.advertNum = 0;
  141. newItem.advertList = [
  142. {
  143. imageUrl: '',
  144. url: '',
  145. imgType: 1,
  146. id: Date.now(),
  147. show: false
  148. },
  149. {
  150. imageUrl: '',
  151. url: '',
  152. imgType: 1,
  153. id: Date.now(),
  154. show: false
  155. },
  156. {
  157. imageUrl: '',
  158. url: '',
  159. imgType: 1,
  160. id: Date.now(),
  161. show: false
  162. },
  163. {
  164. imageUrl: '',
  165. url: '',
  166. imgType: 1,
  167. id: Date.now(),
  168. show: false
  169. }
  170. ];
  171. newItem.realType = 1;
  172. newItem.realDataType = 1;
  173. newItem.realNumber = 5;
  174. newItem.realIds = [];
  175. newItem.navlList = [
  176. {
  177. imageUrl: '',
  178. title: '导航名称',
  179. url: '',
  180. imgType: 1,
  181. id: Date.now()
  182. },
  183. {
  184. imageUrl: '',
  185. title: '导航名称',
  186. url: '',
  187. imgType: 1,
  188. id: Date.now()
  189. },
  190. {
  191. imageUrl: '',
  192. title: '导航名称',
  193. url: '',
  194. imgType: 1,
  195. id: Date.now()
  196. },
  197. {
  198. imageUrl: '',
  199. title: '导航名称',
  200. url: '',
  201. imgType: 1,
  202. id: Date.now()
  203. },
  204. {
  205. imageUrl: '',
  206. title: '导航名称',
  207. url: '',
  208. imgType: 1,
  209. id: Date.now()
  210. },
  211. {
  212. imageUrl: '',
  213. title: '导航名称',
  214. url: '',
  215. imgType: 1,
  216. id: Date.now()
  217. }
  218. ];
  219. newItem.rightRadius = 5;
  220. newItem.login = 1;
  221. } else if (item.id == 2) {
  222. // 文本标题
  223. newItem.styleType = 1;
  224. newItem.title = '标题名称';
  225. newItem.titleUrl = '';
  226. newItem.titleAlign = 'left';
  227. newItem.titleSize = 18;
  228. newItem.titleColor = '#101828';
  229. newItem.titleWeight = 'bold';
  230. newItem.subtitle = '副标题';
  231. newItem.subtitleSize = 16;
  232. newItem.subtitleColor = '#b7bcd2';
  233. newItem.more = '更多';
  234. newItem.moreShow = true;
  235. newItem.moreSize = 14;
  236. newItem.moreColor = '#b7bcd2';
  237. newItem.moreUrl = '';
  238. newItem.pageStartBgColor = '#ffffff';
  239. newItem.padding.top = 10;
  240. newItem.padding.bottom = 10;
  241. newItem.padding.both = 20;
  242. } else if (item.id == 3) {
  243. //图文导航
  244. newItem.styleType = 1;
  245. newItem.number = 3;
  246. newItem.count = 1;
  247. newItem.navlList = [
  248. {
  249. imageUrl: '',
  250. title: '标题名称',
  251. subtitle: '副标题名称',
  252. url: '',
  253. imgType: 1,
  254. id: Date.now()
  255. },
  256. {
  257. imageUrl: '',
  258. title: '标题名称',
  259. subtitle: '副标题名称',
  260. url: '',
  261. imgType: 1,
  262. id: Date.now()
  263. },
  264. {
  265. imageUrl: '',
  266. title: '标题名称',
  267. subtitle: '副标题名称',
  268. url: '',
  269. imgType: 1,
  270. id: Date.now()
  271. }
  272. ];
  273. newItem.titleSize = 16;
  274. newItem.titleColor = '#101828';
  275. newItem.titleWeight = 'bold';
  276. newItem.subtitleSize = 12;
  277. newItem.subtitleColor = '#364153';
  278. newItem.imageRadius = 10;
  279. newItem.componentStartBgColor = '#ffffff';
  280. newItem.topRounded = 10;
  281. newItem.bottomRounded = 10;
  282. } else if (item.id == 4) {
  283. // 图片魔方
  284. newItem.number = 1;
  285. newItem.imageHeight = 150;
  286. newItem.imagelList = [
  287. {
  288. imageUrl: '',
  289. url: '',
  290. imgType: 1,
  291. id: Date.now()
  292. },
  293. {
  294. imageUrl: '',
  295. url: '',
  296. imgType: 1,
  297. id: Date.now()
  298. },
  299. {
  300. imageUrl: '',
  301. url: '',
  302. imgType: 1,
  303. id: Date.now()
  304. },
  305. {
  306. imageUrl: '',
  307. url: '',
  308. imgType: 1,
  309. id: Date.now()
  310. },
  311. {
  312. imageUrl: '',
  313. url: '',
  314. imgType: 1,
  315. id: Date.now()
  316. }
  317. ];
  318. newItem.gap = 10;
  319. newItem.imageTopRounded = 10;
  320. newItem.imageBottomRoundedRounded = 10;
  321. } else if (item.id == 5) {
  322. // 活动魔方
  323. newItem.styleType = 1;
  324. newItem.title = '超值爆款';
  325. newItem.titleUrl = '';
  326. newItem.titleImg = '';
  327. newItem.titleImgType = 1;
  328. newItem.titleColor = '#101828';
  329. newItem.subtitle = '为您精选爆款';
  330. newItem.subtitleUrl = '';
  331. newItem.subtitleColor = '#ffffff';
  332. newItem.subtitleColor1 = '#FA742C';
  333. newItem.subtitleColor2 = '#F91C02';
  334. newItem.navType = 1;
  335. newItem.navWeight = 'bold';
  336. newItem.navBtnType = 1;
  337. newItem.navtopRounded = 10;
  338. newItem.navBtnbottomRounded = 10;
  339. newItem.navlList = [
  340. {
  341. imageUrl: '',
  342. imgType: 1,
  343. title: '标题名称',
  344. subtitle: '副标题名称',
  345. color1: '#ffffff',
  346. color2: '',
  347. btnText: '去看看',
  348. btncolor1: '#FA742C',
  349. btncolor2: '#F91C02',
  350. url: '',
  351. id: Date.now()
  352. },
  353. {
  354. imageUrl: '',
  355. imgType: 1,
  356. title: '标题名称',
  357. subtitle: '副标题名称',
  358. color1: '#ffffff',
  359. color2: '',
  360. btnText: '去看看',
  361. btncolor1: '#FA742C',
  362. btncolor2: '#F91C02',
  363. url: '',
  364. id: Date.now()
  365. },
  366. {
  367. imageUrl: '',
  368. imgType: 1,
  369. title: '标题名称',
  370. subtitle: '副标题名称',
  371. color1: '#ffffff',
  372. color2: '',
  373. btnText: '去看看',
  374. btncolor1: '#FA742C',
  375. btncolor2: '#F91C02',
  376. url: '',
  377. id: Date.now()
  378. },
  379. {
  380. imageUrl: '',
  381. imgType: 1,
  382. title: '标题名称',
  383. subtitle: '副标题名称',
  384. color1: '#ffffff',
  385. color2: '',
  386. btnText: '去看看',
  387. btncolor1: '#FA742C',
  388. btncolor2: '#F91C02',
  389. url: '',
  390. id: Date.now()
  391. }
  392. ];
  393. } else if (item.id == 6) {
  394. //轮播图
  395. newItem.imageHeight = 200;
  396. newItem.imagelList = [
  397. {
  398. imageUrl: '',
  399. imgType: 1,
  400. id: Date.now(),
  401. url: ''
  402. }
  403. ];
  404. newItem.interval = 3000;
  405. newItem.styleType = 1;
  406. newItem.position = 2;
  407. newItem.imageRadius = 10;
  408. newItem.carouselStyleColor = '#ffffff';
  409. newItem.ignore = ['componentBgColor', 'topRounded', 'bottomRounded'];
  410. } else if (item.id == 7) {
  411. //文章咨询
  412. newItem.dataType = 1;
  413. newItem.dataNumber = 4;
  414. newItem.dataIds = [];
  415. newItem.border = 1;
  416. newItem.borderColor = '#ffffff';
  417. newItem.backgroundColor = '#ffffff';
  418. newItem.boxTopRounded = 10;
  419. newItem.boxBottomRounded = 10;
  420. } else if (item.id == 8) {
  421. //品牌组件
  422. newItem.settings = 1;
  423. newItem.imageUrl = '';
  424. newItem.url = '';
  425. newItem.imgType = 1;
  426. newItem.brandList = [
  427. {
  428. imageUrl: '',
  429. title: '品牌名称',
  430. subtitle: '品牌介绍',
  431. url: '',
  432. imgType: 1,
  433. id: Date.now()
  434. },
  435. {
  436. imageUrl: '',
  437. title: '品牌名称',
  438. subtitle: '品牌介绍',
  439. url: '',
  440. imgType: 1,
  441. id: Date.now()
  442. },
  443. {
  444. imageUrl: '',
  445. title: '品牌名称',
  446. subtitle: '品牌介绍',
  447. url: '',
  448. imgType: 1,
  449. id: Date.now()
  450. },
  451. {
  452. imageUrl: '',
  453. title: '品牌名称',
  454. subtitle: '品牌介绍',
  455. url: '',
  456. imgType: 1,
  457. id: Date.now()
  458. },
  459. {
  460. imageUrl: '',
  461. title: '品牌名称',
  462. subtitle: '品牌介绍',
  463. url: '',
  464. imgType: 1,
  465. id: Date.now()
  466. },
  467. {
  468. imageUrl: '',
  469. title: '品牌名称',
  470. subtitle: '品牌介绍',
  471. url: '',
  472. imgType: 1,
  473. id: Date.now()
  474. },
  475. {
  476. imageUrl: '',
  477. title: '品牌名称',
  478. subtitle: '品牌介绍',
  479. url: '',
  480. imgType: 1,
  481. id: Date.now()
  482. },
  483. {
  484. imageUrl: '',
  485. title: '品牌名称',
  486. subtitle: '品牌介绍',
  487. url: '',
  488. imgType: 1,
  489. id: Date.now()
  490. },
  491. {
  492. imageUrl: '',
  493. title: '品牌名称',
  494. subtitle: '品牌介绍',
  495. url: '',
  496. imgType: 1,
  497. id: Date.now()
  498. },
  499. {
  500. imageUrl: '',
  501. title: '品牌名称',
  502. subtitle: '品牌介绍',
  503. url: '',
  504. imgType: 1,
  505. id: Date.now()
  506. },
  507. {
  508. imageUrl: '',
  509. title: '品牌名称',
  510. subtitle: '品牌介绍',
  511. url: '',
  512. imgType: 1,
  513. id: Date.now()
  514. },
  515. {
  516. imageUrl: '',
  517. title: '品牌名称',
  518. subtitle: '品牌介绍',
  519. url: '',
  520. imgType: 1,
  521. id: Date.now()
  522. }
  523. ];
  524. newItem.titleSize = 14;
  525. newItem.titleColor = '#101828';
  526. newItem.titleWeight = 'bold';
  527. newItem.subtitleSize = 12;
  528. newItem.subtitleColor = '#364153';
  529. newItem.imageRadius = 10;
  530. newItem.boxRadius = 5;
  531. } else if (item.id == 9) {
  532. //图文广告
  533. newItem.styleType = 1;
  534. newItem.number = 3;
  535. newItem.count = 1;
  536. newItem.navlList = [
  537. {
  538. imageUrl: '',
  539. title: '标题名称',
  540. subtitle: '副标题名称',
  541. url: '',
  542. imgType: 1,
  543. id: Date.now()
  544. },
  545. {
  546. imageUrl: '',
  547. title: '标题名称',
  548. subtitle: '副标题名称',
  549. url: '',
  550. imgType: 1,
  551. id: Date.now()
  552. },
  553. {
  554. imageUrl: '',
  555. title: '标题名称',
  556. subtitle: '副标题名称',
  557. url: '',
  558. imgType: 1,
  559. id: Date.now()
  560. }
  561. ];
  562. newItem.titleSize = 16;
  563. newItem.titleColor = '#101828';
  564. newItem.titleWeight = 'bold';
  565. newItem.subtitleSize = 12;
  566. newItem.subtitleColor = '#364153';
  567. newItem.imageRadius = 10;
  568. newItem.componentStartBgColor = '#ffffff';
  569. newItem.topRounded = 10;
  570. newItem.bottomRounded = 10;
  571. } else if (item.id == 10) {
  572. //楼层组件
  573. newItem.styleType = 1;
  574. newItem.url = '';
  575. newItem.imageUrl = '';
  576. newItem.imgType = 1;
  577. newItem.imageRadius = 10;
  578. newItem.goodsIds = [];
  579. newItem.goodsShow = [1, 2, 3];
  580. newItem.btnShow = true;
  581. newItem.btnStyle = 1;
  582. newItem.btnText = '购买';
  583. newItem.btnColor = '#ffffff';
  584. newItem.btnbackgroundColor = '#E7000B';
  585. newItem.moreTitle = '更多';
  586. newItem.moreUrl = '';
  587. newItem.moreColor = '#E7000B';
  588. newItem.moreShow = true;
  589. newItem.brandList = [
  590. {
  591. imageUrl: '',
  592. url: '',
  593. imgType: 1,
  594. id: Date.now()
  595. },
  596. {
  597. imageUrl: '',
  598. url: '',
  599. imgType: 1,
  600. id: Date.now()
  601. },
  602. {
  603. imageUrl: '',
  604. url: '',
  605. imgType: 1,
  606. id: Date.now()
  607. },
  608. {
  609. imageUrl: '',
  610. url: '',
  611. imgType: 1,
  612. id: Date.now()
  613. },
  614. {
  615. imageUrl: '',
  616. url: '',
  617. imgType: 1,
  618. id: Date.now()
  619. },
  620. {
  621. imageUrl: '',
  622. url: '',
  623. imgType: 1,
  624. id: Date.now()
  625. }
  626. ];
  627. } else if (item.id == 11) {
  628. // 商品组件
  629. newItem.styleType = 1;
  630. newItem.btnShow = true;
  631. newItem.btnStyle = 1;
  632. newItem.btnText = '购买';
  633. newItem.goodsShow = [1, 2, 3];
  634. newItem.goodsType = 1;
  635. newItem.goodsIds = [];
  636. newItem.categoryIds = [];
  637. newItem.goodsClassify = '';
  638. newItem.topCategoryId = '';
  639. newItem.mediumCategoryId = '';
  640. newItem.bottomCategoryId = '';
  641. newItem.goodsNumber = 5;
  642. newItem.goodsSort = 1;
  643. newItem.brandIds = [];
  644. newItem.goodsbackgroundColor = '#ffffff';
  645. newItem.goodsTitleType = 1;
  646. newItem.goodsTitleColor = '#101828';
  647. newItem.imageRadius = 10;
  648. newItem.goodstopRounded = 10;
  649. newItem.goodsbottomRounded = 10;
  650. newItem.priceColor = '#E7000B';
  651. newItem.btnColor = '#ffffff';
  652. newItem.btnbackgroundColor = '#E7000B';
  653. } else if (item.id == 12) {
  654. //多商品组件
  655. newItem.btnShow = true;
  656. newItem.btnStyle = 1;
  657. newItem.btnText = '购买';
  658. newItem.goodsShow = [1, 2, 3];
  659. newItem.goodsNumber = 5;
  660. newItem.goodsSort = 1;
  661. newItem.goodsbackgroundColor = '#ffffff';
  662. newItem.goodsTitleType = 1;
  663. newItem.goodsTitleColor = '#101828';
  664. newItem.imageRadius = 10;
  665. newItem.goodstopRounded = 10;
  666. newItem.goodsbottomRounded = 10;
  667. newItem.priceColor = '#E7000B';
  668. newItem.btnColor = '#ffffff';
  669. newItem.btnbackgroundColor = '#E7000B';
  670. newItem.tabColor1 = '#333333';
  671. newItem.tabColor2 = '#ffffff';
  672. newItem.tabbackgroundColor1 = '#ffffff';
  673. newItem.tabbackgroundColor2 = '#E7000B';
  674. newItem.tabRadius = 10;
  675. newItem.tabIndex = 0;
  676. newItem.tabList = [
  677. {
  678. title: '选项卡',
  679. goodsType: 1,
  680. goodsIds: [],
  681. categoryIds: [],
  682. goodsClassify: '',
  683. topCategoryId: '',
  684. mediumCategoryId: '',
  685. bottomCategoryId: '',
  686. id: Date.now()
  687. }
  688. ];
  689. } else if (item.id == 13) {
  690. // 发现组件
  691. newItem.settings = 1;
  692. newItem.title = '标题';
  693. newItem.titleUrl = '';
  694. newItem.titleSize = 18;
  695. newItem.titleColor = '#101828';
  696. newItem.titleWeight = 'bold';
  697. newItem.subtitle = '副标题';
  698. newItem.subtitleSize = 14;
  699. newItem.subtitleColor = '#364153';
  700. newItem.imgType = 1;
  701. newItem.tabList = [
  702. {
  703. title: '导航名称',
  704. url: '',
  705. id: Date.now()
  706. }
  707. ];
  708. newItem.imageUrl = '';
  709. newItem.imageRadius = 10;
  710. newItem.boxRadius = 5;
  711. newItem.boxColor = '#E7000B';
  712. newItem.planList = [
  713. {
  714. imageUrl: '',
  715. title: '方案名称',
  716. subtitle: '方案详情',
  717. url: '',
  718. imgType: 1,
  719. id: Date.now()
  720. },
  721. {
  722. imageUrl: '',
  723. title: '方案名称',
  724. subtitle: '方案详情',
  725. url: '',
  726. imgType: 1,
  727. id: Date.now()
  728. },
  729. {
  730. imageUrl: '',
  731. title: '方案名称',
  732. subtitle: '方案详情',
  733. url: '',
  734. imgType: 1,
  735. id: Date.now()
  736. }
  737. ];
  738. newItem.detectList = [
  739. {
  740. imageUrl: '',
  741. title: '名称',
  742. subtitle: '详情',
  743. url: '',
  744. imgType: 1,
  745. id: Date.now()
  746. },
  747. {
  748. imageUrl: '',
  749. title: '名称',
  750. subtitle: '详情',
  751. url: '',
  752. imgType: 1,
  753. id: Date.now()
  754. },
  755. {
  756. imageUrl: '',
  757. title: '名称',
  758. subtitle: '详情',
  759. url: '',
  760. imgType: 1,
  761. id: Date.now()
  762. }
  763. ];
  764. newItem.labelList = [
  765. {
  766. title: '标签名称',
  767. url: '',
  768. id: Date.now()
  769. }
  770. ];
  771. newItem.goodsIds = [];
  772. } else if (item.id == 14) {
  773. // 热区
  774. newItem.imageUrl = '';
  775. newItem.imgWidth = 0;
  776. newItem.imgHeight = 0;
  777. newItem.heatMapData = [];
  778. } else if (item.id == 15) {
  779. // 富文本
  780. newItem.detail = '';
  781. newItem.pageStartBgColor = '#ffffff';
  782. newItem.padding.top = 10;
  783. newItem.padding.bottom = 10;
  784. newItem.padding.both = 10;
  785. } else if (item.id == 16) {
  786. // 辅助空白
  787. newItem.boxHeight = 20;
  788. } else if (item.id == 17) {
  789. // 辅助线
  790. newItem.boxHeight = 1;
  791. newItem.boxColor = '#000000';
  792. }
  793. this.componentList.push(newItem);
  794. this.currentIndex = this.componentList.length - 1;
  795. this.currentKey = newItem.itemKey;
  796. console.log(this.componentList, '4564654');
  797. },
  798. // 上移组件
  799. moveUpComponent() {
  800. if (this.currentIndex <= 0 || this.currentIndex >= this.componentList.length) {
  801. return;
  802. }
  803. if (this.componentList[this.currentIndex].id == 1) {
  804. ElMessage.error('头部组件不可移动~');
  805. return;
  806. }
  807. if (this.currentIndex == 1 && this.componentList[0].id == 1) {
  808. ElMessage.error('头部组件不可移动~');
  809. return;
  810. }
  811. [this.componentList[this.currentIndex], this.componentList[this.currentIndex - 1]] = [
  812. this.componentList[this.currentIndex - 1],
  813. this.componentList[this.currentIndex]
  814. ];
  815. },
  816. // 下移组件
  817. moveDownComponent() {
  818. if (this.currentIndex < 0 || this.currentIndex >= this.componentList.length - 1) {
  819. return;
  820. }
  821. if (this.componentList[this.currentIndex].id == 1) {
  822. ElMessage.error('头部组件不可移动~');
  823. return;
  824. }
  825. [this.componentList[this.currentIndex], this.componentList[this.currentIndex + 1]] = [
  826. this.componentList[this.currentIndex + 1],
  827. this.componentList[this.currentIndex]
  828. ];
  829. },
  830. // 复制
  831. copyComponent() {
  832. // const datas = structuredClone(this.componentList[this.currentIndex]);
  833. // const datas = JSON.parse(JSON.stringify(this.componentList[this.currentIndex]));
  834. // // console.log(datas, '???????')
  835. // this.componentList.splice(this.currentIndex + 1, 0, datas);
  836. },
  837. //删除
  838. delComponent() {
  839. this.componentList.splice(this.currentIndex, 1);
  840. this.currentIndex = -99;
  841. },
  842. //点击组件
  843. onComponent(item: any, index: any) {
  844. this.currentKey = item.itemKey;
  845. this.currentIndex = index;
  846. },
  847. // 修改index值
  848. onIndex(index: any) {
  849. this.currentIndex = index;
  850. },
  851. resetComponent() {
  852. this.currentIndex = -99;
  853. }
  854. }
  855. });
  856. export default usePcdiyStore;