首先首页我们要完成的功能有:
左上角图片,点击图片播放指定音乐,图片并跟着一起360旋转
右下角,授权登陆,授权登陆成功后才会挑选下一页面,否则重新授权登陆
//index.js
const app = getApp()
const innerAudioContext = wx.createInnerAudioContext()
Page({
data: {
b2 : 'b3',
ss : 1
},
UserClick:function(event){
wx.getSetting({
success(res){
console.log(res.authSetting['scope.userInfo'])
if (res.authSetting['scope.userInfo']==true){
wx.navigateTo({
url:'../camera/camera',
})
wx.authorize({
scope: 'scope.userinfo',
success:function(){
wx.getUserInfo({
success(res){
},
fail:function(err){
console.log(err)} })
}
})
}
}
})
},
clickimg:function(){
var ss = this.data.ss;
if(ss === 1){
innerAudioContext.play()
this.setData({
b2 : 'b2',
ss : 2
})
}else{
innerAudioContext.pause()
this.setData({
b2 : 'b3',
ss : 1
})
}
},
//事件处理函数
bindViewTap: function() {
},
onLoad: function () {
innerAudioContext.autoplay = false
innerAudioContext.src = 'http://antiserver.kuwo.cn/anti.s?useless=/resource/&format=mp3&rid=MUSIC_144541061&response=res&type=convert_url&' innerAudioContext.onPlay(() => {
console.log('开始播放')
})
innerAudioContext.onError((res) => {
console.log(res.errMsg)
console.log(res.errCode)
})
innerAudioContext.onPause( () =>{
console.log('停止播放')
}
)
},
getUserInfo: function(e) {
},
// onShow:function(){
// this.onLoad(); // },})
<!--index.wxml-->
<image class="b1" src="../images/1.jpg"></image>
<button class="n1" size="mini" open-type="getUserInfo" bindgetuserinfo="UserClick">请授权</button>
<image class=