Setting.vue 8.6 KB

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