﻿// 用户登录
function Login() {
    var param = { uid: $("#txt_uid").val(), pwd: $("#txt_pwd").val(), code: $("#txt_code").val() };
    $.post("ServicePorxy.ashx?func=UserLogin", param, function (data) {
        if (data == "login") {
            $.post("ServicePorxy.ashx?func=UserInfo", function (txt) {
                eval("var sutdent = " + txt + ";");
                var html =
                    "<div style=\"position: absolute; width: 60px; height: 18px; margin-top: 142px; margin-left: 181px;" +
                    "     cursor: pointer; line-height: 18px; text-align: center; color: #FC9815\" onclick=\"Logout()\">" +
                    "     <span>注 销</span>" +
                    "</div>" +
                    "<div style=\"padding-left: 25px; padding-top: 50px;\">" +
                    "    <table>" +
                    "        <tr>" +
                    "            <td style=\"width: 50px; height: 20px;\">姓　名：</td>" +
                    "            <td >" + sutdent.Name + "</td>" +
                    "        </tr>" +
                    "        <tr>" +
                    "            <td style=\"width: 50px; height: 20px;\">班　级：</td>" +
                    "            <td >" + sutdent.Class + "</td>" +
                    "        </tr>" +
                    "        <tr>" +
                    "            <td colspan=\"2\" style=\"text-align: left\">" +
                    "                [<a style=\"margin: 0px; font-size: 12px; color: #222; text-decoration: none;\" href=\"#\"" +
                    "                    onclick=\"\">修改密码</a>]" +
                    "            </td>" +
                    "        </tr>" +
                    "    </table>" +
                    "</div>";
                $("#userCenter").html(html);

                if (restudy) {
                    WrongTopicInit();
                }
            });
        }
        else if (data == "validate code null" || data == "validate code error") {
            alert("验证码输入错误，请重新输入！");
        }
        else {
            alert("用户名密码错误，请重新输入！");
        }
    });
}

//用户注销
function Logout() {
    $.post("ServicePorxy.ashx?func=UserLogout", function (data) {
        if (data == "logout") {
            html =
                "<div style=\"position: absolute; width: 60px; height: 18px; margin-top: 142px; margin-left: 181px;" +
                "     cursor: pointer; line-height: 18px; text-align: center; color: #FC9815\" onclick=\"Login()\">" +
                "     <span>登 录</span>" +
                "</div>" +
                "<div style=\"padding-left: 25px; padding-top: 50px;\">" +
                "    <table>" +
                "        <tr>" +
                "            <td style=\"width: 50px; height: 20px;\">用户名：</td>" +
                "            <td colspan=\"2\"><input type='text' id='txt_uid' style='width:130px' /></td>" +
                "        </tr>" +
                "        <tr>" +
                "            <td style=\"width: 50px; height: 20px;\">密　码：</td>" +
                "            <td colspan=\"2\"><input type='password' id='txt_pwd' style='width:130px' /></td>" +
                "        </tr>" +
//                "        <tr>" +
//                "            <td style=\"width: 50px; height: 20px;\">验证码：</td>" +
//                "            <td><input type='text' id='txt_code' style='width:50px' /></td>" +
//                "            <td><img src='validate.ashx' onclick='this.src = this.src + \"?\" + Math.random()' title='点击更换验证码' style='cursor: pointer;width:75px;height:24px;' /></td>" +
//                "        </tr>" +
                "    </table>" +
                "</div>";
            $("#userCenter").html(html);   
        } else {
            alert("注销失败！");
        }
    });
}
