<button open-type="getUserInfo" @getuserinfo="getUserInfo">登录</button>
methods: { getUserInfo: function(e) {
console.log(e) wx.setStorageSync("nickname", e.mp.detail.userInfo.nickName); wx.setStorageSync("avatarUrl", e.mp.detail.userInfo.avatarUrl); }, login() { if (!wx.getStorageSync("nickname")) { wx.login({ success: function(res) {
console.log(res)
} }); } } }, created() { this.login(); },