template.js 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229
  1. //0.自助建站的接口 start---------------------------------------->
  2. import { getSiteInfo, getSiteCategory, getFooterCategoryList} from '@/api/cms'
  3. import {
  4. getWebsiteintel, checkWebsiteBuild, getAdminSiteInfo, upWebsiteTemplateintel, getAllTemplateClass,
  5. getWebsiteTemplateList, chooseWebsiteTemplate, getWebsiteTemplateclassintel, saveWebsiteTemplate,
  6. getWebsiteTemplateInfo, getWebsiteTemplateData, getAdminWebsiteFootAll, addTwinAdPlace,
  7. getWebPageType, addWebPageType, checkWebsiteEdit, getWebsiteTemplate
  8. } from '@/api/template'
  9. //0.自助建站的接口 end---------------------------------------->
  10. //1.引入必备方法 start---------------------------------------->
  11. //导入Vue因为我们要进行深层次的json修改,必须调用Vue.Set,否则深拷贝的数据无法令视图更新
  12. import { Message } from 'element-ui';
  13. import Vue from 'vue';
  14. //1.引入必备方法 end---------------------------------------->
  15. //2.引入随机模板json后期删除 start---------------------------------------->
  16. //首页 风格1
  17. import randomIndex1 from '@/utils/templateJson/index/style1/1.js';
  18. //首页 风格2
  19. import randomIndex2 from '@/utils/templateJson/index/style1/2.js';
  20. //2.引入随机模板json后期删除 end---------------------------------------->
  21. const state = {
  22. //0.全局配置 start------------------------------------------------------------>
  23. editWebsiteId: "",//网站id
  24. adKey: "",//网站缩写
  25. editWebsiteClass: "",//网站风格
  26. stepStatus: true,//是否显示现在进行到哪一步:true=显示 false=不显示
  27. componentMenuStatus: 1,//组件菜单是否显示 1=显示 0=隐藏
  28. //0.全局配置 end------------------------------------------------------------>
  29. //1.画布数据 start------------------------------------------------------------>
  30. pageStatus: 1,//当前编辑哪个页面 1=首页 2=分类页 3=列表页 4=详情页 5=搜索页 6=底部列表页 7=底部详情页
  31. menuType: 1, //当前菜单显示板块还是组件 1=板块 2=组件
  32. previewStatus: false,//是否预览
  33. gridKey: 0,//使用gridKey来强制更新视图
  34. loading: false,//是否显示加载中
  35. showPage: { //哪些页面可以被展示
  36. index: true,
  37. class: true,
  38. list: true,
  39. article: true,
  40. search: true,
  41. aloneList: true,
  42. aloneArticle: true
  43. },
  44. pageData: { //自助建站拖拽板块的数据,注意,这里并不是提交到后台的数据
  45. index: [],//首页
  46. class: [],//分类页
  47. list: [],//列表页
  48. article: [],//详情页
  49. search: [],//搜索页
  50. aloneList: [],//自定义列表页
  51. aloneArticle: [],//自定义详情页
  52. },
  53. editSectorY: 0,//当前组件在画布中的位置
  54. mouseXY: {//鼠标位置
  55. "x": 12,
  56. "y": 33
  57. },
  58. DragPos: {//创建的占位符大小
  59. "x": null,
  60. "y": null,
  61. "w": 12,
  62. "h": 2,
  63. "i": null
  64. },
  65. gridlayoutObj: null,//画布gridlayout对象
  66. //1.画布数据 end------------------------------------------------------------>
  67. //2.全局模板数据 start------------------------------------------------------------>
  68. webSiteInfo: "",//网站信息
  69. webSiteMenu: "",//网站包含的导航池
  70. webSiteFooterInfo: "",//网站底部信息
  71. area: {//地区
  72. economize: [],//省区
  73. market: [],//市区
  74. county: []//县区
  75. },
  76. departmentList: [],//职能部门
  77. //2.全局模板数据 end------------------------------------------------------------>
  78. //3.构造的模板json数据 start------------------------------------------------------------>
  79. pageDataStatus:{//页面数据完整度
  80. index:{
  81. sector:0,//当前板块数量,为0表示一个都没有
  82. cid:0,//缺少的导航池id 为0表示没有缺少
  83. ad:0,//缺少的广告名称,为0表示没有缺少
  84. adPrice:0//缺少的广告价格,为0表示没有缺少
  85. },
  86. class:{
  87. sector:0,
  88. cid:0,
  89. ad:0,
  90. adPrice:0
  91. },
  92. list:{
  93. sector:0,
  94. cid:0,
  95. ad:0,
  96. adPrice:0
  97. },
  98. article:{
  99. sector:0,
  100. cid:0,
  101. ad:0,
  102. adPrice:0
  103. },
  104. search:{
  105. sector:0,
  106. cid:0,
  107. ad:0,
  108. adPrice:0
  109. },
  110. aloneList:{
  111. sector:0,
  112. cid:0,
  113. ad:0,
  114. adPrice:0
  115. },
  116. aloneArticle:{
  117. sector:0,
  118. cid:0,
  119. ad:0,
  120. adPrice:0
  121. }
  122. },
  123. ad_id: "",//生成储存的广告标识
  124. pageName:{ //页面名称
  125. 1:"index",
  126. 2:"class",
  127. 3:"list",
  128. 4:"article",
  129. 5:"search",
  130. 6:"aloneList",
  131. 7:"aloneArticle"
  132. },
  133. pageRoute:{ //数据路径
  134. 1:"state.pageData.index",
  135. 2:"state.pageData.class",
  136. 3:"state.pageData.list",
  137. 4:"state.pageData.article",
  138. 5:"state.pageData.search",
  139. 6:"state.pageData.aloneList",
  140. 7:"state.pageData.aloneArticle"
  141. },
  142. editWindowStatus: false,//编辑组件弹出框是否显示
  143. editComponentWindowStatus: false,//选择组件样式弹出框是否显示
  144. editWebsiteTemplateJsonWindow: false,//当前准备提交的数据 后期删除
  145. editWindowTitle: "",//编辑弹出框标题
  146. editSectorId: 0,//当前正在编辑的板块id
  147. editDataSort: 0,//当前正在编辑的数据位置
  148. editComponentSort: 0,//当前正在编辑的组件id
  149. editComponentType: 0,//当前正在编辑的组件类型
  150. editComponentSize: 0,//当前组件文字新闻数量
  151. editComponentSizeImg:0,//当前组件图片新闻数量
  152. editComponentStyle: 0,//当前编辑的组件样式
  153. editWebsiteCategory: [],//当前网站全部关联导航
  154. webSiteData: {
  155. //1.base网站基本信息
  156. base: {
  157. websiteId: "",//网站id
  158. },
  159. //2.style信息
  160. style: {
  161. styleId: "",//风格id
  162. },
  163. //3.板块信息 header,menu,footer 是页面自带的无需构建
  164. template: {
  165. //index = 首页 class=分类页 list=列表页 article=详情页 search=搜索页 aloneList=自定义列表页 aloneArticle=自定义详情页
  166. index: [],
  167. class: [],//分类页
  168. list: [],//列表页
  169. article: [],//详情页
  170. search: [],//搜索页
  171. aloneList: [],//自定义列表页
  172. aloneArticle: []//自定义详情页
  173. },
  174. //4.广告位
  175. ad: {
  176. top:{
  177. "width": 830,//宽度
  178. "height": 110,//高度
  179. "name": "",//广告名称
  180. "price": 0,//价格
  181. "introduce":"",//介绍
  182. "website_id": "",//网站id
  183. "thumb": "https://img.bjzxtw.org.cn/pre/image/png/20250530/1748588901281358.png",//示例图 - 默认值
  184. "typeid": 2,//广告类型 - 2 图片
  185. "ad_tag": ""//广告标识 - 网站标识 + 页面名称 + sort
  186. },
  187. index: [],
  188. class: [],
  189. list: [],
  190. article: [],
  191. search: [],
  192. aloneList: [],
  193. aloneArticle: []
  194. }
  195. },
  196. canSubmit: false,//当前数据是否可以被提交
  197. //3.构造的模板json数据 end------------------------------------------------------------>
  198. //4.组件回显数据 start------------------------------------------------------------>
  199. componentViewData: {
  200. pid_arr: [],//导航池
  201. pageSize: "",//展示文字新闻条数
  202. pageSizeImg: "",//展示图片新闻条数
  203. adName: "",//广告名称
  204. titleName: "",//标题名称
  205. windowKey:0,//级联选择器的key
  206. price:0//广告价格
  207. }
  208. //4.组件回显数据 start------------------------------------------------------------>
  209. }
  210. const mutations = {
  211. //0.全局配置 start------------------------------------------------------------>
  212. //设置网站的id
  213. setEditWebsiteId(state, id) {
  214. state.editWebsiteId = id;
  215. },
  216. //设置网站缩写
  217. setAdKey(state, key) {
  218. state.adKey = key;
  219. },
  220. //设置网站的风格
  221. setClassNumber(state, id) {
  222. state.editWebsiteClass = id;
  223. },
  224. //展示步骤
  225. showStepStatus(state) {
  226. state.stepStatus = true;
  227. },
  228. //隐藏步骤
  229. hiddenStepStatus(state) {
  230. state.stepStatus = false;
  231. },
  232. //设置步骤
  233. setPageStatus(state, num) {
  234. state.pageStatus = num;
  235. },
  236. //设置预览状态
  237. setPreviewStatus(state) {
  238. state.previewStatus = !state.previewStatus;
  239. },
  240. //打开编辑组件弹出框
  241. setEditWindowStatus(state, data) {
  242. state.editWindowStatus = true;
  243. state.editSectorId = data.id;
  244. state.editSectorY = data.y;
  245. state.editDataSort = data.dataSort;
  246. state.editComponentSort = data.sort;
  247. state.editComponentType = data.type;
  248. state.editComponentSize = data.size;
  249. state.editComponentSizeImg = data.sizeImg;
  250. },
  251. //更新编辑窗口中的数据
  252. updateWindowData(state) {
  253. state.componentViewData.windowKey++;
  254. },
  255. //关闭编辑组件弹出框
  256. closeEditWindowStatus(state) {
  257. state.editWindowStatus = false;
  258. },
  259. //打开选择组件样式弹出框
  260. setComponentStyleStatus(state, data) {
  261. state.editComponentWindowStatus = true;
  262. state.editSectorId = data.id;
  263. state.editDataSort = data.dataSort;
  264. state.editComponentSort = data.sort;
  265. state.editComponentType = data.type;
  266. state.editComponentStyle = data.style;
  267. },
  268. //关闭选择组件样式弹出框
  269. closeComponentStyleStatus(state) {
  270. state.editComponentWindowStatus = false;
  271. },
  272. //关闭提交数据弹出框
  273. closeEditWebsiteTemplateJsonWindow(state) {
  274. state.editWebsiteTemplateJsonWindow = false;
  275. },
  276. //选择组件样式
  277. selectComponentStyleNumber(state, data) {
  278. state.editComponentStyle = data;
  279. },
  280. //设置组件回显数据
  281. setComponentViewData(state, data) {
  282. //获取当前页面名称
  283. const currentPageName = state.pageName[state.pageStatus];
  284. //如果页面名称不存在,直接返回
  285. if (!currentPageName) {return;}
  286. //获取当前页面的数据
  287. const currentPageData = state.pageData[currentPageName];
  288. //找到要修改的板块
  289. const targetModuleIndex = currentPageData.findIndex(module => module.i === data.id);
  290. //如果找不到目标模块,直接返回
  291. if (targetModuleIndex === -1) {return;}
  292. //获取目标模块
  293. const targetModule = currentPageData[targetModuleIndex];
  294. //获取目标模块的组件类型
  295. //判断组件类型 1=新闻 2=广告
  296. if (state.editComponentType === 1) {
  297. // 新闻组件:设置导航id
  298. if (targetModule.content.componentList && targetModule.content.componentList[data.sort]) {
  299. const componentData = targetModule.content.componentList[data.sort].componentData;
  300. state.componentViewData.pid_arr = componentData.category_arr;
  301. state.componentViewData.pageSize = state.editComponentSize;
  302. state.componentViewData.pageSizeImg = state.editComponentSizeImg;
  303. }
  304. } else if (state.editComponentType === 2) {
  305. // 广告组件:设置广告名称和价格
  306. if (targetModule.content.ad) {
  307. state.componentViewData.adName = targetModule.content.ad.name;
  308. state.componentViewData.price = targetModule.content.ad.price;
  309. }
  310. }
  311. },
  312. //清空广告位
  313. clearAd(state) {
  314. state.webSiteData.ad.index = [];
  315. state.webSiteData.ad.class = [];
  316. state.webSiteData.ad.list = [];
  317. state.webSiteData.ad.article = [];
  318. state.webSiteData.ad.search = [];
  319. state.webSiteData.ad.aloneList = [];
  320. state.webSiteData.ad.aloneArticle = [];
  321. },
  322. //设置组件菜单是否显示
  323. setComponentMenuStatus(state, data) {
  324. state.componentMenuStatus = data;
  325. },
  326. //0.全局配置 start------------------------------------------------------------>
  327. //1.配置模块 start------------------------------------------------------------>
  328. //获得gridlayout对象
  329. setGridlayoutObj(state, data) {
  330. state.gridlayoutObj = data;
  331. },
  332. //添加板块 - 此代码无需优化,每个页面的规则都不一样
  333. addModule(state, data) {
  334. //pageStatus==1 首页 index
  335. if (state.pageStatus == 1) {
  336. if (state.pageData.index.length >= 10) {
  337. Message.error('最多只能添加10个通栏!');
  338. return;
  339. } else {
  340. this.commit('template/pushModule', data);
  341. }
  342. }
  343. //pageStatus==2 分类页 class
  344. if (state.pageStatus == 2) {
  345. if (state.pageData.class.length >= 10) {
  346. Message.error('最多只能添加10个通栏!');
  347. return;
  348. } else {
  349. this.commit('template/pushModule', data);
  350. }
  351. }
  352. //pageStatus==3 列表页 list
  353. if (state.pageStatus == 3) {
  354. if (state.pageData.list.length >= 10) {
  355. Message.error('最多只能添加10个通栏!');
  356. return;
  357. } else {
  358. this.commit('template/pushModule', data);
  359. }
  360. }
  361. //pageStatus==4 详情页 article
  362. if (state.pageStatus == 4) {
  363. if (state.pageData.article.length >= 10) {
  364. Message.error('最多只能添加10个通栏!');
  365. return;
  366. } else {
  367. this.commit('template/pushModule', data);
  368. }
  369. }
  370. //pageStatus==5 搜索页 search
  371. if (state.pageStatus == 5) {
  372. if (state.pageData.search.length >= 10) {
  373. Message.error('最多只能添加10个通栏!');
  374. return;
  375. } else {
  376. this.commit('template/pushModule', data);
  377. }
  378. }
  379. //pageStatus==6 自定义列表页 aloneList
  380. if (state.pageStatus == 6) {
  381. if (state.pageData.aloneList.length >= 10) {
  382. Message.error('最多只能添加10个通栏!');
  383. return;
  384. } else {
  385. this.commit('template/pushModule', data);
  386. }
  387. }
  388. //pageStatus==7 自定义详情页 aloneArticle
  389. if (state.pageStatus == 7) {
  390. if (state.pageData.aloneArticle.length >= 10) {
  391. Message.error('最多只能添加10个通栏!');
  392. return;
  393. } else {
  394. this.commit('template/pushModule', data);
  395. }
  396. }
  397. },
  398. //该数据可以添加到画布
  399. pushModule(state, data) {
  400. //获取当前页面名称
  401. const currentPageName = state.pageName[state.pageStatus];
  402. if (!currentPageName) {
  403. console.error('无效的页面状态:', state.pageStatus);
  404. return;
  405. }
  406. //获取当前页面数据
  407. const currentPageData = state.pageData[currentPageName];
  408. if (!currentPageData) {
  409. console.error('未找到页面数据:', currentPageName);
  410. return;
  411. }
  412. console.log(data.jsonData);
  413. console.log(`通过${data.source === 'click' ? '点击' : '拖拽'}添加一个板块`);
  414. //通过时间戳生成唯一id
  415. const currentTimestamp = Date.now();
  416. const moduleId = currentTimestamp;
  417. //计算当前布局的最大 y 值
  418. const maxY = Math.max(...currentPageData.map(item => item.y), 0);
  419. //设置数据在构建json中的位置
  420. const dataSort = currentPageData.length;
  421. //根据source类型设置y坐标
  422. const yPosition = data.source === 'click' ? maxY + 1 : data.y;
  423. // 创建新模块
  424. const newModule = {
  425. i: moduleId,
  426. x: 0,
  427. y: yPosition,
  428. w: 12,
  429. h: data.h,
  430. type: data.type,
  431. content: data.jsonData,
  432. dataSort: dataSort,
  433. };
  434. //添加模块到当前页面数据
  435. currentPageData.push(newModule);
  436. console.log(`当前添加模块的dataSort为:${dataSort}`);
  437. console.log('当前的页面构建数据:', currentPageData);
  438. //拖拽特殊处理
  439. if (data.source === 'drag') {
  440. // 调用gridlayout的拖拽结束事件
  441. state.gridlayoutObj.dragEvent('dragend', data.i, data.x, data.y, 1, 1);
  442. // 尝试显示占位符
  443. try {
  444. const targetIndex = currentPageData.length;
  445. if (state.gridlayoutObj.$children &&
  446. state.gridlayoutObj.$children[targetIndex] &&
  447. state.gridlayoutObj.$children[targetIndex].$refs &&
  448. state.gridlayoutObj.$children[targetIndex].$refs.item) {
  449. state.gridlayoutObj.$children[targetIndex].$refs.item.style.display = "block";
  450. }
  451. } catch (error) {
  452. console.log("没有找到占位符:", error);
  453. }
  454. }
  455. },
  456. //删除板块
  457. deleteModule(state, data) {
  458. //data.i = id
  459. //data.dataSort = dataSort
  460. try {
  461. // 获取当前页面名称
  462. const currentPageName = state.pageName[state.pageStatus];
  463. if (!currentPageName) {
  464. Message.warning('无效的页面状态!');
  465. return;
  466. }
  467. // 获取当前页面的数据数组
  468. const currentPageData = state.pageData[currentPageName];
  469. if (!currentPageData) {
  470. Message.warning('未找到页面数据!');
  471. return;
  472. }
  473. //找到要删除的模块
  474. const indexToRemove = currentPageData.findIndex(item => item.i === data.i);
  475. if (indexToRemove === -1) {
  476. Message.warning('未找到要删除的模块!');
  477. return;
  478. }
  479. //创建新的数组,不包含要删除的模块
  480. const newModules = currentPageData.filter(item => item.i !== data.i);
  481. //重新计算所有模块的 dataSort
  482. newModules.forEach((module, index) => {
  483. module.dataSort = index;
  484. });
  485. //使用 Vue.set 更新整个数组
  486. Vue.set(state.pageData, currentPageName, newModules);
  487. //清理 $children 数组
  488. if (state.gridlayoutObj && state.gridlayoutObj.$children) {
  489. //清空$children 数组
  490. state.gridlayoutObj.$children.length = 0;
  491. //强制重新渲染
  492. state.gridKey += 1;
  493. //等待 DOM 更新后重新设置gridlayout对象
  494. Vue.nextTick(() => {
  495. //通知父组件重新设置gridlayout对象
  496. //这里可以通过事件总线或其他方式通知
  497. if (state.gridlayoutObj && state.gridlayoutObj.$parent) {
  498. //尝试重新获取gridlayout对象
  499. const newGridLayout = state.gridlayoutObj.$parent.$refs.gridlayout;
  500. if (newGridLayout) {
  501. state.gridlayoutObj = newGridLayout;
  502. }
  503. }
  504. });
  505. }
  506. Message.success('模块已删除!');
  507. console.log(`模块已删除,当前${currentPageName}页面的构建数据为:`, newModules);
  508. } catch (error) {
  509. console.error('删除模块时发生错误:', error);
  510. Message.error('删除模块时发生错误,请重试!');
  511. }
  512. },
  513. //设置组件样式
  514. setComponentStyleNumber(state, data) {
  515. const id = state.editSectorId;
  516. const dataSort = state.editDataSort;
  517. const sort = state.editComponentSort;
  518. const num = state.editComponentStyle;
  519. console.log(id, dataSort, sort, num);
  520. //获取当前页面名称
  521. const currentPageName = state.pageName[state.pageStatus];
  522. if (!currentPageName) {
  523. console.error('无效的页面状态:', state.pageStatus);
  524. return;
  525. }
  526. //获取当前页面的数据数组
  527. const currentPageData = state.pageData[currentPageName];
  528. if (!currentPageData || !currentPageData[dataSort]) {
  529. console.error('未找到页面数据:', currentPageName, dataSort);
  530. return;
  531. }
  532. //获取当前模块数据并进行深拷贝
  533. const module = JSON.parse(JSON.stringify(currentPageData[dataSort]));
  534. //确保修改属性时 Vue 能监控到变化
  535. Vue.set(module.content.componentList, sort, {
  536. ...module.content.componentList[sort],
  537. component_style: num
  538. });
  539. //使用Vue.set来强制视图更新
  540. Vue.set(currentPageData, dataSort, module);
  541. console.log(`当前${currentPageName}页面的板块数据为:`);
  542. console.log(currentPageData);
  543. },
  544. //保存全局广告的数据
  545. saveAdData(state, data) {
  546. state.webSiteData.ad.top.name = data.data.name;
  547. state.webSiteData.ad.top.introduce = data.data.introduce;
  548. state.webSiteData.ad.top.price = data.data.price;
  549. },
  550. //保存组件设置的数据
  551. saveComponentData(state, data) {
  552. //传入的板块id
  553. console.log("当前编辑板块:" + data.id);
  554. //获取当前页面名称
  555. const currentPageName = state.pageName[state.pageStatus];
  556. if (!currentPageName) {
  557. console.error('无效的页面状态:', state.pageStatus);
  558. return;
  559. }
  560. //获取当前页面的数据数组
  561. const currentPageData = state.pageData[currentPageName];
  562. if (!currentPageData) {
  563. console.error('未找到页面数据:', currentPageName);
  564. return;
  565. }
  566. //找到要修改的板块
  567. const targetModuleIndex = currentPageData.findIndex(module => module.i === data.id);
  568. if (targetModuleIndex === -1) {
  569. console.error('未找到要修改的模块:', data.id);
  570. return;
  571. }
  572. console.log("要修改的模块索引:", targetModuleIndex);
  573. console.log("组件排序:", data.sort);
  574. //组件类型 1=新闻 2=广告
  575. //注意:Vue有一个特性,当修改复杂对象内部数组时,可能无法检测到变化
  576. //解决办法是通过Vue.set方法将整个对象进行深拷贝,然后修改完再替换回去
  577. // 获取当前模块数据并进行深拷贝
  578. let module = JSON.parse(JSON.stringify(currentPageData[targetModuleIndex]));
  579. if (state.editComponentType === 1) {
  580. //1=新闻组件
  581. const componentData = module.content.componentList[data.sort].componentData;
  582. componentData.category_id = data.data.pid_id; // 设置 category_id
  583. componentData.category_arr = data.data.pid_arr; // 设置 category_arr 用于显示
  584. componentData.name = data.data.name; // 设置导航池名字
  585. componentData.textSize = state.editComponentSize; // 设置文字新闻数量
  586. componentData.imgSize = state.editComponentSizeImg; // 设置图片新闻数量
  587. } else if (state.editComponentType === 2) {
  588. //2=广告组件
  589. module.content.ad.name = data.data.adName;
  590. module.content.ad.introduce = data.data.adName;
  591. module.content.ad.price = data.data.price;
  592. //设置用于回显的广告名,否则会导致回显的广告名和实际的广告名不一致
  593. //因为广告名没有默认值,这会导致watch监听不到,所以这里需要手动设置
  594. state.componentViewData.adName = data.data.adName;
  595. }
  596. // 使用Vue.set来强制视图更新
  597. Vue.set(currentPageData, targetModuleIndex, module);
  598. console.log(`当前${currentPageName}页面的板块数据为:`);
  599. console.log(currentPageData);
  600. },
  601. //从外部拖拽板块
  602. drag(state, data) {
  603. //获取当前页面名称
  604. const currentPageName = state.pageName[state.pageStatus];
  605. if (!currentPageName) {
  606. console.error('无效的页面状态:', state.pageStatus);
  607. return;
  608. }
  609. //获取当前页面的数据
  610. const currentPageData = state.pageData[currentPageName];
  611. if (!currentPageData) {
  612. console.error('未找到页面数据:', currentPageName);
  613. return;
  614. }
  615. //获取画布尺寸并判断鼠标是否在画布内
  616. let parentRect = document.getElementById('content').getBoundingClientRect();
  617. let mouseInGrid = false;
  618. if (((state.mouseXY.x > parentRect.left) && (state.mouseXY.x < parentRect.right)) &&
  619. ((state.mouseXY.y > parentRect.top) && (state.mouseXY.y < parentRect.bottom))) {
  620. mouseInGrid = true;
  621. }
  622. //如果没有占位符就创建一个
  623. if (mouseInGrid === true && (currentPageData.findIndex(item => item.i === 'drop')) === -1) {
  624. currentPageData.push({
  625. x: (currentPageData.length * 2) % (this.colNum || 12),
  626. y: currentPageData.length + (this.colNum || 12),
  627. w: 12,
  628. h: 2,
  629. i: 'drop',
  630. });
  631. }
  632. //如果已经存在占位符
  633. let index = currentPageData.findIndex(item => item.i === 'drop');
  634. if (index !== -1) {
  635. try {
  636. console.log(`当前 ${currentPageName} 页面数据长度:`, currentPageData.length);
  637. console.log('当前 gridlayoutObj.$children.length:', state.gridlayoutObj.$children.length);
  638. //计算目标索引
  639. const targetIndex = currentPageData.length;
  640. console.log('尝试隐藏的索引:', targetIndex);
  641. //安全访问并隐藏占位符
  642. if (state.gridlayoutObj.$children &&
  643. targetIndex >= 0 &&
  644. targetIndex < state.gridlayoutObj.$children.length &&
  645. state.gridlayoutObj.$children[targetIndex] &&
  646. state.gridlayoutObj.$children[targetIndex].$refs &&
  647. state.gridlayoutObj.$children[targetIndex].$refs.item) {
  648. //调试信息:确认要隐藏的是drop元素
  649. const targetChild = state.gridlayoutObj.$children[targetIndex];
  650. console.log('要隐藏的元素ID:', targetChild.i || (targetChild.$props && targetChild.$props.i));
  651. state.gridlayoutObj.$children[targetIndex].$refs.item.style.display = "none";
  652. console.log('成功隐藏占位符,索引:', targetIndex);
  653. } else {
  654. console.log('无法安全访问占位符,索引:', targetIndex);
  655. }
  656. } catch (error) {
  657. console.log('处理占位符时出错:', error);
  658. }
  659. //拖拽逻辑处理
  660. if (state.gridlayoutObj.$children[index]) {
  661. let el = state.gridlayoutObj.$children[index];
  662. el.dragging = {
  663. "top": state.mouseXY.y - parentRect.top,
  664. "left": state.mouseXY.x - parentRect.left
  665. };
  666. let new_pos = el.calcXY(state.mouseXY.y - parentRect.top, state.mouseXY.x - parentRect.left);
  667. if (mouseInGrid === true) {
  668. state.gridlayoutObj.dragEvent('dragstart', 'drop', new_pos.x, new_pos.y, 2, 12);
  669. state.DragPos.i = String(index);
  670. state.DragPos.x = currentPageData[index].x;
  671. state.DragPos.y = currentPageData[index].y;
  672. }
  673. if (mouseInGrid === false) {
  674. state.gridlayoutObj.dragEvent('dragend', 'drop', new_pos.x, new_pos.y, 2, 12);
  675. // 使用 Vue.set 确保响应式更新
  676. Vue.set(state.pageData, currentPageName, currentPageData.filter(obj => obj.i !== 'drop'));
  677. }
  678. } else {
  679. console.log('无法找到拖拽元素,索引:', index);
  680. }
  681. }
  682. },
  683. //拖拽结束 定位落点
  684. dragend(state, data) {
  685. //获取当前页面名称
  686. const currentPageName = state.pageName[state.pageStatus];
  687. if (!currentPageName) {
  688. console.error('无效的页面状态:', state.pageStatus);
  689. return;
  690. }
  691. //获取画布尺寸
  692. let parentRect = document.getElementById('content').getBoundingClientRect();
  693. //判断是否在画布内
  694. let mouseInGrid = false;
  695. if (((state.mouseXY.x > parentRect.left) && (state.mouseXY.x < parentRect.right)) &&
  696. ((state.mouseXY.y > parentRect.top) && (state.mouseXY.y < parentRect.bottom))) {
  697. mouseInGrid = true;
  698. }
  699. //如果在画布内,开始创建元素
  700. if (mouseInGrid === true) {
  701. //alert(`Dropped element props:\n${JSON.stringify(state.DragPos, ['x', 'y', 'w', 'h'], 2)}`);
  702. state.gridlayoutObj.dragEvent('dragend', 'drop', state.DragPos.x, state.DragPos.y, 1, 1);
  703. //动态过滤当前页面的 drop 元素
  704. state.pageData[currentPageName] = state.pageData[currentPageName].filter(obj => obj.i !== 'drop');
  705. let sendData = {
  706. source: "drag",//添加时判断此模块来自外部拖拽,而不是点击
  707. type: data.type,
  708. h: data.h,
  709. jsonData: data.jsonData,
  710. x: state.DragPos.x,
  711. y: state.DragPos.y,
  712. w: 12,
  713. }
  714. //调用 addModule 来添加模块
  715. this.commit('template/addModule', sendData);
  716. }
  717. },
  718. //格式化模板信息
  719. formatTemplateInfo(state, data) {
  720. //1.处理广告位
  721. //先把广告位的数据清空,再重新获取
  722. //this.commit('template/clearAd');
  723. // 深拷贝数据,避免直接修改原数据
  724. let clonedData = JSON.parse(JSON.stringify(data));
  725. // 按照 clonedData.data.y 的大小排序
  726. clonedData.data.sort((a, b) => a.y - b.y);
  727. //获取当前页面名称
  728. let getPageName = () =>{
  729. if(state.pageStatus==1){return "index";}
  730. if(state.pageStatus==2){return "category";}
  731. if(state.pageStatus==3){return "list";}
  732. if(state.pageStatus==4){return "detail";}
  733. if(state.pageStatus==5){return "search";}
  734. if(state.pageStatus==6){return "page";}
  735. if(state.pageStatus==7){return "page";}
  736. }
  737. // 取出每个通栏中的广告,并保存到state.webSiteData.ad中
  738. for (let index in clonedData.data) {
  739. if(clonedData.data[index].content.ad){
  740. let ad_index = Number(index)+1;
  741. let ad_tag = `${state.adKey}_${data.type}_${ad_index}`;
  742. clonedData.data[index].content.ad.website_id = state.editWebsiteId;
  743. clonedData.data[index].content.ad.ad_tag = ad_tag;
  744. state.webSiteData.ad[data.type].push(clonedData.data[index].content.ad);
  745. }
  746. }
  747. //设置全局的广告位名称
  748. state.webSiteData.ad.top.website_id = state.editWebsiteId;
  749. state.webSiteData.ad.top.ad_tag = `${state.adKey}_top`
  750. let websiteData = [];
  751. // 获取板块的 sort
  752. for (let index = 0; index < clonedData.data.length; index++) {
  753. console.log(clonedData.data[index].content);
  754. // 使用 Vue.set 来确保属性变更能被 Vue 追踪
  755. Vue.set(clonedData.data[index].content, 'sort', Number(index) + 1);
  756. websiteData.push(clonedData.data[index].content);
  757. }
  758. // 保存到对应的页面 json 中
  759. if (data.type == "index") {state.webSiteData.template.index = websiteData;}
  760. if (data.type == "class") {state.webSiteData.template.class = websiteData;}
  761. if (data.type == "list") {state.webSiteData.template.list = websiteData;}
  762. if (data.type == "article") {state.webSiteData.template.article = websiteData;}
  763. if (data.type == "search") {state.webSiteData.template.search = websiteData;}
  764. if (data.type == "aloneList") {state.webSiteData.template.aloneList = websiteData;}
  765. if (data.type == "aloneArticle") {state.webSiteData.template.aloneArticle = websiteData;}
  766. },
  767. //保存模板
  768. saveTemplate(state) {
  769. //1.保存网站id和模板风格id
  770. state.webSiteData.base.websiteId = state.editWebsiteId;
  771. state.webSiteData.style.styleId = state.editWebsiteClass;
  772. //2.格式化数据
  773. //2.1 清理广告位数据
  774. this.commit('template/clearAd');
  775. //2.2 格式化index页面数据
  776. this.commit('template/formatTemplateInfo', { data: state.pageData.index, type: "index" });
  777. //2.2 格式化class页面数据
  778. this.commit('template/formatTemplateInfo', { data: state.pageData.class, type: "class" });
  779. //2.3 格式化list的信息
  780. this.commit('template/formatTemplateInfo', { data: state.pageData.list, type: "list" });
  781. //2.4 格式化article的信息
  782. this.commit('template/formatTemplateInfo', { data: state.pageData.article, type: "article" });
  783. //2.5 格式化search的信息
  784. this.commit('template/formatTemplateInfo', { data: state.pageData.search, type: "search" });
  785. //2.6 格式化aloneList的信息
  786. this.commit('template/formatTemplateInfo', { data: state.pageData.aloneList, type: "aloneList" });
  787. //2.7 格式化aloneArticle的信息
  788. this.commit('template/formatTemplateInfo', { data: state.pageData.aloneArticle, type: "aloneArticle" });
  789. //3.展示构造json 后期移除
  790. state.editWebsiteTemplateJsonWindow = true;
  791. //4.检测模板数据完整度,如果不完整阻止用户保存
  792. this.commit('template/pageCheck', {data: state.pageData});
  793. },
  794. //检测模板完整度
  795. pageCheck(state, data) {
  796. // 遍历所有页面进行检测
  797. Object.values(state.pageName).forEach(pageName => {
  798. // 获得当前页面板块数量
  799. state.pageDataStatus[pageName].sector = data.data[pageName].length;
  800. // 获得当前页面没有设置导航池的板块数量 - 只检查首页
  801. let noCid = 0;
  802. if (pageName === 'index') {
  803. for(let index in data.data[pageName]){
  804. for(let i in data.data[pageName][index].content.componentList){
  805. if(data.data[pageName][index].content.componentList[i].componentData.category_id != undefined){
  806. if(data.data[pageName][index].content.componentList[i].componentData.category_id == ""){
  807. noCid++;
  808. }
  809. }
  810. }
  811. }
  812. }
  813. state.pageDataStatus[pageName].cid = noCid;
  814. // 获得当前页面没有设置广告名称的组件数量
  815. let noAd = 0;
  816. for(let index in data.data[pageName]){
  817. if(data.data[pageName][index].content.ad != undefined){
  818. if(data.data[pageName][index].content.ad.name == ""){
  819. noAd++;
  820. }
  821. }
  822. }
  823. state.pageDataStatus[pageName].ad = noAd;
  824. // 获得当前页面没有设置广告价格的组件数量
  825. let noAdPrice = 0;
  826. for(let index in data.data[pageName]){
  827. if(data.data[pageName][index].content.ad != undefined){
  828. if(data.data[pageName][index].content.ad.price == 0){
  829. noAdPrice++;
  830. }
  831. }
  832. }
  833. state.pageDataStatus[pageName].adPrice = noAdPrice;
  834. });
  835. // 全局广告特殊处理(只处理一次) 全局广告是算到首页里面的
  836. if(state.webSiteData.ad.top.name == ""){
  837. state.pageDataStatus.index.ad++;
  838. }
  839. if(state.webSiteData.ad.top.price == 0){
  840. state.pageDataStatus.index.adPrice++;
  841. }
  842. },
  843. //清理画布内容
  844. clearWebsiteTemplate(state,data){
  845. //每次进入的时候先清理再回显
  846. //清理state.webSiteData
  847. Vue.set(state.webSiteData, 'template', {
  848. index: [],
  849. class: [],
  850. list: [],
  851. article: [],
  852. search: [],
  853. aloneList: [],
  854. aloneArticle: []
  855. });
  856. Vue.set(state, 'pageData', {
  857. index: [],
  858. class: [],
  859. list: [],
  860. article: [],
  861. search: [],
  862. aloneList: [],
  863. aloneArticle: []
  864. });
  865. Vue.set(state.webSiteData.ad, 'top', {
  866. "width": 830,//宽度
  867. "height": 110,//高度
  868. "name": "",//广告名称
  869. "price": 0,//价格
  870. "introduce":"",//介绍
  871. "website_id": "",//网站id
  872. "thumb": "https://img.bjzxtw.org.cn/pre/image/png/20250530/1748588901281358.png",//示例图 - 默认值
  873. "typeid": 2,//广告类型 - 2 图片
  874. "ad_tag": ""//广告标识 - 网站标识 + 页面名称 + sort
  875. });
  876. Vue.set(state, 'pageStatus', 1);
  877. },
  878. //回显模板内容
  879. setWebsiteTemplate(state, data) {
  880. if(data==null){
  881. this.commit('template/clearWebsiteTemplate');
  882. console.log("第一次添加模板,无需回显!")
  883. }else{
  884. this.commit('template/clearWebsiteTemplate');
  885. console.log("编辑模板,开始回显模板内容!")
  886. console.log(data)
  887. state.webSiteData.ad.top = data.topAd;
  888. state.pageData = data.template;
  889. }
  890. },
  891. //随机生成模板
  892. randomTemplate(state) {
  893. state.loading = true;
  894. const randomIndex = Math.floor(Math.random() * 2);
  895. console.log(`随机生成的数字是: ${randomIndex}`);
  896. // pageStatus == 1 首页
  897. if (state.pageStatus == 1) {
  898. // 先清空里面的内容
  899. Vue.set(state.pageData, 'index', []);
  900. // 深拷贝 randomIndex1 和 randomIndex2
  901. const newData1 = JSON.parse(JSON.stringify(randomIndex1));
  902. const newData2 = JSON.parse(JSON.stringify(randomIndex2));
  903. if (randomIndex == 0) {
  904. Vue.set(state.pageData, 'index', newData1);
  905. }
  906. if (randomIndex == 1) {
  907. Vue.set(state.pageData, 'index', newData2);
  908. }
  909. state.loading = false;
  910. }
  911. // pageStatus == 2 分类页
  912. if (state.pageStatus == 2) { }
  913. // pageStatus == 3 列表页
  914. if (state.pageStatus == 3) { }
  915. // pageStatus == 4 详情页
  916. if (state.pageStatus == 4) { }
  917. // pageStatus == 5 搜索页
  918. if (state.pageStatus == 5) { }
  919. // pageStatus == 6 自定义列表页
  920. if (state.pageStatus == 6) { }
  921. // pageStatus == 7 自定义详情页
  922. if (state.pageStatus == 7) { }
  923. },
  924. //1.配置模块 end------------------------------------------------------------>
  925. //2.获取站点信息 start------------------------------------------------------------>
  926. //获取站点顶部详情
  927. setWebsiteInfo(state, data) {
  928. state.webSiteInfo = data;
  929. },
  930. setWebsiteFooterInfo(state, data) {
  931. state.webSiteFooterInfo = data;
  932. },
  933. //获取站点导航池
  934. setGetSiteCategory(state, data) {
  935. let allData = []
  936. for (let index in data) {
  937. //导航最多只显示24个,超出部分不显示
  938. if (index < 24) {
  939. allData.push(data[index])
  940. }
  941. }
  942. state.webSiteMenu = allData;
  943. },
  944. //设置地区
  945. setArea(state, data) {
  946. //都没有的时候返回的是省
  947. if (data.province == undefined) {
  948. state.area.economize = data;
  949. }
  950. //没有region的时候返回的是市
  951. if (data.province != undefined && data.city != undefined && data.region == undefined) {
  952. state.area.market = data.city;
  953. }
  954. //有region的时候返回的是县
  955. if (data.province != undefined && data.city != undefined && data.region != undefined) {
  956. state.area.county = data.region;
  957. }
  958. },
  959. //设置职能
  960. setDepartment(state, data) {
  961. for (let item of data) {
  962. let options = {
  963. value: item.id,
  964. label: item.name
  965. }
  966. state.departmentList.push(options)
  967. }
  968. console.log(state.departmentList)
  969. },
  970. //获取全部导航
  971. setWebsiteCategory(state, data) {
  972. let arrayData = []
  973. for (let item of data) {
  974. let options = {
  975. key: item.id,
  976. label: item.name,
  977. value: item.id
  978. }
  979. arrayData.push(options);
  980. }
  981. state.editWebsiteCategory = arrayData;
  982. },
  983. //2.获取站点信息 end------------------------------------------------------------>
  984. //3.提示信息 start------------------------------------------------------------>
  985. alertMessage(state, data) {
  986. Message({
  987. message: "配置阶段仅展示,无法真实调用该功能!",
  988. type: 'warning',
  989. duration: 0,
  990. showClose: true
  991. });
  992. }
  993. //3.提示信息 end------------------------------------------------------------>
  994. }
  995. const actions = {
  996. //1.显示画板组件数据 start------------------------------------------------------------>
  997. //1.1 获取网站基本信息
  998. getSiteInfo({ commit }, data) {
  999. return new Promise((resolve, reject) => {
  1000. getSiteInfo(data).then(response => {
  1001. commit('setWebsiteInfo', response.data);
  1002. resolve(response)
  1003. }).catch(error => {
  1004. reject(error)
  1005. })
  1006. })
  1007. },
  1008. //1.2 获取网站导航池
  1009. getSiteCategory({ commit }, data) {
  1010. return new Promise((resolve, reject) => {
  1011. getSiteCategory(data).then(response => {
  1012. commit('setGetSiteCategory', response.data);
  1013. resolve(response)
  1014. }).catch(error => {
  1015. reject(error)
  1016. })
  1017. })
  1018. },
  1019. //1.3 获取网站底部导航
  1020. getFooterCategoryList({ commit }, data) {
  1021. return new Promise((resolve, reject) => {
  1022. getFooterCategoryList(data).then(response => {
  1023. resolve(response)
  1024. }).catch(error => {
  1025. reject(error)
  1026. })
  1027. })
  1028. },
  1029. //1.4 获得页面类型
  1030. getWebPageType({ commit }, data) {
  1031. return new Promise((resolve, reject) => {
  1032. getWebPageType(data).then(response => {
  1033. resolve(response)
  1034. }).catch(error => {
  1035. reject(error)
  1036. })
  1037. })
  1038. },
  1039. //1.5 选择页面类型 - 是否添加搜索页
  1040. addWebPageType({ commit }, data) {
  1041. return new Promise((resolve, reject) => {
  1042. addWebPageType(data).then(response => {
  1043. resolve(response)
  1044. }).catch(error => {
  1045. reject(error)
  1046. })
  1047. })
  1048. },
  1049. //1.显示画板组件数据 end------------------------------------------------------------>
  1050. //2.构建网站json start------------------------------------------------------------>
  1051. //2.1 搜索网站
  1052. getWebsiteintel({ commit }, data) {
  1053. return new Promise((resolve, reject) => {
  1054. getWebsiteintel(data).then(response => {
  1055. resolve(response)
  1056. }).catch(error => {
  1057. reject(error)
  1058. })
  1059. })
  1060. },
  1061. //2.2 添加网站基本信息 如果只传入website_id,则验证是否已经关联导航池
  1062. checkWebsiteBuild({ commit }, data) {
  1063. return new Promise((resolve, reject) => {
  1064. checkWebsiteBuild(data).then(response => {
  1065. resolve(response)
  1066. }).catch(error => {
  1067. reject(error)
  1068. })
  1069. })
  1070. },
  1071. //2.3 获取网站基本信息
  1072. getAdminSiteInfo({ commit }, data) {
  1073. return new Promise((resolve, reject) => {
  1074. getAdminSiteInfo(data).then(response => {
  1075. commit('setWebsiteInfo', response.data);
  1076. commit('setAdKey', response.data.ad_key);
  1077. resolve(response)
  1078. }).catch(error => {
  1079. reject(error)
  1080. })
  1081. })
  1082. },
  1083. //2.4 修改网站基本信息
  1084. upWebsiteTemplateintel({ commit }, data) {
  1085. return new Promise((resolve, reject) => {
  1086. upWebsiteTemplateintel(data).then(response => {
  1087. resolve(response)
  1088. }).catch(error => {
  1089. reject(error)
  1090. })
  1091. })
  1092. },
  1093. //2.5 获取所有风格
  1094. getAllTemplateClass({ commit }, data) {
  1095. return new Promise((resolve, reject) => {
  1096. getAllTemplateClass(data).then(response => {
  1097. resolve(response)
  1098. }).catch(error => {
  1099. reject(error)
  1100. })
  1101. })
  1102. },
  1103. //2.6 搜索并获取所有网站风格
  1104. getWebsiteTemplateList({ commit }, data) {
  1105. return new Promise((resolve, reject) => {
  1106. getWebsiteTemplateList(data).then(response => {
  1107. resolve(response)
  1108. }).catch(error => {
  1109. reject(error)
  1110. })
  1111. })
  1112. },
  1113. //2.7 保存用户选择的风格
  1114. chooseWebsiteTemplate({ commit }, data) {
  1115. return new Promise((resolve, reject) => {
  1116. chooseWebsiteTemplate(data).then(response => {
  1117. resolve(response)
  1118. }).catch(error => {
  1119. reject(error)
  1120. })
  1121. })
  1122. },
  1123. //2.8 获取用户选择的风格
  1124. getWebsiteTemplateclassintel({ commit }, data) {
  1125. return new Promise((resolve, reject) => {
  1126. getWebsiteTemplateclassintel(data).then(response => {
  1127. resolve(response)
  1128. }).catch(error => {
  1129. reject(error)
  1130. })
  1131. })
  1132. },
  1133. //2.9 保存模板
  1134. saveWebsiteTemplate({ commit }, data) {
  1135. return new Promise((resolve, reject) => {
  1136. saveWebsiteTemplate(data).then(response => {
  1137. resolve(response)
  1138. }).catch(error => {
  1139. reject(error)
  1140. })
  1141. })
  1142. },
  1143. //2.10 获取模板配置
  1144. getWebsiteTemplateInfo({ commit }, data) {
  1145. return new Promise((resolve, reject) => {
  1146. getWebsiteTemplateInfo(data).then(response => {
  1147. resolve(response)
  1148. }).catch(error => {
  1149. reject(error)
  1150. })
  1151. })
  1152. },
  1153. //2.11 预览模板信息
  1154. getWebsiteTemplateData({ commit }, data) {
  1155. return new Promise((resolve, reject) => {
  1156. getWebsiteTemplateData(data).then(response => {
  1157. resolve(response)
  1158. }).catch(error => {
  1159. reject(error)
  1160. })
  1161. })
  1162. },
  1163. //2.12 获得网站底部信息
  1164. getAdminWebsiteFootAll({ commit }, data) {
  1165. return new Promise((resolve, reject) => {
  1166. getAdminWebsiteFootAll(data).then(response => {
  1167. commit('setWebsiteFooterInfo', response.data);
  1168. resolve(response)
  1169. }).catch(error => {
  1170. reject(error)
  1171. })
  1172. })
  1173. },
  1174. //2.13 批量创建广告位
  1175. addTwinAdPlace({ commit }, data) {
  1176. return new Promise((resolve, reject) => {
  1177. addTwinAdPlace(data).then(response => {
  1178. resolve(response)
  1179. }).catch(error => {
  1180. reject(error)
  1181. })
  1182. })
  1183. },
  1184. //2.14 验证该网站是否有未结束的订单
  1185. checkWebsiteEdit({ commit }, data) {
  1186. return new Promise((resolve, reject) => {
  1187. checkWebsiteEdit(data).then(response => {
  1188. resolve(response)
  1189. }).catch(error => {
  1190. reject(error)
  1191. })
  1192. })
  1193. },
  1194. //2.15 回显模板
  1195. getWebsiteTemplate({ commit }, data) {
  1196. return new Promise((resolve, reject) => {
  1197. getWebsiteTemplate(data).then(response => {
  1198. resolve(response)
  1199. }).catch(error => {
  1200. reject(error)
  1201. })
  1202. })
  1203. }
  1204. //2.构建网站json end------------------------------------------------------------>
  1205. }
  1206. export default {
  1207. namespaced: true,
  1208. state,
  1209. mutations,
  1210. actions
  1211. }