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,17 +126,20 @@ export default { ...@@ -125,17 +126,20 @@ 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)
if(token){ if(token){
...@@ -151,42 +155,39 @@ export default { ...@@ -151,42 +155,39 @@ export default {
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', //编码格式
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=>{ uploadFilePromise(url) {
console.log(err,'啊hi吧I') 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) { 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