jquery页面注册模版

//声明变量
var Register = function () {
    //提交
    this.btnSubmit = null;
    //获得省份ID
    this.provinceID = null;
    //省份名称
    this.province = null;
    //获得城市ID
    this.cityID = null;
    //区县ID
    this.countyID = null
    //城市名称
    this.cityName = null;
    //区县名称
    this.countyName = null;


    //用户名
    this.loginName = null;
    //密码
    this.Pwd = null;
    //确认密码
    this.confirmPwd = null;
    //联系人姓名
    this.relation = null;
    //Email
    this.email = null;
    //手机号码
    this.mobile = null;
    //身份证号码
    this.idCard = null;

    //主营行业信息
    this.industryID = null;
    //性别信息
    this.gender = null;

    this.countryNo = null;
    this.countyNo = null;
    this.telephonec = null;

    this.countryNoc = null;
    this.countyNoc = null;
    this.telephonec = null;

    this.msn = null;
    this.qq = null;

    this.Address = null;
    //邮政编码
    this.emailCode = null;

    this.protocol = null;
}

//初始化方法
Register.prototype.init = function () {
    var _this = this,
        _d = this.d;

    this.btnSubmit = this.$("btnSubmit");
    this.provinceID = this.$("ProvinceID");
    //省份名称
    this.province = this.$("ProvinceID");
    //获得城市ID
    this.cityID = this.$("CityID");
    //区县ID
    this.countyID = this.$("CountyID");
    //城市名称
    this.cityName = this.$("CityID");
    //区县名称
    this.countyName = $("#sltCounty").find("option:selected").text();


    //用户名
    this.loginName = this.$("LoginName");
    //密码
    this.Pwd = this.$("Pwd");
    //确认密码
    this.confirmPwd = this.$("ConfirmPwd");
    //联系人姓名
    this.relation = this.$("Relation");
    //Email
    this.email = this.$("Email");
    //手机号码
    this.mobile = this.$("Mobile");
    //身份证号码
    this.idCard = this.$("IDCard");

    //主营行业信息
    this.industryID = this.$("Industry");
    //性别信息
    this.gender = this.$("Gender");

    this.countryNo = this.$("CountryNo");
    this.countyNo = this.$("CountyNo");
    this.telephonec = this.$("Telephone");

    this.countryNoc = this.$("CountryNoc");
    this.countyNoc = this.$("CountyNoc");
    this.telephonec = this.$("Telephonec");

    this.msn = this.$("MSN");
    this.qq = this.$("QQ");

    this.Address = this.$("Address");
    //邮政编码
    this.emailCode = this.$("EmailCode");
    this.bindEvent(_d);
}

//绑定事件
Register.prototype.bindEvent = function (d) {
    var _this = this;
    _this.provinceID.change(function (e) {
        _this.Register(e);
    });
    _this.cityID.change(function (e) {
        _this.countyData(e);
    });
    _this.btnSubmit.click(function (e) {
        _this.submitRegistrData(e);
    });
}

//回传区县信息的方法
Register.prototype.countyData = function (e) {
    var _this = this;
    var aj = 1;
    var postData = {};
    postData["cityID"] = this.cityID.attr('value');
    if (aj == 1) {
        aj = 0;
        $.ajax({
            type: "post",
            url: "/Home/RegisterCountyData",
            dataType: 'json',
            data: postData,
            success: function (x) {
                if (x) {
                    $("#sltCounty").empty();
                    for (var i = 0; i < x.length; i++) {

                        var op = $("<option value="+x[i].CountyId+">" + x[i].CountyName + "</option>");
                        $("#sltCounty").append(op);
                    }
                }
            },
            complete: function () { aj = 1; }
        });
        return false;
    }
}
//回传城市信息
Register.prototype.Register = function (e) {
    var _this = this;
    var aj = 1;
    var postData = {};

    postData["provinceID"] = this.provinceID.attr('value');
    if (aj == 1) {
        aj = 0;
        $.ajax({
            type: "post",
            url: "/Home/RegisterData",
            dataType: 'json',
            data: postData,
            success: function (x) {
                if (x) {
                    $("#sltCity").empty();
                    for (var i = 0; i < x.length; i++) {

                        var op = $("<option value="+x[i].CityId+">" + x[i].CityName + "</option>");
                        $("#sltCity").append(op);
                    }

                }
            },
            complete: function () { aj = 1; }
        });
        return false;
    }
}
//获得页面数据
Register.prototype.submitRegistrData = function (e) {
    var _this = this;
    var aj = 1;
    var postData = {};
    postData["ProvinceID"] = this.provinceID.attr('value');
    //省份名称
    postData["Province"] = $("#sltProvince").find("option:selected").text();
    //获得城市ID
    postData["CityID"] = this.cityID.attr('value');
    //区县ID
    postData["CountyID"] = this.countyID.attr('value');
    //城市名称
    postData["CityName"] = $("#sltCity").find("option:selected").text();
    //区县名称
    postData["CountyName"] = $("#sltCounty").find("option:selected").text();


    //用户名
    postData["LoginName"] = this.loginName.attr('value');
    //密码
    postData["Pwd"] = this.Pwd.attr('value');
    //确认密码
    postData["ConfirmPwd"] = this.confirmPwd.attr('value');
    //联系人姓名
    postData["Relation"] = this.relation.attr('value');
    //Email
    postData["Email"] = this.email.attr('value');
    //手机号码
    postData["Mobile"] = this.mobile.attr('value');
    //身份证号码
    postData["IDCard"] = this.idCard.attr('value');

    //主营行业信息
    postData["Industry"] = this.industryID.attr('value');
    //性别信息
    postData["Gender"] = this.gender.attr('value');

    postData["CountryNo"] = this.countryNo.attr('value');
    postData["CountyNo"] = this.countyNo.attr('value');
    postData["Telephone"] = this.telephonec.attr('value');

    postData["CountryNoc"] = this.countryNoc.attr('value');
    postData["CountyNoc"] = this.countyNoc.attr('value');
    postData["Telephonec"] = this.telephonec.attr('value');

    postData["MSN"] = this.msn.attr('value');
    postData["QQ"] = this.qq.attr('value');

    postData["Address"] = this.Address.attr('value');
    //邮政编码
    postData["EmailCode"] = this.emailCode.attr('value');
    if (aj == 1) {
        aj = 0;
        $.ajax({
            type: "post",
            url: "/Home/RegisterAllData",
            dataType: 'json',
            data: postData,
            success: function (x) {
                if (x) {
                    if (x.code) {
                        if ("ok" === x.code || "OK" === x.code) {
                            alert("成功!!");
                        }
                        else {
                            $(x.code).tooltip({ html: x.msg, isFocus: 1, isSelect: 1 });
                            return false;
                        }
                    }
                }
            },
            complete: function () { aj = 1; }
        });
        return false;
    }
}
//获得控件对象
Register.prototype.$ = function (componentName) {
    return $('[name="' + componentName + '"]')
}



var register = new Register();
register.init();

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ligengdipan

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值