< button class = " bottom size_30" type = " primary" lang = " zh_CN" @click = " getUserInfo" > 一键登录</ button>
//第一授权获取用户信息===》按钮触发getUserInfo() {// 展示加载框uni.showLoading({title: '加载中',});uni.getUserProfile({desc: '登录后可同步数据',success: async (obj) => {uni.login({provider: 'weixin',success: (res) => {uni.getUserInfo({provider: 'weixin',success: (info) => { //这里请求接口const data = {code: res.code,userPhoto: info.userInfo.avatarUrl}addEditUser(data).then(res => {if (res.code == 200) {uni.setStorageSync('token', res.data.token);uni.setStorageSync('peopleInfo', res.data.userEntity);uni.reLaunch({ //信息更新成功后跳转到小程序首页url: '/pages/home/index'});}})},fail: () => {uni.showToast({title: "微信登录授权失败",icon: "none"});}})},});},fail: () => {uni.showToast({title: '授权已取消',icon: 'error',mask: true,});},complete: () => {// 隐藏loadinguni.hideLoading();},});},