|
@@ -91,6 +91,27 @@ Page({
|
|
|
this.userLogin()
|
|
|
},
|
|
|
|
|
|
+ // 获取用户头像和昵称权限 该api将于2022年10月25号之后失效
|
|
|
+ getUserinfo () {
|
|
|
+ var that = this
|
|
|
+ wx.getUserProfile({
|
|
|
+ desc: '用于获取用户权益'
|
|
|
+ }).then(res => {
|
|
|
+ const _avatarUrl = res.userInfo.avatarUrl
|
|
|
+ const _nickName = res.userInfo.nickName
|
|
|
+ that.setData({
|
|
|
+ avatarUrl: _avatarUrl,
|
|
|
+ nickname: _nickName
|
|
|
+ })
|
|
|
+ that.handleConfirmNickname()
|
|
|
+ }).catch(e => {
|
|
|
+ wx.showToast({
|
|
|
+ title: '获取授权失败',
|
|
|
+ icon: 'error'
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
// 退出登录后重新登录
|
|
|
handleReLogin () {
|
|
|
this.userLogin()
|
|
@@ -115,8 +136,10 @@ Page({
|
|
|
app.globalData.userInfo.headImg= res.data.headImg
|
|
|
app.globalData.userInfo.userName = res.data.userName
|
|
|
app.globalData.userInfo.phoneNumber = res.data.phoneNumber
|
|
|
+ const resIsNeedPhone = res.data.isNeedPhone
|
|
|
+ const resHeadImg = res.data.headImg
|
|
|
that.getAccountNmberFn()
|
|
|
- if (!res.data.isNeedPhone && res.data.headImg !== '') {
|
|
|
+ if (!resIsNeedPhone && resHeadImg !== '') {
|
|
|
app.globalData.userInfo.login = true
|
|
|
that.setData({
|
|
|
isNeedHeadImgBtn: true,
|
|
@@ -124,12 +147,12 @@ Page({
|
|
|
confirmNickname: app.globalData.userInfo.userName,
|
|
|
})
|
|
|
} else {
|
|
|
- if (res.data.isNeedPhone) { // true 代表需要手机号授权
|
|
|
+ if (resIsNeedPhone) { // true 代表需要手机号授权
|
|
|
that.setData({
|
|
|
isNeedPhoneBtn: true
|
|
|
})
|
|
|
} else {
|
|
|
- if (res.data.headImg == '') {
|
|
|
+ if (resHeadImg == '') {
|
|
|
// 需要授权头像
|
|
|
that.setData({
|
|
|
overshow: true,
|
|
@@ -154,6 +177,8 @@ Page({
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+
|
|
|
+ // 获取用户剩余检测机会
|
|
|
getAccountNmberFn () {
|
|
|
var that = this
|
|
|
getAccountNmber({}).then(res => {
|
|
@@ -162,8 +187,15 @@ Page({
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
+
|
|
|
+ // 用户本地选择图片头像
|
|
|
onChooseAvatar(e) {
|
|
|
- const { avatarUrl } = e.detail
|
|
|
+ const { avatarUrl } = e.detail
|
|
|
+ this.uploadImg(avatarUrl)
|
|
|
+ },
|
|
|
+
|
|
|
+ // 上传用户头像文件到后台
|
|
|
+ uploadImg (avatarUrl) {
|
|
|
var that = this
|
|
|
var data = {
|
|
|
filePath: avatarUrl
|
|
@@ -246,7 +278,7 @@ Page({
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
- // 绑定用户头像和昵称
|
|
|
+ // 提交用户头像和昵称到后台
|
|
|
handleConfirmNickname () {
|
|
|
var that = this
|
|
|
if (that.data.avatarUrl == '') {
|