|
|
@@ -2,394 +2,1159 @@
|
|
|
* Created by yujia on 2017/3/24.
|
|
|
* 原厂认证
|
|
|
*/
|
|
|
-define(['app/app'], function(app) {
|
|
|
- "use strict";
|
|
|
- app.register.controller('vendorAccountManagementCtrl', ['$scope', '$rootScope', 'Enterprise', 'User', 'toaster', '$modal','BaseService','ngTableParams','$http', function($scope, $rootScope, Enterprise, User, toaster, $modal, BaseService, ngTableParams, $http) {
|
|
|
- $rootScope.active = 'vendor_account_management';
|
|
|
- $scope.tab = 'base';
|
|
|
- $scope.userInfo = $rootScope.userInfo;
|
|
|
- $scope.updateState = false;
|
|
|
- // 获取企业信息
|
|
|
- Enterprise.getEnterpriseInfo({enuu : $scope.userInfo.enterprise.uu}, function(data) {
|
|
|
- $scope.enterpriseInfo = data;
|
|
|
- $scope.enterpriseInfoBackup = angular.copy($scope.enterpriseInfo);
|
|
|
- $scope.enAdminuu = $scope.enterpriseInfo.enAdminuu;
|
|
|
- User.getUserByUU({uu: $scope.enAdminuu}, {}, function(data){
|
|
|
- $scope.adminInfo = data;
|
|
|
- console.log($scope.adminInfo);
|
|
|
- }, function(){
|
|
|
- toaster.pop('error', '获取管理员信息失败');
|
|
|
- });
|
|
|
- },function(response) {
|
|
|
- toaster.pop('error', '获取企业信息失败');
|
|
|
- });
|
|
|
-
|
|
|
- $scope.tableParams = new ngTableParams({
|
|
|
- page : 1, // show first page
|
|
|
- count : 10 // count per page
|
|
|
- }, {
|
|
|
- total : 0,
|
|
|
- getData : function($defer, params) {
|
|
|
- var param = BaseService.parseParams(params.url());
|
|
|
- param.enuu = $scope.userInfo.enterprise.uu;
|
|
|
- if(!$scope.searchMthod) {
|
|
|
- Enterprise.getAllUsersByEnuu(param, function (page) {
|
|
|
- if (page) {
|
|
|
- params.total(page.totalElements);
|
|
|
- $defer.resolve(page.content);
|
|
|
- $scope.users = page.content;
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- else {
|
|
|
- param.keyword = $scope.keyword;
|
|
|
- Enterprise.findUsersByKeyword(param,function (page) {
|
|
|
- if (page) {
|
|
|
- params.total(page.totalElements);
|
|
|
- $defer.resolve(page.content);
|
|
|
- $scope.users = page.content;
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- $scope.onSearch = function(keyword) {
|
|
|
- if(keyword != null && keyword != '') {
|
|
|
- $scope.searchMthod = true;
|
|
|
- $scope.keyword = keyword;
|
|
|
- } else {
|
|
|
- $scope.searchMthod = false;
|
|
|
- }
|
|
|
- $scope.tableParams.page(1);
|
|
|
- $scope.tableParams.reload();
|
|
|
- };
|
|
|
-
|
|
|
- $scope.newUser = {};
|
|
|
-
|
|
|
- //弹出添加用户模态框
|
|
|
- $scope.addExistUser = function () {
|
|
|
- var modalInstance = $modal.open({
|
|
|
- animation: true,
|
|
|
- templateUrl: $rootScope.rootPath +'/static/view/vendor/forstore/addExistUser.html',
|
|
|
- controller: 'AddExistUserCtrl'
|
|
|
- });
|
|
|
-
|
|
|
- modalInstance.result.then(function () {
|
|
|
- $scope.userTelSuccess = false;
|
|
|
- $scope.userTelError = false;
|
|
|
- $scope.tableParams.page(1);
|
|
|
- $scope.tableParams.reload();
|
|
|
- }, function () {
|
|
|
-
|
|
|
- });
|
|
|
-
|
|
|
- };
|
|
|
- /**
|
|
|
- * 添加未注册用户
|
|
|
- */
|
|
|
- $scope.addUser = function () {
|
|
|
- $scope.adding = true;
|
|
|
- $scope.loading = true;
|
|
|
- Enterprise.saveUser({}, $scope.newUser, function () {
|
|
|
- $scope.loading = false;
|
|
|
- toaster.pop('success', '提示', '增加用户成功:' + $scope.newUser.userName);
|
|
|
- $scope.newUser = {userSex: 'M'};
|
|
|
- $scope.tableParams.page(1);
|
|
|
- $scope.tableParams.reload();
|
|
|
- $scope.adding = false;
|
|
|
- $scope.newUserForm.newUserTel.$setValidity('available', false);
|
|
|
- $scope.newUserForm.newUserEmail.$setValidity('available', false);
|
|
|
- $scope.userTelSuccess = false;
|
|
|
- $scope.userTelError = false;
|
|
|
- $scope.userEmailSuccess = false;
|
|
|
- $scope.userEmailError = false;
|
|
|
- }, function (response) {
|
|
|
- $scope.loading = false;
|
|
|
- toaster.pop('error', '错误', response.data);
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
- /**
|
|
|
- * 删除用户
|
|
|
- */
|
|
|
- $scope.removeUser = function (user) {
|
|
|
-
|
|
|
- if (confirm('确定删除用户(' + user.userName + ')吗?')) {
|
|
|
- Enterprise.removeUser({uu: user.userUU}, function () {
|
|
|
- toaster.pop('success', '提示', '用户删除成功。');
|
|
|
- $scope.tableParams.page(1);
|
|
|
- $scope.tableParams.reload();
|
|
|
- }, function (response) {
|
|
|
- toaster.pop('error', '删除失败', response.data);
|
|
|
- });
|
|
|
- }
|
|
|
- };
|
|
|
- /**
|
|
|
- * 验证手机号是否可用
|
|
|
- */
|
|
|
- $scope.telValid = function (tel) {
|
|
|
- if (tel) {
|
|
|
- $http.get('basic/user/telEnable', {
|
|
|
- params: {
|
|
|
- tel: tel
|
|
|
- }
|
|
|
- }).success(function (data) {
|
|
|
- data = eval(data);
|
|
|
- if (data == true) {
|
|
|
- $scope.newUserForm.newUserTel.$setValidity('available', true);
|
|
|
- $scope.userTelSuccess = true;
|
|
|
- $scope.userTelError = false;
|
|
|
- } else {
|
|
|
- $scope.newUserForm.newUserTel.$setValidity('available', false);
|
|
|
- $scope.userTelError = true;
|
|
|
- $scope.userTelSuccess = false;
|
|
|
- if (tel.length == 11)
|
|
|
- toaster.pop('error', '错误', '手机号 ' + tel + ' 已被注册');
|
|
|
- }
|
|
|
- }).error(function () {
|
|
|
- $scope.userTelSuccess = false;
|
|
|
- $scope.userTelError = true;
|
|
|
- });
|
|
|
- } else {
|
|
|
- $scope.userTelSuccess = false;
|
|
|
- $scope.userTelError = false;
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- /**
|
|
|
- * 验证邮箱是否可用
|
|
|
- */
|
|
|
- $scope.emailValid = function (email) {
|
|
|
- if (email) {
|
|
|
- $http.get('basic/user/emailEnable', {
|
|
|
- params: {
|
|
|
- email: email
|
|
|
- }
|
|
|
- }).success(function (data) {
|
|
|
- data = eval(data);
|
|
|
- if (data == true) {
|
|
|
- $scope.newUserForm.newUserEmail.$setValidity('available', true);
|
|
|
- $scope.userEmailSuccess = true;
|
|
|
- $scope.userEmailError = false;
|
|
|
- } else {
|
|
|
- $scope.newUserForm.newUserEmail.$setValidity('available', false);
|
|
|
- $scope.userEmailError = true;
|
|
|
- $scope.userEmailSuccess = false;
|
|
|
- }
|
|
|
- }).error(function () {
|
|
|
- $scope.userEmailError = true;
|
|
|
- $scope.userEmailSuccess = false;
|
|
|
- });
|
|
|
- } else {
|
|
|
- $scope.userEmailError = false;
|
|
|
- $scope.userEmailSuccess = false;
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- /**
|
|
|
- * 变更到更新状态
|
|
|
- */
|
|
|
- $scope.changeToUpdate = function(isUpdate) {
|
|
|
- $scope.updateState = isUpdate;
|
|
|
- if ($scope.updateState == false){
|
|
|
- $scope.enterpriseInfo = angular.copy($scope.enterpriseInfoBackup);
|
|
|
- }
|
|
|
- };
|
|
|
- /**
|
|
|
- * 验证企业信息
|
|
|
- */
|
|
|
- function validateEnterpriseInfo() {
|
|
|
- var props = ['enName', 'enShortname', 'enAddress', 'enUrl'];
|
|
|
-
|
|
|
- var flag = true;
|
|
|
- angular.forEach(props, function (prop) {
|
|
|
- if ($scope.enterpriseInfo.hasOwnProperty(prop)) {
|
|
|
- if (!$scope.enterpriseInfo[prop] || $scope.enterpriseInfo[prop] === '') {
|
|
|
- console.log(prop + '不能为空');
|
|
|
- // TODO 记录验证信息
|
|
|
- flag = false;
|
|
|
- }
|
|
|
- } else {
|
|
|
- console.log(prop + '不能为空');
|
|
|
- flag = false;
|
|
|
- }
|
|
|
- });
|
|
|
- return flag;
|
|
|
- }
|
|
|
- /**
|
|
|
- * 保存企业信息
|
|
|
- */
|
|
|
- $scope.saveUpdate = function () {
|
|
|
- // 先检查信息是否为空
|
|
|
- if (angular.equals($scope.enterpriseInfo,$scope.enterpriseInfoBackup)){
|
|
|
- toaster.pop('error', '未做任何修改');
|
|
|
- $scope.updateState = false;
|
|
|
- return ;
|
|
|
- }
|
|
|
- var enterpriseInfoFlag = validateEnterpriseInfo();
|
|
|
- if (!enterpriseInfoFlag) {
|
|
|
- toaster.pop('error', '请补充完信息后再次提交');
|
|
|
- return ;
|
|
|
- }
|
|
|
- Enterprise.updateEnterpriseInfo({enuu : $scope.userInfo.enterprise.uu}, $scope.enterpriseInfo, function () {
|
|
|
- $scope.loading = false;
|
|
|
- toaster.pop('success', '提示', '企业信息修改成功');
|
|
|
- $scope.enterpriseInfoBackup = angular.copy($scope.enterpriseInfo);
|
|
|
- $scope.updateState = false;
|
|
|
-
|
|
|
- }, function (response) {
|
|
|
- $scope.loading = false;
|
|
|
- toaster.pop('error', '修改失败', response.data);
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
-
|
|
|
- // 切换tab
|
|
|
- $scope.checkTab = function (t) {
|
|
|
- $scope.tab = t;
|
|
|
- };
|
|
|
-
|
|
|
- $scope.updatePassword = function(){
|
|
|
- var modalInstance = $modal.open({
|
|
|
- animation: true,
|
|
|
- templateUrl: $rootScope.rootPath + '/static/view/vendor/modal/updatePassword.html',
|
|
|
- controller: 'PasswordCtrl',
|
|
|
- resolve: {
|
|
|
- user: function(){return angular.copy($rootScope.userInfo);}
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- modalInstance.result.then(function(){
|
|
|
- }, function(){
|
|
|
- });
|
|
|
- };
|
|
|
- }]);
|
|
|
-
|
|
|
- /*
|
|
|
- * 绑定用户到企业
|
|
|
- */
|
|
|
- app.register.controller('AddExistUserCtrl', ['$scope', '$modalInstance', 'Enterprise', 'AuthenticationService', '$timeout', 'toaster', function ($scope, $modalInstance, Enterprise, AuthenticationService, $timeout, toaster) {
|
|
|
- $scope.searching = false;
|
|
|
- //根据输入的内容查找用户
|
|
|
- $scope.searchUser = function (keyWord) {
|
|
|
- $scope.searching = true;
|
|
|
- $scope.searchSuccess = false;
|
|
|
- $scope.searchFailed = false;
|
|
|
- $scope.illegalError = false;
|
|
|
- $scope.reBindError = false;
|
|
|
- $scope.okDisabled = false;
|
|
|
- Enterprise.searchUser({keyWord: keyWord}, function (data) {
|
|
|
- $scope.searchSuccess = true;
|
|
|
- $scope.searchFailed = false;
|
|
|
- $scope.user = data; //查询到的用户
|
|
|
- }, function (response) {
|
|
|
- $scope.searchSuccess = false;
|
|
|
- $scope.searchFailed = true;
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
- //确认绑定
|
|
|
- $scope.ok = function (keyWord) {
|
|
|
- AuthenticationService.getAuthentication().success(function (data) {
|
|
|
- $scope.currentUser = data; //当前登录的用户(管理员)
|
|
|
- //不可自己绑定自己
|
|
|
- if ($scope.currentUser.userUU == $scope.user.userUU) {
|
|
|
- $scope.illegalError = true;
|
|
|
- $scope.okDisabled = true;
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- //用户未绑定到任何企业时
|
|
|
- if (!$scope.user.enterprises) {
|
|
|
- //正常绑定
|
|
|
- Enterprise.bindUserToMyEnterprise({userUU: $scope.user.userUU}, function (data) {
|
|
|
- $scope.okDisabled = true;
|
|
|
- toaster.pop("success", "提示", "用户绑定成功");
|
|
|
- $modalInstance.close(true);
|
|
|
- }, function (response) {
|
|
|
- });
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- //用户已绑定到某些企业时
|
|
|
- for (var i = 0; i < $scope.currentUser.enterprises.length; i++) {
|
|
|
- if ($scope.currentUser.enterprises[i].current) {
|
|
|
- for (var j = 0; j < $scope.user.enterprises.length; j++) {
|
|
|
- //该用户已绑定到当前企业,不可重复绑定
|
|
|
- if ($scope.currentUser.enterprises[i].uu == $scope.user.enterprises[j].uu) {
|
|
|
- $scope.reBindError = true;
|
|
|
- $scope.okDisabled = true;
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- //该用户未绑定到当前企业,可以进行绑定
|
|
|
- Enterprise.bindUserToMyEnterprise({userUU: $scope.user.userUU}, function (data) {
|
|
|
- $scope.okDisabled = true;
|
|
|
- toaster.pop("success", "提示", "用户绑定成功");
|
|
|
- $modalInstance.close(true);
|
|
|
- }, function (response) {
|
|
|
- console.log("绑定失败!");
|
|
|
- });
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
- $scope.cancel = function () {
|
|
|
- $modalInstance.dismiss();
|
|
|
- };
|
|
|
- }]);
|
|
|
-
|
|
|
- // 修改密码Controller
|
|
|
- app.register.controller('PasswordCtrl', ['$scope', '$modalInstance', 'user', 'User', 'toaster', function($scope, $modalInstance, user, User, toaster){
|
|
|
- $scope.user = user;
|
|
|
- $scope.checking = false;
|
|
|
- //输入原密码后验证原密码是否正确
|
|
|
- $scope.checkPassword = function(password) {
|
|
|
- $scope.checking = true;
|
|
|
- $scope.checkSuccess = false;
|
|
|
- $scope.checkFailed = false;
|
|
|
- User.checkPassword({password: password}, function(){
|
|
|
- $scope.checkSuccess = true;
|
|
|
- $scope.checking = false;
|
|
|
- $scope.checkFailed = false;
|
|
|
- }, function(){
|
|
|
- $scope.checkFailed = true;
|
|
|
- $scope.checking = false;
|
|
|
- $scope.checkSuccess = false;
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
- //修改密码
|
|
|
- $scope.ok = function () {
|
|
|
- if($scope.user.newPassword == $scope.user.password){
|
|
|
- toaster.pop('error', '错误', '新密码与原密码相同');
|
|
|
- return;
|
|
|
- }
|
|
|
- if($scope.user.newPassword == $scope.user.newPassword1) {//验证重复密码相等
|
|
|
- User.updatePassword({password: $scope.user.password, newPassword: $scope.user.newPassword}, {}, function(){
|
|
|
- toaster.pop('success', '成功', '修改密码成功,请牢记您的新密码。');
|
|
|
- $scope.user.password = null;
|
|
|
- $scope.user.newPassword = null;
|
|
|
- $scope.user.newPassword1 = null;
|
|
|
- $scope.checking = false;
|
|
|
- $scope.checkSuccess = false;
|
|
|
- $scope.checkFailed = false;
|
|
|
- $modalInstance.close();
|
|
|
- }, function(response){
|
|
|
- toaster.pop('error', '错误', response.data);
|
|
|
- $modalInstance.close();
|
|
|
- });
|
|
|
- } else {
|
|
|
- toaster.pop('error', '错误', '重复密码不一致');
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- $scope.cancel = function () {
|
|
|
- $modalInstance.close();
|
|
|
- };
|
|
|
- }]);
|
|
|
+define(['app/app'], function (app) {
|
|
|
+ "use strict";
|
|
|
+ app.register.controller('vendorAccountManagementCtrl',
|
|
|
+ ['$scope', '$rootScope', 'Enterprise', 'User', 'toaster', '$modal',
|
|
|
+ 'BaseService', 'ngTableParams', '$http','$stateParams',
|
|
|
+ function ($scope, $rootScope, Enterprise, User, toaster, $modal,
|
|
|
+ BaseService, ngTableParams, $http,$stateParams) {
|
|
|
+ $rootScope.active = 'vendor_account_management';
|
|
|
+ $scope.tab = 'base';
|
|
|
+ $scope.userInfo = $rootScope.userInfo;
|
|
|
+ $scope.updateState = false;
|
|
|
+ //手机号和邮箱号的部分隐藏
|
|
|
+ $scope.userInfo.userTel = $scope.userInfo.userTel.substr(0, 3) + '****' + $scope.userInfo.userTel.substr(7);
|
|
|
+ var userEmailTemp = $scope.userInfo.userEmail.indexOf("@");
|
|
|
+ $scope.userInfo.userEmail = $scope.userInfo.userEmail.substr(0,userEmailTemp-2)+"***"+$scope.userInfo.userEmail.substr(userEmailTemp);
|
|
|
+ // 获取企业信息
|
|
|
+ Enterprise.getEnterpriseInfo({enuu: $scope.userInfo.enterprise.uu},
|
|
|
+ function (data) {
|
|
|
+ $scope.enterpriseInfo = data;
|
|
|
+ $scope.enterpriseInfoBackup = angular.copy(
|
|
|
+ $scope.enterpriseInfo);
|
|
|
+ $scope.enAdminuu = $scope.enterpriseInfo.enAdminuu;
|
|
|
+ User.getUserByUU({uu: $scope.enAdminuu}, {}, function (data) {
|
|
|
+ $scope.adminInfo = data;
|
|
|
+ console.log($scope.adminInfo);
|
|
|
+ }, function () {
|
|
|
+ toaster.pop('error', '获取管理员信息失败');
|
|
|
+ });
|
|
|
+ }, function (response) {
|
|
|
+ toaster.pop('error', '获取企业信息失败');
|
|
|
+ });
|
|
|
+
|
|
|
+ $scope.tableParams = new ngTableParams({
|
|
|
+ page: 1, // show first page
|
|
|
+ count: 10 // count per page
|
|
|
+ }, {
|
|
|
+ total: 0,
|
|
|
+ getData: function ($defer, params) {
|
|
|
+ var param = BaseService.parseParams(params.url());
|
|
|
+ param.enuu = $scope.userInfo.enterprise.uu;
|
|
|
+ if (!$scope.searchMthod) {
|
|
|
+ Enterprise.getAllUsersByEnuu(param, function (page) {
|
|
|
+ if (page) {
|
|
|
+ params.total(page.totalElements);
|
|
|
+ $defer.resolve(page.content);
|
|
|
+ $scope.users = page.content;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ param.keyword = $scope.keyword;
|
|
|
+ Enterprise.findUsersByKeyword(param, function (page) {
|
|
|
+ if (page) {
|
|
|
+ params.total(page.totalElements);
|
|
|
+ $defer.resolve(page.content);
|
|
|
+ $scope.users = page.content;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ $scope.onSearch = function (keyword) {
|
|
|
+ if (keyword != null && keyword != '') {
|
|
|
+ $scope.searchMthod = true;
|
|
|
+ $scope.keyword = keyword;
|
|
|
+ } else {
|
|
|
+ $scope.searchMthod = false;
|
|
|
+ }
|
|
|
+ $scope.tableParams.page(1);
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.newUser = {};
|
|
|
+
|
|
|
+ //弹出添加用户模态框
|
|
|
+ $scope.addExistUser = function () {
|
|
|
+ var modalInstance = $modal.open({
|
|
|
+ animation: true,
|
|
|
+ templateUrl: $rootScope.rootPath
|
|
|
+ + '/static/view/vendor/forstore/addExistUser.html',
|
|
|
+ controller: 'AddExistUserCtrl'
|
|
|
+ });
|
|
|
+
|
|
|
+ modalInstance.result.then(function () {
|
|
|
+ $scope.userTelSuccess = false;
|
|
|
+ $scope.userTelError = false;
|
|
|
+ $scope.tableParams.page(1);
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ }, function () {
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * 添加未注册用户
|
|
|
+ */
|
|
|
+ $scope.addUser = function () {
|
|
|
+ $scope.adding = true;
|
|
|
+ $scope.loading = true;
|
|
|
+ Enterprise.saveUser({}, $scope.newUser, function () {
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('success', '提示', '增加用户成功:' + $scope.newUser.userName);
|
|
|
+ $scope.newUser = {userSex: 'M'};
|
|
|
+ $scope.tableParams.page(1);
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ $scope.adding = false;
|
|
|
+ $scope.newUserForm.newUserTel.$setValidity('available', false);
|
|
|
+ $scope.newUserForm.newUserEmail.$setValidity('available', false);
|
|
|
+ $scope.userTelSuccess = false;
|
|
|
+ $scope.userTelError = false;
|
|
|
+ $scope.userEmailSuccess = false;
|
|
|
+ $scope.userEmailError = false;
|
|
|
+ }, function (response) {
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '错误', response.data);
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除用户
|
|
|
+ */
|
|
|
+ $scope.removeUser = function (user) {
|
|
|
+
|
|
|
+ if (confirm('确定删除用户(' + user.userName + ')吗?')) {
|
|
|
+ Enterprise.removeUser({uu: user.userUU}, function () {
|
|
|
+ toaster.pop('success', '提示', '用户删除成功。');
|
|
|
+ $scope.tableParams.page(1);
|
|
|
+ $scope.tableParams.reload();
|
|
|
+ }, function (response) {
|
|
|
+ toaster.pop('error', '删除失败', response.data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * 验证手机号是否可用
|
|
|
+ */
|
|
|
+ $scope.telValid = function (tel) {
|
|
|
+ if (tel) {
|
|
|
+ $http.get('basic/user/telEnable', {
|
|
|
+ params: {
|
|
|
+ tel: tel
|
|
|
+ }
|
|
|
+ }).success(function (data) {
|
|
|
+ data = eval(data);
|
|
|
+ if (data == true) {
|
|
|
+ $scope.newUserForm.newUserTel.$setValidity('available', true);
|
|
|
+ $scope.userTelSuccess = true;
|
|
|
+ $scope.userTelError = false;
|
|
|
+ } else {
|
|
|
+ $scope.newUserForm.newUserTel.$setValidity('available',
|
|
|
+ false);
|
|
|
+ $scope.userTelError = true;
|
|
|
+ $scope.userTelSuccess = false;
|
|
|
+ if (tel.length == 11) {
|
|
|
+ toaster.pop('error', '错误', '手机号 ' + tel + ' 已被注册');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).error(function () {
|
|
|
+ $scope.userTelSuccess = false;
|
|
|
+ $scope.userTelError = true;
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ $scope.userTelSuccess = false;
|
|
|
+ $scope.userTelError = false;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 验证邮箱是否可用
|
|
|
+ */
|
|
|
+ $scope.emailValid = function (email) {
|
|
|
+ if (email) {
|
|
|
+ $http.get('basic/user/emailEnable', {
|
|
|
+ params: {
|
|
|
+ email: email
|
|
|
+ }
|
|
|
+ }).success(function (data) {
|
|
|
+ data = eval(data);
|
|
|
+ if (data == true) {
|
|
|
+ $scope.newUserForm.newUserEmail.$setValidity('available',
|
|
|
+ true);
|
|
|
+ $scope.userEmailSuccess = true;
|
|
|
+ $scope.userEmailError = false;
|
|
|
+ } else {
|
|
|
+ $scope.newUserForm.newUserEmail.$setValidity('available',
|
|
|
+ false);
|
|
|
+ $scope.userEmailError = true;
|
|
|
+ $scope.userEmailSuccess = false;
|
|
|
+ }
|
|
|
+ }).error(function () {
|
|
|
+ $scope.userEmailError = true;
|
|
|
+ $scope.userEmailSuccess = false;
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ $scope.userEmailError = false;
|
|
|
+ $scope.userEmailSuccess = false;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 变更到更新状态
|
|
|
+ */
|
|
|
+ $scope.changeToUpdate = function (isUpdate) {
|
|
|
+ $scope.updateState = isUpdate;
|
|
|
+ if ($scope.updateState == false) {
|
|
|
+ $scope.enterpriseInfo = angular.copy($scope.enterpriseInfoBackup);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 验证企业信息
|
|
|
+ */
|
|
|
+ function validateEnterpriseInfo() {
|
|
|
+ var props = ['enName', 'enShortname', 'enAddress', 'enUrl'];
|
|
|
+
|
|
|
+ var flag = true;
|
|
|
+ angular.forEach(props, function (prop) {
|
|
|
+ if ($scope.enterpriseInfo.hasOwnProperty(prop)) {
|
|
|
+ if (!$scope.enterpriseInfo[prop] || $scope.enterpriseInfo[prop]
|
|
|
+ === '') {
|
|
|
+ console.log(prop + '不能为空');
|
|
|
+ // TODO 记录验证信息
|
|
|
+ flag = false;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ console.log(prop + '不能为空');
|
|
|
+ flag = false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存企业信息
|
|
|
+ */
|
|
|
+ $scope.saveUpdate = function () {
|
|
|
+ // 先检查信息是否为空
|
|
|
+ if (angular.equals($scope.enterpriseInfo,
|
|
|
+ $scope.enterpriseInfoBackup)) {
|
|
|
+ toaster.pop('error', '未做任何修改');
|
|
|
+ $scope.updateState = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var enterpriseInfoFlag = validateEnterpriseInfo();
|
|
|
+ if (!enterpriseInfoFlag) {
|
|
|
+ toaster.pop('error', '请补充完信息后再次提交');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Enterprise.updateEnterpriseInfo(
|
|
|
+ {enuu: $scope.userInfo.enterprise.uu}, $scope.enterpriseInfo,
|
|
|
+ function () {
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('success', '提示', '企业信息修改成功');
|
|
|
+ $scope.enterpriseInfoBackup = angular.copy(
|
|
|
+ $scope.enterpriseInfo);
|
|
|
+ $scope.updateState = false;
|
|
|
+
|
|
|
+ }, function (response) {
|
|
|
+ $scope.loading = false;
|
|
|
+ toaster.pop('error', '修改失败', response.data);
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ // 切换tab
|
|
|
+ $scope.checkTab = function (t) {
|
|
|
+ $scope.tab = t;
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.updatePassword = function () {
|
|
|
+ var modalInstance = $modal.open({
|
|
|
+ animation: true,
|
|
|
+ templateUrl: $rootScope.rootPath
|
|
|
+ + '/static/view/vendor/modal/updatePassword.html',
|
|
|
+ controller: 'PasswordCtrl',
|
|
|
+ resolve: {
|
|
|
+ user: function () {
|
|
|
+ return angular.copy($rootScope.userInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ modalInstance.result.then(function () {
|
|
|
+ }, function () {
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.updateUserEmail = function(){
|
|
|
+ var modalInstance = $modal.open({
|
|
|
+ animation: true,
|
|
|
+ templateUrl: $rootScope.rootPath + '/static/view/vendor/modal/updateUserEmail.html',
|
|
|
+ controller: 'UserEmailCtrl',
|
|
|
+ resolve: {
|
|
|
+ user: function(){return angular.copy($rootScope.userInfo);}
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ modalInstance.result.then(function(){
|
|
|
+ }, function(){
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.updateUserTel = function(){
|
|
|
+ var modalInstance = $modal.open({
|
|
|
+ animation: true,
|
|
|
+ templateUrl: $rootScope.rootPath + '/static/view/vendor/modal/updateUserTel.html',
|
|
|
+ controller: 'UserTelCtrl',
|
|
|
+ resolve: {
|
|
|
+ user: function(){return angular.copy($rootScope.userInfo);}
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ modalInstance.result.then(function(){
|
|
|
+ }, function(){
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.updateUserPay = function(){
|
|
|
+ var modalInstance = $modal.open({
|
|
|
+ animation: true,
|
|
|
+ templateUrl: $rootScope.rootPath + '/static/view/vendor/modal/updateUserPay.html',
|
|
|
+ controller: 'UserPayCtrl',
|
|
|
+ resolve: {
|
|
|
+ user: function(){return angular.copy($rootScope.userInfo);}
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ modalInstance.result.then(function(){
|
|
|
+ }, function(){
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.updateUserQuestion = function(){
|
|
|
+ var modalInstance = $modal.open({
|
|
|
+ animation: true,
|
|
|
+ templateUrl: $rootScope.rootPath + '/static/view/vendor/modal/updateUserQuestion.html',
|
|
|
+ controller: 'UserQuestionCtrl',
|
|
|
+ resolve: {
|
|
|
+ user: function(){return angular.copy($rootScope.userInfo);}
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ modalInstance.result.then(function(){
|
|
|
+ }, function(){
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.updateRealAuth = function(){
|
|
|
+ var modalInstance = $modal.open({
|
|
|
+ animation: true,
|
|
|
+ templateUrl: $rootScope.rootPath + '/static/view/vendor/modal/updateRealAuth.html',
|
|
|
+ controller: 'UserRealAuthCtrl',
|
|
|
+ resolve: {
|
|
|
+ user: function(){return angular.copy($rootScope.userInfo);}
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ modalInstance.result.then(function(){
|
|
|
+ }, function(){
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ //卖家中心 等级提示跳转
|
|
|
+ if($stateParams.op!=""){
|
|
|
+ var op =$stateParams.op;
|
|
|
+ $scope.checkTab('safe');
|
|
|
+ switch(op)
|
|
|
+ {
|
|
|
+ case 'pwd':
|
|
|
+ $scope.updatePassword();
|
|
|
+ break;
|
|
|
+ case 'question':
|
|
|
+ $scope.updateUserQuestion();
|
|
|
+ break;
|
|
|
+ case 'email':
|
|
|
+ $scope.updateUserEmail();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }]);
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 绑定用户到企业
|
|
|
+ */
|
|
|
+ app.register.controller('AddExistUserCtrl',
|
|
|
+ ['$scope', '$modalInstance', 'Enterprise', 'AuthenticationService',
|
|
|
+ '$timeout', 'toaster',
|
|
|
+ function ($scope, $modalInstance, Enterprise, AuthenticationService,
|
|
|
+ $timeout, toaster) {
|
|
|
+ $scope.searching = false;
|
|
|
+ //根据输入的内容查找用户
|
|
|
+ $scope.searchUser = function (keyWord) {
|
|
|
+ $scope.searching = true;
|
|
|
+ $scope.searchSuccess = false;
|
|
|
+ $scope.searchFailed = false;
|
|
|
+ $scope.illegalError = false;
|
|
|
+ $scope.reBindError = false;
|
|
|
+ $scope.okDisabled = false;
|
|
|
+ Enterprise.searchUser({keyWord: keyWord}, function (data) {
|
|
|
+ $scope.searchSuccess = true;
|
|
|
+ $scope.searchFailed = false;
|
|
|
+ $scope.user = data; //查询到的用户
|
|
|
+ }, function (response) {
|
|
|
+ $scope.searchSuccess = false;
|
|
|
+ $scope.searchFailed = true;
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ //确认绑定
|
|
|
+ $scope.ok = function (keyWord) {
|
|
|
+ AuthenticationService.getAuthentication().success(function (data) {
|
|
|
+ $scope.currentUser = data; //当前登录的用户(管理员)
|
|
|
+ //不可自己绑定自己
|
|
|
+ if ($scope.currentUser.userUU == $scope.user.userUU) {
|
|
|
+ $scope.illegalError = true;
|
|
|
+ $scope.okDisabled = true;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ //用户未绑定到任何企业时
|
|
|
+ if (!$scope.user.enterprises) {
|
|
|
+ //正常绑定
|
|
|
+ Enterprise.bindUserToMyEnterprise({userUU: $scope.user.userUU},
|
|
|
+ function (data) {
|
|
|
+ $scope.okDisabled = true;
|
|
|
+ toaster.pop("success", "提示", "用户绑定成功");
|
|
|
+ $modalInstance.close(true);
|
|
|
+ }, function (response) {
|
|
|
+ });
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ //用户已绑定到某些企业时
|
|
|
+ for (var i = 0; i < $scope.currentUser.enterprises.length; i++) {
|
|
|
+ if ($scope.currentUser.enterprises[i].current) {
|
|
|
+ for (var j = 0; j < $scope.user.enterprises.length; j++) {
|
|
|
+ //该用户已绑定到当前企业,不可重复绑定
|
|
|
+ if ($scope.currentUser.enterprises[i].uu
|
|
|
+ == $scope.user.enterprises[j].uu) {
|
|
|
+ $scope.reBindError = true;
|
|
|
+ $scope.okDisabled = true;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //该用户未绑定到当前企业,可以进行绑定
|
|
|
+ Enterprise.bindUserToMyEnterprise(
|
|
|
+ {userUU: $scope.user.userUU}, function (data) {
|
|
|
+ $scope.okDisabled = true;
|
|
|
+ toaster.pop("success", "提示", "用户绑定成功");
|
|
|
+ $modalInstance.close(true);
|
|
|
+ }, function (response) {
|
|
|
+ console.log("绑定失败!");
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.cancel = function () {
|
|
|
+ $modalInstance.dismiss();
|
|
|
+ };
|
|
|
+ }]);
|
|
|
+
|
|
|
+ app.register.controller('PasswordCtrl',
|
|
|
+ ['$scope', '$modalInstance', 'user', 'User', 'toaster',
|
|
|
+ function ($scope, $modalInstance, user, User, toaster) {
|
|
|
+ $scope.user = user;
|
|
|
+ $scope.checking = false;
|
|
|
+ //输入原密码后验证原密码是否正确
|
|
|
+ $scope.checkPassword = function (password) {
|
|
|
+ $scope.checking = true;
|
|
|
+ $scope.checkSuccess = false;
|
|
|
+ $scope.checkFailed = false;
|
|
|
+ User.checkPassword({password: password}, function () {
|
|
|
+ $scope.checkSuccess = true;
|
|
|
+ $scope.checking = false;
|
|
|
+ $scope.checkFailed = false;
|
|
|
+ }, function () {
|
|
|
+ $scope.checkFailed = true;
|
|
|
+ $scope.checking = false;
|
|
|
+ $scope.checkSuccess = false;
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ //对新密码进行校验
|
|
|
+ $scope.checkSuccess1 = false;
|
|
|
+ $scope.checkFailed1 = false;
|
|
|
+ $scope.checkNewPassword = function (newPassword) {
|
|
|
+ var reg = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,20}$/;
|
|
|
+ if (newPassword == null || !reg.test(newPassword)) {
|
|
|
+ //toaster.pop('error', '错误', '密码为8-20字符的英文、数字混合');
|
|
|
+ $scope.checkSuccess1 = false;
|
|
|
+ $scope.checkFailed1 = true;
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ $scope.checkSuccess1 = true;
|
|
|
+ $scope.checkFailed1 = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //密码强度校验
|
|
|
+ $scope.secLevel = 0;
|
|
|
+ $scope.checkPasswordLevel = function (newPassword) {
|
|
|
+ $scope.checkFailed1 = false;
|
|
|
+ if (newPassword == null) {
|
|
|
+ $scope.secLevel = 0;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //不足8位,或仅有数字,或仅有英文
|
|
|
+ if (newPassword.length < 8 || /^[0-9]*$/.test(newPassword)
|
|
|
+ || /^[A-Za-z]*$/.test(newPassword)) {
|
|
|
+ $scope.secLevel = 1;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (/^[A-Z0-9]{8,20}$/.test(newPassword) || /^[a-z0-9]{8,20}$/.test(
|
|
|
+ newPassword)) {//达到8位,且 仅有数字+英文小写 或 仅有数字+英文大写
|
|
|
+ $scope.secLevel = 2;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (/^(?=.*[0-9].*)(?=.*[A-Z].*)(?=.*[a-z].*).{8,20}$/.test(
|
|
|
+ newPassword)) {
|
|
|
+ $scope.secLevel = 3;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //校验确认密码是否与新密码相同
|
|
|
+ $scope.checkSuccess2 = false;
|
|
|
+ $scope.checkFailed2 = false;
|
|
|
+ $scope.checkNewPassword1 = function () {
|
|
|
+ if ($scope.checkSuccess1 == true && ($scope.user.newPassword
|
|
|
+ == $scope.user.newPassword1)) {
|
|
|
+ $scope.checkSuccess2 = true;
|
|
|
+ $scope.checkFailed2 = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $scope.checkSuccess2 = false;
|
|
|
+ $scope.checkFailed2 = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ //修改密码
|
|
|
+ $scope.ok = function () {
|
|
|
+ if ($scope.user.newPassword == $scope.user.password) {
|
|
|
+ toaster.pop('error', '错误', '新密码与原密码相同');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if ($scope.secLevel <= 1) {
|
|
|
+ toaster.pop('error', '错误', '密码强度不够,请重新输入');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if ($scope.user.newPassword == $scope.user.newPassword1) {//验证重复密码相等
|
|
|
+ User.updatePassword({
|
|
|
+ password: $scope.user.password,
|
|
|
+ newPassword: $scope.user.newPassword,
|
|
|
+ secLevel: $scope.secLevel
|
|
|
+ }, {}, function () {
|
|
|
+ toaster.pop('success', '成功', '修改密码成功,请牢记您的新密码。');
|
|
|
+ $scope.user.password = null;
|
|
|
+ $scope.user.newPassword = null;
|
|
|
+ $scope.user.newPassword1 = null;
|
|
|
+ $scope.checking = false;
|
|
|
+ $scope.checkSuccess = false;
|
|
|
+ $scope.checkFailed = false;
|
|
|
+ $scope.checkSuccess1 = false;
|
|
|
+ $scope.checkFailed1 = false;
|
|
|
+ $scope.checkSuccess2 = false;
|
|
|
+ $scope.checkFailed2 = false;
|
|
|
+ $modalInstance.close();
|
|
|
+ }, function (response) {
|
|
|
+ toaster.pop('error', '错误', response.data);
|
|
|
+ $modalInstance.close();
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ toaster.pop('error', '错误', '重复密码不一致');
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.cancel = function () {
|
|
|
+ $modalInstance.close();
|
|
|
+ };
|
|
|
+ }]);
|
|
|
+ // 修改邮箱Controller
|
|
|
+ app.register.controller('UserEmailCtrl',
|
|
|
+ ['$scope', '$modalInstance', 'user', 'User', 'toaster', '$interval',
|
|
|
+ function ($scope, $modalInstance, user, User, toaster, $interval) {
|
|
|
+ $scope.user = user;
|
|
|
+ $scope.user.userEmail = null;
|
|
|
+ $scope.user.newUserEmail = null;
|
|
|
+ //验证用户输入的旧邮箱地址是否正确
|
|
|
+ $scope.checkUserEmail = function (userEmail) {
|
|
|
+ if (userEmail == null) {
|
|
|
+ $scope.checkFailed = true;
|
|
|
+ $scope.checkSuccess = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $scope.checkSuccess = false;
|
|
|
+ $scope.checkFailed = false;
|
|
|
+ User.checkUserEmail({userEmail: userEmail}, function () {
|
|
|
+ $scope.checkSuccess = true;
|
|
|
+ $scope.checkFailed = false;
|
|
|
+ }, function () {
|
|
|
+ $scope.checkFailed = true;
|
|
|
+ $scope.checkSuccess = false;
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ //验证用户新输入的邮箱是否可用
|
|
|
+ $scope.checkSuccess1 = false;
|
|
|
+ $scope.checkFailed1 = false;
|
|
|
+ $scope.emailEnable = function (newUserEmail) {
|
|
|
+ if ((newUserEmail == null || newUserEmail.length > 30)
|
|
|
+ && !/^(\w)+(\.\w+)*@(\w)+((\.\w{2,3}){1,3})$/.test(
|
|
|
+ newUserEmail)) {
|
|
|
+ $scope.checkSuccess1 = false;
|
|
|
+ $scope.checkFailed1 = true;
|
|
|
+ $scope.sendSuccess = false;
|
|
|
+ }
|
|
|
+ User.emailEnable({email: newUserEmail}, function (data) {
|
|
|
+ if (data.data == "true") {//邮箱可用
|
|
|
+ $scope.checkSuccess1 = true;
|
|
|
+ $scope.checkFailed1 = false;
|
|
|
+ $scope.sendSuccess = true;
|
|
|
+ } else {//邮箱不可用
|
|
|
+ $scope.checkSuccess1 = false;
|
|
|
+ $scope.checkFailed1 = true;
|
|
|
+ $scope.sendSuccess = false;
|
|
|
+ }
|
|
|
+ }, function () {
|
|
|
+ $scope.checkSuccess1 = false;
|
|
|
+ $scope.checkFailed1 = true;
|
|
|
+ $scope.sendSuccess = false;
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.codeSuccess = false;
|
|
|
+ //发送验证码
|
|
|
+ $scope.sendCheckCode = function (newUserEmail) {
|
|
|
+ User.sendCheckCode({newUserEmail: newUserEmail}, function () {
|
|
|
+ $scope.codeSuccess = true;
|
|
|
+ $interval.cancel(timePromise);
|
|
|
+ var second = 60,
|
|
|
+ timePromise = $interval(function () {
|
|
|
+ $scope.sendSuccess = false;
|
|
|
+ if (second <= 0) {
|
|
|
+ $interval.cancel(timePromise);
|
|
|
+ second = 60;
|
|
|
+ } else {
|
|
|
+ second--;
|
|
|
+ $scope.paracont = second + "秒后可重发";
|
|
|
+ if (second == 0) {
|
|
|
+ $scope.paracont = "重发验证码";
|
|
|
+ $scope.sendSuccess = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, 1000, 60);
|
|
|
+ }, function () {
|
|
|
+ $scope.codeSuccess = false;
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.validSuccess = false;
|
|
|
+ //校验验证码
|
|
|
+ $scope.validCheckCode = function (checkCode) {
|
|
|
+ User.validCheckCode({checkCode: checkCode}, function (data) {
|
|
|
+ var status = data.status;
|
|
|
+ var message = data.message;
|
|
|
+ if (status == 1) {
|
|
|
+ $scope.validSuccess = true;
|
|
|
+ } else {
|
|
|
+ toaster.pop('error', '错误', message);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ //修改邮箱地址
|
|
|
+ $scope.ok = function () {
|
|
|
+ if ($scope.user.newUserEmail == $scope.user.userEmail) {
|
|
|
+ toaster.pop('error', '错误', '新邮箱地址与旧邮箱地址相同');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ User.updateUserEmail({
|
|
|
+ userEmail: $scope.user.userEmail,
|
|
|
+ newUserEmail: $scope.user.newUserEmail
|
|
|
+ }, {}, function () {
|
|
|
+ toaster.pop('success', '成功', '修改邮箱成功。');
|
|
|
+ $scope.user.userEmail = null;
|
|
|
+ $scope.user.newUserEmail = null;
|
|
|
+ $scope.checking = false;
|
|
|
+ $scope.checkSuccess = false;
|
|
|
+ $scope.checkFailed = false;
|
|
|
+ $scope.codeSuccess = false;
|
|
|
+ $scope.validSuccess = false;
|
|
|
+ $scope.checkSuccess1 = false;
|
|
|
+ $scope.checkFailed1 = false;
|
|
|
+ $scope.sendSuccess = false;
|
|
|
+ $modalInstance.close();
|
|
|
+ }, function (response) {
|
|
|
+ toaster.pop('error', '错误', response.data);
|
|
|
+ $modalInstance.close();
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.cancel = function () {
|
|
|
+ $modalInstance.close();
|
|
|
+ };
|
|
|
+ }]);
|
|
|
+
|
|
|
+ //手机验证Controller
|
|
|
+ app.register.controller('UserTelCtrl',
|
|
|
+ ['$scope', '$modalInstance', 'user', 'User', 'toaster', '$interval',
|
|
|
+ function ($scope, $modalInstance, user, User, toaster, $interval) {
|
|
|
+ User.getPageToken();
|
|
|
+ $scope.user = user;
|
|
|
+ $scope.user.userTel = null;
|
|
|
+ //原手机号校验
|
|
|
+ $scope.checking = false;
|
|
|
+ //验证用户输入的旧邮箱地址是否正确
|
|
|
+ $scope.checkUserTel = function (userTel) {
|
|
|
+ $scope.checking = true;
|
|
|
+ $scope.checkSuccess = false;
|
|
|
+ $scope.checkFailed = false;
|
|
|
+ User.checkUserTel({userTel: userTel}, function () {
|
|
|
+ $scope.checkSuccess = true;
|
|
|
+ $scope.checking = false;
|
|
|
+ $scope.checkFailed = false;
|
|
|
+ }, function () {
|
|
|
+ $scope.checkFailed = true;
|
|
|
+ $scope.checking = false;
|
|
|
+ $scope.checkSuccess = false;
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ //新手机号是否可用
|
|
|
+ $scope.sendSuccess = false;
|
|
|
+ $scope.checkFailed1 = false;
|
|
|
+ $scope.checkSuccess1 = false;
|
|
|
+ $scope.telEnable = function (newUserTel) {
|
|
|
+ if (newUserTel == null || !/^[0-9]{8,11}$/.test(newUserTel)) {
|
|
|
+ $scope.checkFailed1 = true;
|
|
|
+ $scope.checkSuccess1 = false;
|
|
|
+ $scope.sendSuccess = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $scope.checking1 = true;
|
|
|
+ $scope.checkSuccess1 = false;
|
|
|
+ $scope.checkFailed1 = false;
|
|
|
+ User.telEnable({tel: newUserTel}, function (data) {
|
|
|
+ if (data.data == "true") {//手机可用
|
|
|
+ $scope.checkSuccess1 = true;
|
|
|
+ $scope.checkFailed1 = false;
|
|
|
+ $scope.sendSuccess = true;
|
|
|
+ } else {//手机不可用
|
|
|
+ $scope.checkFailed1 = true;
|
|
|
+ $scope.checking1 = false;
|
|
|
+ $scope.checkSuccess1 = false;
|
|
|
+ $scope.sendSuccess = false;
|
|
|
+ }
|
|
|
+ }, function () {
|
|
|
+ $scope.checkFailed1 = true;
|
|
|
+ $scope.checking1 = false;
|
|
|
+ $scope.checkSuccess1 = false;
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ //发送验证码
|
|
|
+ $scope.codeSuccess = false;
|
|
|
+ //发送验证码
|
|
|
+ $scope.sendTelCheckCode = function (newUserTel) {
|
|
|
+ User.sendTelCheckCode({newUserTel: newUserTel}, function () {
|
|
|
+ $scope.codeSuccess = true;
|
|
|
+ $interval.cancel(timePromise);
|
|
|
+ var second = 60,
|
|
|
+ timePromise = $interval(function () {
|
|
|
+ $scope.sendSuccess = false;
|
|
|
+ if (second <= 0) {
|
|
|
+ $interval.cancel(timePromise);
|
|
|
+ second = 60;
|
|
|
+ } else {
|
|
|
+ second--;
|
|
|
+ $scope.paracont = second + "秒后可重发";
|
|
|
+ if (second == 0) {
|
|
|
+ $scope.paracont = "重发验证码";
|
|
|
+ $scope.sendSuccess = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, 1000, 60);
|
|
|
+ }, function () {
|
|
|
+ $scope.codeSuccess = false;
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.validSuccess = false;
|
|
|
+ $scope.validFailed = false;
|
|
|
+ //校验验证码
|
|
|
+ $scope.validTelCheckCode = function (telCheckCode) {
|
|
|
+ User.validTelCheckCode({telCheckCode: telCheckCode},
|
|
|
+ function (data) {
|
|
|
+ var status = data.status;
|
|
|
+ var message = data.message;
|
|
|
+ if (status == 1) {
|
|
|
+ $scope.validSuccess = true;
|
|
|
+ $scope.validFailed = false;
|
|
|
+ } else {
|
|
|
+ $scope.validSuccess = false;
|
|
|
+ $scope.validFailed = true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ //修改手机
|
|
|
+ $scope.ok = function () {
|
|
|
+ if ($scope.user.newUserTel == $scope.user.userTel) {
|
|
|
+ toaster.pop('error', '错误', '新手机号与旧手机号相同');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ User.updateUserTel({
|
|
|
+ newUserTel: $scope.user.newUserTel,
|
|
|
+ userTel: $scope.user.userTel
|
|
|
+ }, {}, function () {
|
|
|
+ toaster.pop('success', '成功', '手机修改成功。');
|
|
|
+ $scope.user.userTel = null;
|
|
|
+ $scope.user.newUserTel = null;
|
|
|
+ $scope.checking = false;
|
|
|
+ $scope.checkSuccess = false;
|
|
|
+ $scope.checkFailed = false;
|
|
|
+ $scope.checking1 = false;
|
|
|
+ $scope.checkSuccess1 = false;
|
|
|
+ $scope.checkFailed1 = false;
|
|
|
+ $scope.emailSuccess = false;
|
|
|
+ $scope.codeSuccess = false;
|
|
|
+ $scope.validSuccess = false;
|
|
|
+ $modalInstance.close();
|
|
|
+ }, function (response) {
|
|
|
+ toaster.pop('error', '错误', response.data);
|
|
|
+ $modalInstance.close();
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.cancel = function () {
|
|
|
+ $modalInstance.close();
|
|
|
+ };
|
|
|
+ }]);
|
|
|
+
|
|
|
+ // 设置支付密码Controller
|
|
|
+ app.register.controller('UserPayCtrl',
|
|
|
+ ['$scope', '$modalInstance', 'user', 'User', 'toaster',
|
|
|
+ function ($scope, $modalInstance, user, User, toaster) {
|
|
|
+ //原密码框是否显示
|
|
|
+ $scope.checking = true;
|
|
|
+ //验证是否设置密码
|
|
|
+ $scope.checkHaveUserPay = function () {
|
|
|
+ $scope.userPayHidden = false;
|
|
|
+ $scope.isNewSuccess = false;
|
|
|
+ $scope.isNewFailed = true;
|
|
|
+ User.checkHaveUserPay(function (data) {
|
|
|
+ var flag = data.data;
|
|
|
+ if (flag == "false") {
|
|
|
+ //隐藏原密码输入框
|
|
|
+ angular.element(".oldUserPay").remove();
|
|
|
+ //修改新密码框内容
|
|
|
+ $scope.newUserPayLabel = "密码";
|
|
|
+ $scope.isNewSuccess = true;
|
|
|
+ $scope.isNewFailed = false;
|
|
|
+ $scope.checking = false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ //校验原密码是否正确
|
|
|
+ $scope.checkUserPay = function (userPay) {
|
|
|
+ if (userPay != null) {
|
|
|
+ $scope.checkSuccess = false;
|
|
|
+ $scope.checkFailed = false;
|
|
|
+ User.checkUserPay({userPay: userPay}, function () {
|
|
|
+ $scope.checkFailed = false;
|
|
|
+ $scope.checkSuccess = true;
|
|
|
+ }, function () {
|
|
|
+ $scope.checkFailed = true;
|
|
|
+ $scope.checkSuccess = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //输入新密码,进行校验
|
|
|
+ $scope.checkSuccess1 = false;
|
|
|
+ $scope.checkFailed1 = false;
|
|
|
+ $scope.checkNewUserPay = function (newUserPay) {
|
|
|
+ if (newUserPay != null) {
|
|
|
+ //如果两者相同 则返回
|
|
|
+ if ($scope.checking && ($scope.user.userPay
|
|
|
+ == $scope.user.newUserPay)) {
|
|
|
+ toaster.pop('error', '错误', '新密码与原密码相同');
|
|
|
+ $scope.checkFailed1 = true;
|
|
|
+ $scope.checkSuccess1 = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //正则校验
|
|
|
+ var reg = /^\d{6}$/;
|
|
|
+ if (!reg.test(newUserPay)) {
|
|
|
+ $scope.checkFailed1 = true;
|
|
|
+ $scope.checkSuccess1 = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $scope.checkFailed1 = false;
|
|
|
+ $scope.checkSuccess1 = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //校验确认密码是否与新密码相同
|
|
|
+ $scope.checkSuccess2 = false;
|
|
|
+ $scope.checkFailed2 = false;
|
|
|
+ $scope.checkNewUserPay1 = function () {
|
|
|
+ if ($scope.checkSuccess1 == true && ($scope.user.newUserPay
|
|
|
+ == $scope.user.newUserPay1)) {
|
|
|
+ $scope.checkSuccess2 = true;
|
|
|
+ $scope.checkFailed2 = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $scope.checkSuccess2 = false;
|
|
|
+ $scope.checkFailed2 = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ //支付密码
|
|
|
+ $scope.ok = function () {
|
|
|
+ if ($scope.checking && ($scope.user.newUserPay
|
|
|
+ == $scope.user.userPay)) {
|
|
|
+ toaster.pop('error', '错误', '新密码与旧密码相同');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ User.updateUserPay({
|
|
|
+ newUserPay: $scope.user.newUserPay,
|
|
|
+ userPay: $scope.user.userPay
|
|
|
+ }, {}, function () {
|
|
|
+ toaster.pop('success', '成功', '支付密码设置成功。');
|
|
|
+ $scope.user.userPay = null;
|
|
|
+ $scope.user.newUserPay = null;
|
|
|
+ $scope.checkSuccess = false;
|
|
|
+ $scope.checkFailed = false;
|
|
|
+ $scope.checkSuccess1 = false;
|
|
|
+ $scope.checkFailed1 = false;
|
|
|
+ $scope.checkSuccess2 = false;
|
|
|
+ $scope.checkFailed2 = false;
|
|
|
+ $scope.checking = true;
|
|
|
+ $modalInstance.close();
|
|
|
+ }, function (response) {
|
|
|
+ toaster.pop('error', '错误', response.data);
|
|
|
+ $modalInstance.close();
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.cancel = function () {
|
|
|
+ $modalInstance.close();
|
|
|
+ };
|
|
|
+ }]);
|
|
|
+
|
|
|
+ // 设置密保问题Controller
|
|
|
+ app.register.controller('UserQuestionCtrl',
|
|
|
+ ['$scope', '$modalInstance', 'user', 'User', 'toaster',
|
|
|
+ function ($scope, $modalInstance, user, User, toaster) {
|
|
|
+ //查询所有的密保问题
|
|
|
+ $scope.pageInfo = {page: 1, size: 100};
|
|
|
+ User.getAllSecQuestion({pageInfo: $scope.pageInfo}, {},
|
|
|
+ function (data) {
|
|
|
+ $scope.secQuestions = data.content;
|
|
|
+ //查询当前用户密保问题
|
|
|
+ User.getUserQuestion(function (data) {
|
|
|
+ $scope.uq[0] = data[0];
|
|
|
+ $scope.uq[1] = data[1];
|
|
|
+ });
|
|
|
+ });
|
|
|
+ //选择问题 校验
|
|
|
+ $scope.checkSuccess = false;
|
|
|
+ $scope.checkFailed = false;
|
|
|
+ $scope.checkSuccess2 = false;
|
|
|
+ $scope.checkFailed2 = false;
|
|
|
+ $scope.choose = function () {
|
|
|
+ if ($scope.uq[0].question != "") {
|
|
|
+ $scope.checkSuccess = true;
|
|
|
+ $scope.checkFailed = false;
|
|
|
+ } else {
|
|
|
+ $scope.checkSuccess = false;
|
|
|
+ $scope.checkFailed = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.choose1 = function () {
|
|
|
+ if ($scope.uq[1].question != "") {
|
|
|
+ $scope.checkSuccess2 = true;
|
|
|
+ $scope.checkFailed2 = false;
|
|
|
+ } else {
|
|
|
+ $scope.checkSuccess2 = false;
|
|
|
+ $scope.checkFailed2 = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //答案校验 不超过30个字符
|
|
|
+ $scope.checkSuccess1 = false;
|
|
|
+ $scope.checkFailed1 = false;
|
|
|
+ $scope.checkFailed1_1 = false;
|
|
|
+ $scope.checkSuccess3 = false;
|
|
|
+ $scope.checkFailed3 = false;
|
|
|
+ $scope.checkFailed3_1 = false;
|
|
|
+ $scope.inputAnswer = function () {
|
|
|
+ if ($scope.uq[0].answer == null) {
|
|
|
+ $scope.checkSuccess1 = false;
|
|
|
+ $scope.checkFailed1 = true;
|
|
|
+ $scope.checkFailed1_1 = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if ($scope.uq[0].answer.length > 30) {
|
|
|
+ $scope.checkSuccess1 = false;
|
|
|
+ $scope.checkFailed1 = false;
|
|
|
+ $scope.checkFailed1_1 = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $scope.checkSuccess1 = true;
|
|
|
+ $scope.checkFailed1 = false;
|
|
|
+ $scope.checkFailed1_1 = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.inputAnswer1 = function () {
|
|
|
+ if ($scope.uq[1].answer == null) {
|
|
|
+ $scope.checkSuccess3 = false;
|
|
|
+ $scope.checkFailed3 = true;
|
|
|
+ $scope.checkFailed3_1 = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if ($scope.uq[1].answer.length > 30) {
|
|
|
+ $scope.checkSuccess3 = false;
|
|
|
+ $scope.checkFailed3 = false;
|
|
|
+ $scope.checkFailed3_1 = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $scope.checkSuccess3 = true;
|
|
|
+ $scope.checkFailed3 = false;
|
|
|
+ $scope.checkFailed3_1 = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ //保存密保
|
|
|
+ $scope.ok = function () {
|
|
|
+ var arr = [];
|
|
|
+ for (var key in $scope.uq) {
|
|
|
+ $scope.uq[key].sort = Number(key) + 1;
|
|
|
+ arr[key] = $scope.uq[key];
|
|
|
+ }
|
|
|
+ User.updateUserQuestion({}, arr, function () {
|
|
|
+ toaster.pop('success', '成功', '密保问题设置成功。');
|
|
|
+ $modalInstance.close();
|
|
|
+ $scope.uq = null;
|
|
|
+ $scope.checkSuccess = false;
|
|
|
+ $scope.checkFailed = false;
|
|
|
+ $scope.checkSuccess1 = false;
|
|
|
+ $scope.checkFailed1 = false;
|
|
|
+ $scope.checkSuccess2 = false;
|
|
|
+ $scope.checkFailed2 = false;
|
|
|
+ $scope.checkSuccess3 = false;
|
|
|
+ $scope.checkFailed3 = false;
|
|
|
+ $scope.checkFailed3_1 = false;
|
|
|
+ $scope.checkFailed1_1 = false;
|
|
|
+ }, function (response) {
|
|
|
+ toaster.pop('error', '错误', response.data);
|
|
|
+ $modalInstance.close();
|
|
|
+ });
|
|
|
+ };
|
|
|
+ $scope.cancel = function () {
|
|
|
+ $modalInstance.close();
|
|
|
+ };
|
|
|
+ }]);
|
|
|
+
|
|
|
+ // 实名认证Controller
|
|
|
+ app.register.controller('UserRealAuthCtrl',
|
|
|
+ ['$scope', '$modalInstance', 'user', 'User', 'toaster',
|
|
|
+ function ($scope, $modalInstance, user, User, toaster) {
|
|
|
+ $scope.user = user;
|
|
|
+ //姓名验证 不超过20个字符
|
|
|
+ $scope.checkSuccess = false;
|
|
|
+ $scope.checkFailed = false;
|
|
|
+ $scope.checkUserName = function (userName) {
|
|
|
+ if (userName == null) {
|
|
|
+ //toaster.pop('error', '请输入您的真实姓名');
|
|
|
+ $scope.checkSuccess = false;
|
|
|
+ $scope.checkFailed = true;
|
|
|
+ return;
|
|
|
+ } else if (userName.length > 20) {
|
|
|
+ //toaster.pop('error', '请勿超过20个字符');
|
|
|
+ $scope.checkSuccess = false;
|
|
|
+ $scope.checkFailed_1 = true;
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ $scope.checkSuccess = true;
|
|
|
+ $scope.checkFailed = false;
|
|
|
+ $scope.checkFailed_1 = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //检查身份证
|
|
|
+ $scope.checkSuccess1 = false;
|
|
|
+ $scope.checkFailed1 = false;
|
|
|
+ $scope.checkUserIdcode = function (userIdcode) {
|
|
|
+ if (userIdcode == null) {
|
|
|
+ //toaster.pop('error', '请输入您的身份证号');
|
|
|
+ $scope.checkSuccess1 = false;
|
|
|
+ $scope.checkFailed1 = true;
|
|
|
+ return;
|
|
|
+ } else if (userIdcode.length != 18) {
|
|
|
+ //toaster.pop('error', '请输入18位的身份证号');
|
|
|
+ $scope.checkSuccess1 = false;
|
|
|
+ $scope.checkFailed1_1 = true;
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ $scope.checkSuccess1 = true;
|
|
|
+ $scope.checkFailed1 = false;
|
|
|
+ $scope.checkFailed1_1 = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //图片上传
|
|
|
+ $scope.checkSuccess2 = false;
|
|
|
+ $scope.onUploadID = function ($data) {
|
|
|
+ if (!$data || !$data.path) {
|
|
|
+ toaster.pop('error', '图片上传失败');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $scope.user.idImgUrl = $data.path;
|
|
|
+ $scope.checkSuccess2 = true;
|
|
|
+ };
|
|
|
+
|
|
|
+ //保存
|
|
|
+ $scope.ok = function () {
|
|
|
+ User.updateRealAuth({
|
|
|
+ userName: $scope.user.userName,
|
|
|
+ userIdcode: $scope.user.userIdcode,
|
|
|
+ idImgUrl: $scope.user.idImgUrl
|
|
|
+ }, {}, function () {
|
|
|
+ toaster.pop('success', '成功', '身份信息提交成功。');
|
|
|
+ $modalInstance.close();
|
|
|
+ $scope.checkSuccess2 = false;
|
|
|
+ $scope.checkSuccess1 = false;
|
|
|
+ $scope.checkFailed1 = false;
|
|
|
+ $scope.checkSuccess = false;
|
|
|
+ $scope.checkFailed = false;
|
|
|
+ location.reload();
|
|
|
+ }, function (response) {
|
|
|
+ toaster.pop('error', '错误', response.data);
|
|
|
+ $modalInstance.close();
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.cancel = function () {
|
|
|
+ $modalInstance.close();
|
|
|
+ };
|
|
|
+ }]);
|
|
|
+
|
|
|
});
|