| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254 |
- angular.module('push')
- .controller('FortPasdCtrl', function ($scope, ConfigService, $ionicPopup, RegisterService, UtilService, UserService, $timeout, SqliteStorageService, ConstantService, CommonService) {
- //TODO
- if ($scope.app) {
- $scope.setStatusBar(0);
- }
- $scope.defaultLan = UserService.defaultLan;
- $scope.loginLogo = 'img/push_login.png';
- if ($scope.isLiyangApp) {
- $scope.loginLogo = 'img/liyang_login.jpg';
- }
- $scope.user = {
- name: '',
- captcha:'',
- password: '',
- repeat_password: ''
- };
- $scope.ifcta=""
- $scope.show_psd = false;
- $scope.show_psd1 = false;
- $scope.showPassword = function () {
- $scope.show_psd = !$scope.show_psd;
- //$scope.show_psd = false;
- };
- $scope.showPassword1 = function () {
- $scope.show_psd1 = !$scope.show_psd1;
- //$scope.show_psd1 = false;
- };
- $scope.isIncludeSChar = function (strData) {
- if (strData == "") {
- return false;
- }
- // 全部特殊字符
- var reg = new RegExp("[`~!@#$^&*%()_+=|{}':;',\\-\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
- return reg.test(strData);
- }
- $scope.isIncludeNumber = function (strData) {
- if (!strData) {
- return false;
- }
- var reg = /[0-9]/;
- if (!reg.test(strData)) {
- return false;
- }
- return true;
- }
- $scope.isIncludeLiter = function (strData) {
- if (!strData) {
- return false;
- }
- var reg = /[a-z]/i;
- if (!reg.test(strData)) {
- return false;
- }
- return true;
- }
- $scope.GetStrLen = function (strData) {
- if (!strData) {
- return 0;
- }
- var length = 0;
- for (var i = 0; i < strData.length; i++) {
- var char = strData.charCodeAt(i);
- //单字节加1
- if ((char >= 0x0001 && char <= 0x007e) || (0xff60 <= char && char <= 0xff9f)) {
- length++;
- }
- else {
- length += 2;
- }
- }
- return length;
- }
- //获取验证码
- $scope.time=60
- $scope.captcha=function(){
- var myVa=setInterval(function(){
- if($scope.time==0){
- clearInterval(myVa)
- $scope.$apply(function () {
- $scope.time=60
- });
- }else {
- $scope.$apply(function () {
- $scope.time--
- });
- }
- },1000);
- var params={
- node:localStorage.node,
- mobile:$scope.user.name
- }
- RegisterService.getcaptcha(params).then(function (res) {
- if(res.code==3350){
- if ($scope.app) {
- if ($scope.defaultLan == 'Chinese') {
- UtilService.showMess("验证码已发送");
- } else {
- UtilService.showMess("Verification code sent");
- }
- } else {
- if ($scope.defaultLan == 'Chinese') {
- CommonService.showMessage('验证码已发送', $scope);
- } else {
- CommonService.showMessage('Verification code sent', $scope);
- }
- }
- }else if(res.code==3352){
- // clearInterval(myVa)
- // $scope.time=60
- if ($scope.app) {
- if ($scope.defaultLan == 'Chinese') {
- UtilService.showMess(" 短信验证码已发送至您的手机,有效时长10分钟,请勿重复获取。");
- } else {
- UtilService.showMess("SMS verification code has been sent to your mobile phone, valid for 10 minutes, please do not get it again.");
- }
- } else {
- if ($scope.defaultLan == 'Chinese') {
- CommonService.showMessage('短信验证码已发送至您的手机,有效时长10分钟,请勿重复获取。', $scope);
- } else {
- CommonService.showMessage('SMS verification code has been sent to your mobile phone, valid for 10 minutes, please do not get it again.', $scope);
- }
- }
- } else {
- clearInterval(myVa)
- $scope.time=60
- if ($scope.app) {
- if ($scope.defaultLan == 'Chinese') {
- UtilService.showMess(res.message);
- } else {
- UtilService.showMess("error");
- }
- } else {
- if ($scope.defaultLan == 'Chinese') {
- CommonService.showMessage(res.message, $scope);
- } else {
- CommonService.showMessage('error', $scope);
- }
- }
- }
- })
- }
- //确认
- $scope.confirm = function () {
- /**
- * 起码强度(强中弱)判断
- */
- if(UserService.node == 320481000) {
- var len = $scope.GetStrLen($scope.user.password); // 获取字符串长度
- // 条件1 判断
- $scope.newPswdValidOne = (len >= 8 && len <= 20);
- // 条件2 判断
- $scope.newPswdValidTwo = $scope.isIncludeSChar($scope.user.password);
- // 包含字母
- $scope.newPswdHasLiter = $scope.isIncludeLiter($scope.user.password);
- // 包含数字
- $scope.newPswdHasNumber = $scope.isIncludeNumber($scope.user.password);
- // 条件3 判断
- $scope.newPswdValidThree = ($scope.newPswdHasNumber && $scope.newPswdHasLiter) || // 数字和字母
- ($scope.newPswdHasNumber && $scope.newPswdValidTwo) || // 数字和特殊字符
- ($scope.newPswdHasLiter && $scope.newPswdValidTwo); // 数字、字母和特殊字符
- // 密码等级判断
- // 3.密码中包含数字、字母和多个特殊字符时,密码强度强
- if ($scope.newPswdValidOne && $scope.newPswdHasNumber && $scope.newPswdHasLiter && $scope.newPswdValidTwo) {
- $scope.newPswdRank = 3;
- $scope.newPswdRankText = "强";
- $ionicPopup.alert({
- title: '提示',
- template: '密码强度强,欢迎注册!'
- })
- }
- // 2.密码中包含数字、字母和任一特殊字符时,密码强度中;
- else if ($scope.newPswdValidOne && $scope.newPswdValidThree ) {
- $scope.newPswdRank = 2;
- $scope.newPswdRankText = "中";
- $ionicPopup.alert({
- title: '提示',
- template: '密码强度中,必须包含数字、字母和特殊字符,请重新输入密码!'
- })
- return;
- }
- // 1.密码中仅包含数字、字母时,密码强度弱;
- else {
- $scope.newPswdRank = 1;
- $scope.newPswdRankText = "弱";
- $ionicPopup.alert({
- title: '提示',
- template: '密码强度弱,必须包含数字、字母和特殊字符,且至少输入8位密码,请重新输入密码!'
- })
- return;
- }
- }
- $scope.showLoadingToast();
- $scope.register_finish = 'colorName';
- $scope.inputuser = {
- node:localStorage.node,
- smsVerCode: $scope.user.captcha,
- mobile: $scope.user.name,
- newPwd: $scope.user.password,
- };
- RegisterService.PwdReset($scope.inputuser).then(function (response) {
- $scope.hideLoadingToast();
- if (response.code == ConstantService.INTERFACE_STATUS_CODE_3350) {
- if ($scope.app) {
- if ($scope.defaultLan == 'Chinese') {
- UtilService.showMess("重置成功");
- } else {
- UtilService.showMess("Reset successful");
- }
- } else {
- if ($scope.defaultLan == 'Chinese') {
- CommonService.showMessage('重置成功', $scope);
- } else {
- CommonService.showMessage('Reset successful', $scope);
- }
- }
- localStorage.setItem("mobile", $scope.user.name);
- localStorage.setItem("password", $scope.user.password);
- UserService.id = response.data;
- $timeout(function () {
- $scope.go('login');
- }, 3000);
- } else{
- if ($scope.app) {
- if ($scope.defaultLan == 'Chinese') {
- UtilService.showMess(response.message);
- } else {
- UtilService.showMess("error");
- }
- } else {
- if ($scope.defaultLan == 'Chinese') {
- CommonService.showMessage(response.message, $scope);
- } else {
- CommonService.showMessage('error', $scope);
- }
- }
- }
- }, function () {
- $scope.hideLoadingToast();
- if ($scope.app) {
- UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
- } else {
- CommonService.showMessage(ConstantService.INTERFACE_MESSAGE_ERROR, $scope)
- }
- });
- }
- });
|