base.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. import Vue from "vue";
  2. import { i18n } from "@/lang";
  3. import { saveBaseWorkInfo } from "@/api";
  4. import { deepClone, isSameObject } from "@/utils/other.js";
  5. import { $waiting } from "@/components/shared/loading";
  6. let vue = new Vue();
  7. export default {
  8. namespaced: true,
  9. state() {
  10. return {
  11. sceneList: [],
  12. baseInfo: null,
  13. };
  14. },
  15. getters: {
  16. sceneList: (state) => {
  17. return state.sceneList;
  18. },
  19. baseInfo: (state, getters, rootState, rootGetters) => {
  20. if (state?.baseInfo?.navigationTrees) {
  21. state.sceneList = [];
  22. state.baseInfo.navigationTrees.forEach((one_tree) => {
  23. if (one_tree.type == "group" && one_tree.children.length) {
  24. one_tree.children.forEach((two_tree) => {
  25. if (two_tree.type == "group" && two_tree.children.length) {
  26. two_tree.children.forEach((scene) => {
  27. state.sceneList.push(scene);
  28. });
  29. } else if (two_tree.type == "pano" || two_tree.type == "4dkk") {
  30. state.sceneList.push(two_tree);
  31. }
  32. });
  33. }
  34. });
  35. }
  36. // console.error("11111", state.sceneList);
  37. // if (rootState.scene.currentScene) {
  38. // let currentScene = state.sceneList.find((item) => item.id == rootState.scene.currentScene.id || item.sid == rootState.scene.currentScene.id);
  39. // if (currentScene) {
  40. // this.commit("scene/setCurrentScene", currentScene);
  41. // }
  42. // }
  43. return state.baseInfo;
  44. },
  45. },
  46. mutations: {
  47. initDefaultData(state, payload) {
  48. let forArr = ["workCustomMaskList", "workVisualAngleList", "workExplanationList"];
  49. // state.baseInfo.workVisualAngleList.forEach((item, index) => {
  50. // if (!state.sceneList.some((j_item) => item.navigationId == j_item.id || item.navigationId == j_item.sid)) {
  51. // console.error(index, "删除了");
  52. // state.baseInfo.workVisualAngleList.splice(index, 1);
  53. // }
  54. // });
  55. // setTimeout(() => {
  56. // console.error(state.sceneList);
  57. this.commit("screen/setVisualAngleList", { sceneList: state.sceneList, workVisualAngleList: state.baseInfo.workVisualAngleList });
  58. this.commit("mask/setCustomMaskList", { sceneList: state.sceneList, workCustomMaskList: state.baseInfo.workCustomMaskList, workId: state.baseInfo.workId });
  59. this.commit("explanation/setExplanationList", { sceneList: state.sceneList, workExplanationList: state.baseInfo.workExplanationList });
  60. // }, 0);
  61. // if (state.sceneList.length) {
  62. // state.sceneList.forEach((item, index) => {
  63. // forArr.map((key) => {
  64. // let obj = {};
  65. // state.baseInfo[key].forEach((key_item, key_index) => {
  66. // if (key == "workVisualAngleList" && item.id == key_item.navigationId || item.sid == key_item.navigationId ) {
  67. // key_item.icon = item.icon;
  68. // }
  69. // obj[key_item.navigationId] = key_item;
  70. // });
  71. // if (obj[item.id]) {
  72. // console.error(key,1);
  73. // } else {
  74. // console.error(key,2);
  75. // switch (key) {
  76. // case "workCustomMaskList":
  77. // console.error("workCustomMaskList");
  78. // state.baseInfo[key].push({
  79. // data: {
  80. // earth: {
  81. // antidistorted: true,
  82. // fodderId: null,
  83. // icon: "",
  84. // isDelete: 0,
  85. // isShow: false,
  86. // navigationId: item.sid ? item.sid : item.id,
  87. // scale: 1,
  88. // type: "earth",
  89. // workId: state.baseInfo.workId,
  90. // },
  91. // sky: {
  92. // antidistorted: true,
  93. // fodderId: null,
  94. // icon: "",
  95. // isDelete: 0,
  96. // isShow: true,
  97. // navigationId: item.sid ? item.sid : item.id,
  98. // scale: 1,
  99. // type: "sky",
  100. // workId: state.baseInfo.workId,
  101. // },
  102. // },
  103. // navigationId: item.sid ? item.sid : item.id,
  104. // });
  105. // break;
  106. // case "workVisualAngleList":
  107. // state.baseInfo[key].push({
  108. // hlookat: 0,
  109. // icon: item.icon,
  110. // // id: 0,
  111. // vlookat: 0,
  112. // vlookatmax: 90,
  113. // vlookatmin: -90,
  114. // workId: state.baseInfo.workId,
  115. // navigationId: item.sid ? item.sid : item.id,
  116. // });
  117. // break;
  118. // case "workExplanationList":
  119. // console.error("workExplanationList");
  120. // state.baseInfo[key].push({
  121. // fodderId: null,
  122. // audioName: "",
  123. // audioUrl: "",
  124. // openByDefault: true,
  125. // navigationId: item.sid ? item.sid : item.id,
  126. // playRepeat: true,
  127. // });
  128. // break;
  129. // }
  130. // }
  131. // // if (key == "workCustomMaskList") {
  132. // // let hasMask = false;
  133. // // state.baseInfo[key].forEach((mask_item, mask_index) => {
  134. // // if (mask_item.navigationId == item.id) {
  135. // // hasMask = true;
  136. // // }
  137. // // });
  138. // // if (!hasMask) {
  139. // // state.baseInfo[key].push({
  140. // // data: {
  141. // // earth: {
  142. // // antidistorted: true,
  143. // // fodderId: null,
  144. // // icon: "",
  145. // // isDelete: 0,
  146. // // isShow: false,
  147. // // navigationId: item.id,
  148. // // scale: 1,
  149. // // type: "earth",
  150. // // workId: state.baseInfo.workId,
  151. // // },
  152. // // sky: {
  153. // // antidistorted: true,
  154. // // fodderId: null,
  155. // // icon: "",
  156. // // id: 7,
  157. // // isDelete: 0,
  158. // // isShow: true,
  159. // // navigationId: item.id,
  160. // // scale: 1,
  161. // // type: "sky",
  162. // // workId: state.baseInfo.workId,
  163. // // },
  164. // // },
  165. // // navigationId: item.id,
  166. // // });
  167. // // }
  168. // // }
  169. // // if (key == "workVisualAngleList") {
  170. // // let hasVisual = false;
  171. // // state.baseInfo[key].forEach((visual_item, visual_index) => {
  172. // // if (visual_item.navigationId == item.id) {
  173. // // hasVisual = true;
  174. // // visual_item.icon = item.icon;
  175. // // }
  176. // // });
  177. // // if (!hasVisual) {
  178. // // state.baseInfo[key].push({
  179. // // hlookat: 0,
  180. // // icon: item.icon,
  181. // // // id: 0,
  182. // // vlookat: 0,
  183. // // vlookatmax: 90,
  184. // // vlookatmin: -90,
  185. // // workId: state.baseInfo.workId,
  186. // // navigationId: item.id,
  187. // // });
  188. // // }
  189. // // }
  190. // // if(key=='workExplanationList'){
  191. // // }
  192. // });
  193. // });
  194. // }
  195. // console.error(state.baseInfo["workVisualAngleList"]);
  196. },
  197. initbaseInfo(state, payload) {
  198. // console.error('initbaseInfo')
  199. let data = {
  200. firstScene: null,
  201. workVisualAngleList: [],
  202. navigationTrees: [],
  203. workCustomMaskList: [],
  204. workId: "",
  205. work: {
  206. description: "",
  207. icon: "",
  208. id: "",
  209. isAuto: 0,
  210. name: "",
  211. password: "",
  212. },
  213. workBackgroundMusic: null,
  214. workCoverType: {
  215. coverImageInWay: 0,
  216. coverImageOrder: "",
  217. coverImgBac: "",
  218. coverMo: "",
  219. coverMoLoc: "",
  220. coverPc: "",
  221. coverPcLoc: "",
  222. coverSelect: "img",
  223. coverVideoBac: "",
  224. coverVideoControl: 0,
  225. coverVideoInWay: 0,
  226. cover_mo_id: 0,
  227. cover_pc_id: 0,
  228. id: 0,
  229. imgColorSelec: "",
  230. isShowCover: 0,
  231. videoBacImg: "",
  232. videoColorSelec: "",
  233. videoMo: "",
  234. videoMoIcon: "",
  235. videoMoId: 0,
  236. videoMoLoc: "",
  237. videoPc: "",
  238. videoPcIcon: "",
  239. videoPcLoc: "",
  240. video_pc_id: 0,
  241. workId: "",
  242. },
  243. workLogo: {
  244. id: 0,
  245. isLogo: 0,
  246. logo: "",
  247. logoChange: false,
  248. workId: "",
  249. },
  250. workOpeningAnimation: {
  251. id: 0,
  252. isShowOpeningAnimation: false,
  253. openingAnimationType: 0,
  254. workId: "",
  255. },
  256. workOpeningTip: {
  257. appIcon: "",
  258. appIconId: "",
  259. id: 0,
  260. isRemind: 0,
  261. pcIcon: "",
  262. pcIconId: "",
  263. remindTime: 0,
  264. workId: "",
  265. },
  266. workCustomButtonList: [
  267. {
  268. id: 0,
  269. isShow: 0,
  270. name: "",
  271. openMethod: "",
  272. type: "",
  273. value: "",
  274. workId: "",
  275. },
  276. ],
  277. workExplanationList: [],
  278. workHotList: [],
  279. };
  280. if (!state.baseInfo) {
  281. state.baseInfo = data;
  282. // state.baseInfo = {};
  283. }
  284. for (let key in state.baseInfo) {
  285. if (state.baseInfo.hasOwnProperty(key)) {
  286. if (payload[key] == null) {
  287. state.baseInfo[key] = data[key];
  288. } else {
  289. state.baseInfo[key] = payload[key];
  290. }
  291. }
  292. }
  293. },
  294. setData(state, payload) {
  295. // this.commit("base/initbaseInfo");
  296. for (let key in payload) {
  297. if (state.baseInfo.hasOwnProperty(key)) {
  298. state.baseInfo[key] = payload[key];
  299. }
  300. }
  301. },
  302. updateBaseInfo(state, payload) {
  303. for (let key in payload) {
  304. state.baseInfo[key] = payload[key];
  305. // if (key == "navigationTrees") {
  306. // console.error(state.sceneList);
  307. // }
  308. }
  309. },
  310. },
  311. actions: {
  312. save({ commit, state, rootState }) {
  313. // return new Promise((resolve,reject)=>{})
  314. return new Promise((resolve, reject) => {
  315. saveBaseWorkInfo(
  316. state.baseInfo,
  317. (res) => {
  318. // vue.$msg.success(i18n.t("gather.save_done"));
  319. // document.title = this.info.name;
  320. document.title = state.baseInfo.work.name || i18n.t("gather.no_title");
  321. $waiting.hide();
  322. // this.getInfo();
  323. // this.$store.commit("UpdateIsShowState", true);
  324. // this.commit("TakeInfoSnapShotAtSave");
  325. resolve(res);
  326. },
  327. (rej) => {
  328. reject(rej);
  329. }
  330. );
  331. });
  332. },
  333. },
  334. };