Commit dcb62df5 by honghong

头像

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