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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
@model sbcLabSystem.Models.Backstage.UserRequestInfoModel
@{
    ViewBag.Title = "用户登录";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
 
<script>
    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)
    {
        console.log(data)
        var self = this;
        self.LabCode = ko.observable("").extend({
            required: {
                params: true,
                message: "用户编码不能为空"
            }
        });
        self.LabPassword = ko.observable("").extend({
            required: {
                params: true,
                message: "用户密码不能为空"
            }
        });
        self.LabLoginName = ko.observable("").extend({
            required: {
                params: true,
                message: "验证码不能为空"
            }
        });
        self.UpdatePdw = function (dataInfo) {
                $.bootstrapLoading.start(); 
                $.ajax({
                    type: "post",
                    url: '@Url.Action("SeveUpdatePwd", "home")',
                    dataType: 'json',
                    cache: false,
                    contentType: 'application/json; charset=utf-8',
                    data: JSON.stringify(ko.toJS(self)),
                    success: function (json) {
                        if (json == "ok") {
                            //$.messager.popup("已经提交到管理员了,请实验室管理员注意查收邮件");
                            $('#exampleModal').modal('hide');
                            $.bootstrapLoading.end();
                            var cof = confirm("已经提交到管理员了,请实验室管理员注意查收邮件")
                        }
                        else {
                            $.messager.popup("实验室信息输入有误,请重新验证 ");
                            $.bootstrapLoading.end();
                        }
                    },
                    error: function (err) {
                        $.bootstrapLoading.end();
                        $.messager.alert(JSON.stringify(err));
                    }
                });
        }
        self.submitRequest = function (dataInfo) {
            var errors = ko.validation.group(self, { deep: true });
            console.log(errors());
            if (errors().length == 0) {
                $.bootstrapLoading.start();
                $.ajax({
                    type: "post",
                    url: '@Url.Action("SeveLogin", "home")',
                    dataType: 'json',
                    cache: false,
                    contentType: 'application/json; charset=utf-8',
                    data: JSON.stringify(ko.toJS(self)),
                    success: function (json) {
                        if (json == "ok") {
                            window.location.href = "@Url.Action("introduce", "UserUI")";
                        }
                        else if (json == "3") {
                            $.bootstrapLoading.end();
                            $.messager.popup("你已经多次登录失败,请60分钟后再试 ");
                        }
                        else if (json == "yzm") {
                            $.bootstrapLoading.end();
                            $.messager.popup("验证码错误");
                        }
                        else {
                            $.messager.popup("用户信息输入有误 ");
                            $.bootstrapLoading.end();
                        }
                    },
                    error: function (err) {
                        $.bootstrapLoading.end();
                        $.messager.alert(JSON.stringify(err));
                    }
                });
            }
            else {
                errors.showAllMessages();
            }
            };
        ko.mapping.fromJS(data, {}, self);
        console.log(self.LabPassword())
    }
</script>
@Html.Partial("Head");
<div class="container">
    <div class="row">
        <div class="col-xs-4">
            <h3>实验室用户登录</h3>
        </div>
        <div class="col-xs-4 col-xs-offset-4 pull-right" style="text-align:right">
            @*<a href="@Url.Action("Login","Backstage")">室间质评管理登录</a>*@
        </div>
    </div>
    <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:LabCode" placeholder="*实验室编码" />
                    </div>
                    <div class="form-group">
                        <input type="password" class="form-control" data-bind="textinput:LabPassword" placeholder="*密码" />
                    </div>
                    <div class="form-group">
                        <input type="text" class="form-control" data-bind="textinput:LabLoginName" 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-info center-block">登 录</a>
                    </div>
                    <div class="form-group">
                        <a href="javascript:void(1);" data-toggle="modal" data-target="#exampleModal">忘记密码!</a>
                    </div>
                </div>
 
            </div>
 
        </div>
 
        <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="exampleModalLabel">申请修改密码</h4>
                    </div>
                    <div class="modal-body">
                        <form>
                            <div class="form-group">
                                <label for="recipient-name" class="control-label">实验室编号:</label>
                                <input type="text" class="form-control" data-bind="textinput:LabCode" id="recipient-name">
                            </div>
                            <div class="form-group">
                                <label for="message-text" class="control-label">实验室联系人邮箱地址</label>
                                <input type="text" class="form-control" data-bind="textinput:ManagerEmail" id="recipient-eail">
                            </div>
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <button type="button" class="btn btn-primary" data-bind="click:UpdatePdw">提交</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@Html.Partial("Bottom");