.wxml
.wxss
.greetings{
background: #ffffff;
margin: 15rpx;
height: 100%;
overflow: hidden;
}
.music {
display: flex;
flex-direction: row;
justify-content: flex-end;
margin: 30rpx;
position: fixed;
top:150rpx;
right: 15rpx;
z-index: 2000;
}
.music image {
width: 50rpx;
height: 50rpx;
transition: All 0.4s ease-in-out;
}
@-webkit-keyframes rotation{
from {-webkit-transform: rotate(0deg);}
to {-webkit-transform: rotate(360deg);}
}
.auto{
-webkit-transform: rotate(360deg);
animation: rotation 3s linear infinite;
-moz-animation: rotation 3s linear infinite;
-webkit-animation: rotation 3s linear infinite;
-o-animation: rotation 3s linear infinite;
}
.js
onReady:function(){
this.audioCtx = wx.createAudioContext('greetings');
this.audioCtx.play()
},
autoMusic:function(e){
var that = this;
that.setData({
auto:!that.data.auto
});
if(that.data.auto){
this.audioCtx.pause()
}else{
this.audioCtx.play()
}
},