|
@@ -10,6 +10,7 @@ import { Task1,Task1Vue } from './task1'
|
|
|
import { Task2,Task2Vue } from './task2'
|
|
|
import bgm from '../audio/primary-bgm.mp3'
|
|
|
const util = require('./util.js')
|
|
|
+const isWX = navigator.userAgent.toLowerCase().match(/micromessenger/i) == "micromessenger"
|
|
|
|
|
|
let app = new Vue({
|
|
|
el: '#app',
|
|
@@ -22,7 +23,8 @@ let app = new Vue({
|
|
|
vidsSource: [],
|
|
|
swiperIndex : 0,//页面下标 [Int]
|
|
|
sound: null,//背景音乐 [DOM]
|
|
|
- stopSound: 0,//背景音乐停止 [Enum]
|
|
|
+ stopSound: 1,//背景音乐停止 [Enum]
|
|
|
+ isInitSound : false,
|
|
|
|
|
|
introIndex : 0,//任务下标
|
|
|
task1: Object.assign({}, Task1),
|
|
@@ -47,18 +49,26 @@ let app = new Vue({
|
|
|
|
|
|
},
|
|
|
beforeMount() {
|
|
|
- this.sound = new Howl({
|
|
|
- src: [bgm],
|
|
|
- loop: true,
|
|
|
- volume: 1
|
|
|
- })
|
|
|
- mediaCtrl.play(this.sound)
|
|
|
+ //微信
|
|
|
+ document.addEventListener("WeixinJSBridgeReady", () =>{
|
|
|
+ this.initSound();
|
|
|
+ }, false);
|
|
|
},
|
|
|
mounted() {
|
|
|
this.loaderVideoSource()
|
|
|
this.checkOrientation()
|
|
|
},
|
|
|
methods: Object.assign({}, {
|
|
|
+ initSound(){
|
|
|
+ this.stopSound = 0
|
|
|
+ this.isInitSound = true
|
|
|
+ this.sound = new Howl({
|
|
|
+ src: [bgm],
|
|
|
+ loop: true,
|
|
|
+ volume: 1
|
|
|
+ })
|
|
|
+ mediaCtrl.play(this.sound)
|
|
|
+ },
|
|
|
getVideoSource(videoRef, vids) {
|
|
|
return axios.get(`//video.duowan.com/jsapi/playPageVideoInfo/?vids=${vids.join(',')}`)
|
|
|
.then(({ data }) => {
|
|
@@ -94,6 +104,14 @@ let app = new Vue({
|
|
|
await this.getVideoSource(videoRef2, vids2)
|
|
|
await this.getVideoSource(videoRef3, vids3)
|
|
|
},
|
|
|
+ startGame(){
|
|
|
+ console.log(!isWX && !this.isInitSound)
|
|
|
+ if(!isWX && !this.isInitSound) {
|
|
|
+ this.initSound()
|
|
|
+ }
|
|
|
+
|
|
|
+ this.slideTo(2)
|
|
|
+ },
|
|
|
startTask() {
|
|
|
this.slideTo(this.introIndex+3)
|
|
|
},
|
|
@@ -131,9 +149,6 @@ let app = new Vue({
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
- /**初始化首屏 */
|
|
|
- initPregame() {
|
|
|
- },
|
|
|
/**
|
|
|
* 更改video状态 play | pause
|
|
|
*/
|
|
@@ -175,7 +190,7 @@ let app = new Vue({
|
|
|
if (this.stopSound) return
|
|
|
if (bgmCtrl[newVal] == 0) {
|
|
|
mediaCtrl.pause(this.sound)
|
|
|
- } else {
|
|
|
+ } else if (mediaCtrl.media != this.sound) {
|
|
|
this.transitionEnd(() => {
|
|
|
mediaCtrl.play(this.sound)
|
|
|
})
|
|
@@ -286,6 +301,10 @@ let app = new Vue({
|
|
|
this.swiperIndex = 5
|
|
|
}
|
|
|
},
|
|
|
+ resetTaskData(index) {
|
|
|
+ var Task = [null, Task1, Task2]
|
|
|
+ this[`task${index}`] = Object.assign({}, Task[index])
|
|
|
+ },
|
|
|
//返回游戏主页
|
|
|
toGamePage() {
|
|
|
let curSwiperIndex = this.swiperIndex
|
|
@@ -341,15 +360,6 @@ let app = new Vue({
|
|
|
},
|
|
|
})
|
|
|
},
|
|
|
- checkTask1NavBar(index) {
|
|
|
- const showNavBar = [0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0]
|
|
|
-
|
|
|
- if (this.swiperIndex <= 2) {
|
|
|
- this.showNavBar = 1
|
|
|
- } else {
|
|
|
- this.showNavBar = showNavBar[index]
|
|
|
- }
|
|
|
- },
|
|
|
checkTask2NavBar(index) {
|
|
|
const showNavBar = [1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
|
|
|
|
|
@@ -378,10 +388,8 @@ let app = new Vue({
|
|
|
},
|
|
|
watch: {
|
|
|
swiperIndex(newVal, oldVal) {
|
|
|
- const showNavBar = [1, 0, 1, 0]
|
|
|
+ const showNavBar = [1, 0, 1, 0, 0, 0,1]
|
|
|
switch (newVal) {
|
|
|
- case 1: this.initPregame()
|
|
|
- break
|
|
|
}
|
|
|
this.handleBgm(newVal)
|
|
|
|