| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- $(function() {
- /*cook存储数据*/
- if($.cookie("username")) {
- //取值如果存在则赋值
- $(".gl_user").val($.cookie("user")); //用户名
- $("zx_fj").val($.cookie("fj"));
- $(".zx_user").val($.cookie("user"));
- }
- })
- //键盘登录事件
- $('input').bind('keypress', function(event) {
- if(event.keyCode == "13") {
- $(".login_gl").trigger("click");
- }
- });
- $(".btnVerifi_user").click(function() {
- if(!$(".gl_user").val()) {
- layer.msg('请输入账号')
- return false;
- }
- var mobile = $(".gl_user").val();
- var user_psw = DOMPurify.sanitize($(".gl_psw").val());
- var encrypted = encryptFn($.md5(user_psw))
- var pass = encrypted.toString()
- sendMsg(mobile, pass);
- })
- //用户登录
- $('.login_gl').click(function() {
- localStorage.setItem('loginPassword', $('.gl_psw').val())
- var gl_user = DOMPurify.sanitize($(".gl_user").val());
- var gl_psw = DOMPurify.sanitize($(".gl_psw").val());
- if(gl_user == "" || gl_psw == "") {
- $(".error_gl").addClass('errorShow');
- if(gl_user == "") {
- $(".gl_user").focus(function() {
- $(".error_gl").removeClass('errorShow');
- });
- } else {
- $(".error_gl_user").removeClass('errorShow');
- }
- } else {
- var currenttime = CurentTime();
- var datatime = currenttime.split(' ')[1].split(':').join('')
-
- var encrypted = encryptFn($.md5(gl_psw))
- /*请求后台*/
- $.ajax({
- type: "post",
- url: huayi.config.callcenter_url + "/Login/login",
- dataType: 'json',
- async: true,
- data: {
- username: gl_user,
- password: encrypted.toString(),
- LoginTime: currenttime,
- Code: $(".verification_user").val()
- },
- success: function(data) {
- /*验证请求*/
- if(data.state == "success") {
- $.cookie("token", data.data.token, {
- expires: 7
- });
- $.cookie("zx_user", gl_user, {
- expires: 7
- });
- loginHref()
- }else {
- layer.confirm(data.message, {
- btn: ['确定'] //按钮
- });
- }
- }
- });
- }
- })
- function loginHref() {
- var thisUrl = window.document.location.href
- var toHrefUrl = ""
- if(thisUrl.indexOf("127.0.0.1") > 0) {
- toHrefUrl = "index.html"
- } else {
- toHrefUrl = thisUrl.split('/')
- toHrefUrl.pop();
- toHrefUrl = toHrefUrl.join("/") + "/index.html"
- }
- if(huayi.config.callcenter_url.indexOf("https") !== -1) {
- $.getJSON(
- huayi.config.callcenter_url + "UserAccount/GetNowUser", {
- token: $.cookie("token"),
- },
- function(result) {
- if(result.state.toLowerCase() == "success") {
- toHrefUrl = "http://12345rx.zwfw.anyang.gov.cn:65525/index.html"
- window.location.href = toHrefUrl;
- }
- })
- } else {
- window.location.href = toHrefUrl;
- }
- }
- function sendMsg(mobile, pass) {
- var currenttime = CurentTime();
- console.log(mobile, pass, currenttime)
- $.ajax({
- type: "post",
- url: huayi.config.callcenter_url + "Login/SendCode",
- async: true,
- dataType: 'json',
- data: {
- usercode: mobile,
- Password: pass,
- LoginTime: currenttime
- },
- success: function(data) {
- if(data.state == "success") {
- layer.msg('发送成功')
- verifi();
- }else{
- layer.msg(data.message)
- }
- }
- });
- }
- function verifi() {
- var time = 60;
- var timer = null;
- $('.btnVerifi').text(time + '秒后重新发送');
- $('.btnVerifi').attr('disabled', 'disabled'); // 禁用按钮
- $('.btnVerifi_user').text(time + '秒后重新发送');
- $('.btnVerifi_user').attr('disabled', 'disabled'); // 禁用按钮
- timer = setInterval(function() {
- // 定时器到底了 兄弟们回家啦
- if(time == 1) {
- clearInterval(timer);
- $('.btnVerifi').text("获取验证码")
- $('.btnVerifi_user').text('获取验证码')
- $('.btnVerifi').removeAttr('disabled')
- $('.btnVerifi_user').removeAttr('disabled')
- } else {
- time--;
- $('.btnVerifi').text(time + '秒后重新发送');
- $('.btnVerifi_user').text(time + '秒后重新发送');
- }
- }, 1000)
- }
- function CurentTime() {
- var now = new Date();
- var year = now.getFullYear(); //年
- var month = now.getMonth() + 1; //月
- var day = now.getDate(); //日
- var hh = now.getHours(); //时
- var mm = now.getMinutes(); //分
- var ss = now.getSeconds(); //秒
- var clock = year + "-";
- if(month < 10)
- clock += "0";
- clock += month + "-";
- if(day < 10)
- clock += "0";
- clock += day + " ";
- if(hh < 10)
- clock += "0";
- clock += hh + ":";
- if(mm < 10) clock += '0';
- clock += mm + ":";
- if(ss < 10) clock += '0';
- clock += ss;
- return(clock);
- }
|