123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <template>
- <view class="container">
- <view class="changeAudio" :class="[audioState?'changeAudioPlay':'']" @click="changeAudio">
- <image :src="audioImgA" v-show="audioState" mode="aspectFit"></image>
- <image :src="audioImgB" v-show="!audioState" mode="aspectFit"></image>
- </view>
- <view class="h5box">
- <web-view :webview-styles="webviewStyles" :src="webUrl"></web-view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- audioImgA: "https://dadu.ispush.com/static/zhongduxiu/img/audioOn.png",
- audioImgB: "https://dadu.ispush.com/static/zhongduxiu/img/audioOff.png",
- audioUrl: "",
- webUrl: "https://dadu.ispush.com/api/getHtml",
- audioState: false,
- innerAudioContext: ""
- }
- },
- methods: {
- createAudio() {
- this.innerAudioContext = uni.createInnerAudioContext()
- this.innerAudioContext.autoplay = true
- this.innerAudioContext.loop = true
- this.innerAudioContext.src = `${this.$g.baseUrl}/static/zhongduxiu/audio/audio.mp3`
- },
- changeAudio() {
- if (this.audioState) {
- this.innerAudioContext.pause()
- } else {
- this.innerAudioContext.play()
- }
- this.audioState = !this.audioState
- },
- },
- created() {
- this.createAudio()
- },
- onHide() {
- this.audioState = false
- this.innerAudioContext.pause()
- clearInterval(this.T)
- },
- onShow(){
- if (this.innerAudioContext) {
- this.audioState = true
- this.innerAudioContext.play()
- }
- }
-
- }
- </script>
- <style scoped>
- .conatiner {
- position: relative;
- width: 100vw;
- height: 100vh;
- }
- .container .changeAudio {
- position: absolute;
- right: 45rpx;
- top: 105rpx;
- width: 47rpx;
- height: 47rpx;
- }
- .container .changeAudio image {
- width: 100%;
- height: 100%;
- }
- .container .changeAudioPlay {
- animation: 1s changeAudioAnime linear infinite;
- }
- @keyframes changeAudioAnime {
- from {
- transform: rotate(0deg);
- }
- to {
- transform: rotate(360deg);
- }
- }
- .container .h5box{
- position: absolute;
- top: 0;
- left: 0;
- width: 100vw;
- height: 100vh;
-
- }
- </style>
|