setting.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. <template>
  2. <div class="cover-panel">
  3. <template v-if="currentScene.type !== '4dkk'">
  4. <div class="title">
  5. 遮罩设置
  6. <i
  7. class="iconfont icon-help_i tool-tip-for-editor"
  8. v-tooltip="$i18n.t('cover.cover_tips')"
  9. />
  10. </div>
  11. <!-- sky start -->
  12. <div class="swi-col">
  13. <span> 天空遮罩 </span>
  14. <switcher
  15. :value="sky.isShow"
  16. @change="(value) => (sky.isShow = Boolean(value))"
  17. ></switcher>
  18. </div>
  19. <div class="swi-col update-col">
  20. <SelectedImage
  21. :imgSrc="sky.icon"
  22. :defaultImgSrc="
  23. require(`@/assets/images/default/mask_bg_${$lang}.png`)
  24. "
  25. @cancel="onClickCancelSkyLogo"
  26. ></SelectedImage>
  27. <div class="action">
  28. <button @click="onSelectPic('sky')" class="ui-button submit">
  29. 选择图片
  30. </button>
  31. <div
  32. class="ui-remark"
  33. v-html="$i18n.t(`edit_settings.mask_size`)"
  34. ></div>
  35. </div>
  36. </div>
  37. <div class="up-col">
  38. <span> 缩放比例 </span>
  39. <slider
  40. v-model="sky.scale"
  41. show-stops
  42. :marks="scaleMarks"
  43. :step="0.1"
  44. :min="0.5"
  45. :max="2"
  46. />
  47. </div>
  48. <div class="swi-col">
  49. <span> 跟随场景转动 </span>
  50. <switcher
  51. :value="sky.antidistorted"
  52. @change="(sa) => (sky.antidistorted = Boolean(sa))"
  53. ></switcher>
  54. </div>
  55. <div class="swi-col">
  56. <span> 应用到全部全景图 </span>
  57. <switcher
  58. :value="isApplySkyToAll"
  59. @change="(sat) => (isApplySkyToAll = Boolean(sat))"
  60. ></switcher>
  61. </div>
  62. <!-- sky end -->
  63. <div style="margin: 30px 0"></div>
  64. <!-- earth start -->
  65. <div class="swi-col">
  66. <span> 地面遮罩 </span>
  67. <switcher
  68. :value="earth.isShow"
  69. @change="(value) => (earth.isShow = Boolean(value))"
  70. ></switcher>
  71. </div>
  72. <div class="swi-col update-col">
  73. <SelectedImage
  74. :imgSrc="earth.icon"
  75. :defaultImgSrc="
  76. require(`@/assets/images/default/mask_bg_${$lang}.png`)
  77. "
  78. @cancel="onClickCancelEarthLogo"
  79. ></SelectedImage>
  80. <div class="action">
  81. <button @click="onSelectPic('earth')" class="ui-button submit">
  82. 选择图片
  83. </button>
  84. <div
  85. class="ui-remark"
  86. v-html="$i18n.t(`edit_settings.mask_size`)"
  87. ></div>
  88. </div>
  89. </div>
  90. <div class="up-col">
  91. <span> 缩放比例 </span>
  92. <slider
  93. v-model="earth.scale"
  94. show-stops
  95. :marks="scaleMarks"
  96. :step="0.1"
  97. :min="0.5"
  98. :max="2"
  99. />
  100. </div>
  101. <div class="swi-col">
  102. <span> 跟随场景转动 </span>
  103. <switcher
  104. :value="earth.antidistorted"
  105. @change="(ve) => (earth.antidistorted = Boolean(ve))"
  106. ></switcher>
  107. </div>
  108. <div class="swi-col">
  109. <span> 应用到全部全景图 </span>
  110. <switcher
  111. :value="isApplyEarthToAll"
  112. @change="(vet) => (isApplyEarthToAll = Boolean(vet))"
  113. ></switcher>
  114. </div>
  115. <!-- earth end -->
  116. </template>
  117. <div class="goto-4dkk-tip" v-if="currentScene.type === '4dkk'">
  118. <div class="img-wrap">
  119. <img
  120. class=""
  121. src="@/assets/images/default/goto-4dage.png"
  122. alt=""
  123. draggable="false"
  124. />
  125. <div class="tip-text">
  126. {{ $i18n.t("screen.goto_4dkk_edit_tips") }}
  127. </div>
  128. </div>
  129. <button class="ui-button submit" @click="onClickGo4dkk">
  130. {{ $i18n.t("navigation.go_scene_editor") }}
  131. </button>
  132. </div>
  133. <div class="dialog" style="z-index: 2000" v-if="isShowSelectionWindow">
  134. <MaterialSelector
  135. :title="$i18n.t(`gather.select_material`)"
  136. @cancel="isShowSelectionWindow = false"
  137. @submit="handleSubmitFromMaterialSelector"
  138. :selectableType="['image']"
  139. />
  140. </div>
  141. </div>
  142. </template>
  143. <script>
  144. import { mapGetters } from "vuex";
  145. import Switcher from "@/components/shared/Switcher";
  146. import { Slider } from "element-ui";
  147. import SelectedImage from "@/components/selectedImageInEditor.vue";
  148. import MaterialSelector from "@/components/materialSelector.vue";
  149. export default {
  150. name: "cover-setting-panel",
  151. components: {
  152. Switcher,
  153. Slider,
  154. SelectedImage,
  155. MaterialSelector,
  156. },
  157. computed: {
  158. ...mapGetters({
  159. currentScene: "scene/currentScene",
  160. }),
  161. },
  162. data() {
  163. return {
  164. isApplySkyToAll: false,
  165. isApplyEarthToAll: false,
  166. isShowSelectionWindow: false,
  167. isSelect: "",
  168. scaleMarks: {
  169. 0.52: "0.5倍",
  170. 1: "1倍",
  171. 1.99: "2倍",
  172. },
  173. sky: {
  174. isShow: false,
  175. icon: "",
  176. scale: 1,
  177. fodderId: "",
  178. antidistorted: false,
  179. },
  180. earth: {
  181. isShow: false,
  182. icon: "",
  183. scale: 1,
  184. fodderId: "",
  185. antidistorted: false,
  186. },
  187. };
  188. },
  189. watch: {
  190. sky: {
  191. handler: function (val) {
  192. if (this.currentScene.type === "pano" && val) {
  193. this.currentScene.customMask.sky = val;
  194. this.updateCurrentScene();
  195. this.handlePeakStatus(val.isShow);
  196. this.handlePeakScale(val.scale);
  197. this.handlePeakURL(val.icon);
  198. this.handlePeakDistorted(val.antidistorted);
  199. }
  200. },
  201. deep: true,
  202. },
  203. earth: {
  204. handler: function (val) {
  205. if (this.currentScene.type === "pano" && val) {
  206. this.currentScene.customMask.earth = val;
  207. this.updateCurrentScene();
  208. this.handleNadirStatus(val.isShow);
  209. this.handleNadirScale(val.scale);
  210. this.handleNadirURL(val.icon);
  211. this.handleNadirDistorted(val.antidistorted);
  212. }
  213. },
  214. deep: true,
  215. },
  216. isApplySkyToAll: {
  217. handler: function (val) {
  218. if (val) {
  219. this.$confirm({
  220. content: "是否应用到全部全景图?",
  221. ok: () => {
  222. this.$store.dispatch("scene/applycustomMaskToAll", "sky");
  223. },
  224. no: () => {
  225. this.isApplySkyToAll = false;
  226. },
  227. });
  228. }
  229. },
  230. immediate: true,
  231. },
  232. isApplyEarthToAll: {
  233. handler: function (val) {
  234. if (val) {
  235. this.$confirm({
  236. content: "是否应用到全部全景图?",
  237. ok: () => {
  238. this.$store.dispatch("scene/applycustomMaskToAll", "earth");
  239. },
  240. no: () => {
  241. this.isApplyEarthToAll = false;
  242. },
  243. });
  244. }
  245. },
  246. immediate: true,
  247. },
  248. "currentScene.customMask": {
  249. handler: function (newVal, oldVal) {
  250. if (newVal && newVal !== oldVal) {
  251. const { sky, earth } = newVal;
  252. this.isApplyEarthToAll = false;
  253. this.isApplySkyToAll = false;
  254. this.sky = { ...sky };
  255. this.earth = { ...earth };
  256. }
  257. },
  258. deep: true,
  259. immediate: true,
  260. },
  261. },
  262. mounted() {},
  263. methods: {
  264. onClickGo4dkk() {
  265. window.open("/#/scene");
  266. },
  267. onClickCancelSkyLogo() {
  268. this.handlePeakURL("/static/template/skin/masking.png");
  269. this.sky.fodderId = "";
  270. this.sky.icon = "";
  271. },
  272. onClickCancelEarthLogo() {
  273. this.handlePeakURL("/static/template/skin/masking.png");
  274. this.earth.fodderId = "";
  275. this.earth.icon = "";
  276. },
  277. onSelectPic(type) {
  278. this.isSelect = type;
  279. this.isShowSelectionWindow = true;
  280. },
  281. handleSubmitFromMaterialSelector(selected) {
  282. this[this.isSelect].icon = selected[0].icon;
  283. this[this.isSelect].fodderId = selected[0].id;
  284. this.isShowSelectionWindow = false;
  285. },
  286. handlePeakStatus(status) {
  287. const status_b = !!status;
  288. const kr = this.$getKrpano();
  289. if (kr) {
  290. kr.set("hotspot[peaklogo].visible", status_b);
  291. }
  292. },
  293. handlePeakURL(url) {
  294. const kr = this.$getKrpano();
  295. if (kr && url) {
  296. kr.set("hotspot[peaklogo].url", url);
  297. }
  298. },
  299. handlePeakScale(scale) {
  300. const kr = this.$getKrpano();
  301. if (kr) {
  302. kr.set("hotspot[peaklogo].scale", scale);
  303. }
  304. },
  305. handlePeakDistorted(anti) {
  306. const kr = this.$getKrpano();
  307. if (kr) {
  308. kr.set("hotspot[peaklogo].distorted", anti);
  309. }
  310. },
  311. handleNadirStatus(status) {
  312. const status_b = !!status;
  313. const kr = this.$getKrpano();
  314. if (kr) {
  315. kr.set("hotspot[nadirlogo].visible", status_b);
  316. }
  317. },
  318. handleNadirURL(url) {
  319. const kr = this.$getKrpano();
  320. if (kr && url) {
  321. kr.set("hotspot[nadirlogo].url", url);
  322. }
  323. },
  324. handleNadirScale(scale) {
  325. const kr = this.$getKrpano();
  326. if (kr) {
  327. kr.set("hotspot[nadirlogo].scale", scale);
  328. }
  329. },
  330. handleNadirDistorted(anti) {
  331. const kr = this.$getKrpano();
  332. if (kr) {
  333. kr.set("hotspot[nadirlogo].distorted", anti);
  334. }
  335. },
  336. updateCurrentScene() {
  337. this.$store.dispatch("scene/syncCurrentSceneToStore");
  338. },
  339. },
  340. };
  341. </script>
  342. <style>
  343. .cover-panel .el-slider__marks-text {
  344. white-space: nowrap;
  345. }
  346. </style>
  347. <style lang="less" scoped>
  348. .cover-panel {
  349. padding: 20px;
  350. height: 100%;
  351. overflow-y: scroll;
  352. > .title {
  353. font-size: 18px;
  354. color: #fff;
  355. margin-bottom: 16px;
  356. > i {
  357. font-size: 12px;
  358. position: relative;
  359. top: -2px;
  360. }
  361. }
  362. .swi-col,
  363. .up-col {
  364. display: inline-flex;
  365. width: 100%;
  366. justify-content: space-between;
  367. align-items: center;
  368. flex-direction: row;
  369. margin: 12px 0;
  370. }
  371. .up-col {
  372. flex-direction: column;
  373. justify-content: flex-start;
  374. align-items: flex-start;
  375. flex-wrap: nowrap;
  376. > * {
  377. flex: 1;
  378. width: 100%;
  379. }
  380. }
  381. .update-col {
  382. justify-content: flex-start;
  383. align-items: flex-start;
  384. }
  385. .action {
  386. .ui-button {
  387. margin-bottom: 10px;
  388. }
  389. }
  390. .el-slider {
  391. padding: 0 8px;
  392. color: #fff;
  393. }
  394. .img-wrapper {
  395. width: 120px;
  396. height: 120px;
  397. }
  398. .goto-4dkk-tip {
  399. > .img-wrap {
  400. position: relative;
  401. width: 100%;
  402. > .img {
  403. width: 100%;
  404. }
  405. > .tip-text {
  406. position: absolute;
  407. left: 50%;
  408. bottom: 32px;
  409. transform: translateX(-50%);
  410. font-size: 14px;
  411. color: #fff;
  412. opacity: 0.6;
  413. white-space: pre;
  414. }
  415. }
  416. > button {
  417. margin-top: 16px;
  418. width: 100%;
  419. }
  420. }
  421. }
  422. </style>