$(function() { $('#login').on('click', function() { var username = $('#username').val(); var password = $('#password').val(); if (username == '' || password == '') { alert('账号或密码不能为空'); return ; } var params = {'username':username, 'password':password}; XZ_SSO_Controller.login(params, function(data) { if(data.flag == 0) { if(window.localStorage){ window.localStorage["lastcontact"] = $("#username").val() + "|" + $("#password").val() } var redirect_url = _GET['redirect'] ? _GET['redirect'] : (_GET['done'] ? _GET['done'] : '<?php echo $this->createAbsoluteUrl('home/index');?>'); window.location.href = redirect_url; }else{ alert('用户名或密码错误!'); } }, 'script'); //退出 //XZ_SSO_Controller.logout('script'); }) if(window.localStorage && window.JSON && window.localStorage["lastcontact"]){ var data = window.localStorage["lastcontact"].split("|"); if(data && data.length > 1){ data[0] && $("#username").val(data[0]); data[1] && $("#password").val(data[1]); } } }) </script>