export async function getUserProfileFunction() {
return new Promise(async (resolve, reject) => {
let { nickName = '' } = wx.getStorageSync('airRabbit-userinfo-new') || {};
let { userInfo } = wx.getStorageSync('airRabbit-userinfo') || {};
if (userInfo.nickName === '微信用户' && !nickName) {
console.log('微信用户');
wx.showModal({
title: '提示',
content: '二兔开门小程序请求获取您的昵称和头像信息',
success: (s) => {
if (s.confirm) {
wx.getUserProfile({
desc: '您的信息用户二兔开门小程序',
success: (m) => {
console.info('----getUserProfile----', m);
wx.setStorageSync('airRabbit-userinfo-new', m.userInfo);
resolve();
},
});
}
},
});
} else {
console.log('用户信息自动写入', userInfo);
if (userInfo.nickName != '微信用户') {
wx.setStorageSync('airRabbit-userinfo-new', userInfo);
}
resolve();
}
});
}