common.js

//var rootDomain="http://api.yangguangeshequ.com";
//var rootDomain="http://54.223.174.57/eliveapi/";
var rootDomain="http://www.yangguangeshequ.com/eliveapi/";
//定义全局变量
window.$$$ = {
    isNull : function(str){//判断是否为空
        if(str.replace(/\s/g,"") == ""){
            return true;
        }else{
            return false;
        }
    },
    isUrl : function(url){//判断当前页是否为xxx.html
        var s = ".+"+ url.replace(".","\\.") +"(\\?|$)";
        var reg = new RegExp(s);//console.log(reg);
        if(reg.test(location.href)){
            return true;
        }else{
            return false;
        }
    },
    valiPhone : function(p){//验证手机号码
        if(/^1[3|4|5|6|7|8|9][0-9]\d{8}$/.test(p)){
            return true;
        }else{
            return false;
        }
    },
    valiEmail : function(e){//验证邮箱
        var reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
        if(reg.test(e)){
            return true;
        }else{
            return false;
        }
    },
    valiZcode : function(code){//验证邮编
        if(/^\d{6}$/.test(code)){
            return true;
        }else{
            return false;
        }
    },
    checkname : function(v) {//验证用户名,最多1个汉字或20个字母/数字
        /*var rx = /[a-z\d]/i, rxcn = /[\u4e00-\u9fa5]/, num = 0, chr;
         for (var i = 0, j = v.length; i < j; i++) {
         chr = v.charAt(i);
         if (rx.test(chr)) num += 1;
         else if (rxcn.test(chr)) num += 2;
         else return false;
         }
         if (num < 1 || num > 20) return false;
         return true;*/
        if(!/^[a-zA-Z0-9]{2,20}$/.test(v)){
            return false;
        }else{
            return true;
        }
    },
    checkpwd : function(pwd){//验证密码
        var reg = /^[a-zA-Z0-9]{6,20}$/;
        if(reg.test(pwd)){
            return true;
        }else{
            return false;
        }
    },
    getParaVal : function(para){//根据参数名截取Url中的参数值
        var regStr = "(^|&)"+para+"="+"([^&]*)(&|$)";
        var reg = new RegExp(regStr);
        var pval = window.location.search.substr(1).match(reg);
        if(pval == null) return null
        else return decodeURI(pval[2]);
    },
    getNullVal: function(para){//把null变为''
        if(para == null)  return ''
        else return para;
    },
    // 获取本周的日期(周日到周六)
    getWeek: function(date){
        var y = parseInt(date.match(/\d{4}/));
        var m = parseInt(date.match(/-\d{2}-/)[0].replace(/-/g,""));
        var d = parseInt(date.match(/\d{2}$/)[0]);
        var ssdate=new Date(y,m-1,d);
        var week = ssdate.getDay();
        var weekStr = null;
        switch(week){
            case 1 :
                weekStr = "星期一";
                break;
            case 2 :
                weekStr = "星期二";
                break;
            case 3 :
                weekStr = "星期三";
                break;
            case 4 :
                weekStr = "星期四";
                break;
            case 5 :
                weekStr = "星期五";
                break;
            case 6 :
                weekStr = "星期六";
                break;
            case 0 :
                weekStr = "星期日";
                break;
        }
        return weekStr;
    },
    //json对象转字符串
    jsonToStr : function(json){
        return JSON.stringify(json)
    },
    //字符串转json对象
    strToJson : function(str){
        return JSON.parse(str);
    },
    addLing:function(price){//小数点后保留两位
        var priceL=0;
        typeof price == "number"?price+="":"";
        if(price.indexOf(".")>0){
            priceL=price.substring(price.indexOf(".")+1,price.length).length;
        }
        if(priceL==1){
            price=price+"0";
        }
        price=/\.\d{2,}/.test(price)==false?price+".00":price;
        return price;
    },
    addCourierPrice: function(totalMoney){ // 将订单价格+10元的快递费用
        var courierPrice = parseFloat(totalMoney.replace("¥",""))*100;
        courierPrice = courierPrice + parseInt(firstData.expressPrice);
        courierPrice = $$.addLing(courierPrice/100);
        courierPrice = '¥'+ courierPrice;
        return courierPrice
    }
}
//日期格式化
Date.prototype.Format = function (fmt) { //author: meizz
    var o = {
        "M+": this.getMonth() + 1, //月份
        "d+": this.getDate(), //
        "h+": this.getHours(), //小时
        "m+": this.getMinutes(), //
        "s+": this.getSeconds(), //
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
        "S": this.getMilliseconds() //毫秒
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
};
function getHouseInfoList(district,houseType,housePrice,searchType,isSort,pageSize,page){
    $.ajax({
        type: "POST",
        url: rootDomain+"/house/getHouseInfoList.json",
        data: {
            district: district,
            houseType: houseType,
            housePrice: housePrice,
            searchType: searchType,
            isSort: isSort,
            pageSize: pageSize,
            page: page
        },
        dataType: "json",//此处格式一定要正确
        timeout: 10000,
        context: null,
        success: function (date) {
            //alert(".....");
            //$("#houseInfoList").html("");
            if(date.respCode=="9000"){
               alert(date.respMsg);
            }
            houseAllRow = window.houseAllRow = date.allRow;
            houseTotalPage = houseAllRow/pageSize;
            nowPage = "-1";
            //console.log(houseAllRow);
            var houseInfoList = date.houseList;
            var houseInfoListHtml="";
            for(var i=0;i<houseInfoList.length;i++){
                var communityName= date.houseList[i].communityName;
                var imgUrl= date.houseList[i].imgUrl;
                var monthRent= date.houseList[i].monthRent;
                var housePrice= date.houseList[i].housePrice;
                var houseType= date.houseList[i].houseType;
                var houseArea= date.houseList[i].houseArea;
                var houseAround= date.houseList[i].houseAround;
                var houseToward= date.houseList[i].houseToward;
                var houseTitle= date.houseList[i].houseTitle;
                var houseId= date.houseList[i].houseId;

                houseInfoListHtml = "<li class='clearfix'>";
                if(searchType=="1"){
                    houseInfoListHtml+="<a class='pic' href='house_rental_information.html?houseId="+houseId+"'>";
                }else if(searchType=="2"){
                    houseInfoListHtml+="<a class='pic' href='house_sell_information.html?houseId="+houseId+"'>";
                }else{
                    houseInfoListHtml+="<a class='pic' href='house_rental_information.html?houseId="+houseId+"'>";
                }

                if(imgUrl){
                    houseInfoListHtml+="<img src='"+ imgUrl +"' alt='"+ houseTitle +"' />";
                }else{
                    houseInfoListHtml+="<img src='http://www.ddfcw.com/uploads/5FD420121131010.jpg' alt='"+ houseTitle +"' />";
                }
                if(searchType=="1"){
                    houseInfoListHtml+="</a><a class='txt' href='house_rental_information.html?houseId="+houseId+"'>";
                }else if(searchType=="2"){
                    houseInfoListHtml+="</a><a class='txt' href='house_sell_information.html?houseId="+houseId+"'>";
                }else{
                    houseInfoListHtml+="</a><a class='txt' href='house_rental_information.html?houseId="+houseId+"'>";
                }
                houseInfoListHtml+="<h2>"+ houseTitle +"</h2>";
                houseInfoListHtml+="<span>"+ houseType + "&nbsp;&nbsp;&nbsp;&nbsp;"+ houseToward +"</span>";
                houseInfoListHtml+="<span>"+ houseAround +"</span>";
                if(searchType=="1"){
                    houseInfoListHtml+="<b>"+ monthRent +"元/月</b></a>";
                }else if(searchType=="2"){
                    houseInfoListHtml+="<b>"+ housePrice +"万元/总价</b></a>";
                }else{
                    houseInfoListHtml+="<b>"+ monthRent +"元/月</b></a>";
                }
                houseInfoListHtml+="</li>";
                $("#houseInfoList").append(houseInfoListHtml);
            }
            //houseInfoListHtml +="<li style='height:0;line-height:0;overflow:hidden;'><a href='#"+ page + "'</a></li>";
        },
        error: function (b, a) {
            //alert(b);
            console.log(b);
        }
    })
}
//获取门小区楼数
function getCommunityInfo(communityName,communityId){
    var buildingNo;
    $.ajax({
        type: "POST",
        //url: rootDomain+"/user/newQueryCommunityInfo.json",
        url: rootDomain+"/user/queryCommunityInfo.json",
        data: {
            communityName: communityName,
            communityId: communityId
        },
        dataType: "json",//此处格式一定要正确
        timeout: 10000,
        context: null,
        async:false,
        success: function (date){
            var buidingNoList = date.buidingNoList;
            buildingNo=buidingNoList;
            var _company=$("#company");
            _company.val(date.manageName);
            var firstBuilding=buidingNoList[0];
            var firstBuildingHtml="";
            $.each(buidingNoList,function(i,n){
                var BuildingNo=buidingNoList[i];
                firstBuildingHtml="<option id='buildingNo_"+i+"' value='"+ n.buildingNo +"'>"+ n.buildingNo +"</option>";
                $("#room_address_a").append(firstBuildingHtml);
            })
            getRoomAddressList("0",buildingNo);
        },
        error: function (b, a) {
            alert(b);
        }
    })
    return buildingNo;
}
//获取门小区楼数牌号
//function getRoomAddressList(i,buildingNo){
//    console.log(buildingNo);
//    var storeyInfo="";
//    var buildingUnitNoHtml="";
//    var buildingHouseNoHtml="";
//    $("#room_address_b").html("");
//    $("#room_address_c").html("");
//    if(buildingNo[i].buildingList){
//        $.each(buildingNo[i].buildingList,function(i,n){
//            buildingUnitNoHtml+="<option value='"+ n.unitNo +"'>"+ n.unitNo +"</option>";
//        })
//        $("#room_address_b").append(buildingUnitNoHtml);
//    }else{
//        $("#room_address_b").append("<option>无</option>");
//    }
//    return storeyInfo;
//}
function getRoomAddressList(i,buildingNo){
    var buildingUnitNoHtml="";
    var buildingHouseNoHtml="";
    $("#room_address_b").html("");
    $("#room_address_c").html("");
    if(buildingNo[i].unitNoList){
        $.each(buildingNo[i].unitNoList,function(i,n){
            buildingUnitNoHtml+="<option value='"+ n +"'>"+ n +"</option>";
        })
        $("#room_address_b").append(buildingUnitNoHtml);
    }else{
        $("#room_address_b").append("无");
    }

    if(buildingNo[i].houseNoList){
        $.each(buildingNo[i].houseNoList,function(i,n){
            buildingHouseNoHtml+="<option value='"+ n +"'>"+ n +"</option>";
        })
        $("#room_address_c").append(buildingHouseNoHtml);
    }else{
        $("#room_address_c").append("无");
    }
}
/*倒计时60秒*/
var wait=120;
function countdown(o) {
    console.log(o);
    if (wait == 0) {
        o.removeAttribute("disabled");
        o.value="获取验证码";
        wait = 120;
    } else {
        o.setAttribute("disabled", true);        //o.removeClass("no");
        o.value="重新发送" + wait + "";
        wait--;
        setTimeout(function() {
                countdown(o)
            },
            1000)
    }
}
/*获取头部参数函数*/
var getArgs = function ()
{
    var args = new Object( ); //声明一个空对象
    var query = window.location.search.substring(1); // 取查询字符串,如从http://www.snowpeak.org/testjs.htm?a1=v1&a2=&a3=v3#anchor 中截出 a1=v1&a2=&a3=v3。
    var pairs = query.split("&"); // 以 & 符分开成数组
    for(var i = 0; i < pairs.length; i++) {
        var pos = pairs[i].indexOf('='); // 查找 "name=value" 对
        if (pos == -1) continue; // 若不成对,则跳出循环继续下一对
        var argname = pairs[i].substring(0,pos); // 取参数名
        var value = pairs[i].substring(pos+1); // 取参数值
        value = decodeURIComponent(value); // 若需要,则解码
        args[argname] = value; // 存成对象的一个属性
    }
    return args; // 返回此对象
};

function getLinkParam(){
    $("a").each(function(){
        var originalLinkLink=$(this).attr("href");
        if(originalLinkLink){
            var originalLinkLinkJudge= originalLinkLink.indexOf(".html");
            var originalLinkLinkJudgeJ= originalLinkLink.indexOf(".jsp");
            var originalLinkJudgeH5= originalLinkLink.indexOf("&h=5");
            var needParam=getLinkImParam();
            //var originalLinkLinkType=originalLinkLink.substr(0,originalLinkLinkJudge);
            //var query = location.search.substring(1).split('&');
            var linkParam = location.search.substring(1);
            var originalLinkLinkType=originalLinkLink.substr(originalLinkLinkJudge);
            if(originalLinkLinkJudge!=-1 || originalLinkLinkJudgeJ!=-1){
                var originalLinkLinkM= originalLinkLink.substr(originalLinkLinkJudge+5,1);
                if(originalLinkLinkM=="?"){
                    if(originalLinkJudgeH5!=-1){
                        $(this).attr("href",originalLinkLink+needParam+"&h="+5);
                    }else{
                        $(this).attr("href",originalLinkLink+needParam);
                    }
                }else{
                    if(originalLinkJudgeH5!=-1){
                        $(this).attr("href",originalLinkLink+"?"+needParam+"&h="+5);
                    }else{
                        $(this).attr("href",originalLinkLink+"?"+needParam);
                    }
                }
            }
            //console.log(originalLinkLink+"---"+originalLinkLinkM+"---"+linkParam);
        }
    })
}

function getLinkImParam(){
    var oJson=getArgs();
    var userId = oJson.userId;
    var mobile = oJson.mobile;
    var client = oJson.client;
    var communityId = oJson.communityId;
    var osName = oJson.osName;
    var versionNo = oJson.versionNo;
    var lon = oJson.lon;
    var lat = oJson.lat;
    var clientParam = "&client="+ client;
    var linkParam = "userId="+ userId + "&mobile="+ mobile +"&communityId="+ communityId +"&osName="+ osName +"&versionNo="+ versionNo +"&lon="+ lon +"&lat="+ lat;
    return linkParam;
}

//广告客户端
function getAdImg(n){
    var oJson=getArgs();
    var communityId = oJson.communityId;
    var communityIda=communityId;
    if(communityIda=undefined){
        communityIda=null;
    }
    $.ajax({
        type: "POST",
        url: rootDomain+"ad/adList.json",
        data: {
            communityId: communityIda,
            position: n
        },
        dataType: "json",//此处格式一定要正确
        //beforeSend: function(XMLHttpRequest){
        //    $("#loading").css('display','');
        //},
        timeout: 10000,
        context: null,
        success: function (data) {
            console.log(data);
            $(data.ads).each(function(i,n){
                var imgSrc=n.image;
                var imgAll="";
                var showType=n.showType;
                if(showType==1){imgAll+="<div class='swiper-slide'><a href='important_information.html?id="+ n.id +"'><img src='"+n.image+"'/></a></div>";}
                else if(showType==2){imgAll+="<div class='swiper-slide'><a href='"+ n.adUrl +"'><img src='"+n.image+"'/></a></div>";}
                else{imgAll+="<div class='swiper-slide'><a href='#'><img src='"+n.image+"'/></a></div>"}
                //imgAll+="<div class='swiper-slide'><a href='important_information.html?id="+ n.id +"'><img src='"+n.image+"'/></a></div>";
                $("#imgList").append(imgAll);
            })
            var swiper = new Swiper('.swiper-container',{
                pagination: '.pagination',
                loop:true,
                grabCursor: true,
                autoplay:3000,
                speed:500,
                autoplayDisableOnInteraction:false,
                paginationClickable: true
            });
        },
        error: function (b, a) {
            //alert(b);
            console.log(b);
        }
    })
}
//滚动到底时加载数据
function goNextPage(callBack){
    $(window).scroll(function(){
        var o = $("body");
        if(o!=null && o.length !=0){
            //获取网页的完整高度(fix)
            var height= $(document).height();

            //获取浏览器高度(fix)
            var clientHeight =$(window).height();

            //获取网页滚过的高度(dynamic)
            var top= window.pageYOffset || (document.compatMode == 'CSS1Compat' ? document.documentElement.scrollTop :    document.body.scrollTop);

            //当 top+clientHeight = scrollHeight的时候就说明到底儿了
            if(top>=(parseInt(height)-clientHeight)){
                //alert("go to next page");
                console.log(window.houseAllRow+"----"+houseTotalPage+"----"+nowPage);
                if(houseTotalPage > nowPage){
                    callBack();
                }
            }
        }
    })
}
//下拉上拉加载,初始化上拉刷新组件 iScroll 滚动框架

//user login
function userLogin(){
    var mobile=$("#telephone").val();
    var pwd=$("#password").val();
    var versionNo="";
    var osName="";
    if (!$$$.valiPhone(mobile)){
        popTip("手机输入错误,请重新输入");
        return false;
    }
    $.ajax({
        type: "POST",
        url: rootDomain+"user/login.json",
        data: {
            mobile: mobile,
            pwd: pwd,
            versionNo: versionNo,
            osName: osName
        },
        dataType: "json",
        timeout: 10000,
        context: null,
        success: function (data) {
            if(data.respCode=="0000"){
                var userInfo = data.userModel;
                var userCommunityList = userInfo.userCommunityList;
                var CommunityId = "";
                $(userCommunityList).each(function(i,d){
                    //console.log(d.userCommunityStatus)
                    if(d.userCommunityStatus=="1"){
                        CommunityId=d.communityId;
                    }
                });
                localStorage.setItem("userId",userInfo.userId);
                localStorage.setItem("sessionId",userInfo.sessionId);
                localStorage.setItem("mobile",userInfo.mobile);
                localStorage.setItem("communityId",CommunityId);
                location.href = "my_community.html?userId="+ userInfo.userId +"&mobile="+userInfo.mobile+"&communityId="+CommunityId+"&osName=&versionNo=&lon=&lat="
            }else{
                //alert("...");
                popTip(data.respMsg);
            }
        },
        error: function (b, a) {
            //alert(b);
            console.log(b);
        }
    })
}
//get the VerifyCode
function getVerifyCode(mobile,status){
    if (!$$$.valiPhone(mobile)){
        popTip("手机输入错误,请重新输入");
        return false;
    }
    status=(status===undefined || status==="")?"1":"0";
    //if(status=="0"){alert("注册用户");}
    $.ajax({
        async : false,
        type: "POST",
        url: rootDomain+"user/sendVerifyCode.json",
        data: {
            mobile: mobile,
            sendType: status
        },
        dataType: "json",
        timeout: 10000,
        context: null,
        success: function (data) {
            if(data.respCode=="0000"){
                $("#verifyCode").focus();
                popTip(data.respMsg);
                backCodeGetVerifyCode=0;
            }else{
                popTip(data.respMsg);
                backCodeGetVerifyCode=1;
            }
        },
        error: function (b, a) {
            console.log(b);
        }
    })
}
//validate the VerifyCode
function validateVerifyCode(mobile,verifyCode,url){
    $.ajax({
        type: "POST",
        url: rootDomain+"user/validateVerifyCode.json",
        data: {
            mobile: mobile,
            verifyCode: verifyCode
        },
        dataType: "json",
        timeout: 10000,
        context: null,
        success: function (data) {
            if(data.respCode=="0000"){
                location.href=url+"?mobile="+mobile+"&verifyCode="+verifyCode;
            }else{
                popTip(data.respMsg);
            }
        },
        error: function (b, a) {
            console.log(b);
        }
    })
}
//forget page edit the new pw
function forgetPwEdit(url){
    var oJson=getArgs();
    var mobile = oJson.mobile;
    var verifyCode = oJson.verifyCode;
    var passWord=$("#password_a").val();
    var rePassWord=$("#password_b").val();
    if(passWord!=rePassWord){
        popTip("密码输入不同");
        return false;
    }
    $.ajax({
        type: "POST",
        url: rootDomain+"user/forgetPwd.json",
        data: {
            mobile: mobile,
            newPwd: passWord,
            confirmPwd: rePassWord,
            verifyCode: verifyCode
        },
        dataType: "json",
        timeout: 10000,
        context: null,
        success: function (data) {
            if(data.respCode=="0000"){
                location.href=url;
            }else{
                popTip(data.respMsg);
            }
        },
        error: function (b, a) {
            console.log(b);
        }
    })
}
//register
function register(url){
    var oJson=getArgs();
    var mobile = oJson.mobile;
    var verifyCode = oJson.verifyCode;
    var passWord=$("#password_a").val();
    var rePassWord=$("#password_b").val();
    $.ajax({
        type: "POST",
        url: rootDomain+"user/register.json",
        data: {
            mobile: mobile,
            pwd: passWord,
            confirmPwd: rePassWord,
            verifyCode: verifyCode
        },
        dataType: "json",
        timeout: 10000,
        context: null,
        success: function (data) {
            var userInfo=data.userModel;
            if(data.respCode=="0000"){
                location.href=url+"?userId="+ userInfo.userId + "&mobile="+ mobile +"&userCommunityId=" + userInfo.userCommunityList[0].userCommunityId;
                localStorage.setItem("userId",userInfo.userId);
                localStorage.setItem("sessionId",userInfo.sessionId);
                localStorage.setItem("mobile",userInfo.mobile);
                localStorage.setItem("communityId",userCommunityList[0].communityId);
            }else{
                popTip(data.respMsg);
            }
        },
        error: function (b, a) {
            console.log(b);
        }
    })
}
//pop tip
function popTip(txt,callBack){
    var popLayout = "";
    popLayout+= '<div class="tip_mask">';
    popLayout+=    '<div class="tip">';
    popLayout+=        '<h5>提示</h5>';
    popLayout+=        '<p class="tip_txt">'+ txt +'</p>';
    popLayout+=        '<span>确认</span>';
    popLayout+=    '</div>';
    popLayout+= '</div>';
    $("body").append(popLayout);
    $(".tip_mask span").click(function(){
        $(".tip_mask").remove();
    });
}
//客户端上传图片后获取图片链接
function sendImgLink(a){
    var houseImg="<img src='"+a+"'/>";
    $("#houseImg").append(houseImg);
}

$(document).ready(function(){
    getLinkParam();

    var oJson=getArgs();
    var mobile = oJson.mobile;
    var communityId = oJson.communityId;
    var userId = oJson.userId;
    var osName = oJson.osName;
    var versionNo = oJson.versionNo;
    //if($$$.isUrl("my_community.html")){
    //    //var linkParam = location.search.substring(1);
    //    $(".header .b").attr("href","elive://go?url=back&mobile=" + mobile + "&communityId=" + communityId + "&userId=" + userId);
    // }
    if(('undefined' == userId || userId == null || userId == '')&&localStorage.getItem("userId")){
        mobile = localStorage.getItem("mobile");
        communityId = localStorage.getItem("communityId");
        userId = localStorage.getItem("userId");
        if('undefined' == userId || userId == null || userId == ''){
            location.href = "my_community.html?userId="+ userId +"&mobile="+mobile+"&communityId="+communityId+"&osName=&versionNo=&lon=&lat="
        }
        return;
    }else if(!localStorage.getItem("userId")){
        mobile = oJson.mobile;
        communityId = oJson.communityId;
        userId = oJson.userId;
    }

    //if(userId == 'undefined' || userId == null || userId == ''&& !localStorage.getItem("userId")){}
    $("#login_submit").click(function(){
        userLogin();
    });

    $(".verify").on("click",".btn",function(){
        if($(this).attr("id") == "getVerifyCode"){
            var wocao=$("#telephone").val()
            if(wocao==undefined){
                return false;}
            getVerifyCode($("#telephone").val());
        }else if($(this).attr("id") == "getRegVerifyCode"){
            getVerifyCode($("#telephone").val(),"0");
            var mobile=$("#telephone").val();
            if (!$$$.valiPhone(mobile)){
                popTip("手机输入错误,请重新输入");
                return false;
            }
            if(backCodeGetVerifyCode!==1){
                var verifyobj=$("#getRegVerifyCode")[0];
                countdown(verifyobj);
                backCodeGetVerifyCode=0;
            }
        }else{
            //getVerifyCode($("#telephone").val(),"0");
        }
        //  countdown(this);
    });

    $("#validate").click(function(){
        var resetUrl="reset-pw.html";
        validateVerifyCode($("#telephone").val(),$("#verifyCode").val(),resetUrl);
    });

    $("#confirm_pw").click(function(){
        var confirmUrl="login.html";
        forgetPwEdit(confirmUrl);
    });

    $(".access em").click(function(){
        $(this).toggleClass("i_check_f");
    });

    $("#reg_next").click(function(){
//        var regEndUrl="register_end.html?userId="+ userId + "&mobile="+ mobile +"&communityId="+ communityId +"&osName="+ osName +"&versionNo="+ versionNo;
        var regEndUrl="register_end.html"
        validateVerifyCode($("#telephone").val(),$("#verifyCode").val(),regEndUrl);
    });

    $("#reg_finish").click(function(){
        var passWord=$("#password_a").val();
        var rePassWord=$("#password_b").val();
        if(passWord!=rePassWord){
            popTip("密码输入不同");
            return false;
        }
        if( $(".access em").attr("class").indexOf("i_check_f") != -1 ){
            popTip("请阅读并勾选用户协议");
            return false;
        }else{
//            var regEndUrl="add_community.html?userId="+ userId + "&mobile="+ mobile +"&communityId="+ communityId +"&osName="+ osName +"&versionNo="+ versionNo;
            var regEndUrl="add_community.html";
            register(regEndUrl);
        }
    });

    if('android' == osName){
        $(".m").css("padding","10px 0");
        $(".i_back").css("height","18px");
        $(".ms").css("padding","10px 0");
        $(".header .t").css("margin","10px 25px 7px 0");
    }
    if('undefined' == userId || userId == null || userId == ''){
        $(".download").show();
        $(".mainHeader").css("top","57px");
        $(".mainSlider").css("margin-top","99px");
        if($(window).width()>640){
            $(".mainHeader").css("top","114px");
            $(".mainSlider").css("margin-top","198px");
        }
//        $(".download").hide();
        $("#user").show();
        //$(".b").hide();
//      $(".header").css("top","57px");
        $("#user").attr('href','login.html');
    }else if('undefined' != osName && osName != null && osName != ''){
        $("#user").hide();
        //$(".b").show();
        $(".download").hide();
    }else if('undefined' == osName || osName == null || osName == ''){
        $(".download").show();
        $(".mainHeader").css("top","57px");
        $(".mainSlider").css("margin-top","99px");
        if($(window).width()>640){
            $(".mainHeader").css("top","114px");
            $(".mainSlider").css("margin-top","198px");
        }
        $("#user").show();
        //$(".b").hide();
        //$(".header").css("top","57px");
        $("#user").attr('href','user.html?userId='+ userId + '&mobile='+ mobile +'&communityId='+ communityId);
    }

//    $("#my_community > li").click(function(){
//        if('undefined' == userId || userId == null || userId == ''){
//            window.location.href="http://www.yangguangeshequ.com/elive-h5/login.html";
//            return false;
//        }
//    });

});

 

posted @ 2015-08-03 16:15  刺蛇笑眯眯  阅读(310)  评论(0编辑  收藏  举报