123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352 |
- 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;
- }
|