|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- <template>
- <div id="app">
- <transition name="fade">
- <router-view />
- </transition>
- <btn-music :bgLoop="bgLoop"></btn-music>
- <!-- <sidebar style="position: absolute;top: 20vw;left: 10vw;"></sidebar> -->
- </div>
- </template>
- <script>
- let allPage = [];//所有可滑动的页面
- let stopSliding = [];//仅可向上或向下滑动的页面
- let startPage=[];
- let endPage=[];
- let siteRecord = 0;
- import BtnMusic from './components/music.vue'
- // import Sidebar from './components/sidebar.vue'
- export default {
- name: 'APP',
- data() {
- return {
- btnAudio: null,
- bgLoop: false,
- }
- },
- components: {
- BtnMusic
- },
- mounted() {
- var that = this;
- this.bgAudio=window['bgAudio'];
- this.bgLoop=window['bgLoop'];
- if(!this.bgLoop){
- this.bgAudio.removeEventListener('play',window['openLoop']);
- }
- this.bgAudio.addEventListener('play', function() {
- that.bgLoop = true;
- })
- this.bgAudio.addEventListener('pause', function() {
- that.bgLoop = false;
- })
- // this.calculateJumpRules();
- },
- methods: {
- playMusic() {
- if (this.bgLoop) { //暂停
- this.bgAudio.pause();
- } else { //播放
- this.bgAudio.play();
- }
- },
- // startEvent(e){
- // siteRecord=0;
- // var _y= e.changedTouches[0].clientY;
- // siteRecord=_y;
- // var type = e.target.dataset.type;
- // },
- // endEvent(e){//抬起事件
- // var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
- // let direction = "";//可滑动的方向
- // //获取当前页面路径
- // let path = this.$route.path;
- // //判断是否在可滑动切换页面的列表中
- // if(allPage.indexOf(path)==-1 || scrollTop){
- // return;
- // }
- // //判断是否只可向一个方向滑动
- // for(let i=0;i<stopSliding.length;i++){
- // if(stopSliding[i]["page"]==path){
- // direction = stopSliding[i]['direction'];
- // break;
- // }
- // }
- // var _y= e.changedTouches[0].clientY;
- // if(direction=="next"){
- // if(siteRecord-_y>=50){
- // console.log("只能换到下一页");
- // this.$router.replace(allPage[allPage.indexOf(path)+1]);
- // }
- // }else if(direction=="prev"){
- // if(siteRecord-_y<-50){
- // console.log("只能换到上一页");
- // this.$router.replace(allPage[allPage.indexOf(path)-1]);
- // }
- // }else{
- // if(siteRecord-_y>=50){
- // console.log("下一页");
- // console.log(allPage)
- // console.log(path)
- // console.log(allPage[allPage.indexOf(path)-1])
- // // return;
- // this.$router.replace(allPage[allPage.indexOf(path)+1]);
- // }else if(siteRecord-_y<-50){
- // console.log("上一页");
- // this.$router.replace(allPage[allPage.indexOf(path)-1]);
- // }
- // }
- // },
- calculateJumpRules(){
- let pagePath = this.$store.state.pagePath;
- for(let i=0;i<pagePath.length;i++){
- for(let j=0;j<pagePath[i].length;j++){
- for(let key in pagePath[i][j]){
- if(pagePath[i][j][key]){
- allPage.push(pagePath[i][j][key]);
- }
- }
- stopSliding.push({page:pagePath[i][j]['店外'],direction:"next"});
- stopSliding.push({page:pagePath[i][j]['浏览全部物料'],direction:"prev"});
- endPage.push({page:pagePath[i][j]['浏览全部物料'],direction:"prev"});
- }
- }
- }
- }
- }
- </script>
-
- <style lang="scss">
- * {
- margin: 0;
- padding: 0;
- }
-
- html,
- body {
- position: absolute;
- width: 100%;
- height: 100%;
- background-color: #3f4447;
- }
-
- body {
- -webkit-touch-callout: none;
- -webkit-user-select: none;
- -khtml-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;
- }
-
- img {
- display: block;
- }
-
- #app {
- position: relative;
- height: 100%;
- text-align: center;
- }
-
- .middleContainer {
- position: absolute;
- width: 100%;
- height: calc(1206/750*100vw);
- left: 50%;
- top: 50%;
- transform: translate(-50%, -50%);
- }
-
- .showBg {
- position: absolute;
- width: 100%;
- left: 50%;
- top: 50%;
- transform: translate(-50%, -50%);
- }
- .fade-enter-active, .fade-leave-active {
- transition: opacity .5s;
- }
- .fade-enter, .fade-leave-to{
- opacity: 0;
- }
- </style>
|