|
@ -5,8 +5,8 @@ |
|
|
<view class="item"> |
|
|
<view class="item"> |
|
|
<view class="left PfScMedium">头像</view> |
|
|
<view class="left PfScMedium">头像</view> |
|
|
<view class="right" @click="upload"> |
|
|
<view class="right" @click="upload"> |
|
|
<img :src="avator" class="avator" v-if="!uinfo.avatar"> |
|
|
<img :src="avator" class="avator" v-if="!uinfo.avator"> |
|
|
<img :src="uinfo.avatar" class="avator" v-else> |
|
|
<img :src="uinfo.avator" class="avator" v-else> |
|
|
<view class="avator_tips">点击上传照片</view> |
|
|
<view class="avator_tips">点击上传照片</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
@ -39,7 +39,8 @@ |
|
|
cssUrl:this.cssUrl, |
|
|
cssUrl:this.cssUrl, |
|
|
avator:this.cssUrl+'default_avator.svg', |
|
|
avator:this.cssUrl+'default_avator.svg', |
|
|
uinfo:{}, |
|
|
uinfo:{}, |
|
|
nick:'' |
|
|
nick:'', |
|
|
|
|
|
tempFilePaths:'', |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
onLoad() { |
|
|
onLoad() { |
|
@ -47,19 +48,45 @@ |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
getUser(){ |
|
|
getUser(){ |
|
|
this.$http.req('client/user/info', {}, 'POST').then(data=>{ |
|
|
this.$http.req('get_userinfo', {}, 'GET').then(data=>{ |
|
|
if(data == -1) return |
|
|
if(data == -1) return |
|
|
this.uinfo = data |
|
|
this.uinfo = data |
|
|
this.nick = this.uinfo.nickname |
|
|
this.nick = this.uinfo.nick |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|
save(){ |
|
|
save(){ |
|
|
var param = new Object() |
|
|
var param = new Object() |
|
|
param.name = this.nick |
|
|
param.nick = this.nick |
|
|
this.$http.req('client/user/info', param, 'PUT').then(data=>{ |
|
|
var that = this |
|
|
if(data == -1) return |
|
|
var token = uni.getStorageSync('token') |
|
|
this.$pop.modelShow('保存成功') |
|
|
console.log(that.tempFilePaths) |
|
|
}) |
|
|
uni.uploadFile({ |
|
|
|
|
|
url: '/api/user/setting_user/', |
|
|
|
|
|
filePath: that.tempFilePaths, |
|
|
|
|
|
name: that.tempFilePaths ? 'avator':'empty', |
|
|
|
|
|
header: { |
|
|
|
|
|
'Authorization': token |
|
|
|
|
|
}, |
|
|
|
|
|
formData:{nick:param.nick}, |
|
|
|
|
|
success: function(res){ |
|
|
|
|
|
try{ |
|
|
|
|
|
var data = JSON.parse(res.data) |
|
|
|
|
|
if(data.code != 0){ |
|
|
|
|
|
that.$pop.modelShow(data.msg) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title:data.msg |
|
|
|
|
|
}) |
|
|
|
|
|
if(that.tempFilePaths) that.uinfo.avator = that.tempFilePaths |
|
|
|
|
|
}catch(e){ |
|
|
|
|
|
that.$pop.modelShow('保存失败~'+e.message) |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
fail: function(res){ |
|
|
|
|
|
that.$pop.modelShow('保存失败') |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
}, |
|
|
}, |
|
|
copyUid(uid) { |
|
|
copyUid(uid) { |
|
|
var that = this |
|
|
var that = this |
|
@ -71,34 +98,12 @@ |
|
|
}, |
|
|
}, |
|
|
upload() { |
|
|
upload() { |
|
|
var that = this |
|
|
var that = this |
|
|
var token = uni.getStorageSync('token') |
|
|
|
|
|
uni.chooseImage({ |
|
|
uni.chooseImage({ |
|
|
count: 1, |
|
|
count: 1, |
|
|
success: function(res) { |
|
|
success: function(res) { |
|
|
var tempFilePaths = res.tempFilePaths; |
|
|
var tempFilePaths = res.tempFilePaths |
|
|
uni.uploadFile({ |
|
|
that.tempFilePaths = tempFilePaths[0] |
|
|
url: '/api/client/common/avatar/', |
|
|
that.uinfo.avator = that.tempFilePaths |
|
|
filePath: tempFilePaths[0], |
|
|
|
|
|
name: 'file', |
|
|
|
|
|
header: { |
|
|
|
|
|
'Authorization': token |
|
|
|
|
|
}, |
|
|
|
|
|
success: function(res){ |
|
|
|
|
|
try{ |
|
|
|
|
|
var data = JSON.parse(res.data) |
|
|
|
|
|
if(data.code != 2000){ |
|
|
|
|
|
that.$pop.modelShow('上传失败:'+data.msg) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
that.uinfo.avatar = data.data.url |
|
|
|
|
|
}catch(e){ |
|
|
|
|
|
that.$pop.modelShow('上传失败~'+e.message) |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
fail: function(res){ |
|
|
|
|
|
that.$pop.modelShow('上传失败') |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|