Rbottom.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. <template>
  2. <div class="Rbottom" :style="`${leftList[1].done ? 'bottom:0px' : ''}`">
  3. <audio src="@/assets/media/bacMusic.mp3" loop id="bacMusic"></audio>
  4. <div class="box1">
  5. <div class="mainll mainrr">
  6. <div
  7. v-show="list.length !== 0 || item.type > 2"
  8. @click="leftCutClick(item.type)"
  9. class="row"
  10. :class="{ active2: item.done }"
  11. v-for="item in leftList"
  12. :key="item.type"
  13. >
  14. <img
  15. :src="
  16. require(`@/assets/img/LeftTop/inco${item.type}${
  17. item.done ? 'Ac' : ''
  18. }.png`)
  19. "
  20. alt=""
  21. />
  22. <p>{{ item.name }}</p>
  23. </div>
  24. </div>
  25. <div class="mainrr">
  26. <div
  27. class="row"
  28. @click="rightClisk(item.type)"
  29. v-for="item in rightList"
  30. :key="item.type"
  31. :class="{
  32. active2:
  33. (music && item.type === 2) ||
  34. (like && item.type === 3) ||
  35. (share && item.type === 4) ||
  36. (isFullscreen && item.type === 5),
  37. }"
  38. >
  39. <img
  40. :src="require(`@/assets/img/Goods/inco${item.type}Ac.png`)"
  41. alt=""
  42. v-if="music && item.type === 2"
  43. />
  44. <img
  45. :src="require(`@/assets/img/Goods/inco${item.type}Ac.png`)"
  46. alt=""
  47. v-else-if="like && item.type === 3"
  48. />
  49. <img
  50. :src="require(`@/assets/img/Goods/inco${item.type}Ac.png`)"
  51. alt=""
  52. v-else-if="share && item.type === 4"
  53. />
  54. <img
  55. :src="require(`@/assets/img/Goods/inco${item.type}Ac.png`)"
  56. alt=""
  57. v-else-if="isFullscreen && item.type === 5"
  58. />
  59. <img
  60. :src="require(`@/assets/img/Goods/inco${item.type}.png`)"
  61. alt=""
  62. v-else
  63. />
  64. <transition name="likeAddAnimate">
  65. <div class="likeMove" v-show="like && item.type === 3">+ 1</div>
  66. </transition>
  67. <p>
  68. {{ item.name }}
  69. </p>
  70. </div>
  71. </div>
  72. </div>
  73. <div
  74. class="box2"
  75. :style="`${leftList[1].done ? '' : 'height:0px;padding:0;opacity:0'}`"
  76. >
  77. <div class="swiper-container">
  78. <div class="swiper-wrapper" v-if="list.length">
  79. <div
  80. @click="cutGoods(index)"
  81. class="swiper-slide"
  82. v-for="(item, index) in list"
  83. :class="{ active: (acList === index && playing) || (clickBottomAc&&acList === index) }"
  84. :key="index"
  85. >
  86. <img :src="item.list[0].enter.cover" alt="" />
  87. <div
  88. class="plan"
  89. v-show="(acList === index && playing) || (clickBottomAc&&acList === index)"
  90. :style="{ width: progressPart + '%' }"
  91. ></div>
  92. <p
  93. :class="{
  94. txtActive: (acList === index && playing) || (clickBottomAc&&acList === index),
  95. }"
  96. >
  97. {{ item.name }}
  98. </p>
  99. </div>
  100. <div class="swiper-slide" style="pointer-events: none"></div>
  101. </div>
  102. <div class="swiper-scrollbar"></div>
  103. </div>
  104. </div>
  105. <!-- 分享页面 -->
  106. <div class="shareBox" :class="{ shareBoxShow: share }">
  107. <div class="shareMain">
  108. <div class="close" @click="share = false"></div>
  109. <h3>分享</h3>
  110. <p>
  111. 请使用手机扫描二维码或
  112. <br />
  113. 复制分享链接
  114. </p>
  115. <img src="@/assets/img/Goods/Rcode.jpg" alt="" />
  116. <div class="btnn" @click="copyPcTxt">复制分享链接</div>
  117. </div>
  118. </div>
  119. </div>
  120. </template>
  121. <script>
  122. import { addNumAPI } from "@/utils/api";
  123. import Swiper from "./swiper.js";
  124. export default {
  125. name: "Rbottom",
  126. components: {},
  127. props: ["acList", "progressPart", "playing", "clickBottomAc"],
  128. data() {
  129. //这里存放数据
  130. return {
  131. rightList: [
  132. { name: "首页", type: 1 },
  133. { name: "声音", type: 2 },
  134. { name: "点赞", type: 3 },
  135. { name: "分享", type: 4 },
  136. { name: "全屏", type: 5 },
  137. ],
  138. rightType: "",
  139. music: false,
  140. like: false,
  141. share: false,
  142. isFullscreen: false,
  143. // --------------
  144. leftList: [
  145. { name: "自动漫游", type: 1, done: false },
  146. { name: "场景导览", type: 2, done: false },
  147. { name: "全景漫游", type: 3, done: true },
  148. { name: "迷你模型", type: 4, done: false },
  149. { name: "顶部俯视", type: 5, done: false },
  150. ],
  151. list: [],
  152. Swiper: null,
  153. };
  154. },
  155. //监听属性 类似于data概念
  156. computed: {},
  157. //监控data中的数据变化
  158. watch: {
  159. acList(val) {
  160. let temp = val - 2;
  161. if (temp < 0) temp = 0;
  162. this.Swiper.slideTo(temp);
  163. },
  164. music(val) {
  165. let dom = document.querySelector("#bacMusic");
  166. if (val) dom.play();
  167. else dom.pause();
  168. },
  169. },
  170. //方法集合
  171. methods: {
  172. cutGoods(index) {
  173. this.$emit("update:clickBottomAc", false);
  174. this.$emit("daoLanCut", index);
  175. this.leftList[0].done = false;
  176. if (window.bacMusic) {
  177. setTimeout(() => {
  178. this.music = true;
  179. }, 100);
  180. }
  181. },
  182. leftCutClick(type) {
  183. this.$emit("cutKankan", type - 1);
  184. if (type === 1) {
  185. let dom = document.querySelector("#bacMusic");
  186. if (!this.leftList[0].done) {
  187. // 防止多次点击自动漫游
  188. let mainApp = document.querySelector("#app");
  189. mainApp.style.pointerEvents = "none";
  190. // 自动漫游开始的时候的音乐播放状态
  191. window.bacMusic = !dom.paused;
  192. setTimeout(() => {
  193. this.music = false;
  194. }, 200);
  195. } else {
  196. if (window.bacMusic) {
  197. setTimeout(() => {
  198. this.music = true;
  199. }, 100);
  200. }
  201. }
  202. this.leftList[1].done = true;
  203. this.leftList[0].done = !this.leftList[0].done;
  204. } else if (type === 2) {
  205. this.leftList[1].done = !this.leftList[1].done;
  206. } else if (type >= 4) {
  207. this.$emit("stopPlay", true);
  208. }
  209. },
  210. // 给父组件调用的控制音乐播放的方法
  211. opMusic(val) {
  212. this.music = val;
  213. },
  214. // 给父组件操作控制左边按钮的方法
  215. leftCut(index) {
  216. if (index > 2) {
  217. if (window.bacMusic) {
  218. setTimeout(() => {
  219. this.music = true;
  220. }, 100);
  221. }
  222. this.leftList.forEach((v, i) => {
  223. if (i === index) v.done = true;
  224. else v.done = false;
  225. });
  226. } else if (index === -1) {
  227. if (window.bacMusic) {
  228. setTimeout(() => {
  229. this.music = true;
  230. }, 100);
  231. }
  232. this.leftList[0].done = false;
  233. } else if (index === 2) {
  234. this.leftList[2].done = true;
  235. this.leftList[3].done = this.leftList[4].done = false;
  236. }
  237. },
  238. // 点击全屏
  239. fullShow() {
  240. let element = document.documentElement;
  241. if (this.isFullscreen) {
  242. if (document.exitFullscreen) {
  243. document.exitFullscreen();
  244. } else if (document.webkitCancelFullScreen) {
  245. document.webkitCancelFullScreen();
  246. } else if (document.mozCancelFullScreen) {
  247. document.mozCancelFullScreen();
  248. } else if (document.msExitFullscreen) {
  249. document.msExitFullscreen();
  250. }
  251. } else {
  252. if (element.requestFullscreen) {
  253. element.requestFullscreen();
  254. } else if (element.webkitRequestFullScreen) {
  255. element.webkitRequestFullScreen();
  256. } else if (element.mozRequestFullScreen) {
  257. element.mozRequestFullScreen();
  258. } else if (element.msRequestFullscreen) {
  259. element.msRequestFullscreen();
  260. }
  261. }
  262. // 改变当前全屏状态
  263. this.isFullscreen = !this.isFullscreen;
  264. },
  265. rightClisk(type) {
  266. if (type === 1) window.location.replace("/YHT/index.html");
  267. else if (type === 2) {
  268. let dom = document.querySelector("#bacMusic");
  269. window.bacMusic = dom.paused;
  270. this.music = !this.music;
  271. this.$emit("stopPlay");
  272. } else if (type === 3) {
  273. if (this.like) return;
  274. this.like = true;
  275. setTimeout(() => {
  276. this.like = false;
  277. }, 2000);
  278. addNumAPI("star");
  279. } else if (type === 4) {
  280. this.$emit("stopPlay");
  281. this.share = true;
  282. } else this.fullShow();
  283. },
  284. //点击复制链接
  285. copyPcTxt() {
  286. // 存储传递过来的数据
  287. let OrderNumber = window.location.origin + "/YHT/index.html";
  288. // 创建一个input 元素
  289. // createElement() 方法通过指定名称创建一个元素
  290. let newInput = document.createElement("input");
  291. // 讲存储的数据赋值给input的value值
  292. newInput.value = OrderNumber;
  293. // appendChild() 方法向节点添加最后一个子节点。
  294. document.body.appendChild(newInput);
  295. // 选中input元素中的文本
  296. // select() 方法用于选择该元素中的文本。
  297. newInput.select();
  298. // 执行浏览器复制命令
  299. // execCommand方法是执行一个对当前文档,当前选择或者给出范围的命令
  300. document.execCommand("Copy");
  301. // 清空输入框
  302. newInput.remove();
  303. alert("复制成功");
  304. },
  305. // 初始化轮播图
  306. baseSw(data) {
  307. this.list = data;
  308. this.$nextTick(() => {
  309. this.Swiper = new Swiper(".Rbottom .swiper-container", {
  310. slidesPerView: 9,
  311. spaceBetween: 25,
  312. scrollbar: {
  313. el: ".swiper-scrollbar",
  314. },
  315. });
  316. });
  317. },
  318. },
  319. //生命周期 - 创建完成(可以访问当前this实例)
  320. created() {},
  321. //生命周期 - 挂载完成(可以访问DOM元素)
  322. mounted() {
  323. // 监听esc事件
  324. document.addEventListener("webkitfullscreenchange", (e) => {
  325. if (!e.currentTarget.webkitIsFullScreen) this.isFullscreen = false;
  326. });
  327. document.addEventListener("fullscreenchange", (e) => {
  328. if (!document.fullscreenElement) this.isFullscreen = false;
  329. });
  330. document.addEventListener("MSFullscreenChange", (e) => {
  331. if (!document.msFullscreenElement) this.isFullscreen = false;
  332. });
  333. document.addEventListener("mozfullscreenchange", (e) => {
  334. if (!document.mozFullScreenElement) this.isFullscreen = false;
  335. });
  336. },
  337. beforeCreate() {}, //生命周期 - 创建之前
  338. beforeMount() {}, //生命周期 - 挂载之前
  339. beforeUpdate() {}, //生命周期 - 更新之前
  340. updated() {}, //生命周期 - 更新之后
  341. beforeDestroy() {}, //生命周期 - 销毁之前
  342. destroyed() {}, //生命周期 - 销毁完成
  343. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  344. };
  345. </script>
  346. <style lang='less' scoped>
  347. .swiper-scrollbar {
  348. height: 4px;
  349. background-color: #fff;
  350. overflow: hidden;
  351. }
  352. /deep/.swiper-scrollbar-drag {
  353. background-color: #930909;
  354. }
  355. @import "./swiper.css";
  356. .likeAddAnimate-enter-active,
  357. .likeAddAnimate-leave-active {
  358. transition: all 2s ease;
  359. }
  360. .likeAddAnimate-enter,
  361. .likeAddAnimate-leave {
  362. transform: translateY(0) scale(0);
  363. opacity: 0;
  364. }
  365. .likeAddAnimate-enter-to,
  366. .likeAddAnimate-leave-to {
  367. transform: translateY(-50px) scale(1.2);
  368. opacity: 1;
  369. }
  370. .Rbottom {
  371. transition: all 0.5s;
  372. z-index: 10;
  373. position: absolute;
  374. bottom: 24px;
  375. right: 0px;
  376. width: 100%;
  377. .box1 {
  378. padding: 0 25px;
  379. width: 100%;
  380. display: flex;
  381. justify-content: space-between;
  382. .mainrr {
  383. display: flex;
  384. .row {
  385. position: relative;
  386. cursor: pointer;
  387. width: 50px;
  388. text-align: center;
  389. margin-left: 18px;
  390. color: #fff;
  391. & > img {
  392. width: 50px;
  393. }
  394. p {
  395. font-size: 12px;
  396. }
  397. .likeMove {
  398. color: #930909;
  399. position: absolute;
  400. top: 10px;
  401. width: 100%;
  402. text-align: center;
  403. }
  404. }
  405. .active2 {
  406. color: #930909;
  407. font-weight: 700;
  408. p {
  409. font-size: 12px;
  410. }
  411. }
  412. }
  413. .mainll {
  414. .row {
  415. width: 80px;
  416. margin-left: 0;
  417. }
  418. }
  419. }
  420. .box2 {
  421. overflow: hidden;
  422. transition: height 0.5s;
  423. margin-top: 5px;
  424. width: 100%;
  425. height: 170px;
  426. background-color: #d8b275;
  427. padding: 15px 25px 0;
  428. .swiper-container {
  429. cursor: grab;
  430. height: 100%;
  431. .swiper-slide {
  432. cursor: pointer;
  433. height: 120px;
  434. img {
  435. width: 100%;
  436. height: 110px;
  437. object-fit: cover;
  438. }
  439. p {
  440. text-align: center;
  441. height: 30px;
  442. line-height: 30px;
  443. color: #ffffff;
  444. font-size: 14px;
  445. }
  446. .plan {
  447. height: 4px;
  448. background-color: #930909;
  449. }
  450. .txtActive {
  451. color: #930909;
  452. }
  453. }
  454. .active {
  455. img {
  456. border: 3px solid #930909;
  457. }
  458. }
  459. }
  460. }
  461. }
  462. .shareBox {
  463. z-index: 11;
  464. position: fixed;
  465. top: 0;
  466. left: 0;
  467. width: 100%;
  468. height: 100%;
  469. opacity: 0;
  470. pointer-events: none;
  471. backdrop-filter: blur(4px);
  472. transition: opacity 0.5s;
  473. .shareMain {
  474. padding: 40px 30px 0;
  475. position: absolute;
  476. top: 50%;
  477. left: 50%;
  478. transform: translate(-50%, -50%);
  479. width: 450px;
  480. height: 650px;
  481. background-image: url("../assets/img/Goods/shareBac.png");
  482. background-size: 100% 100%;
  483. text-align: center;
  484. .close {
  485. width: 48px;
  486. height: 48px;
  487. cursor: pointer;
  488. position: absolute;
  489. right: -24px;
  490. top: -24px;
  491. background-image: url("../assets/img/Goods/shareClose.png");
  492. background-size: 100% 100%;
  493. }
  494. h3 {
  495. text-align: left;
  496. color: #d8b275;
  497. font-size: 24px;
  498. margin-bottom: 50px;
  499. }
  500. p {
  501. font-size: 20px;
  502. color: #ffffff;
  503. margin-bottom: 40px;
  504. }
  505. img {
  506. width: 240px;
  507. margin-bottom: 50px;
  508. }
  509. .btnn {
  510. cursor: pointer;
  511. width: 280px;
  512. margin: 0 auto;
  513. height: 60px;
  514. border-radius: 30px;
  515. border: 2px solid #d8b275;
  516. line-height: 58px;
  517. font-size: 20px;
  518. color: #ffffff;
  519. }
  520. }
  521. }
  522. .shareBoxShow {
  523. opacity: 1;
  524. pointer-events: auto;
  525. }
  526. </style>