user.js
2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
(function () {
"use strict";
var app =angular.module("xn.page", []);
app.controller("NavCtrl", function ($scope) {
$scope.navShow = 4;
});
// 全局配置 form提交验证
app.config(["xnValidatorProvider", function (xnValidatorProvider) {
xnValidatorProvider.setRules({
mobilePhone: {
pattern: "手机格式不正确!"
}
});
}]);
//个人信息页面
app.controller("UserInformationCtrl", ["$scope", "$http", "SystemService", "$location", "toolsService" ,"dialogService",
function ($scope, $http, SystemService, $location, toolsService,dialogService) {
SystemService.getUserInformation().success(function (data) {
if(data.errors == null || data.errors.length > 0){
dialogService.tip(data.errors);
}else{
$scope.user = data.user;
}
});
/**
*图片保存的功能
*/
$scope.showPicture=function(){
var fileId=document.getElementById("imgFile");
fileId.onchange=function(){
var fileList = document.getElementById("imgFile").files;
var file = fileList[0];
var fileReader = new FileReader();
fileReader.readAsDataURL(file);
fileReader.onload=function(){
document.getElementById("spanImage").src = fileReader.result;
};
SystemService.uploadAvatar(file,$scope.user.id).success(function(data) {
$scope.updateLogoData={
avatarId:data.id,
userId:$scope.user.id
};
SystemService.updateAvatar($scope.updateLogoData).success(function(data) {
if(data.errors === null || data.errors.length > 0){
dialogService.tip(data.errors);
}else{
dialogService.tip([{"message":"上传成功!" }]);
}
});
});
};
};
/**
* 编辑用户信息后保存
*/
$scope.doSave = function () {
SystemService.userEditSave($scope.user).success(function (data) {
if(data.errors === null || data.errors.length > 0){
dialogService.tip(data.errors);
}else{
dialogService.tip([{"message":"保存成功!" }],"/profile_view.htm");
}
});
};
}]);
})();