scene.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <template>
  2. <div class="parent-body">
  3. <!-- 热点 -->
  4. <!-- <hot/> -->
  5. <!-- 热点弹出框 -->
  6. <popup/>
  7. <!-- 加载初始页面 -->
  8. <div id="gui-thumb"></div>
  9. <!-- cad -->
  10. <cad/>
  11. <!-- 主容器 -->
  12. <div id="player"></div>
  13. <div id="gui-parent">
  14. <!-- 进度条加载 -->
  15. <gui-loading/>
  16. <div id="hot"></div>
  17. <div id="gui" style="display: none;">
  18. <!-- 退出VR模式按钮 -->
  19. <div id="vrOff">
  20. <img id="vrOffImg" src="images/vrOffImg.png" alt="">
  21. </div>
  22. <!-- 热点列表 -->
  23. <hotspot-list/>
  24. <!-- 标题 -->
  25. <v-title/>
  26. <!-- 底部菜单 -->
  27. <v-menu ref="menu" @btnactive="handleActive"/>
  28. <!-- 导览 -->
  29. <v-guide/>
  30. <!-- logo -->
  31. <div id="myCompany"></div>
  32. </div>
  33. <!-- vr -->
  34. <web-vr/>
  35. <!-- loading -->
  36. <div id="gui-spinner" style="display: none;">
  37. <div class="gui-spinner-icon"></div>
  38. </div>
  39. <!-- guimsg -->
  40. <guimsg/>
  41. <!-- 错误提示 -->
  42. <v-error/>
  43. <vr-con/>
  44. <v-other/>
  45. </div>
  46. <exhibition v-if="isMainScene" class="exhibition" :isShow="isShowEXH" @isShow="handleShow" :style="{zIndex:showType?0:99}"/>
  47. <hovercom @close="handlepopClose" :showType="showType"/>
  48. <huizhang :visit="visit" @close="()=>{showhuizhang = false}" :showhuizhang="showhuizhang"/>
  49. </div>
  50. </template>
  51. <script>
  52. import popup from './popup';
  53. import cad from './cad';
  54. import guiLoading from './gui/loading';
  55. import hotspotList from './gui/hotspotlist';
  56. import vTitle from './gui/title';
  57. import vMenu from './gui/menu';
  58. import vGuide from './gui/guide';
  59. import webVr from './gui/webvr';
  60. import guimsg from './gui/guimsg';
  61. import vError from './gui/error';
  62. import vrCon from './gui/vrcon';
  63. import vOther from './gui/other';
  64. import exhibition from '@/components/exhibition';
  65. import vpopup from './components/popup.vue'
  66. import hovercom from "@/newcomponents/hovercom";
  67. import huizhang from "@/newcomponents/huizhang";
  68. export default {
  69. name: 'Home',
  70. components: {
  71. popup,
  72. cad,
  73. guiLoading,
  74. hotspotList,
  75. vTitle,
  76. vMenu,
  77. vGuide,
  78. webVr,
  79. guimsg,
  80. vError,
  81. vrCon,
  82. vOther,
  83. exhibition,
  84. vpopup,
  85. hovercom,
  86. huizhang
  87. },
  88. watch:{
  89. showType(newVal){
  90. let tt = newVal?0:99
  91. $('.cad').css({zIndex:tt})
  92. $('.cad1').css({zIndex:tt})
  93. }
  94. },
  95. mounted(){
  96. this.$nextTick(() => {
  97. if (!window.evt) {
  98. window.evt = document.createEvent("HTMLEvents");
  99. window.evt.initEvent("loadfinish", false, false);
  100. }
  101. window.addEventListener("loadfinish", ()=>{
  102. this.loading=false
  103. this.getHotSpotList();
  104. this.isMainScene = window.number == '1149_2'
  105. window.parent.postMessage(
  106. {
  107. source: "loadfinish",
  108. data: true,
  109. },
  110. "*"
  111. );
  112. // window.player.on("openTips", () => {
  113. // this.$showTips()
  114. // });
  115. window.player.director.on("tour.start", () => {
  116. if(!window.ISMUTED){
  117. this.$bus.$emit("changexlzmode","Speaking1")
  118. }
  119. });
  120. window.player.director.on("tour.end", () => {
  121. console.log('tour.end')
  122. this.$bus.$emit("resetxlzmode")
  123. });
  124. window.player.director.on('isPulltttttt',data=>{
  125. if(data) {
  126. this.isShowEXH = false
  127. }
  128. })
  129. window.player.director.on("action.interrupted", () => {
  130. this.$bus.$emit("resetxlzmode")
  131. });
  132. window.player.model.on("floor.changed", (data) => {
  133. this.$bus.$emit("floorchanged",data.floorIndex + 1)
  134. });
  135. window.player.on("flying.ended", (...data) => {
  136. this.$bus.$emit("flyingEnded", data[2])
  137. });
  138. window.player.on("openHotspot", (data) => {
  139. this.$showHotspot({
  140. hotspot: this.hotspots[data],
  141. });
  142. window.parent.postMessage(
  143. {
  144. source: "openHotspot",
  145. data: true,
  146. },
  147. "*"
  148. );
  149. });
  150. this.timer && clearTimeout(this.timer)
  151. this.timer = setTimeout(() => {
  152. this.visit = window.manage.number('visit')
  153. console.log(this.visit);
  154. this.showhuizhang = true
  155. }, 3 * 60 * 1000);
  156. document.addEventListener("visibilitychange", () =>{
  157. if(document.visibilityState == 'hidden'){
  158. window.player.director.stopTour()
  159. }
  160. });
  161. }, false);
  162. });
  163. this.$bus.$on('opendaolan',()=>{
  164. this.showExhibition = true
  165. })
  166. this.$bus.$on('openhovercom',(data)=>{
  167. this.showType = data
  168. })
  169. this.$bus.$on('moveCan',()=>{
  170. if (this.fisrstIn && this.isMainScene) {
  171. this.fisrstIn = false
  172. let rotate = player.cameraControls.controls.panorama.rotationAcc
  173. rotate.x = 0.3
  174. setTimeout(() => {
  175. rotate.x = 0
  176. }, 2000);
  177. }
  178. })
  179. },
  180. methods:{
  181. handleShow(data){
  182. this.isShowEXH = data;
  183. this.$refs.menu.handleguide('',true)
  184. },
  185. handleActive(data){
  186. this.showType = data
  187. window.player.director.stopTour()
  188. },
  189. getHotSpotList() {
  190. $.ajax({
  191. url:
  192. g_Prefix +
  193. "data/" +
  194. window.number +
  195. "/hot/js/data.js" +
  196. "?" +
  197. Math.random(),
  198. type: "get",
  199. dataType: "json",
  200. contentType: "application/json",
  201. success: (result) => {
  202. this.hotspots = result;
  203. },
  204. });
  205. },
  206. handleClose(){
  207. $('.cad').css('transform', 'translate(-150%,-50%)')
  208. this.showExhibition=false
  209. },
  210. handlepopClose(){
  211. this.showType = ''
  212. this.$bus.$emit('resetbtnactive')
  213. },
  214. destroy() {
  215. window.hadLoad = true;
  216. if (window.player) {
  217. window.player.sceneRenderer.suspend();
  218. window.player = "";
  219. $(".parent-body").remove();
  220. $("#player").remove();
  221. $(document).unbind('keydown')
  222. $(document).off('keydown')
  223. }
  224. },
  225. },
  226. beforeDestroy(){
  227. this.destroy();
  228. },
  229. data(){
  230. return {
  231. danmu:[],
  232. showExhibition: true,
  233. showhuizhang:false,
  234. showType:'',
  235. timer:null,
  236. cp:'',
  237. visit:0,
  238. isShowEXH:false,
  239. isMainScene: false,
  240. fisrstIn:true
  241. }
  242. }
  243. }
  244. </script>
  245. <style lang="less" scoped>
  246. .parent-body{
  247. width: 100%;
  248. height: 100%;
  249. overflow: hidden;
  250. position: relative;
  251. }
  252. .exhibition{
  253. position: absolute;
  254. top: 50px;
  255. right: 0;
  256. z-index: 99;
  257. }
  258. </style>