【小程序】【在线缴费系统】(二)管理端功能-登录页面
导读部分
教程目录:http://www.sufeinet.com/thread-40967-1-1.html
教程部分
登录部分页面效果:
页面Jquery:
[JavaScript] 纯文本查看 复制代码
<script>
$("#code,#pwd").keyup(function (event) {
if (event.keyCode == 13) {
save();
}
});
$("#refresh").click(function () {
$("#img-enti").attr("src", "")
$("#img-enti").attr("src", "/web/checkCode.aspx?" + Math.random())
})
function save() {
var user = $("#account").val();
var pwd = $("#pwd").val();
var code = $("#code").val();
if (user.length <= 0) { layer.msg("请输入用户名", { time: 800 }); $("#account").focus(); }
else if (pwd.length <= 0) { layer.msg("请输入密码", { time: 800 }); $("#pwd").focus(); }
else if (code.length <= 0) { layer.msg("请输入验证码", { time: 800 }); $("#code").focus(); }
else {
$.ajax({
type: "post",
dataType: "json",
url: "/Handler/SysHandler.ashx",
data: "action=login&user=" + user + "&pwd=" + pwd + "&code=" + code,
async: false,
success: function (result) {
if (result.msgCode == 0) {
window.location.href = result.info;
} else {
layer.msg(result.msg, { time: 800 });
}
},
error: function (e) {
layer.msg(e.responseText, { time: 800 });
}
});
}
}
</script>
Aps.Net页面程序:
[C#] 纯文本查看 复制代码
// 登录
funlist.TryAdd("login", (context, _handitem) =>
{
var resultJson = new JsonResultHelper<dynamic>() { msgCode = -1, msg = "登录失败" };
// 获取参数
string username = InputHelper.GetInputString(context.Request["user"]);
string password = InputHelper.GetInputString(context.Request["pwd"]);
string code = context.Request.Params["code"];
string loginIP = context.Request.UserHostAddress.ToString();
// 获取cookie中的验证码
HttpCookie codecookie = context.Request.Cookies["CheckCode"];
if (codecookie == null || string.IsNullOrEmpty(codecookie.Value))
{
resultJson.msg = "验证码错误";
}
else
{
if (new Encrypt().EncryptString(code) != codecookie.Value) { resultJson.msg = "验证码错误"; }
else
{
sys_userBLL userBLL = new sys_userBLL();
sys_user user = userBLL.FindListOne($"username='{username}'") ?? new sys_user();
if (user != null && user.id != 0)
{
//判断密码
var pwd = RSAFromPkcs8.RSADecrypt(user.pwd, ResourceConfig.QR_PRIVATE_8, "UTF-8");
if (password != pwd)
{
return new JsonResultHelper<dynamic>() { info = "", msgCode = -1, msg = "密码错误" }; ;
}
if (user != null && user.id > 0)
{
LoginHelper.Login(user.id, "");
// 获取跳转地址
string redirect_url = "/web/index.aspx";
resultJson = new JsonResultHelper<dynamic>() { info = redirect_url, msgCode = 0, msg = "登录成功" };
}
}
else
{
resultJson.msg = "账号错误";
}
}
}
return resultJson;
});
用户部分,数据库设计,以及Model,BLL程序, 下章再说, 加油!!
用户数据库设计+逻辑处理
|