|
|
@ -37,42 +37,44 @@ Page({ |
|
|
|
onShow: function () { |
|
|
|
this.getUserInfo() |
|
|
|
}, |
|
|
|
isAuthUserInfo () { |
|
|
|
let that = this |
|
|
|
wx.showLoading() |
|
|
|
console.log('未授权') |
|
|
|
return new Promise(resolve => { |
|
|
|
wx.getSetting({ |
|
|
|
success (res) { |
|
|
|
if (res.authSetting['scope.userInfo']) { |
|
|
|
// 已经授权,可以直接调用 getUserInfo 获取头像昵称
|
|
|
|
wx.getUserInfo({ |
|
|
|
success: function (res) { |
|
|
|
// isAuthUserInfo () {
|
|
|
|
// let that = this
|
|
|
|
// wx.showLoading()
|
|
|
|
// console.log('未授权')
|
|
|
|
// return new Promise(resolve => {
|
|
|
|
// wx.getSetting({
|
|
|
|
// success (res) {
|
|
|
|
// if (res.authSetting['scope.userInfo']) {
|
|
|
|
// // 已经授权,可以直接调用 getUserInfo 获取头像昵称
|
|
|
|
// wx.getUserInfo({
|
|
|
|
// success: function (res) {
|
|
|
|
|
|
|
|
let nickName = res.userInfo.nickName |
|
|
|
let avatarUrl = res.userInfo.avatarUrl |
|
|
|
// let nickName = res.userInfo.nickName
|
|
|
|
// let avatarUrl = res.userInfo.avatarUrl
|
|
|
|
|
|
|
|
store.saveUserInfo({ |
|
|
|
nickName: nickName, |
|
|
|
avatarUrl: avatarUrl, |
|
|
|
phone: '' |
|
|
|
}) |
|
|
|
// store.saveUserInfo({
|
|
|
|
// nickName: nickName,
|
|
|
|
// avatarUrl: avatarUrl,
|
|
|
|
// phone: ''
|
|
|
|
// })
|
|
|
|
|
|
|
|
if (nickName && avatarUrl) { |
|
|
|
that.setData({ |
|
|
|
isAuth: false |
|
|
|
}, () => { |
|
|
|
wx.hideLoading() |
|
|
|
}) |
|
|
|
} |
|
|
|
that.getUserInfo() |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
// if (nickName && avatarUrl) {
|
|
|
|
// that.setData({
|
|
|
|
// isAuth: false
|
|
|
|
// }, () => {
|
|
|
|
// wx.hideLoading()
|
|
|
|
// })
|
|
|
|
// }
|
|
|
|
// that.getUserInfo()
|
|
|
|
// }
|
|
|
|
// })
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// })
|
|
|
|
// })
|
|
|
|
// },
|
|
|
|
|
|
|
|
// 授权登录
|
|
|
|
bindGetUserInfo (e) { |
|
|
|
console.log(e.detail.userInfo) |
|
|
|
if (e.detail.userInfo){ |
|
|
@ -82,17 +84,16 @@ Page({ |
|
|
|
this.updateUserInfo(avatarUrl,nickName) |
|
|
|
} |
|
|
|
}, |
|
|
|
hasBindUserInfo () { |
|
|
|
return store.hasBindUserInfo(); |
|
|
|
}, |
|
|
|
|
|
|
|
// 将用户信息发送服务器
|
|
|
|
updateUserInfo (avatarUrl, nickName) { |
|
|
|
userModel.updateUserInfo(avatarUrl, nickName, res => { |
|
|
|
if(res.code === 200){ |
|
|
|
this.isAuthUserInfo() |
|
|
|
this.getUserInfo() |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 获取用户信息
|
|
|
|
getUserInfo () { |
|
|
|
userModel.getUserInfo(res => { |
|
|
|
let nickName = res.result.nickName |
|
|
@ -104,7 +105,7 @@ Page({ |
|
|
|
userInfo: res.result, |
|
|
|
avatarUrl: res.result.avatarUrl, |
|
|
|
nickName: res.result.nickName, |
|
|
|
reAuth: true |
|
|
|
reAuth: true, |
|
|
|
},()=>{ |
|
|
|
if (store.hasPhone()) { |
|
|
|
console.log('已经绑定手机号码') |
|
|
@ -130,6 +131,7 @@ Page({ |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
// 获取未读消息
|
|
|
|
getMsgStatus () { |
|
|
|
userModel.getMyMessageTotal(res => { |
|
|
|
console.log(res.result.total) |
|
|
@ -138,13 +140,15 @@ Page({ |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
// cell点击
|
|
|
|
onTapItem (e) { |
|
|
|
const { type } = e.currentTarget.dataset |
|
|
|
console.log(type) |
|
|
|
if (type === 'myInfo'){ |
|
|
|
// wx.navigateTo({
|
|
|
|
// url: `/pages/user/${type}/index?userIcon=${this.data.userInfo.avatarUrl}&userName=${this.data.userInfo.nickName}&userPhone=${this.data.userInfo.phone || ''}&company=${this.data.userInfo.company || ''}&position=${this.data.userInfo.position || ''}`,
|
|
|
|
// })
|
|
|
|
wx.navigateTo({ |
|
|
|
url: `/pages/user/${type}/index?userIcon=${this.data.userInfo.avatarUrl}&userName=${this.data.userInfo.nickName}&userPhone=${this.data.userInfo.phone || ''}&company=${this.data.userInfo.company || ''}&position=${this.data.userInfo.position || ''}`, |
|
|
|
}) |
|
|
|
} else { |
|
|
|
wx.navigateTo({ |
|
|
|
url: `/pages/user/${type}/index`, |
|
|
|