PanoView.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <div class="pano-view">
  3. <div
  4. id="pano"
  5. :style="{zIndex: $globalConfig.zIndex.pano.self}"
  6. />
  7. <button
  8. class="top back"
  9. @click="onClickBack"
  10. >
  11. <img
  12. src="@/assets/images/pano/back.png"
  13. alt=""
  14. draggable="false"
  15. >
  16. <div>返回</div>
  17. </button>
  18. <button
  19. class="top switch-pano"
  20. @click="onClickSwitchPano"
  21. >
  22. <img
  23. src="@/assets/images/swkk/changjingdaolan.png"
  24. alt=""
  25. draggable="false"
  26. >
  27. <div>全景切换</div>
  28. </button>
  29. <router-view />
  30. </div>
  31. </template>
  32. <script>
  33. import * as krfn from "@/libs/pano-core/index.js"
  34. let __krfn = krfn.default
  35. export default {
  36. data() {
  37. return {
  38. scene: null,
  39. }
  40. },
  41. computed: {
  42. ...globalMapState([
  43. 'panoData',
  44. ])
  45. },
  46. async mounted() {
  47. console.log('this.$route.params.scene: ', this.$route.params.scene)
  48. this.scene = this.$route.params.scene
  49. window.__krfn = __krfn
  50. this.loadScene()
  51. this.$msgCenter.subscribe('clickHotspot', (hotspotName) => {
  52. console.log('hotspotName: ', hotspotName)
  53. let someData = this.scene.someData
  54. if (typeof someData == "string") {
  55. someData = JSON.parse(this.activeItem.someData)
  56. }
  57. let clickedHotspot = someData.hotspots.find((item) => item.name == hotspotName)
  58. if (clickedHotspot) {
  59. if (clickedHotspot.hotspotType == "link") {
  60. window.open(clickedHotspot.hyperlink, "_blank")
  61. } else if (clickedHotspot.hotspotType == "scene") {
  62. this.scene = clickedHotspot.secne
  63. this.loadScene()
  64. // this.$router.replace({ name: 'PanoView', params: { scene: clickedHotspot.secne } })
  65. }
  66. }
  67. })
  68. },
  69. methods: {
  70. loadScene() {
  71. $("#pano").empty()
  72. window.vrInitFn = () => {
  73. // eslint-disable-next-line no-undef
  74. // $smallWaiting.hide()
  75. var krpano = document.getElementById("krpanoSWFObject")
  76. __krfn.utils.initHotspot(krpano, this.scene.someData, false)
  77. }
  78. window.vrViewFn = () => {
  79. try {
  80. let tmp = this.scene.initVisual || {}
  81. var krpano = document.getElementById("krpanoSWFObject")
  82. krpano.set("view.vlookat", tmp.vlookat || 0)
  83. krpano.set("view.hlookat", tmp.hlookat || 0)
  84. krpano.set("autorotate.enabled", Boolean(this.panoData.isAuto))
  85. } catch (error) {
  86. console.log(error)
  87. }
  88. }
  89. let settings = {
  90. "events[skin_events].onxmlcomplete": "js(window.vrViewFn());",
  91. "events[skin_events].onloadcomplete": "js(window.vrInitFn());",
  92. }
  93. // eslint-disable-next-line no-undef
  94. removepano("#pano")
  95. // eslint-disable-next-line no-undef
  96. embedpano({
  97. xml: `${process.env.VUE_APP_PROTOCOL}zzbbh.4dage.com/YHT/Qjkk/local/pano/${this.scene.sceneCode}/vtour/tour.xml`,
  98. swf: "%HTMLPATH%/static/template/tour.swf", // todo: 咋回事?
  99. target: "pano",
  100. html5: "auto",
  101. mobilescale: 1,
  102. vars: settings,
  103. passQueryParameters: true,
  104. })
  105. },
  106. onClickBack: globalUtils.throttle(function() {
  107. this.$router.push({ name: 'ObliqueView' })
  108. }, 1000),
  109. onClickSwitchPano() {
  110. this.$router.push({ name: 'PanoList' })
  111. }
  112. },
  113. }
  114. </script>
  115. <style lang="less" scoped>
  116. .pano-view {
  117. position: relative;
  118. width: 100%;
  119. height: 100%;
  120. z-index: 0;
  121. #pano {
  122. width: 100%;
  123. height: 100%;
  124. }
  125. > button.top {
  126. position: absolute;
  127. top: 2.08rem;
  128. width: 5rem;
  129. height: 5rem;
  130. z-index: 2;
  131. > img {
  132. width: 100%;
  133. height: 100%;
  134. }
  135. > div {
  136. margin-top: 0.17rem;
  137. text-shadow: 0 0 0.1rem rgba(0,0,0,0.3);
  138. color: #333333;
  139. font-size: 1.17rem;
  140. font-weight: bold;
  141. }
  142. &.back {
  143. left: 1.63rem;
  144. }
  145. &.switch-pano {
  146. right: 1.63rem;
  147. }
  148. }
  149. }
  150. </style>