parent
c9c63eeb85
commit
c234a8d2cb
@ -0,0 +1,42 @@
|
|||||||
|
<div class="post-container">
|
||||||
|
<div loading-spinner></div>
|
||||||
|
<div class="blue-title">编辑资料</div>
|
||||||
|
<div class="blank-row mt10">
|
||||||
|
<div class="upload-input-container img-circle fl ml10 mt4">
|
||||||
|
<!--<input class="upload-input" accept="image/*" multiple="" type="file">-->
|
||||||
|
<input class="upload-input" type="file" capture="camera" accept="image/*" load-head>
|
||||||
|
<img ng-src="{{replaceUrl(user.img_url)}}" width="30" class="fl ml10 img-circle mt4" />
|
||||||
|
</div>
|
||||||
|
<span class="fl ml25">{{user.login}}</span><span ng-click="unbind()" class="fr f13 mr10 c-blue">解除绑定</span><div class="cl"></div></div>
|
||||||
|
|
||||||
|
<form name="regFrm" novalidate>
|
||||||
|
|
||||||
|
<div class="course-list-row f13 c-grey3 mt10"><span class="fl ml15 c-grey3">姓名</span><input class="new-class-input ml25" ng-model="lastname" placeholder="请输入您的姓名全称" maxlength="30" /></div>
|
||||||
|
<div class="course-list-row f13 c-grey3 mt10">
|
||||||
|
<span class="c-grey3 select-text">性别</span>
|
||||||
|
<div class="select-container">
|
||||||
|
<select ng-model="gender" class="select-model">
|
||||||
|
<!--<option selected="selected">请选择您的性别</option>-->
|
||||||
|
<option ng-selected="sex==0">男</option>
|
||||||
|
<option ng-selected="sex==1">女</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="course-list-row f13 c-grey3 mt10">
|
||||||
|
<span class="fl ml15 c-grey3">邮箱</span>
|
||||||
|
<input class="new-class-input ml25" type="email" name="email" ng-model="mail" placeholder="请输入您的邮箱地址" maxlength="60" />
|
||||||
|
<div ng-show="regFrm.$submitted || regFrm.email.$touched">
|
||||||
|
<span class="f12 c-red fl" ng-show="regFrm.email.$error.required">电子邮箱地址不能为空</span>
|
||||||
|
<span class="f12 c-red fl" ng-show="regFrm.email.$error.email">电子邮箱地址不合法</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="bottom-tab-wrap mt10">
|
||||||
|
<a ng-click="cancel()" class="weixin-tab c-grey border-top">取消</a>
|
||||||
|
<a ng-click="confirm(regFrm)" ng-class="[{'btn-disabled':!regFrm.$valid} ]" class="weixin-tab link-blue2 border-top">确定</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<my-alert message="alertService_1.message" title="alertService_1.title" visible="alertService_1.visible" cb="alertService_1.cb"></my-alert>
|
||||||
|
<my-alert2 message="alertService_2.message" title="alertService_2.title" visible="alertService_2.visible" cb="alertService_2.cb"></my-alert2>
|
||||||
|
</div>
|
@ -0,0 +1,103 @@
|
|||||||
|
app.controller('EditUserInfoController', ['$scope', 'config','$http', 'auth','$location','$routeParams','alertService','rms','common','$timeout','wx', function($scope, config, $http, auth, $location, $routeParams,alertService,rms,common,$timeout,wx){
|
||||||
|
// common.checkLogin();
|
||||||
|
|
||||||
|
$scope.replaceUrl = function(url){
|
||||||
|
return url;
|
||||||
|
};
|
||||||
|
|
||||||
|
var vm = $scope;
|
||||||
|
|
||||||
|
//单弹框
|
||||||
|
vm.alertService_1 = alertService.create();
|
||||||
|
|
||||||
|
//双弹框
|
||||||
|
vm.alertService_2 = alertService.create();
|
||||||
|
|
||||||
|
vm.getuserinfo = function(){
|
||||||
|
$http.get(config.apiUrl + 'users/get_userinfo?token='+auth.token()).then(
|
||||||
|
function(response) {
|
||||||
|
console.log(response.data);
|
||||||
|
vm.user = response.data.data;
|
||||||
|
vm.lastname = vm.user.lastname;
|
||||||
|
vm.mail = vm.user.mail;
|
||||||
|
vm.sex = vm.user.gender;
|
||||||
|
if(vm.sex == 0){
|
||||||
|
vm.gender = "男";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
vm.gender = "女";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
vm.getuserinfo();
|
||||||
|
|
||||||
|
vm.unbind = function(){
|
||||||
|
vm.alertService_2.showMessage('提示', '是否确认解除绑定', function() {
|
||||||
|
$http.post(config.apiUrl + "users/user_unbind",
|
||||||
|
{token: auth.token()}
|
||||||
|
).then(function (response) {
|
||||||
|
if (response.data.status == 0) {
|
||||||
|
vm.alertService_1.showMessage('提示', '解除绑定成功', function () {
|
||||||
|
wx.closeWindow();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
vm.alertService_1.showMessage('提示', response.data.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
vm.cancel = function(){
|
||||||
|
vm.alertService_2.showMessage('提示', '是否确认取消', function() {
|
||||||
|
wx.closeWindow();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
vm.confirm = function(frm){
|
||||||
|
frm.$setSubmitted();
|
||||||
|
|
||||||
|
console.log(frm);
|
||||||
|
if (!frm.$valid) {
|
||||||
|
console.log(frm.$error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var sex = 0;
|
||||||
|
if(vm.gender == "女"){
|
||||||
|
sex = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(vm.lastname == ""){
|
||||||
|
vm.alertService_1.showMessage('提示', '姓名不能为空');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(vm.mail == ""){
|
||||||
|
vm.alertService_1.showMessage('提示', '邮箱不能为空');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if(!(/\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i.test(vm.mail))){
|
||||||
|
// vm.alertService_1.showMessage('提示', '邮箱不合法');
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
$http.post(config.apiUrl + "users/edit_userinfo",
|
||||||
|
{token: auth.token(),lastname: vm.lastname, sex: sex, mail: vm.mail}
|
||||||
|
).then(function(response){
|
||||||
|
if(response.data.status == 0)
|
||||||
|
{
|
||||||
|
vm.alertService_1.showMessage('提示', '修改成功',function(){
|
||||||
|
wx.closeWindow();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
vm.alertService_1.showMessage('提示', response.data.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
}]);
|
@ -1,25 +0,0 @@
|
|||||||
app.directive('inputOnChange', function(){
|
|
||||||
return{
|
|
||||||
restrict: 'A',
|
|
||||||
scope: {},
|
|
||||||
link: function (scope, element, attrs) {
|
|
||||||
var onChangeFunc = scope.$eval(attrs.inputOnChange);
|
|
||||||
element.bind('change', onChangeFunc);
|
|
||||||
|
|
||||||
scope.uploadDown = function () {
|
|
||||||
var file = event.target.files[0];
|
|
||||||
//判断类型是不是图片
|
|
||||||
if (!/image\/\w+/.test(file.type)) {
|
|
||||||
alert("非图片");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var reader = new FileReader();
|
|
||||||
reader.readAsDataURL(file);
|
|
||||||
reader.onload = function (e) {
|
|
||||||
alert(this.result);//base64
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
@ -0,0 +1,36 @@
|
|||||||
|
app.directive('loadHead',['$http','config','auth','$location','alertService',function($http,config,auth,$location,alertService){
|
||||||
|
return{
|
||||||
|
restrict: 'A',
|
||||||
|
scope: {},
|
||||||
|
link: function (scope, element, attrs) {
|
||||||
|
element.bind('change', function(){
|
||||||
|
var file = event.target.files[0];
|
||||||
|
//判断类型是不是图片
|
||||||
|
if (!/image\/\w+/.test(file.type)) {
|
||||||
|
alert("非图片");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var reader = new FileReader();
|
||||||
|
reader.readAsDataURL(file);
|
||||||
|
reader.onload = function (e) {
|
||||||
|
alert(this.result);//base64
|
||||||
|
|
||||||
|
$http.post(config.apiUrl + "users/upload_head",
|
||||||
|
{token: auth.token(),imgdata:this.result}
|
||||||
|
).then(function (response) {
|
||||||
|
if(response.data.status == 0){
|
||||||
|
scope.$parent.alertService_1.showMessage('提示',"上传成功",function(){
|
||||||
|
scope.$parent.user = null;
|
||||||
|
scope.$parent.getuserinfo();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
scope.$parent.alertService_1.showMessage('提示',"上传失败");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}]);
|
Loading…
Reference in new issue