index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <template>
  2. <div class="Construct">
  3. <!-- 模型的嵌套盒子 -->
  4. <div class="ifrBox" v-if="unityUrl">
  5. <iframe :src="unityUrl" frameborder="0"></iframe>
  6. </div>
  7. <!-- 左上的场景选择 -->
  8. <div class="vrChange" @click="vrShow = true">
  9. <img src="../../assets/img/construct/vrChange.png" alt="" />
  10. <p>场景选择</p>
  11. </div>
  12. <!-- 右下角的搜索按钮 -->
  13. <img
  14. class="search"
  15. @click="searchShow = !searchShow"
  16. src="../../assets/img/construct/search.png"
  17. alt=""
  18. />
  19. <!-- 点击左上角出来的轮播图 -->
  20. <div class="vrBox" :class="{ vrBoxAc: vrShow }">
  21. <!-- 关闭按钮 -->
  22. <div class="close" @click="vrShow = false">
  23. <van-icon name="cross" />
  24. </div>
  25. <div class="vrBoxSwi">
  26. <div class="swiper-container">
  27. <div class="swiper-wrapper">
  28. <div
  29. class="swiper-slide"
  30. @click="handlClick(item.id)"
  31. v-for="item in data"
  32. :key="item.id"
  33. >
  34. <img :src="require(`@/assets/img/home/${item.id}.jpg`)" alt="" />
  35. <p>{{ item.name }}</p>
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. <!-- 点击右下角的搜索出来的页面 -->
  42. <div class="searcBox" :class="{ searcBoxAc: searchShow }">
  43. <Search />
  44. </div>
  45. <!-- 进入景点详情的按钮 -->
  46. <div class="toInfo" @click="$router.push(`/layout/goods/${Uid}`)">
  47. <img src="../../assets/img/construct/infoBtn.png" alt="" />
  48. </div>
  49. </div>
  50. </template>
  51. <script>
  52. const unityUrlObj = {
  53. 1: "https://4dscene.4dage.com/culturalrelics/YFYCM2/Model2.html?m=yfyc204",
  54. 2: "https://4dscene.4dage.com/culturalrelics/YFYCM2/Model2.html?m=yfyc214",
  55. 3: "https://4dscene.4dage.com/culturalrelics/YFYCM2/Model2.html?m=yfyc215",
  56. 4: "https://4dscene.4dage.com/culturalrelics/YFYCM2/Model2.html?m=yfyc211",
  57. 5: "https://4dscene.4dage.com/culturalrelics/YFYCM2/Model2.html?m=yfyc213",
  58. 6: "https://4dscene.4dage.com/culturalrelics/YFYCM2/Model2.html?m=yfyc210",
  59. 7: "https://4dscene.4dage.com/culturalrelics/YFYCM2/Model2.html?m=yfyc206",
  60. 8: "https://4dscene.4dage.com/culturalrelics/YFYCM2/Model2.html?m=yfyc209",
  61. 9: "https://4dscene.4dage.com/culturalrelics/YFYCM2/Model2.html?m=yfyc207",
  62. 10: "https://4dscene.4dage.com/culturalrelics/YFYCM2/Model2.html?m=yfyc208",
  63. 11: "https://4dscene.4dage.com/culturalrelics/YFYCM2/Model2.html?m=yfyc205",
  64. 12: "https://4dscene.4dage.com/culturalrelics/YFYCM2/Model2.html?m=yfyc201",
  65. 13: "https://4dscene.4dage.com/culturalrelics/YFYCM2/Model2.html?m=yfyc212",
  66. 14: "https://4dscene.4dage.com/culturalrelics/YFYCM2/Model2.html?m=yfyc203",
  67. 15: "https://4dscene.4dage.com/culturalrelics/YFYCM2/Model2.html?m=yfyc202",
  68. };
  69. const dataAll = [
  70. { id: 1, name: "老芜湖海关旧址", loction: "滨江公园内" },
  71. { id: 2, name: "英驻芜领事署旧址", loction: "范罗山" },
  72. { id: 3, name: "总税务司公所旧址", loction: "范罗山" },
  73. { id: 4, name: "洋员帮办楼旧址", loction: "范罗山" },
  74. {
  75. id: 5,
  76. name: "英驻芜领事官邸旧址",
  77. loction: "吉和南路 26 号雨耕山顶",
  78. },
  79. { id: 6, name: "天主堂", loction: "吉和街28 号" },
  80. { id: 7, name: "神父楼", loction: "吉和街28 号" },
  81. { id: 8, name: "天主教主教公署旧址", loction: "狮子山马路39号" },
  82. { id: 9, name: "圣母院旧址", loction: "狮子山马路39号" },
  83. { id: 10, name: "天主教修士楼", loction: "大官山顶" },
  84. { id: 11, name: "内思高级工业职业学校旧址", loction: "吉和街26号" },
  85. { id: 12, name: "博仁堂", loction: "安师大附属外国语学校中学内" },
  86. { id: 13, name: "义德堂", loction: "安师大附属外国语学校中学内" },
  87. { id: 14, name: "经方堂", loction: "安师大附属外国语学校中学内" },
  88. { id: 15, name: "广济寺塔", loction: "广济寺内" },
  89. ];
  90. import Search from "./components/search.vue";
  91. import Swiper from "../../assets/libs/swiper.js";
  92. export default {
  93. components: { Search },
  94. name: "RK-id",
  95. data() {
  96. return {
  97. Uid: Number(this.$route.params.id),
  98. vrShow: false,
  99. searchShow: false,
  100. data: [],
  101. unityUrl: "",
  102. mySwiper: null,
  103. };
  104. },
  105. computed: {},
  106. watch: {
  107. $route(val) {
  108. let id = val.params.id;
  109. this.Uid = Number(id);
  110. this.unityUrl = unityUrlObj[id] || "";
  111. this.data = dataAll.filter((v) => v.id != id);
  112. // 轮播图重新生成
  113. setTimeout(() => {
  114. this.mySwiper = new Swiper(".Construct .swiper-container", {
  115. slidesPerView: 1.4,
  116. spaceBetween: 30,
  117. centeredSlides: true,
  118. initialSlide: 0,
  119. });
  120. }, 200);
  121. },
  122. },
  123. methods: {
  124. handlClick(id) {
  125. this.vrShow = false;
  126. this.$router.push(`/layout/construct/${id}`);
  127. },
  128. },
  129. created() {},
  130. mounted() {
  131. // ------
  132. let id = this.Uid;
  133. this.unityUrl = unityUrlObj[id] || "";
  134. this.data = dataAll.filter((v) => v.id != id);
  135. setTimeout(() => {
  136. this.mySwiper = new Swiper(".Construct .swiper-container", {
  137. slidesPerView: 1.4,
  138. spaceBetween: 30,
  139. centeredSlides: true,
  140. initialSlide: 0,
  141. });
  142. }, 200);
  143. },
  144. beforeCreate() {}, //生命周期 - 创建之前
  145. beforeMount() {}, //生命周期 - 挂载之前
  146. beforeUpdate() {}, //生命周期 - 更新之前
  147. updated() {}, //生命周期 - 更新之后
  148. beforeDestroy() {}, //生命周期 - 销毁之前
  149. destroyed() {}, //生命周期 - 销毁完成
  150. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  151. };
  152. </script>
  153. <style lang='less' scoped>
  154. @import "../../assets/libs/swiper.css";
  155. .Construct {
  156. font-size: 16px;
  157. color: #fff;
  158. width: 100%;
  159. height: calc(100% - 80px);
  160. position: relative;
  161. .ifrBox {
  162. position: absolute;
  163. top: 0;
  164. left: 0;
  165. width: 100%;
  166. height: 100%;
  167. iframe {
  168. width: 100%;
  169. height: 100%;
  170. }
  171. }
  172. .vrChange {
  173. position: absolute;
  174. top: 20px;
  175. left: 20px;
  176. z-index: 2;
  177. width: 60px;
  178. text-align: center;
  179. & > img {
  180. width: 40px;
  181. }
  182. & > p {
  183. font-size: 14px;
  184. }
  185. }
  186. .toInfo {
  187. position: absolute;
  188. bottom: 20px;
  189. left: 50%;
  190. transform: translateX(-50%);
  191. width: 160px;
  192. & > img {
  193. width: 100%;
  194. }
  195. }
  196. .search {
  197. position: absolute;
  198. bottom: 20px;
  199. right: 20px;
  200. width: 40px;
  201. z-index: 4;
  202. }
  203. .vrBox {
  204. opacity: 0;
  205. pointer-events: none;
  206. transition: opacity 0.3s;
  207. position: absolute;
  208. z-index: 4;
  209. width: 100%;
  210. height: 100%;
  211. background-color: rgba(0, 0, 0, 0.6);
  212. .close {
  213. position: absolute;
  214. z-index: 3;
  215. top: 20px;
  216. right: 20px;
  217. font-size: 24px;
  218. color: #fff;
  219. }
  220. .vrBoxSwi {
  221. position: absolute;
  222. top: 50%;
  223. transform: translateY(-50%);
  224. width: 100%;
  225. height: 55vh;
  226. .swiper-container {
  227. width: 100%;
  228. height: 100%;
  229. .swiper-slide {
  230. & > img {
  231. border-radius: 8px 8px 0 0;
  232. width: 100%;
  233. height: calc(100% - 40px);
  234. object-fit: cover;
  235. }
  236. & > p {
  237. height: 40px;
  238. line-height: 40px;
  239. font-size: 18px;
  240. text-align: center;
  241. }
  242. }
  243. }
  244. }
  245. }
  246. .vrBoxAc {
  247. opacity: 1;
  248. pointer-events: auto;
  249. }
  250. .searcBox {
  251. transform: translateX(-300px);
  252. opacity: 0;
  253. pointer-events: none;
  254. transition: all 0.3s;
  255. position: absolute;
  256. z-index: 3;
  257. left: 0;
  258. width: 100%;
  259. background-color: rgba(0, 0, 0, 0.6);
  260. height: 100%;
  261. }
  262. .searcBoxAc {
  263. transform: translateX(0);
  264. opacity: 1;
  265. pointer-events: auto;
  266. }
  267. }
  268. </style>