Commit dcb62df5 by honghong

头像

parent 32134905
......@@ -5,7 +5,8 @@
<view class="content-in">
<view class="content-in-info baiyin-flex baiyin-flex-c-b">
<button class="content-in-info-l" type="balanced" open-type="chooseAvatar" @chooseavatar="onChooseavatar">
<image src="@/static/icon/my03.png" mode=""></image>
<image v-if="!headImgUrl" src="@/static/icon/my03.png" mode=""></image>
<image v-else :src="headImgUrl" mode=""></image>
</button>
<view v-if="token" class="content-in-info-r">
<view class="content-in-info-r-t baiyin-flex">
......@@ -125,16 +126,19 @@ export default {
}
],
token:'',
userParams:{
nickname:'',
headImgUrl:'',
}
uploadUrl: apiBaseConfig.upload,
headImgUrl:''
};
},
onLoad() {
let that = this
if(that.$store.state.login.userInfo && that.$store.state.login.userInfo.user){
let that = this
console.log(that.$store.state.login.userInfo.user,'打死你')
if(that.$store.state.login.userInfo && that.$store.state.login.userInfo.user && that.$store.state.login.userInfo.user.nickname){
that.nickname = that.$store.state.login.userInfo.user.nickname
}
if(that.$store.state.login.userInfo && that.$store.state.login.userInfo.user && that.$store.state.login.userInfo.user.headImgUrl){
that.headImgUrl = that.$store.state.login.userInfo.user.headImgUrl
}
let token = uni.getStorageSync('token')
console.log('token',token)
......@@ -150,43 +154,40 @@ export default {
// return;
let that = this;
const { avatarUrl } = e.detail;
that.fdsa = avatarUrl;
wx.getFileSystemManager().readFile({
filePath: avatarUrl, //选择图片返回的相对路径
// encoding: 'base64', //编码格式
success: res => {
//成功的回调
console.log(res,'返回值,');
console.log(res.data,'的撒胡');
// that.$set(that.userParams,'headImgUrl',res.data)
// userUpdatePOST({
// headImgUrl: res.data
// }).then(res => {
// console.log(res.code, 'pppppppppppp');
// if (res.code === 200) {
// uni.showToast({
// title: '修改成功',
// icon: 'none'
// });
// console.log(111111111111);
// }
// });
},
fail:err=>{
console.log(err,'啊hi吧I')
}
});
that.fdsa = avatarUrl;
that.uploadFilePromise(avatarUrl)
},
uploadFilePromise(url) {
let that = this
return new Promise((resolve, reject) => {
let a = uni.uploadFile({
url: this.uploadUrl, // 仅为示例,非真实的接口地址
filePath: url,
name: 'file',
header: {
'Authorization': `Bearer ${uni.getStorageSync('token')}`
},
success: (res) => {
const {
data
} = JSON.parse(res.data);
that.updateUser({headImgUrl:data.url})
setTimeout(() => {
resolve(data.url)
}, 1000)
}
});
})
},
inputNameConfirm(e) {
console.log('======inputNameConfirm:', e.detail.value);
let that = this
that.$set(that.userParams,'nickname',e.detail.value)
this.updateUser()
this.updateUser({nickname:e.detail.value})
},
async updateUser(){
async updateUser(data){
let that = this
const back_data = await updateUserMsg(that.userParams)
const back_data = await updateUserMsg(data)
console.log(back_data)
const {code} = back_data
if(code === 200){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment