邓洁 : 获取个人信息接口
This commit is contained in:
@@ -25,7 +25,7 @@
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
Info: {
|
Info: {
|
||||||
avatar: [],
|
avatar: '',
|
||||||
username: '',
|
username: '',
|
||||||
avatarUrl: ''
|
avatarUrl: ''
|
||||||
}
|
}
|
||||||
@@ -36,10 +36,9 @@
|
|||||||
getUserInfo() {
|
getUserInfo() {
|
||||||
this.$api.getUser().then(res => {
|
this.$api.getUser().then(res => {
|
||||||
const data = res.data.data
|
const data = res.data.data
|
||||||
console.log('头像昵称', res);
|
|
||||||
if (data) {
|
if (data) {
|
||||||
this.avatar = this.$api.imgUrl + data.avatar
|
this.Info.avatar = this.$api.imgUrl + data.avatar
|
||||||
this.avatarUrl = '/' + data.avatar
|
this.avatarUrl = data.avatar
|
||||||
this.Info.username = data.nickname
|
this.Info.username = data.nickname
|
||||||
}
|
}
|
||||||
}).finally(_ => {})
|
}).finally(_ => {})
|
||||||
@@ -98,8 +97,6 @@
|
|||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
let that = this
|
let that = this
|
||||||
this.$data.Info.username = wx.getStorageSync('nickname')
|
|
||||||
this.$data.Info.avatar = wx.getStorageSync('avatar')
|
|
||||||
this.getUserInfo()
|
this.getUserInfo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,9 +56,6 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.isLoad = true
|
this.isLoad = true
|
||||||
// this.$data.account = wx.getStorageSync('account')
|
|
||||||
// this.$data.username = wx.getStorageSync('nickname')
|
|
||||||
this.getInfo()
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
reOnLoad() {
|
reOnLoad() {
|
||||||
@@ -68,6 +65,9 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.isLoad = true
|
this.isLoad = true
|
||||||
|
if(this.isLoad){
|
||||||
|
this.getInfo()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
failToLoad() {
|
failToLoad() {
|
||||||
uni.reLaunch({
|
uni.reLaunch({
|
||||||
@@ -97,11 +97,11 @@
|
|||||||
//---------页面调用接口示例------------
|
//---------页面调用接口示例------------
|
||||||
getInfo() {
|
getInfo() {
|
||||||
this.$api.getUser().then(res => {
|
this.$api.getUser().then(res => {
|
||||||
console.log('userInfo', res);
|
|
||||||
var data = res.data.data
|
var data = res.data.data
|
||||||
if (data) {
|
if (data) {
|
||||||
this.src = uni.getStorageSync('img_url') + data.avatar
|
this.src = this.$api.imgUrl + data.avatar
|
||||||
this.username = data.nickname
|
this.username = data.nickname
|
||||||
|
this.account = data.sn
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user