buttonclick:function(event){
? ? ? ? let exportJson = {};
? ? ? ? let sysInfo = window.wx.getSystemInfoSync();
? ? ? ? //獲取微信界面大小
? ? ? ? let width = sysInfo.screenWidth;
? ? ? ? let height = sysInfo.screenHeight;
? ? ? ? window.wx.login({
? ? ? ? ? ? success: (res) => {
? ? ? ? ? ? ? ? if (res.code) {
? ? ? ? ? ? ? ? ? ? console.log("res.code:", res);
? ? ? ? ? ? ? ? ? ? exportJson.code = res.code;//向服務端傳遞code用于獲取微信小游戲的用戶唯一標識
? ? ? ? ? ? ? ? ? ? window.wx.getSetting({
? ? ? ? ? ? ? ? ? ? ? ? success (res) {
? ? ? ? ? ? ? ? ? ? ? ? ? ? console.log(res.authSetting);
? ? ? ? ? ? ? ? ? ? ? ? ? ? if (res.authSetting["scope.userInfo"]) {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? console.log("用戶已授權");
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? window.wx.getUserInfo({
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? success(res){
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? console.log(res);
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? exportJson.userInfo = res.userInfo;
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //此時可進行登錄操作
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? });
? ? ? ? ? ? ? ? ? ? ? ? ? ? }else {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? console.log("用戶未授權");
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? let button = window.wx.createUserInfoButton({
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? type: 'text',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? text: '',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? style: {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? left: 0,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? top: 0,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? width: width,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? height: height,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? backgroundColor: '#00000000',//最后兩位為透明度
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? color: '#ffffff',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? fontSize: 20,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? textAlign: "center",
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? lineHeight: height,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? });
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? button.onTap((res) => {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? if (res.userInfo) {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? console.log("用戶授權:", res);
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? exportJson.userInfo = res.userInfo;
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //此時可進行登錄操作
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? button.destroy();
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }else {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? console.log("用戶拒絕授權:", res);
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? });
? ? ? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? })
? ? ? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? ? ? console.log('登錄失?。? + res.errMsg)
? ? ? ? ? ? ? ? }
? ? ? ? ? ? },
? ? ? ? });
? ? },