? function gameLogin()
? ? {
? ? ? ? wx.login(
? ? ? ? {
? ? ? ? ? ? success: (res) =>?
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if (res.code)?
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? code= res.code;
? ? ? ? ? ? ? ? ? ? console.log("登陸成功,獲取到code")
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? var button = wx.createUserInfoButton(
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? type: 'text',
? ? ? ? ? ? ? ? ? ? text: '點(diǎn)擊進(jìn)入游戲',
? ? ? ? ? ? ? ? ? ? style:?
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? left: wx.getSystemInfoSync().windowWidth/2-70,
? ? ? ? ? ? ? ? ? ? ? ? bottom: wx.getSystemInfoSync().windowHeight/2,
? ? ? ? ? ? ? ? ? ? ? ? width: 140,
? ? ? ? ? ? ? ? ? ? ? ? height: 40,
? ? ? ? ? ? ? ? ? ? ? ? lineHeight: 40,
? ? ? ? ? ? ? ? ? ? ? ? backgroundColor: '#ff0000',
? ? ? ? ? ? ? ? ? ? ? ? color: '#ffffff',
? ? ? ? ? ? ? ? ? ? ? ? textAlign: 'center',
? ? ? ? ? ? ? ? ? ? ? ? fontSize: 16,
? ? ? ? ? ? ? ? ? ? ? ? borderRadius: 4
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? })
? ? ? ? ? ? ? ? button.onTap((res) =>?
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? if(res.errMsg=="getUserInfo:ok")
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? console.log("授權(quán)用戶信息")
? ? ? ? ? ? ? ? ? ? ? ? //獲取到用戶信息
? ? ? ? ? ? ? ? ? ? ? ? wxUserHead = res.userInfo.avatarUrl
? ? ? ? ? ? ? ? ? ? ? ? wxUserName = res.userInfo.nickName
? ? ? ? ? ? ? ? ? ? ? ? LayaSample.gameLoad.toStartGame()
? ? ? ? ? ? ? ? ? ? ? ? //清除微信授權(quán)按鈕
? ? ? ? ? ? ? ? ? ? ? ? button.destroy()
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? console.log("授權(quán)失敗")
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? })
? ? ? ? ? ? }
? ? ? ? })