diff --git a/app/api/mobile/apis/users.rb b/app/api/mobile/apis/users.rb index 3a1a897ee..557b06cea 100644 --- a/app/api/mobile/apis/users.rb +++ b/app/api/mobile/apis/users.rb @@ -27,11 +27,18 @@ module Mobile dirPath = "public/images/avatars/User" fileDir = dirPath + "/"+current_user.id.to_s - begin - File.open(fileDir,'wb'){ |f| f.write(Base64.decode64(params[:imgdata].split(",")[1])) } - present :status, 0 - rescue + imgdata = Base64.decode64(params[:imgdata].split(",")[1]) + if imgdata.length > 1024*1024 + present :message,"上传图片不能超过1M" present :status, -1 + else + begin + File.open(fileDir,'wb'){ |f| f.write(imgdata) } + present :status, 0 + rescue + present :message,"上传失败" + present :status, -1 + end end end diff --git a/config/menu.yml.test b/config/menu.yml.test index 4508e843c..5888996cf 100644 --- a/config/menu.yml.test +++ b/config/menu.yml.test @@ -31,6 +31,6 @@ button: name: "联系我们" key: "FEEDBACK" - - type: "click" - name: "解除绑定" - key: "UNBIND" + type: "view" + name: "个人资料" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=edit_userinfo#wechat_redirect" diff --git a/public/javascripts/wechat/directives/load_head.js b/public/javascripts/wechat/directives/load_head.js index 6cbb8e743..47862f0b7 100644 --- a/public/javascripts/wechat/directives/load_head.js +++ b/public/javascripts/wechat/directives/load_head.js @@ -14,7 +14,7 @@ app.directive('loadHead',['$http','config','auth','$location','alertService',fun var reader = new FileReader(); reader.readAsDataURL(file); reader.onload = function (e) { - alert(this.result);//base64 +// alert(this.result);//base64 $http.post(config.apiUrl + "users/upload_head", {token: auth.token(),imgdata:this.result} @@ -25,7 +25,7 @@ app.directive('loadHead',['$http','config','auth','$location','alertService',fun }); } else{ - scope.$parent.alertService_1.showMessage('提示',"上传失败"); + scope.$parent.alertService_1.showMessage('提示',response.data.message); } }); }