123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- 'use strict';
- var app = angular.module('app', [
- 'angularUtils.directives.dirPagination'
- ]);
- app.controller("addUserCtrl", ["$http", "$timeout", function ($http, $timeout) {
- var self = this;
-
-
- self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
- //console.log(self.get_AccessToken);
- self.get_userid = $.cookie("GlWorkPlatform-userid"); //获取userid;
- var postCfgJson = {
- headers: {
- 'Content-Type': 'application/json',
- "Authorization": "Bearer " + self.get_AccessToken
- }
- };
-
- self.info = {
- "UserRealName": "",
- "UserName": "",
- "Password": "",
- "ConfirmPassword": "",
- "Email": "",
- "PhoneNumber": "",
- "WorkNo": "",
- "Avatar": ""
- };
- self.btnSubmit = function () {
- //console.log(self.info);
- if (spngvld.submit("#form_checkData")) {
- //大小写字母、数字、特殊符号、8位以上
- var pwdReg = !!self.info.Password.match(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,16}$/);
- if (!self.info.Password) {
- sp.dialog("请填写新密码");
- } else if (pwdReg == false) {
- sp.dialog("密码必须同时包含:数字、大写字母、小写字母、特殊符号,并且8~16位");
- } else if (self.info.Password !== self.info.ConfirmPassword) {
- sp.dialog("两次新密码输入不一致");
- }else {
- var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
- var dialogBody = "<div class=\"sp-dialog-body\">确认要提交吗?</div>";
- var dialogFoot = "<div class=\"sp-dialog-foot\"><input id='dialog_btnConfirm' type='button' value='确 认' class='sp-dialog-btnTrue' /><input type='button' value='取 消' class='sp-dialog-btnCancle sp-closeDialog' /></div>";
- $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
- sp.openCenter(".sp-dialog");
- ///取消按钮
- $('.sp-closeDialog').click(function (event) {
- sp.dialoghide();
- event.preventDefault();
- event.stopPropagation();
- });
- $("#dialog_btnConfirm").click(function () {
- var postPwdData = {
- "UserRealName": self.info.UserRealName,
- "UserName": self.info.UserName,
- "Password": self.info.Password,
- "ConfirmPassword": self.info.ConfirmPassword,
- "Email": self.info.Email,
- "PhoneNumber": self.info.PhoneNumber,
- "WorkNo": self.info.WorkNo,
- "Avatar": self.info.Avatar
- }
- //console.log(postPwdData);
- $http.post(apiurljs.refineapi + "api/User/Register", postPwdData, postCfgJson)
- .success(function (res) {
- //sp.dialoghide();
- console.log(res);
- if (res.success) {
- sp.dialog("创建成功!");
- self.btnCancel();
- } else {
- sp.dialog(res.message + " 用户创建失败!");
- }
- }).error(function (err) {
- sp.dialog(JSON.stringify(err));
- });
- });
- }
- }
- };
- self.btnCancel = function () {
- spngvld.clear("#form_checkData");
- self.info = {
- "UserRealName": "",
- "UserName": "",
- "Password": "",
- "ConfirmPassword": "",
- "Email": "",
- "PhoneNumber": "",
- "WorkNo": "",
- "Avatar": ""
- };
- };
- }]);
|