PageSourceSearch

http://www.houdask.com/site/hd/resources/views/utils/login.js

js houdask.com collected 2026-10-02 06:29:22 UTC 11,645 bytes, 389 lines download raw bytes

1//点击显示登陆弹框
2$("#login>span,.LOGIN").click(function(){
3    $(".loginWrap").show();
4})
5//点击显示忘记密码弹框
6$("#showForget").click(function(){
7    $(".forgetWrap").show();
8    $(".loginWrap").hide();
9})
10//去学习(个人中心)
11$("#username>span,.goPerson").click(function(){
12    location.href="/site/personal/personal.html";
13})
14//账号密码登录功能
15//获取cookie值
16function GetCookie(name){   
17    var arr, reg = new RegExp("(^| )"+name+"=([^;]*)(;|$)");  
18    if(arr=document.cookie.match(reg)){
19        return unescape(arr[2]);   
20    }else{  
21        return null;   
22    }
23}  
24//设置cookie值  
25function SetCookie(name,value){   
26    //document.cookie.setPath("/"); 
27    var exp = new Date();   
28    exp.setTime(exp.getTime() + 1000*60*60*24*365*10);
29    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString()+";path=/";   
30}
31//删除cookie值
32function DelCookie(name){   
33    var exp = new Date();   
34    exp.setTime(exp.getTime() - 1);   
35    var cval=GetCookie(name);   
36    if(cval!=null)document.cookie= name + "="+cval+"; path=/;expires="+exp.toGMTString();
37}
38$(".homeLoginClose").click(function(){
39    $(".loginWrap,.forgetWrap").hide();
40})
41//切换登录方式
42$(".loginType span").click(function(){
43    var idx=$(this).index();
44    $(this).addClass("active").siblings("span").removeClass("active");
45    $(".loginCen>div").eq(idx).show().siblings().hide();
46})
47//存储单点登录code
48function device(){
49    var deviceId=new Date().getTime();
50    var deviceData={
51        "deviceId":deviceId
52    }
53    $.ajax({
54        url:"/api/sys/login/sendDownlineMessage",
55        type:"POST",
56        dataType:"json",
57        async: false,
58        headers:{
59            "appType":"WEB"
60        },
61        data:{
62            "data":JSON.stringify(deviceData)
63        },
64        success:function(msg){
65            if(msg.code=="1"){
66                SetCookie("deviceId",deviceId);
67            }
68        },
69        error:function(){
70            $.ajax({
71                url:"/api/sys/login/sendDownlineMessage",
72                type:"POST",
73                dataType:"json",
74                async: false,
75                headers:{
76                    "appType":"WEB"
77                },
78                data:{
79                    "data":JSON.stringify(deviceData)
80                },
81                success:function(msg){
82                    if(msg.code=="1"){
83                        SetCookie("deviceId",deviceId);
84                    }
85                }
86            })
87        }
88    })
89}
90$("#btn_login").click(function(){//登陆
91    var type=$(".loginType .active").attr("data-type");
92    if(type==1){//1验证码 2密码
93        yzLogin();
94    }else{
95        mmLogin();
96    }
97});
98
99//密码登录
100function mmLogin(){
101    var reg=new RegExp(localStorage.getItem("phone"));
102    var username=$("#loginPhone").val();
103    if(!reg.test(username)){
104        layer.msg("请输入正确的手机号");
105        return;
106    }
107    if(!$("#password").val()){
108        layer.msg("请输入密码");
109        return;
110    }
111    if(!$("#loginAgree").prop("checked")){
112        layer.msg("未同意用户服务条款");
113        return;
114    }
115    var data={
116        "loginWay":"WEB",//系统类型
117        "regWayId":"SJ",//手机号登陆
118        "userName":username,//手机号
119        "password":hex_md5($("#password").val())//密码
120    }
121    $.ajax({
122        url:"/api/sys/login/authc",
123        type:"POST",
124        dataType:"json",
125        headers:{
126            "appType":"WEB"
127        },
128        data:{
129            "data":JSON.stringify(data)
130        },
131        success:function(msg){
132            if(msg.code=="1"){
133                var userID=msg.data;
134                //向本地存储用户信息
135                sessionStorage.setItem("userID",JSON.stringify(userID));
136                $("#login").hide();
137                $("#username").show();
138                //单点登录
139                device();
140                location.href="/site/hd/resources/views/home/jump.html?text=登陆成功";
141            }else{
142                layer.msg(msg.message);
143            }
144        }
145    })
146}
147//验证码登录
148function yzLogin(){
149    var reg=new RegExp(localStorage.getItem("phone"));
150    var username=$("#loginPhone1").val();
151    var loginCode=$("#loginCode").val();
152    if(!reg.test(username)){
153        layer.msg("请输入正确的手机号");
154        return;
155    }
156    if(!loginCode){
157        layer.msg("请输入验证码");
158        return;
159    }
160    if(!$("#loginAgree").prop("checked")){
161        layer.msg("未同意用户服务条款");
162        return;
163    }
164    var data={
165        "loginWay":"WEB",//系统类型
166        "regWayId":"SJ",//手机号登陆
167        "userName":username,//手机号
168        "code":loginCode//短信验证码
169    }
170    $.ajax({
171        url:"/api/sys/anon/phone/code/login",
172        dataType:"json",
173        type:"POST",
174        headers:{
175            "appType":"WEB"
176        },
177        data:{
178            "data":JSON.stringify(data)
179        },
180        success:function(res){
181            if(res.code=="1"){
182                var userID=res.data;
183                //向本地存储用户信息
184                sessionStorage.setItem("userID",JSON.stringify(userID));
185                $("#login").hide();
186                $("#username").show();
187                //单点登录
188                device();
189                location.href="/site/hd/resources/views/home/jump.html?text=登陆成功";
190            }else{
191                layer.msg(res.message);
192            }
193        }
194    })
195}
196
197//退出登陆
198$(".exit").click(function(){
199    $.ajax({
200        url:"/api/sys/anon/logout",
201        dataType:"json",
202        type:"POST",
203        success:function(data){
204            if(data.code=="1"){
205                sessionStorage.removeItem("userID");
206                sessionStorage.removeItem("zxPlay");//删除直播路径
207                DelCookie("deviceId");//删除单点登录code
208                location.href="/site/hd/index.html";
209            }
210        }
211    })
212})
213
214
215/*验证码登录*/
216function getValidation(code){
217    var data={
218        "mobile":$("#loginPhone1").val(),
219        "type":"LOGIN",
220    }
221    $.ajax({
222        url:"/api/sys/anon/v3/phone/code",
223        type:"POST",
224        dataType:"json",
225        headers:{
226            appType:"WEB",
227            captchaCode:code,
228            type:"login"
229        },
230        data:{
231            "data":JSON.stringify(data)
232        },
233        success:function(data){
234            if(data.code==1){
235                var num=60;
236                var timer=setInterval(function(){
237                    num--
238                    if(num<=0){
239                        $("#getCode").html("获取验证码");
240                        clearInterval(timer);
241                        $("#getCode").attr("disabled",false);
242                    }else{
243                        $("#getCode").html(num+"s");
244                        $("#getCode").attr("disabled",true);
245                    }
246                },1000)
247            }else{
248                layer.msg(data.message);
249            }
250        }
251    })
252}
253// 初始化验证码  弹出式
254$('#mpanel').slideVerify({
255    baseUrl:'/api/sys/anon',   //服务器请求地址
256    containerId:'getCode', // pop模式 必填 被点击之后出现行为验证码的元素id
257    mode:'pop',
258    imgSize : {       //图片的大小对象
259        width: '400px',
260        height: '200px',
261    },
262    beforeCheck:function(){  //检验参数合法性的函数  mode ="pop"有效
263        var flag = true;
264        //实现: 参数合法性的判断逻辑, 返回一个boolean值
265        return flag
266    },
267    ready : function() {
268    },
269    success : function(params) {
270        //返回的二次验证参数 合并到验证通过之后的逻辑 参数中回传服务器
271        getValidation(params.captchaVerification);
272    },
273    error : function() {
274    }
275});
276
277//忘记密码
278//获取验证码
279function forgetCode(code){
280    var phone=$(".forgetPhone").val();
281    var reg=new RegExp(localStorage.getItem("phone"));
282    if(!reg.test(phone)){
283        layer.msg("请输入正确的手机号");
284    }else{
285        var data={
286            "mobile":phone,
287            "type":"RESET"
288        }
289        $.ajax({
290            type:"POST",
291            dataType:"json",
292            url:"/api/sys/anon/v3/phone/code",
293            headers:{
294                appType:"WEB",
295                captchaCode:code,
296                type:"fogetPwd"
297            },
298            data:{
299                "data":JSON.stringify(data)
300            },
301            success:function(msg){
302                if(msg.code==1){
303                    var num=60;
304                    var timer=setInterval(function(){
305                        num--
306                        if(num<=0){
307                            $("#forgetCode").html("获取验证码");
308                            clearInterval(timer);
309                            $("#forgetCode").attr("disabled",false);
310                        }else{
311                            $("#forgetCode").html(num+"s");
312                            $("#forgetCode").attr("disabled",true);
313                        }
314                    },1000)
315                }else{
316                    layer.msg(msg.message);
317                }
318            }
319        })
320    }
321}
322$('#forgetMpanel').slideVerify({
323    baseUrl:'/api/sys/anon',   //服务器请求地址, 默认地址为安吉服务器;
324    containerId:'forgetCode', // pop模式 必填 被点击之后出现行为验证码的元素id
325    mode:'pop',
326    imgSize : {       //图片的大小对象
327        width: '400px',
328        height: '200px',
329    },
330    beforeCheck:function(){  //检验参数合法性的函数  mode ="pop"有效
331        var flag = true;
332        //实现: 参数合法性的判断逻辑, 返回一个boolean值
333        return flag
334    },
335    ready : function() {
336    },
337    success : function(params) {
338        //返回的二次验证参数 合并到验证通过之后的逻辑 参数中回传服务器
339        forgetCode(params.captchaVerification);
340    },
341    error : function() {
342    }
343});
344
345//提交
346$("#forgetSubmit").click(function(){
347    var forgetPhone=$(".forgetPhone").val();
348    var newPassword=$(".newPassword").val();
349    var oldPassword=$(".oldPassword").val();
350    var forgetCode=$(".forgetCodeTxt").val();
351    if(!forgetPhone){
352        layer.msg("请输入手机号");
353        return;
354    }
355    if(!forgetCode){
356        layer.msg("请输入验证码");
357        return;
358    }
359    if(newPassword.length<6){
360        layer.msg("密码最少6个字符");
361        return;
362    }
363    if(newPassword!=oldPassword){
364        layer.msg("请输入一致的密码");
365        return;
366    }
367    var data={
368        "userName":forgetPhone,
369        "password":hex_md5(newPassword),
370        "code":forgetCode
371    }
372    $.ajax({
373        type:"POST",
374        dataType:"json",
375        url:"/api/sys/anon/user/reset/pwd",
376        data:{
377            "data":JSON.stringify(data)
378        },
379        success:function(msg){
380            if(msg.code==1){
381                layer.msg("密码修改成功");
382                $(".forgetWrap").hide();
383                $(".loginWrap").show();
384            }else{
385                layer.msg(msg.message);
386            }
387        }
388    })
389})

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.