jq²¿·ÖдµÄÏêϸһµã£¬ÕâÀïҲͦÏêϸµÄ£¬Èç¹û²»¶®µÄ»°£¬¿ÉÒÔ»ØÍ·¿´¿´jq²¿·Ö£¬ÔÀí¶¼ÊÇÒ»ÑùµÄ£¬¸´ÖƵ½±¾µØ×Ô¼º¶àÊÔÊÔ¡£
var enter=angular.module("myApp"); enter.controller('enterCtrl',['$scope','$http','$state',function ($scope,$http,$state) { $scope.changeVerify=function () {//¶¨ÒåÁËÒ»¸öµã»÷ʼþ£¬»ñÈ¡ÑéÖ¤Âë var authCode=""; var authCodeLength=4;//È¡¼¸¸öËæ»úÊý×Ö var randomArray=[0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R', 'S','T','U','V','W','X','Y','Z']; for(var i=0;i<authCodeLength;i++){ var index=Math.floor(Math.random()*36);//Ëæ»úȡһλÊý authCode +=randomArray[index];//È¡ËÄλÊý£¬²¢+ÏàÁ¬ } $scope.showAuthCode=authCode;//¸³Öµ console.log($scope.showAuthCode); }; //ÉÏÃæÊÇ·â×°µÄ»ñÈ¡ÑéÖ¤ÂëµÄº¯Êý£¬»áÔÚÏÂÃæ½øÐе÷Óà (function () { $scope.changeVerify();//µ÷Óõã»÷ʼþ¡£ $scope.enter=function (userName,userPsd) { //µã»÷µÇ¼°´Å¥Ê¼þ£¬½«Ë«Ïò°ó¶¨µÄÕ˺ÅÃÜÂëµ±×ö²ÎÊý´«È뺯Êý if ($scope.writeCode.toUpperCase() ==$scope.showAuthCode){//toUpperCase()½«Ð¡Ð´×ª»¯Îª´óд //Ë«Ïò°ó¶¨ÑéÖ¤ÂëÊäÈë¿ò£¬¿ÉÒÔÖ±½ÓʹÓã¬ÕâÀïÊÇÑéÖ¤ÑéÖ¤Âë $http({ method:"POST", url:"ÄãµÄ¿çÓòµØÖ·",//$httpµÄ¹Ì¶¨¸ñʽ params:{ "name":userName, "pwd":userPsd //Ë«Ïò°ó¶¨µÄ²ÎÊý´«µ½Ï¸öÒ³Ãæ } }).then(function (res) { //»ñÈ¡·þÎñÆ÷·µ»ØµÄ²ÎÊý console.log(res); if (res.data.code!==0){ //²ÎÊý²»Îª0µÄʱºò£¬µ¯³öÌáʾ alert(res.data.message); }else { //²ÎÊýΪ0µÄʱºò£¬ÌøתҳÃæ $state.go("home.studentList"); } }) }else { alert("ÑéÖ¤ÂëÊäÈë´íÎó¿©£¬¿©¿©¿©"); $scope.changeVerify();//ÑéÖ¤ºó£¬Ë¢ÐÂÑéÖ¤Âë } } }());ºó»°
¶Ï¶ÏÐøÐøдÁËÁ½Ì죬ÏÖÔÚдµÄûÓÐ֮ǰÄÇô¿ìÁË¡£¡£²î²»¶à¾ÍÒÔÉÏÕâЩÄÚÈÝ£¬ÓÐÎÊÌâ¿ÉÔÚÆÀÂÛÇøÁôÑÔ¡£Óв»×㻶ÓÖ¸µ¼£¬ÅÄש¡£
ÒÔÉÏËùÊöÊÇС±à¸ø´ó¼Ò½éÉܵÄʹÓÃjQuery,AngularʵÏֵǼ½çÃæÑéÖ¤ÂëÏê½â£¬Ï£Íû¶Ô´ó¼ÒÓÐËù°ïÖú£¬Èç¹û´ó¼ÒÓÐÈκÎÒÉÎÊÇë¸øÎÒÁôÑÔ£¬Ð¡±à»á¼°Ê±»Ø¸´´ó¼ÒµÄ¡£ÔÚ´ËÒ²·Ç³£¸Ðл´ó¼Ò¶Ô½Å±¾Ö®¼ÒÍøÕ¾µÄÖ§³Ö£¡
¡¡