Переглянути джерело

解决bug,修改密码不能成功的问题

raolu 6 роки тому
батько
коміт
8c975b4601
3 змінених файлів з 367 додано та 303 видалено
  1. 14 302
      html/home/html/forgetPwd.html
  2. 352 0
      html/home/js/forgetPwd.js
  3. 1 1
      html/yszx/html/focused-doctor.html

+ 14 - 302
html/home/html/forgetPwd.html

@ -81,7 +81,7 @@
        <h1>登录</h1>
    </div>
</div>-->
<div class="main">
    <div class="main">
    <div id="idcardBox">
        <ul class="n-list edit-info registered c-border-tb mt15 c-f15 form-register">
            <li>
@ -136,7 +136,7 @@
                    <span class="f-fs16 c-323232">设置密码</span>
                </div>
                <div class="n-list-info">
                    <input type="password" class="width-100 c-f16 c-5b5b5b reg-pwd" placeholder="请输入密码"/>
                    <input type="password" class="width-100 c-f16 c-5b5b5b reg-pwd" id="pwd1" placeholder="请输入密码"/>
                    <a href="#" class="searchbar-clear"></a>
                </div>
              </li>
@ -145,7 +145,7 @@
                    <span class="f-fs16 c-323232">确认密码</span>
                </div>
                <div class="n-list-info">
                    <input id="apwd" type="password" class="width-100 c-f16 c-5b5b5b" placeholder="请再次输入密码"/>
                    <input id="pwd2" type="password" class="width-100 c-f16 c-5b5b5b" placeholder="请再次输入密码"/>
                    <a href="#" class="searchbar-clear"></a>
                </div>
              </li>
@ -157,305 +157,17 @@
    </div>
    <p style="font-size: 16px;text-align: center;color: #323232;" class="mr15 c-t-right">返回<span style="font-size: 17px;font-style: italic;color: #17b3ec;"  onclick="accountShenshu()">账号申诉</span></p>
  
</div>
    </div>
    <script type="text/javascript" src="../../../js/jquery/2.1.3/jquery.js"></script>
    <script type="text/javascript" src="../../../js/common_http.js"></script>
    <script type="text/javascript" src="../../../js/weixin_common.js"></script>
    <link rel="stylesheet" type="text/css" href="../../../widget/artDialog/6.0.5/css/ui-dialog.min.css">
    <script src="../../../widget/artDialog/6.0.5/js/dialog-plus.js"></script>
    <script src="../../../js/security.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="../../../js/commit_validate.js"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
    <script src="../../../js/mui.min.js"></script>
    <script src="../js/forgetPwd.js" type="text/javascript" charset="utf-8"></script>
</body>
<script type="text/javascript" src="../../../js/jquery/2.1.3/jquery.js"></script>
<script type="text/javascript" src="../../../js/common_http.js"></script>
<script type="text/javascript" src="../../../js/weixin_common.js"></script>
<link rel="stylesheet" type="text/css" href="../../../widget/artDialog/6.0.5/css/ui-dialog.min.css">
<script src="../../../widget/artDialog/6.0.5/js/dialog-plus.js"></script>
<script type="text/javascript" src="../../../js/commit_validate.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script src="../../../js/mui.min.js"></script>
<script type="text/javascript">
    var dd = dialog({contentType: 'load', skin: 'bk-popup', content: '验证中...'});
    var Request = new Object();
    Request = GetRequest();
    var openid = Request["openid"];
    var type = Number(Request["type"]);
    var mobile1 = Request["mobile"];
    var clock = "";
    var nums = 60;
    var loginParams = Request["loginParams"];
    var $phoneBox = $('#phoneBox');
    var $idcardBox = $('#idcardBox');
    bindEvents();
    if (loginParams) {
        loginParams = JSON.parse(decodeURIComponent(Request["loginParams"]));
    }
    $(function () {
        var userAgent = window.localStorage.getItem(agentName);
        if (userAgent) {
            var paurl = "";
            if (type == 0) {
                paurl = "wx/html/home/html/login.html?type=0&openid=" + openid;
            }
            else {
                if (mobile1) {
                    paurl = "wx/html/home/html/login.html?type=" + type + "&openid=" + openid + "&mobile=" + mobile1;
                }
                else {
                    paurl = "wx/html/home/html/login.html?type=" + type + "&openid=" + openid;
                }
            }
            //从后台那边获取签名等信息
            var params = {};
            params.pageUrl = window.location.href;
            $.ajax(server + "weixin/getSign", {
                data: params,
                dataType: "json",
                type: "post",
                success: function (res) {
                    if (res.status == 200) {
                        var t = res.data.timestamp;
                        var noncestr = res.data.noncestr;
                        var signature = res.data.signature;
                        wx.config({
                            //debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
                            appId: appId, // 必填,公众号的唯一标识
                            timestamp: t, // 必填,生成签名的时间戳
                            nonceStr: noncestr, // 必填,生成签名的随机串
                            signature: signature,// 必填,签名,见附录1
                            jsApiList: [
                                'closeWindow'
                            ] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
                        });
                    }
                }
            });
            wx.ready(function () {
                wx.closeWindow();
            });
        }
        else {
            if (!openid) {
                dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: 'openid获取失败'}).show();
            }
            if (mobile1) {
                $("#txtMobile").val(mobile1);
            }
        }
    })
    function bindEvents() {
        $("#checkIdCard").on("click", function () {
            var idcard = $('#idcardTxt').val();
            var data = {}
            if (idcard == "") {
                dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: '身份证不能为空'}).show();
                return;
            }
            if (!isIdcard(idcard)) {
                dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: '请输入正确的身份证号'}).show();
                return;
            }
            data.idCard = idcard;
            sendPost("weixin/getMobile", data, "json", "post", operateFailed, operateSuccesss);
            function operateSuccesss(res) {
                if (res.status == -1) {
                    dd.close();
                    if (res && res.msg) {
                        dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: res.msg}).show();
                    setTimeout(function () {
                        mui.openWindow({
                            url: "regist-info.html",
                            waiting: {
                                autoShow: false, //自动显示等待框,默认为true
                                title: '正在加载...'
                            }
                        });
                    },1500)
                    return;
                    }
                } else if (res.status == -2) {
                    dd.close();
                    if (res && res.msg) {
                        dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: '您还未绑定手机,无法重置密码,请尝试使用默认密码登录。'}).show();
                    setTimeout(function () {
                        mui.openWindow({
                            url: "zhmm-login.html",
                            waiting: {
                                autoShow: false, //自动显示等待框,默认为true
                                title: '正在加载...'
                            }
                        });
                    },1500)
                    }
                } else if (res.status == 200) {
                    dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: res.msg}).show();
                    var mobile = res.data.mobile;
                    var phoneNum = mobile.substring(0, 3) + "*****" + mobile.substring(8, 11);
                    $('#txtMobile').val(mobile);
                    $('#checkIdCard').hide().next().show();
                }
            };
            function operateFailed(res) {
                dd.close();
                if (res && res.msg) {
                    dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: res.msg}).show();
                } else {
                    dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: '校验失败'}).show();
                }
            };
        })
        $("#phoneBtn").on("click", function () {
            if ($(this).hasClass("active")) {
                commit();
            }
            else{
                dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content:'请将相关信息补充完毕'}).show();
            }
        })
        $("input").on("focus", function () {
            $(".searchbar-clear").css("pointer-events", "none").css("opacity", 0);
            if ($(this).val()) {
                $(this).next().css("pointer-events", "auto").css("opacity", 1);
            }
        }).on("input", function () {
            $(this).next().css("pointer-events", "auto").css("opacity", 1);
        });
        $("input").on('keyup',function(){
            var allHaveValue = true,
                a = $('input');
            $('input').each(function(){
                if(!$(this).val()) {
                    allHaveValue = false;
               }
            });
            
            if(allHaveValue){
                $("#phoneBtn").addClass("active");
            }
            else{
                $("#phoneBtn").removeClass("active");
            }
        })
        $(".n-list-info").on("click", ".searchbar-clear", function () {
            $(this).prev().val("");
            $(this).css("pointer-events", "none").css("opacity", 0);
            $(this).prev().focus();
            return false;
        });
    }
    
    function sendCode() {
        var mobile = document.getElementById("txtMobile").value;
        if (!mobile) {
            dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: '请先校验身份证'}).show();
            return;
        }
        if (!isphone(mobile)) {
            dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: '手机号格式不正确'}).show();
            return;
        }
        $("#messageCode1").hide();
        document.getElementById("message").innerHTML = nums + '秒后可重新获取';
        $("#messageCode2").show();
        clock = setInterval(doLoop, 1000); //一秒执行一次
        var data = {};
        data.mobile = mobile;
        data.type = 2;
        sendPost("common/captcha", data, "json", "post", sendFailed, sendSuccesss);
    }
    //失败
    function sendFailed(res) {
        clearInterval(clock); //清除js定时器
        $("#messageCode1").show();
        $("#messageCode2").hide();
        nums = 60; //重置时间
        if (res && res.msg) {
            dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: res.msg}).show();
        } else {
            dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: '获取失败'}).show();
        }
    }
    function sendSuccesss(res) {
        if (res.status == 200) {
        }
        else {
            sendFailed(res);
        }
    }
    function doLoop() {
        nums--;
        if (nums > 0) {
            document.getElementById("message").innerHTML = nums + '秒后可重新获取';
        } else {
            clearInterval(clock); //清除js定时器
            $("#messageCode1").show();
            $("#messageCode2").hide();
            nums = 60; //重置时间
        }
    }
    var mobile;
    function commit() {
        mobile = document.getElementById("txtMobile").value;
        var captcha = document.getElementById("txtCode").value;
        if (!mobile || !captcha) {
            dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: '手机号和验证码不能为空'}).show();
            return;
        }
        if (!isphone(mobile)) {
            dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: '手机号格式不正确'}).show();
            return;
        }
        dd.showModal();
        //拼请求内容
        var data = {};
        data.mobile = mobile;
        data.captcha = captcha;
        data.type = 2;
        sendPost("common/check_captcha", data, "json", "post", operateFailed, operateSuccesss);
    }
    //失败
    function operateFailed(res) {
        dd.close();
        if (res && res.msg) {
            dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: res.msg}).show();
        } else {
            dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: '验证码验证失败'}).show();
        }
    }
    //成功调用登录接口
    function operateSuccesss(res) {
        var idcard = $('#idcardTxt').val();
        if (res.status == 200) {
            window.location.href = "login.html?type=" + type + "&openid=" + openid + "&mobile=" + mobile + '&idcard=' + idcard;
            dd.close();
        } else {
            //非200则为失败
            operateFailed(res);
        }
    }
    
    $('#accounts').on('tap',function(){
		mui.openWindow({
			id: "account_back",
			url: "../../yjfk/html/account_back.html",
			extras: {
				
			}
		});
	})
    function accountShenshu(){
		window.location.href = "../../yjfk/html/account_back.html?type=" + type + "&openid=" + openid;
	}
</script>
</html>

+ 352 - 0
html/home/js/forgetPwd.js

@ -0,0 +1,352 @@
var dd = dialog({contentType: 'load', skin: 'bk-popup', content: '验证中...'});
var Request = new Object();
Request = GetRequest();
var openid = Request["openid"];
var type = Number(Request["type"]);
var mobile1 = Request["mobile"];
var clock = "";
var nums = 60;
var loginParams = Request["loginParams"];
var $phoneBox = $('#phoneBox');
var $idcardBox = $('#idcardBox');
bindEvents();
if (loginParams) {
    loginParams = JSON.parse(decodeURIComponent(Request["loginParams"]));
}
$(function () {
    var userAgent = window.localStorage.getItem(agentName);
    if (userAgent) {
        var paurl = "";
        if (type == 0) {
            paurl = "wx/html/home/html/login.html?type=0&openid=" + openid;
        }
        else {
            if (mobile1) {
                paurl = "wx/html/home/html/login.html?type=" + type + "&openid=" + openid + "&mobile=" + mobile1;
            }
            else {
                paurl = "wx/html/home/html/login.html?type=" + type + "&openid=" + openid;
            }
        }
        //从后台那边获取签名等信息
        var params = {};
        params.pageUrl = window.location.href;
        $.ajax(server + "weixin/getSign", {
            data: params,
            dataType: "json",
            type: "post",
            success: function (res) {
                if (res.status == 200) {
                    var t = res.data.timestamp;
                    var noncestr = res.data.noncestr;
                    var signature = res.data.signature;
                    wx.config({
                        //debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
                        appId: appId, // 必填,公众号的唯一标识
                        timestamp: t, // 必填,生成签名的时间戳
                        nonceStr: noncestr, // 必填,生成签名的随机串
                        signature: signature,// 必填,签名,见附录1
                        jsApiList: [
                            'closeWindow'
                        ] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
                    });
                }
            }
        });
        wx.ready(function () {
            wx.closeWindow();
        });
    }
    else {
        if (!openid) {
            dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: 'openid获取失败'}).show();
        }
        if (mobile1) {
            $("#txtMobile").val(mobile1);
        }
    }
})
function bindEvents() {
    $("#checkIdCard").on("click", function () {
        var idcard = $('#idcardTxt').val();
        var data = {}
        if (idcard == "") {
            dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: '身份证不能为空'}).show();
            return;
        }
        if (!isIdcard(idcard)) {
            dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: '请输入正确的身份证号'}).show();
            return;
        }
        data.idCard = idcard;
        sendPost("weixin/getMobile", data, "json", "post", operateFailed, operateSuccesss);
        function operateSuccesss(res) {
            if (res.status == -1) {
                dd.close();
                if (res && res.msg) {
                    dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: res.msg}).show();
                setTimeout(function () {
                    mui.openWindow({
                        url: "regist-info.html",
                        waiting: {
                            autoShow: false, //自动显示等待框,默认为true
                            title: '正在加载...'
                        }
                    });
                },1500)
                return;
                }
            } else if (res.status == -2) {
                dd.close();
                if (res && res.msg) {
                    dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: '您还未绑定手机,无法重置密码,请尝试使用默认密码登录。'}).show();
                setTimeout(function () {
                    mui.openWindow({
                        url: "zhmm-login.html",
                        waiting: {
                            autoShow: false, //自动显示等待框,默认为true
                            title: '正在加载...'
                        }
                    });
                },1500)
                }
            } else if (res.status == 200) {
                dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: res.msg}).show();
                var mobile = res.data.mobile;
                var phoneNum = mobile.substring(0, 3) + "*****" + mobile.substring(8, 11);
                $('#txtMobile').val(mobile);
                $('#checkIdCard').hide().next().show();
            }
        };
        function operateFailed(res) {
            dd.close();
            if (res && res.msg) {
                dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: res.msg}).show();
            } else {
                dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: '校验失败'}).show();
            }
        };
    })
    $("#phoneBtn").on("click", function () {
        if ($(this).hasClass("active")) {
            commit();
        }
        else{
            dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content:'请将相关信息补充完毕'}).show();
        }
    })
    $("input").on("focus", function () {
        $(".searchbar-clear").css("pointer-events", "none").css("opacity", 0);
        if ($(this).val()) {
            $(this).next().css("pointer-events", "auto").css("opacity", 1);
        }
    }).on("input", function () {
        $(this).next().css("pointer-events", "auto").css("opacity", 1);
    });
    $("input").on('keyup',function(){
        var allHaveValue = true,
            a = $('input');
        $('input').each(function(){
            if(!$(this).val()) {
                allHaveValue = false;
           }
        });
        
        if(allHaveValue){
            $("#phoneBtn").addClass("active");
        }
        else{
            $("#phoneBtn").removeClass("active");
        }
    })
    $(".n-list-info").on("click", ".searchbar-clear", function () {
        $(this).prev().val("");
        $(this).css("pointer-events", "none").css("opacity", 0);
        $(this).prev().focus();
        return false;
    });
    
    $('#accounts').on('tap',function(){
        mui.openWindow({
            id: "account_back",
            url: "../../yjfk/html/account_back.html",
            extras: {
                
            }
        });
    })
}
function sendCode() {
    var mobile = document.getElementById("txtMobile").value;
    if (!mobile) {
        dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: '请先校验身份证'}).show();
        return;
    }
    if (!isphone(mobile)) {
        dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: '手机号格式不正确'}).show();
        return;
    }
    $("#messageCode1").hide();
    document.getElementById("message").innerHTML = nums + '秒后可重新获取';
    $("#messageCode2").show();
    clock = setInterval(doLoop, 1000); //一秒执行一次
    var data = {};
    data.mobile = mobile;
    data.type = 2;
    sendPost("common/captcha", data, "json", "post", sendFailed, sendSuccesss);
}
//失败
function sendFailed(res) {
    clearInterval(clock); //清除js定时器
    $("#messageCode1").show();
    $("#messageCode2").hide();
    nums = 60; //重置时间
    if (res && res.msg) {
        dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: res.msg}).show();
    } else {
        dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: '获取失败'}).show();
    }
}
function sendSuccesss(res) {
    if (res.status == 200) {
    }
    else {
        sendFailed(res);
    }
}
function doLoop() {
    nums--;
    if (nums > 0) {
        document.getElementById("message").innerHTML = nums + '秒后可重新获取';
    } else {
        clearInterval(clock); //清除js定时器
        $("#messageCode1").show();
        $("#messageCode2").hide();
        nums = 60; //重置时间
    }
}
var mobile;
function commit() {
    mobile = document.getElementById("txtMobile").value;
    var captcha = document.getElementById("txtCode").value,
        pwd1 = $("#pwd1").val(),
        pwd2 = $("#pwd2").val();
    if (!mobile || !captcha) {
        dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: '手机号和验证码不能为空'}).show();
        return;
    }
    if (!isphone(mobile)) {
        dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: '手机号格式不正确'}).show();
        return;
    }
    
    if(!pwd1){
        dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: '请输入新的登录密码'}).show();
        return;
    }else{
        var isValid = validPwd();
        if(!isValid){
            return false;
        }
    }
    
    if(pwd1 != pwd2){
        dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: '两次输入的密码不一致!'}).show();
        return;
    }
    dd.showModal();
    //拼请求内容
    var data = {};
    data.mobile = mobile;
    data.captcha = captcha;
    data.type = 2;
    sendPost("common/check_captcha", data, "json", "post", operateFailed, operateSuccesss);
}
//失败
function operateFailed(res) {
    dd.close();
    if (res && res.msg) {
        dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: res.msg}).show();
    } else {
        dialog({contentType: 'tipsbox', bottom: true, skin: 'bk-popup', content: '验证码验证失败'}).show();
    }
}
//成功调用登录接口
function operateSuccesss(res) {
    var idcard = $('#idcardTxt').val();
    if (res.status == 200) {
        //修改密码
        updatePassword();
    } else {
        //非200则为失败
        operateFailed(res);
    }
}
function updatePassword(){
    var mobile = document.getElementById("txtMobile").value,
        pwd1 = $("#pwd1").val(),
        idcard = $("#idcardTxt").val();
    //加密设置:获取公钥
    var encryURL = server + "login/public_key";
    var key = RSAUtils.getKeyFromServer(encryURL);
    //拼请求内容
    var data = {
        mobile: mobile,
        idcard: idcard,
        newpwd: RSAUtils.encryStr(key, pwd1),
        openid: openid,
        type: 1
    };
    sendPost("login/forgetpwd", data, "json", "post", operateFailed, function(res){
        if (res.status == 200) {
            dd.close();
            dialog({
                content: '重置密码成功',
                okValue:'确定',
                ok: function (){                                    
                    window.location.href = "login.html?type=0&openid=" + openid + "&mobile=" + mobile;
                }
            }).showModal();
        } else {
            //非200则为失败
            operateFailed(res);
        }
    });
}
var chineseReg = /.*[\u4e00-\u9fa5]+.*$/;
function validPwd(){
    var pwd = $.trim($('#pwd1').val());
    if(chineseReg.test(pwd)){
        dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'密码不可包含中文'}).show();
        return false;
    }
    if(pwd.length<6){
        dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'密码不得少于6位'}).show();
        return false;
    }
    return pwd;
}
function accountShenshu(){
    window.location.href = "../../yjfk/html/account_back.html?type=" + type + "&openid=" + openid;
}

+ 1 - 1
html/yszx/html/focused-doctor.html

@ -17,7 +17,7 @@
    <body>
        <div class="main">
            <!--<a class="focused" id='focused' href="javascript:void(0)" style="top: 0;">已关注(咨询)</a>-->
            <div class="mui-scroll-wrapper bgc-f2f4f6" style="top: 40px;">
            <div class="mui-scroll-wrapper bgc-f2f4f6" style="top: 0px;">
                <div class="mui-scroll">
                    <ul class="plr10 pb50" id="docList">