1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<template>
<div class="refueling2" :style="{backgroundImage:`url(${imgUrl.refueling1.bg})`}">
<div class="bg-block">
<img :src="imgUrl.refueling1.title" class="title">
<audio v-if="nowLesson.content.radio.length" :src="nowLesson.content.radio[0].url" autoplay ref="jiayouAudio"></audio>
<div class="content-img" :style="{backgroundImage:nowLesson.content.banner[0] ? `url(${nowLesson.content.banner[0].url}`:''}">
<img :src="imgUrl.refueling2.radio" class="radio-icon" @click="playJiayou()">
<img :src="imgUrl.refueling2.back" class="left-icon" @click="goNext(nowLesson.content.lastIndex)"/>
<img :src="imgUrl.refueling2.next" class="right-icon" v-if="nowLesson.content.nextIndex !== -1" @click="goNext(nowLesson.content.nextIndex)"/>
</div>
</div>
<div class="bottom-block">
</div>
</div>
</template>
<script>
import {refueling1,refueling2} from "../../util/imgUrl";
export default {
name: "refueling2",
props:[
'nowLesson'
],
data(){
return{
imgUrl:{
refueling1:refueling1,
refueling2:refueling2
}
}
},
methods:{
goNext(i){
this.$emit('goNext',i)
},
// 播放加油包音频
playJiayou(){
if(this.$refs.jiayouAudio.paused){
this.$refs.jiayouAudio.play()
}else{
this.$refs.jiayouAudio.pause()
}
},
},
watch:{
'nowLesson'(){
let voice = this.$refs.jiayouAudio;
let that = this;
wx.ready(function () {
that.$nextTick(()=> {
wx.ready(function () {
that.$nextTick(()=>{
if (typeof WeixinJSBridge === "object" && typeof WeixinJSBridge.invoke === "function") {
voice.play();
} else {
//監聽客户端抛出事件"WeixinJSBridgeReady"
if (document.addEventListener) {
document.addEventListener("WeixinJSBridgeReady", function(){
voice.play();
}, false);
} else if (document.attachEvent) {
document.attachEvent("WeixinJSBridgeReady", function(){
voice.play();
});
document.attachEvent("onWeixinJSBridgeReady", function(){
voice.play();
});
}
}
wx.ready(()=>{
that.$refs.jiayouAudio.play()
})
})
})
})
})
}
}
}
</script>
<style scoped lang="less">
@import "../../util/public";
.refueling2{
height: 100%;
overflow: hidden;
width: 100%;
background-size: 100% 100%;
.bg-block{
width: 1154/2 * @toVw;
height: 690/2 * @toVw;
transform-origin: 355/2 * @toVw 370/2 * @toVw;
transform: rotate(90deg);
background: white;
text-align: center;
.title{
position: relative;
top: -30/2 * @toVw;
width: 560 / 2 * @toVw;
}
.content-img{
width: 1078/2 * @toVw;
height: 550/2 * @toVw;
margin: -40/2 * @toVw auto 0 auto;
background: black;
position: relative;
border-radius: 8/2 * @toVw;
background-size: 100% 100%;
.radio-icon{
width: 32 * @toVw;
position: absolute;
bottom: 20/2 * @toVw;
left: 20/2 * @toVw;
}
.left-icon{
position: absolute;
top: 50%;
width: 32 * @toVw;
margin-top: -30/2 * @toVw;
left: 20/2 * @toVw;
}
.right-icon{
position: absolute;
top: 50%;
width: 32 * @toVw;
margin-top: -30/2 * @toVw;
right: 20/2 * @toVw;
}
}
}
}
</style>