提交 84bfee97 编写于 作者: C chenruilong

fix(uni-id-co): 修复 微信登录时用户未设置头像的报错问题

上级 de9fd580
...@@ -120,6 +120,8 @@ module.exports = async function (params = {}) { ...@@ -120,6 +120,8 @@ module.exports = async function (params = {}) {
accessToken, accessToken,
openid openid
}) })
if (avatar) {
// eslint-disable-next-line n/no-deprecated-api // eslint-disable-next-line n/no-deprecated-api
const avatarPath = url.parse(avatar).pathname const avatarPath = url.parse(avatar).pathname
const extName = avatarPath.indexOf('.') > -1 ? url.parse(avatar).pathname.split('.').pop() : 'jpg' const extName = avatarPath.indexOf('.') > -1 ? url.parse(avatar).pathname.split('.').pop() : 'jpg'
...@@ -130,19 +132,23 @@ module.exports = async function (params = {}) { ...@@ -130,19 +132,23 @@ module.exports = async function (params = {}) {
errCode: ERROR.GET_THIRD_PARTY_USER_INFO_FAILED errCode: ERROR.GET_THIRD_PARTY_USER_INFO_FAILED
} }
} }
const { const {
fileID fileID
} = await uniCloud.uploadFile({ } = await uniCloud.uploadFile({
cloudPath, cloudPath,
fileContent: getAvatarRes.data fileContent: getAvatarRes.data
}) })
extraData.nickname = nickname
extraData.avatar_file = { extraData.avatar_file = {
name: cloudPath, name: cloudPath,
extname: extName, extname: extName,
url: fileID url: fileID
} }
} }
extraData.nickname = nickname
}
await saveWeixinUserKey.call(this, { await saveWeixinUserKey.call(this, {
openid, openid,
sessionKey, sessionKey,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册