Administrator
2022-10-09 23f93897d618a5253a18b65b124196f95891f240
提交 | 用户 | 时间
58d006 1 window.I = {}
A 2 var basic = getpath();
3 var modelview = function() {
4     var self = this;
5     self.opwd = ko.observable();
6     self.npwd = ko.observable();
7     self.rnpwd = ko.observable();
8 }
9 jQuery(document).ready(
10         function($) {
11             var flag = true;
12             var md = window.md = new modelview();
13             ko.applyBindings(md);
14             var fm1 = $('#fm1');
15             fm1.validate({
16                 rules : {
17                     opwd : "required",
18                     npwd : {
19                         required : true,
20                         maxlength : 16,
21                         minlength : 6
22                     },
23                     rnpwd : {
24                         required : true,
25                         equalTo : '#npwd',
26                         maxlength : 16,
27                         minlength : 6
28                     }
29                 },
30                 messages : {
31                     opwd : "请输入旧密码",
32                     npwd : {
33                         required : "请输入新密码",
34                         maxlength : '最大长度不能超过16',
35                         minlength : '最小长度不能小于6'
36                     },
37                     rnpwd : {
38                         required : "请输入新密码确认",
39                         maxlength : '最大长度不能超过16',
40                         minlength : '最小长度不能小于6',
41                         equalTo : '#新密码前后输入不一致,请重新输入'
42                     }
43                 }
44             });
45             $("#npwd").change(function() {
46                 var opwd = $("#opwd").val();
47                 var npwd = $("#npwd").val();
48                 if (opwd == npwd) {        
49                     flag=false;
50                     alert("新密码和旧密码不能一致,请重新输入!");
51                 }
52             })
53             $('#tjbtn').click(
54                     function(event) {
55                         /* Act on the event */
56                         if (!fm1.valid()||flag==false)
57                             return;                    
58                         var obj = {};
59                         obj.oldpwd = md.opwd();
60                         obj.newpwd = md.npwd();
61                         obj.rnpwd = md.rnpwd();
62                         jQuery.post(basic + '/system/savePwd.htm',
63                                 obj, function(data, textStatus, xhr) {
64                                     // optional stuff to do after success
65                                     if (data == null) {
66                                         // showErrmsg('系统没有响应!');
67                                         swal({title:'',text:'系统没有响应!',type:'error',confirmButtonText:'确定'}); 
68                                         return;
69                                     }
70                                     if (data.code == 0) {
71                                         showErrmsg('密码修改成功!');
72                                         return;
73                                     } else {
74                                         swal({title:'',text:'密码失败,请重新修改!',type:'error',confirmButtonText:'确定'}); 
75                                         // showErrmsg('密码失败,请重新修改!');
76                                         return;
77                                     }
78                                 }, 'json');
79                     });
80         });