﻿<!DOCTYPE html><html lang="en">
<head>
    <meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><meta name="renderer" content="webkit"><link type="image/x-icon" rel="shortcut icon" href="/sso/themes/cpu/images/favicon.ico"/><script type="text/javascript" src="/sso/themes/cpu/js/jquery.js"></script>
    <script type="text/javascript" src="/sso/themes/cpu/js/pintuer.js"></script>
    <script type="text/javascript" src="/sso/themes/cpu/js/respond.js"></script>

    <link rel="stylesheet" href="/sso/themes/cpu/css/pintuer.css"/><link rel="stylesheet" href="/sso/themes/cpu/css/login.css"/><title>统一身份认证平台</title>
    <script type="text/javascript">
        //重新获取验证码
        function refresh(codeId) {
            $("#vcodeimg").attr("src", 'authImg?now=' + new Date().getTime() + '&refresh=1&authCodeKey=' + codeId);
        }
    </script>
    <style>
        input:-webkit-autofill,
        textarea:-webkit-autofill,
        select:-webkit-autofill {
            -webkit-box-shadow: 0 0 0 1000px white inset; /*---- 设置内阴影 ----*/
        }
        iframe {
            height:290px!important;
            width: 280px!important;
        }
    </style>
</head>
<body>
<div class="content" >

    <div class="container-layout leftcontent">
        <div class="wrapper20" >
            <div class="header">
                <div class="header-title logoimg"></div>
                <!-- <div class="floatright">
                    <a href="javascript:void(0);" target="_blank">操作手册</a> |
                    <a href="javascript:void(0);" target="_blank">常见问题</a>
                </div> --></div>
        </div>
        <div class="container wrapper ie10" id="wrapper">

            <div class="login" id="zhmm">
                <form method="post" class="form-auto" id="loginForm" action="/sso/login">
                    <input type="hidden" name="lt" value="${loginTicket}"/><input type="hidden" id="useVCode" name="useVCode" value=""/><input type="hidden" id="isUseVCode" name="isUseVCode" value="true"/><input type="hidden" id="sessionVcode" name="sessionVcode" value=""/><input type="hidden" id="errorCount" name="errorCount" value=""/><input type="hidden" name="execution" value="e1s1"/><input type="hidden" id="service" name="service" value="http://www.7th-august.com/ws/sso/themes/cpu/css/login.css"/><input type="hidden" name="_eventId" value="submit"/><input type="hidden" name="geolocation"/><div class="login-title">统一身份认证登录</div>
                    <!--         <div class="tips">账号或密码错误</div> --><div>
                        <div class="login-title bluebottomsel" style="float:left;font-size: 14px;color:#0B5099;" >账户登录</div>
                        <div class="login-title greybottomsel" style="font-size: 14px;" onclick="sjhdl()">手机登录</div>
                    </div>
                    <div id="qrcode" style="display: none;background-color: white;"></div>
                    <div id="wxqrcode" style="display: none;background-color: white;border-radius: 5px;"><iframe height="400px" scrolling="no" ></iframe></div>

                    <div class="form-group zclogin">
                        <div class="field field-icon">
                            <div class="usericon"></div>
                            <input type="text" class="input" id="username" name="username" placeholder="请输入职工号/学号"
                                   accesskey="u" autocomplete="off"
                                   value=""/></div>
                    </div>
                    <div class="form-group zclogin">
                        <div class="field field-icon">
                            <div class="lockicon"></div>
                            <input type="password" class="input" id="password" name="password" placeholder="请输入密码"
                                   accesskey="p" autocomplete="off" value=""/></div>
                    </div>
                    <div class="form-group zclogin">

                        <label class="rememberpwd"><input id="rememberpwd" name="rememberpwd" type="checkbox" checked="checked"/>记住密码</label>
                        <div class="forgetpwd">
                            <!--                            <a href="//www.7th-august.com/ims/findPswdByEmail/change/query" target="_blank">账号查询</a>--><a href="//www.7th-august.com/id/grzx/findpassword" target="_blank">找回密码</a>
                        </div>
                    </div>
                    <div class="form-button zclogin">
                        <a onclick="login()" class="button button-block" id="submit">登录</a>
                    </div>
                    <div class="tips" title="" style=" width: 300px; font-weight: bold;"><span>本平台为互联网非涉密平台，严禁处理、传输国家秘密。</span></div>

                    <div class="dlfs clearfix">

                        <a id="wechat" class="" href="javascript:openWxQrCode()" title="使用微信登录" >
                            <img src="/sso/themes/cpu/images/wx.png" style="width: 30px;"><div class="iconword">微信</div>
                        </a>
                        <a id="qywx" class="" href="javascript:openQrCode()" title="使用企业微信登录" style="width: 30px;">
                            <img src="/sso/themes/cpu/images/qywx.png" alt="" ><div class="iconword">企业微信</div>
                        </a>
                        <a id="qq" class="" href="" title="使用QQ登录" target="_blank" >
                            <img src="/sso/themes/cpu/images/qq.png" style="width: 30px;"><div class="iconword">QQ</div>
                        </a>
                    </div>
                </form>
            </div>

            <div class="login" id="sj" style="display:none;">
                <form method="post" class="form-auto" id="sjloginForm" action="/sso/login">
                    <input type="hidden" name="lt" value="${loginTicket}"/><input type="hidden" id="useVCode" name="useVCode" value=""/><input type="hidden" id="isUseVCode" name="isUseVCode" value="true"/><input type="hidden" id="sessionVcode" name="sessionVcode" value=""/><input type="hidden" id="errorCount" name="errorCount" value=""/><input type="hidden" name="execution" value="e1s1"/><input type="hidden" id="service" name="service" value="http://www.7th-august.com/ws/sso/themes/cpu/css/login.css"/><input type="hidden" name="_eventId" value="submit"/><input type="hidden" name="geolocation"/><div class="login-title">统一身份认证登录</div>
                    <!--         <div class="tips">账号或密码错误</div> --><div class="login-title greybottomsel" onclick="zhmmdl()" style="float:left;font-size: 14px;">账户登录</div>
                    <div class="login-title bluebottomsel" style="font-size: 14px;color:#0B5099;">手机登录</div>
                    <div id="userslist" style="width:240px;height:130px;display:none;overflow-y: auto;"></div>
                    <div class="form-group ssj" style="display: none">近期上线，敬请期待 </div>
                    <div class="form-group ssj" >
                        <div class="field sj-icon">
                            <div class="sjicon"></div>
                            <input type="text" class="input" id="phone" name="phone" placeholder="请输入手机号" /></div>
                    </div>
                    <div class="form-group ssj">
                        <div class="field field-icon">
                            <div class="dunicon"></div>
                            <input type="text" class="input" id="code" name="code"
                                   style="width:190px;display: inline-block;"
                                   placeholder="请输入验证码" /><button type="button" class="btn-sjh yxyzmbut hqyzm"
                                    data-toggle="button" onclick="getyxcode(this)">获取验证码</button>
                        </div>
                    </div>
                    <div class="form-button ssj">
                        <a onclick="phonelogin()" class="button button-block" id="submit1">登录</a>
                    </div>

                    <!-- <div class="dlfs clearfix">
                        <a id="qq" class="" href="javascript:openQqQrCode()" title="使用QQ登录" >
                            <img th:src="@{${#themes.code('cpu.qq.png')}}" style="width: 30px;">
                            <div class="iconword">QQ</div>
                        </a>
                        <a id="wechat" class="" href="javascript:openWxQrCode()" title="使用微信登录" >
                            <img th:src="@{${#themes.code('cpu.wx.png')}}" style="width: 30px;">
                            <div class="iconword">微信</div>
                        </a>
                        <a id="qywx" class="" href="javascript:openQrCode()" title="使用企业微信登录" style="width: 30px;">
                            <img th:src="@{${#themes.code('cpu.qywx.png')}}" alt="" >
                            <div class="iconword">企业微信</div>
                        </a>
                    </div> --></form>
            </div>
        </div>
    </div>

    <div class="container-layout rightcontent"></div>
    <div class="sjbottomdiv">
        <div class="logoworddiv logow"></div>
        <div class="logoworddiv" style="font-size:12px;">版权所有&#169中国药科大学 苏ICP备05007142 </div>
        <div class="logoworddiv" style="font-size:12px;">玄武门校区：南京市鼓楼区童家巷24号 江宁校区：南京市江宁区龙眠大道639号</div>
    </div>
</div>
<script type="text/javascript">
    $("#loginForm").attr("action","/sso/login?service="+encodeURIComponent($("#service").val()))
    var service =encodeURIComponent($("#service").val());
    var redirect_uri = "";
    if(service=="${service}"||service==""){
        redirect_uri = encodeURIComponent("https://id.cpu.edu.cn/sso/qywxLogin");
    }else{
        redirect_uri = encodeURIComponent("https://id.cpu.edu.cn/sso/qywxLogin?service="+service);
    }

    var qqredirect_uri=encodeURIComponent("https://id.cpu.edu.cn/sso/qqLogin?service="+$("#service").val())
    var qqsrc="https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=101914353&redirect_uri="+qqredirect_uri+"&scope=get_user_info"
    $("#qq").attr("href",qqsrc)
    function openQrCode(){
        /*if(!window.WwLogin){
        var element = document.createElement("script");
        element.src = "https://rescdn.qqmail.com/node/ww/wwopenmng/js/sso/wwLogin-1.0.0.js";
        document.body.appendChild(element);
        for(var i=0;!window.WwLogin;i++){

        }

        }*/
        var dis = document.getElementById("qrcode").style.display;
        if(dis=="block"){
            $(".zclogin").show();
            document.getElementById("qrcode").style.display = "none";
        }else{
            $(".zclogin").hide();
            document.getElementById("wxqrcode").style.display = "none";
            document.getElementById("qrcode").style.display = "block";
            document.getElementById("qrcode").getElementsByTagName('iframe')[0].src=document.getElementById("qrcode").getElementsByTagName('iframe')[0].src;
        }
    }
    function openWxQrCode(){
        var dis = document.getElementById("wxqrcode").style.display;
        if(dis=="block"){
            $(".zclogin").show();
            document.getElementById("wxqrcode").style.display = "none";
        }else{
            $(".zclogin").hide();
            document.getElementById("qrcode").style.display = "none";
            document.getElementById("wxqrcode").style.display = "block";
            var redirect_uri=encodeURIComponent("https://id.cpu.edu.cn/sso/wxLogin?service="+$("#service").val())
            var href=encodeURIComponent("https://id.cpu.edu.cn/sso/themes/cpu/css/login.css")
            var src="https://open.weixin.qq.com/connect/qrconnect?appid=wx5ba894dd7f2337a5&redirect_uri="
                +redirect_uri+"&response_type=code&scope=snsapi_login&state=STATE&href="
                +href+"#wechat_redirect"
            document.getElementById("wxqrcode").getElementsByTagName('iframe')[0].src=src;
        }
    }


    var flag = 0
    function Base64() {
        // private property
        _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
        // 公共编码方法
        this.encode = function (input) {
            var output = "";
            var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
            var i = 0;
            input = _utf8_encode(input);
            while (i < input.length) {
                chr1 = input.charCodeAt(i++);
                chr2 = input.charCodeAt(i++);
                chr3 = input.charCodeAt(i++);
                enc1 = chr1 >> 2;
                enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
                enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
                enc4 = chr3 & 63;
                if (isNaN(chr2)) {
                    enc3 = enc4 = 64;
                } else if (isNaN(chr3)) {
                    enc4 = 64;
                }
                output = output +
                    _keyStr.charAt(enc1) + _keyStr.charAt(enc2) +
                    _keyStr.charAt(enc3) + _keyStr.charAt(enc4);
            }
            return output;
        }

        // 公共解码方法
        this.decode = function (input) {
            var output = "";
            var chr1, chr2, chr3;
            var enc1, enc2, enc3, enc4;
            var i = 0;
            input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
            while (i < input.length) {
                enc1 = _keyStr.indexOf(input.charAt(i++));
                enc2 = _keyStr.indexOf(input.charAt(i++));
                enc3 = _keyStr.indexOf(input.charAt(i++));
                enc4 = _keyStr.indexOf(input.charAt(i++));
                chr1 = (enc1 << 2) | (enc2 >> 4);
                chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
                chr3 = ((enc3 & 3) << 6) | enc4;
                output = output + String.fromCharCode(chr1);
                if (enc3 != 64) {
                    output = output + String.fromCharCode(chr2);
                }
                if (enc4 != 64) {
                    output = output + String.fromCharCode(chr3);
                }
            }
            output = _utf8_decode(output);
            return output;
        }

        // UTF-8编码的私有方法
        _utf8_encode = function (string) {
            string = string.replace(/\r\n/g,"\n");
            var utftext = "";
            for (var n = 0; n < string.length; n++) {
                var c = string.charCodeAt(n);
                if (c < 128) {
                    utftext += String.fromCharCode(c);
                } else if((c > 127) && (c < 2048)) {
                    utftext += String.fromCharCode((c >> 6) | 192);
                    utftext += String.fromCharCode((c & 63) | 128);
                } else {
                    utftext += String.fromCharCode((c >> 12) | 224);
                    utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                    utftext += String.fromCharCode((c & 63) | 128);
                }
            }
            return utftext;
        }

        // UTF-8解码的私有方法
        _utf8_decode = function (utftext) {
            var string = "";
            var i = 0;
            var c = c1 = c2 = 0;
            while ( i < utftext.length ) {
                c = utftext.charCodeAt(i);
                if (c < 128) {
                    string += String.fromCharCode(c);
                    i++;
                } else if((c > 191) && (c < 224)) {
                    c2 = utftext.charCodeAt(i+1);
                    string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                    i += 2;
                } else {
                    c2 = utftext.charCodeAt(i+1);
                    c3 = utftext.charCodeAt(i+2);
                    string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                    i += 3;
                }
            }
            return string;
        }
    }
    function login() {
        if ($("#rememberpwd")[0].checked) {
            saveUserPassword();
        } else {
            deleteCookie("bms_sso_username", "/");
            deleteCookie("bms_sso_password", "/");
        }
        if (flag == 0) {
            flag = 1;
            var base64=new Base64();
            var userName = $('#username').val();
            var password = $('#password').val();
            $('#username').val(base64.encode(base64.encode(userName)));
            $('#password').val(base64.encode(base64.encode(password)));
            $("#loginForm").submit();
            $('#username').val(userName);
            $('#password').val(password);

        }
    }

    $(function () {
        if (parent && parent != self) {
            top.window.location = window.location.href;
        }
        $('#vCode').val("");

        refresh('authCodeKeySSO');

        initUserPassword();
    });
    //cookier操作
    //保存到cookier
    function setCookie(name, value, hours, path) {
        var name = escape(name);
        var value = escape(value);
        var expires = new Date();
        expires.setTime(expires.getTime() + hours * 3600000);
        path = path == "" ? "" : ";path=" + path;
        _expires = (typeof hours) == "string" ? "" : ";expires=" + expires.toUTCString();
        document.cookie = name + "=" + value + _expires + path;
    }

    //删除cookie
    function deleteCookie(name, path) {
        var name = escape(name);
        var expires = new Date(0);
        path = path == "" ? "" : ";path=" + path;
        document.cookie = name + "=" + ";expires=" + expires.toUTCString() + path;
    }

    //获取cookie值
    function getCookieValue(name) {
        var name = escape(name);
        //读cookie属性，这将返回文档的所有cookie
        var allcookies = document.cookie;
        //查找名为name的cookie的开始位置
        name += "=";
        var pos = allcookies.indexOf(name);
        //如果找到了具有该名字的cookie，那么提取并使用它的值
        if (pos != -1) {                                             //如果pos值为-1则说明搜索"version="失败
            var start = pos + name.length;                  //cookie值开始的位置
            var end = allcookies.indexOf(";", start);        //从cookie值开始的位置起搜索第一个";"的位置,即cookie值结尾的位置
            if (end == -1) end = allcookies.length;        //如果end值为-1说明cookie列表里只有一个cookie
            var value = allcookies.substring(start, end);  //提取cookie的值
            return unescape(value);                           //对它解码
        } else return "";                                             //搜索失败，返回空字符串
    }

    //保存用户名密码
    function saveUserPassword() {
        var base64=new Base64();
        var userName = $.trim(document.getElementById("username").value);
        setCookie("bms_sso_username", base64.encode(base64.encode(userName)), 24 * 7, "/");
        var password = $.trim(document.getElementById("password").value);
        setCookie("bms_sso_password", base64.encode(base64.encode(password)), 24 * 7, "/");
    }

    //初始化用户名密码
    function initUserPassword() {
        var base64=new Base64();
        var userName = getCookieValue("bms_sso_username");
        var password = getCookieValue("bms_sso_password");
        $('#username').val(base64.decode(base64.decode(userName)));
        $('#password').val(base64.decode(base64.decode(password)));
        if (userName && userName.length > 0) {
            document.getElementById("password").focus();
        }
    }

    var JPlaceHolder = {
        //检测
        _check: function () {
            return 'placeholder' in document.createElement('input');
        },
        //初始化
        init: function () {
            if (!this._check()) {
                this.fix();
            }
        },
        //修复
        fix: function () {
            jQuery(':input[placeholder]').each(function (index, element) {
                var self = $(this), txt = self.attr('placeholder');
                self.wrap($('<div></div>').css({
                    position: 'relative',
                    zoom: '1',
                    border: 'none',
                    background: 'none',
                    padding: 'none',
                    margin: 'none'
                }));
                var pos = self.position(), h = self.outerHeight(true), paddingleft = self.css('padding-left');
                var holder = $('<span style="margin-top:32px;margin-left: 33px"></span>').text(txt).css({
                    position: 'absolute',
                    left: pos.left,
                    top: pos.top,
                    height: 42,
                    lienHeight: h,
                    paddingLeft: 0,
                    color: '#aaa'
                })
                    .appendTo(self.parent());
                if (!self.val()) {
                    holder.show();
                } else {
                    holder.hide();
                }
                self.focusin(function (e) {
                    holder.hide();
                }).focusout(function (e) {
                    if (!self.val()) {
                        holder.show();
                    }
                });
                holder.click(function (e) {
                    holder.hide();
                    self.focus();
                });
            });
        }
    };
    //执行
    jQuery(function () {
        JPlaceHolder.init();
    });

    var s;
    function getyxcode(e) {
        var yxnumber = $("#phone").val();
        if(yxnumber.length==0){
            alert( "手机号不能为空");
            $("#phone").focus();
            return;
        }else{
            $.ajax({
                url : "./pl/sendCode",
                type:"get",
                data:{"phone":yxnumber,"service":$("#service").val()},
                dataType:"json",
                async:false,
                success:function(data, status, XHR){
                    if(data!=null&&data>0){
                        s = setInterval(function () {
                            yxcountdown(e)
                        }, 1000)
                        yxcountdown(e);
                    }else if(data!=null&&data==-1){
                        alert( "无此手机号");
                        return;
                    }else if(data!=null&&data==-2){
                        alert( "获取验证码过于频繁");
                        return;
                    }else{
                        alert( "获取验证码失败");
                        return;
                    }
                },
                error:function(){
                    alert( "获取验证码失败");
                    return;
                }
            });

        }
    }

    var ytime = 60;
    function yxcountdown(e){
        if (ytime == 0) {
            //这里时设置当时间到0的时候重新设置点击事件，并且默认time修改为60
            e.setAttribute("onclick","getyxcode(this)");
            $(".yxyzmbut").text("发送验证码");
            ytime = 60;
            clearInterval(s);
        }else{
            //这里是显示时间倒计时的时候点击不生效
            e.setAttribute("onclick", '');
            $(".yxyzmbut").text("重新发送"+ytime);
            ytime--;
        }
    }

    function phonelogin(){
        var yxnumber = $("#phone").val()
        if(yxnumber.length==0){
            alert( "手机号不能为空");
            $("#phone").focus();
            return;
        }
        if(checkPhone(yxnumber)){
            alert("手机号码有误，请重填");
            $("#phone").focus();
            return;
        }
        var yzm = $("#code").val()
        if(yzm.length==0){
            alert( "验证码不能为空");
            $("#code").focus();
            return;
        }

        $.ajax({
            url : "./pl/checkCode",
            type:"get",
            data:{"phone":yxnumber,"code":yzm},
            dataType:"json",
            async:false,
            success:function(data, status, XHR){
                if(data!=null&&data>0){
                    showUser(yxnumber,yzm)
                }else{
                    alert( "验证码不正确");
                    return;
                }
            },
            error:function(){
                alert( "校验失败");
                return;
            }
        });
    }

    function checkPhone(phone){
        if(!(/^1[3456789]\d{9}$/.test(phone))){
            return true;
        }
        return false;
    }

    function showUser(phone,code){
        $.ajax({
            url : "./pl/showUsers",
            type:"get",
            data:{"phone":phone},
            dataType:"json",
            async:false,
            success:function(data, status, XHR){
                if(data!=null&&data.length==1){
                    phoneLogin(data[0].USERID,phone,code)
                }else if(data!=null&&data.length>0){
                    $(".ssj").remove();
                    var str = '';
                    for (var s in data) {
                        var userid = data[s].USERID;
                        var name = data[s].CN;
                        str += '<a style="text-align: center;background-color: #0B5099;color: #fff;border-radius: 30px;" onclick="phoneLogin(\''+userid+'\',\''+phone+'\',\''+code+'\')" ';
                        str += ' class="button  button-block" id="submit1">登录'+name+'</a>';
                    }
                    $("#userslist").append(str).show();
                }else{
                    alert( "无此手机号");
                    return;
                }
            },
            error:function(){
                alert( "查询失败");
                return;
            }
        });
    }

    function phoneLogin(userName,phone,code) {
        window.location.href = "./pl/phoneLogin?service="+$("#service").val()+"&userName="+userName+"&phone="+phone+"&code="+code;
    }

    function zhmmdl(){
        $("#zhmm").show();
        $("#sj").hide();
    }
    function sjhdl(){
        $("#sj").show();
        $("#zhmm").hide();
    }

</script>
<SCRIPT src="https://rescdn.qqmail.com/node/ww/wwopenmng/js/sso/wwLogin-1.0.0.js" type=text/javascript></SCRIPT>
<script>
    window.WwLogin({
        "id" : "qrcode",
        "appid" : "wx3adc7f6c8df963cc",
        "agentid" : "1000025",
        "redirect_uri" : redirect_uri,
        "state" : "",
        "href" : "https://id.cpu.edu.cn/sso/themes/cpu/css/login.css",
    });
</script>
</body>
</html>
