Setting.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <template>
  2. <div v-if="currentScene" class="view-setting" app-border dir-left>
  3. <div class="title">
  4. {{ $i18n.t("screen.init_screen") }}
  5. <i class="iconfont icon-help_i tool-tip-for-editor" v-tooltip="$i18n.t('screen.screen_tips')" />
  6. </div>
  7. <template v-if="currentScene.type !== '4dkk'">
  8. <img class="preview" v-if="initImg" :src="`${initImg}?${Math.random()}`" alt="" />
  9. <img class="placeholder" v-else src="@/assets/images/pano-image-placeholder.png" alt="" />
  10. <div class="item">
  11. <div class="">
  12. {{ $i18n.t("modules.screen.v_angle_re") }}
  13. </div>
  14. <vue-slider
  15. v-model="vlookat"
  16. :min="-90"
  17. :max="90"
  18. :height="6"
  19. :width="`95%`"
  20. :marks="marks"
  21. direction="rtl"
  22. tooltip="active"
  23. @change="handleChange"
  24. :tooltip-formatter="formatterMarks"
  25. :processStyle="{
  26. backgroundColor: '#409eff',
  27. }"
  28. :enable-cross="false"
  29. :minRange="30"
  30. />
  31. <!-- <slider
  32. v-model="vlookat"
  33. range
  34. show-stops
  35. :marks="marks"
  36. :min="-90"
  37. :max="90"
  38. >
  39. </slider> -->
  40. </div>
  41. <div class="col">
  42. <span>{{ $i18n.t("mask.apply_to_all_pano") }}</span>
  43. <Switcher :value="applyToAll" @change="onSwitcherChange"></Switcher>
  44. </div>
  45. </template>
  46. <div class="goto-4dkk-tip" v-if="currentScene.type === '4dkk'">
  47. <div class="img-wrap">
  48. <img class="" src="@/assets/images/default/goto-4dage.png" alt="" draggable="false" />
  49. <div class="tip-text">
  50. {{ $i18n.t("screen.goto_4dkk_edit_tips") }}
  51. </div>
  52. </div>
  53. <button class="ui-button submit" @click="onClickGo4dkk">
  54. {{ $i18n.t("navigation.go_scene_editor") }}
  55. </button>
  56. </div>
  57. </div>
  58. </template>
  59. <script>
  60. import { mapGetters } from "vuex";
  61. import { Slider } from "element-ui";
  62. import VueSlider from "vue-slider-component";
  63. import "vue-slider-component/theme/antd.css";
  64. import Switcher from "@/components/shared/Switcher";
  65. export default {
  66. components: {
  67. // Slider,
  68. Switcher,
  69. VueSlider,
  70. },
  71. computed: {
  72. ...mapGetters({
  73. currentScene: "scene/currentScene",
  74. workVisualAngleList: "screen/workVisualAngleList",
  75. baseInfo: "base/baseInfo",
  76. sceneList: "base/sceneList",
  77. }),
  78. },
  79. data() {
  80. return {
  81. formatterMarks: (v) => `${v * -1}`,
  82. marks: {
  83. "-90": this.$i18n.t("modules.model.attr_top"),
  84. 90: this.$i18n.t("modules.model.attr_bottom"),
  85. },
  86. initImg: "",
  87. vlookat: [-90, 90],
  88. applyToAll: false,
  89. changeScene: false,
  90. };
  91. },
  92. watch: {
  93. "$route.name": {
  94. handler() {
  95. this.handleHiddenAllMasks();
  96. },
  97. immediate: true,
  98. },
  99. "currentScene.id": {
  100. handler(val, oldVal) {
  101. if (val && val !== oldVal) {
  102. this.applyToAll = false;
  103. this.handleHiddenAllMasks();
  104. }
  105. },
  106. immediate: true,
  107. },
  108. // "currentScene.initVisual": {
  109. // handler(val) {
  110. // console.error(val)
  111. // if (val) {
  112. // const { vlookatmin, vlookatmax } = val;
  113. // if (vlookatmin && vlookatmax) {
  114. // this.vlookat = [vlookatmin, vlookatmax];
  115. // }
  116. // }
  117. // },
  118. // deep: true,
  119. // immediate: true,
  120. // },
  121. currentScene: {
  122. handler(val) {
  123. if (val) {
  124. // console.error("currentScene change", val);
  125. // let vlookatmin, vlookatmax;
  126. let item = this.workVisualAngleList.find((item) => item.navigationId == this.currentScene.id || item.navigationId == this.currentScene.sid);
  127. if (item) {
  128. this.changeScene = true;
  129. const { vlookatmin, vlookatmax } = item;
  130. if (vlookatmin && vlookatmax) {
  131. this.vlookat = [vlookatmin, vlookatmax];
  132. }
  133. }
  134. let scene = this.sceneList.find((scene) => scene.id == val.id);
  135. if (scene) {
  136. scene.icon = val.icon;
  137. }
  138. // const { vlookatmin, vlookatmax } = this.baseInfo.workVisualAngleList;
  139. // if (vlookatmin && vlookatmax) {
  140. // this.vlookat = [vlookatmin, vlookatmax];
  141. // }
  142. }
  143. },
  144. deep: true,
  145. immediate: true,
  146. },
  147. vlookat: {
  148. handler: function (val) {
  149. this.handleVlootAt(val);
  150. if (val && this.$route.name == "screen" && this.changeScene == false) {
  151. this.$store.commit("scene/setSaveApiList", "screen");
  152. }
  153. this.changeScene = false;
  154. },
  155. },
  156. applyToAll: {
  157. handler: function (val) {
  158. if (val) {
  159. const kr = this.$getKrpano();
  160. const vlookat = kr.get("view.vlookat");
  161. const hlookat = kr.get("view.hlookat");
  162. console.log("当前视野", vlookat, hlookat);
  163. this.$confirm({
  164. content: this.$i18n.t("mask.is_apply_to_all_pano"),
  165. ok: () => {
  166. this.$store.dispatch("screen/applyInitVisualToAll", this.vlookat);
  167. // this.$store.dispatch("scene/applyInitVisualToAll", {
  168. // vlookat,
  169. // hlookat,
  170. // });
  171. // this.updateCurrentScene();
  172. this.$msg.success(this.$i18n.t("gather.edit_success"));
  173. setTimeout(() => (this.applyToAll = false), 1000);
  174. this.$store.commit("scene/setSaveApiList", "screen");
  175. },
  176. no: () => {
  177. this.applyToAll = false;
  178. },
  179. });
  180. }
  181. },
  182. immediate: true,
  183. },
  184. },
  185. methods: {
  186. handleChange(value, index) {
  187. this.workVisualAngleList.forEach((item, index) => {
  188. if (item.navigationId == this.currentScene.id || item.navigationId == this.currentScene.sid) {
  189. item.vlookatmin = this.vlookat[0];
  190. item.vlookatmax = this.vlookat[1];
  191. }
  192. });
  193. // 拖动结束时的处理逻辑
  194. },
  195. onClickGo4dkk() {
  196. window.open("/#/scene");
  197. },
  198. onSwitcherChange(value) {
  199. this.applyToAll = value;
  200. },
  201. handleVlootAt(val) {
  202. if (val) {
  203. const min = Math.min(...val);
  204. const max = Math.max(...val);
  205. // if (this.currentScene.initVisual) {
  206. // this.currentScene.initVisual.vlookatmin = min;
  207. // this.currentScene.initVisual.vlookatmax = max;
  208. this.handleKrAction(min, max);
  209. // }
  210. }
  211. },
  212. handleKrAction(min, max) {
  213. const kr = this.$getKrpano();
  214. if (kr) {
  215. kr.set("view.limitview", "lookat");
  216. // const mid = min + max;
  217. // console.log("mid", min, max);
  218. // kr.set("view.vlookat", min);
  219. kr.set("view.vlookatmin", String(min));
  220. kr.set("view.vlookatmax", String(max));
  221. }
  222. },
  223. handleHiddenAllMasks() {
  224. if (this.$getKrpano()) {
  225. if (this.$route.name === "screen") {
  226. // console.log('handleHiddenAllMasks')
  227. setTimeout(() => {
  228. this.$getKrpano().set("hotspot[peaklogo].visible", false);
  229. this.$getKrpano().set("hotspot[nadirlogo].visible", false);
  230. }, 500);
  231. }
  232. }
  233. },
  234. updateCurrentScene() {
  235. this.$store.dispatch("scene/syncCurrentSceneToStore");
  236. },
  237. },
  238. mounted() {
  239. this.$bus.on("initView", (data) => {
  240. this.initImg = data;
  241. });
  242. if (!this.initImg) {
  243. this.initImg = this.currentScene?.icon || "";
  244. }
  245. },
  246. };
  247. </script>
  248. <style>
  249. /* .vue-slider-dot-tooltip {
  250. display: none !important;
  251. } */
  252. </style>
  253. <style lang="less" scoped>
  254. .view-setting {
  255. padding: 20px;
  256. > .title {
  257. font-size: 18px;
  258. color: #fff;
  259. margin-bottom: 16px;
  260. > i {
  261. font-size: 12px;
  262. position: relative;
  263. top: -2px;
  264. }
  265. }
  266. .preview {
  267. width: 100%;
  268. height: 132px;
  269. border-radius: 4px;
  270. margin-bottom: 16px;
  271. object-fit: cover;
  272. image-rendering: smooth;
  273. }
  274. .placeholder {
  275. width: 100%;
  276. height: 132px;
  277. margin-bottom: 16px;
  278. }
  279. .item {
  280. .el-slider {
  281. padding: 0 5px;
  282. margin-bottom: 10px;
  283. }
  284. .vue-slider {
  285. margin: 15px auto;
  286. }
  287. }
  288. .col {
  289. width: 100%;
  290. margin: 15px 0;
  291. display: inline-flex;
  292. justify-content: space-between;
  293. align-items: center;
  294. }
  295. .goto-4dkk-tip {
  296. > .img-wrap {
  297. position: relative;
  298. width: 100%;
  299. > .img {
  300. width: 100%;
  301. }
  302. > .tip-text {
  303. position: absolute;
  304. left: 50%;
  305. bottom: 32px;
  306. transform: translateX(-50%);
  307. font-size: 14px;
  308. color: #fff;
  309. opacity: 0.6;
  310. white-space: pre;
  311. }
  312. }
  313. > button {
  314. margin-top: 16px;
  315. width: 100%;
  316. }
  317. }
  318. }
  319. </style>