Setting.vue 8.9 KB

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