Setting.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <div class="view-setting" app-border dir-left>
  3. <div class="title">
  4. {{ $i18n.t("screen.init_screen") }}
  5. <i
  6. class="iconfont icon-help_i tool-tip-for-editor"
  7. v-tooltip="$i18n.t('screen.screen_tips')"
  8. />
  9. </div>
  10. <template v-if="currentScene.type !== '4dkk'">
  11. <img
  12. class="preview"
  13. v-if="initImg"
  14. :src="`${initImg}?${Math.random()}`"
  15. alt=""
  16. />
  17. <img
  18. class="placeholder"
  19. v-else
  20. src="@/assets/images/pano-image-placeholder.png"
  21. alt=""
  22. />
  23. <div class="item">
  24. <div class="">垂直视角限制</div>
  25. <slider
  26. v-model="vlookat"
  27. range
  28. show-stops
  29. :marks="marks"
  30. :min="-90"
  31. :max="90"
  32. >
  33. </slider>
  34. </div>
  35. <div class="col">
  36. <span>应用到全部全景图</span>
  37. <Switcher :value="applyToAll" @change="onSwitcherChange"></Switcher>
  38. </div>
  39. </template>
  40. <div class="goto-4dkk-tip" v-if="currentScene.type === '4dkk'">
  41. <div class="img-wrap">
  42. <img
  43. class=""
  44. src="@/assets/images/default/goto-4dage.png"
  45. alt=""
  46. draggable="false"
  47. />
  48. <div class="tip-text">
  49. {{ $i18n.t("screen.goto_4dkk_edit_tips") }}
  50. </div>
  51. </div>
  52. <button class="ui-button submit" @click="onClickGo4dkk">
  53. {{ $i18n.t("navigation.go_scene_editor") }}
  54. </button>
  55. </div>
  56. </div>
  57. </template>
  58. <script>
  59. import { mapGetters } from "vuex";
  60. import { Slider } from "element-ui";
  61. import Switcher from "@/components/shared/Switcher";
  62. export default {
  63. components: {
  64. Slider,
  65. Switcher,
  66. },
  67. computed: {
  68. ...mapGetters({
  69. currentScene: "scene/currentScene",
  70. }),
  71. },
  72. data() {
  73. return {
  74. marks: {
  75. "-90": "-90°",
  76. 90: "90°",
  77. },
  78. initImg: "",
  79. vlookat: null,
  80. applyToAll: false,
  81. };
  82. },
  83. watch: {
  84. "$route.name": {
  85. handler() {
  86. this.handleHiddenAllMasks();
  87. },
  88. immediate: true,
  89. },
  90. "currentScene.id": {
  91. handler(val, oldVal) {
  92. if (val && val !== oldVal) {
  93. this.applyToAll = false;
  94. this.handleHiddenAllMasks();
  95. }
  96. },
  97. immediate: true,
  98. },
  99. "currentScene.initVisual": {
  100. handler(val) {
  101. if (val) {
  102. const { vlookatmin, vlookatmax } = val;
  103. if (vlookatmin && vlookatmax) {
  104. this.vlookat = [vlookatmin, vlookatmax];
  105. }
  106. }
  107. },
  108. deep: true,
  109. immediate: true,
  110. },
  111. vlookat: {
  112. handler: function (val) {
  113. this.handleVlootAt(val);
  114. },
  115. },
  116. applyToAll: {
  117. handler: function (val) {
  118. if (val) {
  119. const kr = this.$getKrpano();
  120. const vlookat =kr.get("view.vlookat");
  121. const hlookat = kr.get("view.hlookat");
  122. console.log("当前视野", vlookat, hlookat);
  123. this.$confirm({
  124. content: "是否应用到全部全景图?",
  125. ok: () => {
  126. this.$store.dispatch("scene/applyInitVisualToAll", {
  127. vlookat,
  128. hlookat,
  129. });
  130. },
  131. no: () => {
  132. this.applyToAll = false;
  133. },
  134. });
  135. }
  136. },
  137. immediate: true,
  138. },
  139. },
  140. methods: {
  141. onClickGo4dkk() {
  142. window.open("/#/scene");
  143. },
  144. onSwitcherChange(value) {
  145. this.applyToAll = value;
  146. },
  147. handleVlootAt(val) {
  148. if (val) {
  149. const min = Math.min(...val);
  150. const max = Math.max(...val);
  151. if (this.currentScene.initVisual) {
  152. this.currentScene.initVisual.vlookatmin = min;
  153. this.currentScene.initVisual.vlookatmax = max;
  154. this.handleKrAction(min, max);
  155. }
  156. }
  157. },
  158. handleKrAction(min, max) {
  159. const kr = this.$getKrpano();
  160. if (kr) {
  161. kr.set("view.limitview", "lookat");
  162. const mid = min + max;
  163. kr.set("view.vlookat", mid);
  164. kr.set("view.vlookatmin", String(min));
  165. kr.set("view.vlookatmax", String(max));
  166. }
  167. },
  168. handleHiddenAllMasks() {
  169. if (this.$getKrpano()) {
  170. if (this.$route.name === "screen") {
  171. setTimeout(() => {
  172. this.$getKrpano().set("hotspot[peaklogo].visible", false);
  173. this.$getKrpano().set("hotspot[nadirlogo].visible", false);
  174. }, 100);
  175. }
  176. }
  177. },
  178. },
  179. mounted() {
  180. this.$bus.on("initView", (data) => {
  181. this.initImg = data;
  182. });
  183. if (!this.initImg) {
  184. this.initImg = this.currentScene.icon;
  185. }
  186. },
  187. };
  188. </script>
  189. <style lang="less" scoped>
  190. .view-setting {
  191. padding: 20px;
  192. > .title {
  193. font-size: 18px;
  194. color: #fff;
  195. margin-bottom: 16px;
  196. > i {
  197. font-size: 12px;
  198. position: relative;
  199. top: -2px;
  200. }
  201. }
  202. .preview {
  203. width: 100%;
  204. height: 132px;
  205. border-radius: 4px;
  206. margin-bottom: 16px;
  207. object-fit: cover;
  208. image-rendering: smooth;
  209. }
  210. .placeholder {
  211. width: 100%;
  212. height: 132px;
  213. margin-bottom: 16px;
  214. }
  215. .item {
  216. .el-slider {
  217. padding: 0 5px;
  218. margin-bottom: 10px;
  219. }
  220. }
  221. .col {
  222. width: 100%;
  223. margin: 15px 0;
  224. display: inline-flex;
  225. justify-content: space-between;
  226. align-items: center;
  227. }
  228. .goto-4dkk-tip {
  229. > .img-wrap {
  230. position: relative;
  231. width: 100%;
  232. > .img {
  233. width: 100%;
  234. }
  235. > .tip-text {
  236. position: absolute;
  237. left: 50%;
  238. bottom: 32px;
  239. transform: translateX(-50%);
  240. font-size: 14px;
  241. color: #fff;
  242. opacity: 0.6;
  243. white-space: pre;
  244. }
  245. }
  246. > button {
  247. margin-top: 16px;
  248. width: 100%;
  249. }
  250. }
  251. }
  252. </style>