diff --git a/pages/user_modify/user_modify.vue b/pages/user_modify/user_modify.vue
index 268902a..5ecf4f0 100644
--- a/pages/user_modify/user_modify.vue
+++ b/pages/user_modify/user_modify.vue
@@ -5,8 +5,8 @@
头像
-
-
+
+
点击上传照片
@@ -39,7 +39,8 @@
cssUrl:this.cssUrl,
avator:this.cssUrl+'default_avator.svg',
uinfo:{},
- nick:''
+ nick:'',
+ tempFilePaths:'',
}
},
onLoad() {
@@ -47,19 +48,45 @@
},
methods: {
getUser(){
- this.$http.req('client/user/info', {}, 'POST').then(data=>{
+ this.$http.req('get_userinfo', {}, 'GET').then(data=>{
if(data == -1) return
this.uinfo = data
- this.nick = this.uinfo.nickname
+ this.nick = this.uinfo.nick
});
},
save(){
var param = new Object()
- param.name = this.nick
- this.$http.req('client/user/info', param, 'PUT').then(data=>{
- if(data == -1) return
- this.$pop.modelShow('保存成功')
- })
+ param.nick = this.nick
+ var that = this
+ var token = uni.getStorageSync('token')
+ 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) {
var that = this
@@ -71,34 +98,12 @@
},
upload() {
var that = this
- var token = uni.getStorageSync('token')
uni.chooseImage({
count: 1,
success: function(res) {
- var tempFilePaths = res.tempFilePaths;
- uni.uploadFile({
- url: '/api/client/common/avatar/',
- 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('上传失败')
- }
- });
+ var tempFilePaths = res.tempFilePaths
+ that.tempFilePaths = tempFilePaths[0]
+ that.uinfo.avator = that.tempFilePaths
}
});
}
diff --git a/pages/usercenter/usercenter.vue b/pages/usercenter/usercenter.vue
index 909ebac..af736e0 100644
--- a/pages/usercenter/usercenter.vue
+++ b/pages/usercenter/usercenter.vue
@@ -1,7 +1,7 @@
-
+
{{uinfo.uid}}
@@ -39,10 +39,9 @@
},
methods: {
getUser(){
- this.$http.req('client/user/info', {}, 'POST').then(data=>{
+ this.$http.req('get_userinfo', {}, 'GET').then(data=>{
if(data == -1) return
this.uinfo = data
- console.log(this.uinfo)
});
},
toVisitors(){