songjun
2024-09-04 cc908053e0b5075fbfd27350b6da4b39bca9e550
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
@model sbcLabSystem.Data.Domain.Account.UserInfo
@{
    ViewBag.Title = "管理员登录";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
 
<script type="text/javascript">
    var viewModel;
    $(function () {
        $("#valiCode").bind("click", function () {
            this.src = "../Account/GetValidateCode?time=" + (new Date()).getTime();
        });
        viewModel = new myViewModel_User(@Html.Raw(Json.Encode(Model)));
        ko.applyBindings(viewModel, $(".container")[1]);
    });
    function myViewModel_User(data) {
        var self = this;
        self.UserNo = ko.observable("").extend({
            required: {
                params: true,
                message: "用户名不能为空"
            }
        });
        self.Password = ko.observable("").extend({
            required: {
                params: true,
                message: "密码不能为空"
            }
        });
        self.Remark = ko.observable("").extend({
            required: {
                params: true,
                message: "验证码不能为空"
            }
        });
        self.submitRequest = function (dataInfo) {
            var errors = ko.validation.group(self, { deep: true });
            if (errors().length == 0) {
                $.bootstrapLoading.start();
                $.ajax({
                    type: "post",
                    url: '@Url.Action("DoLogin", "Backstage")',
                    dataType: 'json',
                    cache: false,
                    contentType: 'application/json; charset=utf-8',
                    data: JSON.stringify(ko.toJS(self)),
                    success: function (json) {
                        if (json == "No")
                        {
                            $.bootstrapLoading.end();
                            $.messager.popup("你已经连续登录三次了,请过60分钟再试");
                        }
                        else if (json == "ok") {
                            window.location.href = "@Url.Action("Index","Backstage")";
                        }
                        else if (json == "yzm") {
                            $.bootstrapLoading.end();
                            $.messager.popup("验证码错误");
                        }
                        else {
                            $.bootstrapLoading.end();
                            $.messager.popup(json);
                        }
                    },
                    error: function (err) {
                        $.bootstrapLoading.end();
                        $.messager.alert(JSON.stringify(err));
                    }
                });
            }
            else {
                errors.showAllMessages();
            }
        };
        ko.mapping.fromJS(data, {}, self);
    }
</script>
 
@Html.Partial("Head");
<div class="container">
    <div class="row">
        <div class="col-xs-12" style="text-align: center; border-top: solid #c2bfbf">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">管理员登录</h3>
                </div> 
                <div class="panel-body">
                    <div class="form-group">
                        <input type="text" class="form-control" data-bind="textinput:UserNo" placeholder="*管理员ID" />
                    </div>
                    <div class="form-group">
                        <input type="password" class="form-control" data-bind="textinput:Password" placeholder="*密码" />
                    </div>
                    <div class="form-group">
                        <input type="text" class="form-control" data-bind="textinput:Remark" placeholder="*验证码" />
                        <img id="valiCode" style="cursor: pointer;"  src="~/Account/GetValidateCode" alt="验证码" />
                    </div>
                    <div class="form-group">
                        <a href="javascript:void(0);" data-bind="click:submitRequest"
                           class="btn btn-success">提  交</a> 
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@Html.Partial("Bottom");