用户首次登陆一直在获取头像处转圈,点确定无法登陆,真机调试可以正常登陆,发布后就一直在获取头像处转圈,是什么原因?HBuilder X 3.6.15,在此处点关闭能登陆成功,后台用户信息显示为匿名微信用户
uni-id-pages-user-profile文件中的获取头像方法
async getUserProfile(){
uni.showLoading();
let res = await new Promise((callBack) => {
uni.getUserProfile({
desc: "用于设置账户昵称和头像",
success: (e) => {
console.log("getUserProfile:", e);
callBack(e)
}
})
})
// console.log("userInfo", res.userInfo);
if(res.errMsg != "getUserProfile:ok"){
return this.closeMe()
}
let {avatarUrl,nickName} = res.userInfo;
let tempFilePath = await new Promise((callBack)=>{
uni.downloadFile({
url: avatarUrl,
success: (res) => {
if (res.statusCode === 200) {
// console.log('下载成功');
callBack(res.tempFilePath)
}
callBack()
},
fail: (err) => {
console.error(err)
},
complete: (e) => {
// console.log("downloadFile",e);
}
});
})
const extName = tempFilePath.split('.').pop() || 'jpg'
const cloudPath = 'user/avatar/'+ userId+'/'+Date.now()+'-avatar.'+extName;
// console.log(tempFilePath);
const result = await uniCloud.uploadFile({
filePath: tempFilePath,
cloudPath,
fileType:'image'
});
// console.log("上传成功",{result});
let userInfo = {
"nickname":nickName,
"avatar_file":{
name:cloudPath,
extname:"jpg",
url:result.fileID
}
}
this.doUpdate(userInfo,()=>{
this.$refs.popup.close()
})
},