var tncode_div = null; var regFunc = { username: null, password: null, password_again: null, validation_picture: null, companycn: null, tel: null, email: null, phone_code: null, mng_host: null, PSign: false, telPreg: /^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(16[0-9]{1})|(17[0-9]{1})|(18[0-9]{1})|(19[0-9]{1}))+\d{8})$/, emailPreg: /^([a-zA-Z0-9]+[-_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[-_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/, usernamePreg: /^(\w){4,20}$/, passwordPreg: /^(\w){6,18}$/, validation: function () { var t = this; if (!t.username) { t.tips('用户名不能为空', '[name=username]'); return false; } if (!t.usernamePreg.test(t.username)) { t.tips('请填写4-20数字字母组成的用户名', '[name=username]'); return false; } if (!t.password) { t.tips('密码不能为空', '[name=password]'); return false; } if (!t.passwordPreg.test(t.password)) { t.tips('请填写6-18数字字母下滑线组成的密码', '[name=password]'); return false; } if (t.PSign) { if (!t.tel) { t.tips('手机号码不能为空', '[name=tel]'); return false; } /*if (!t.telPreg.test(t.tel)) { t.tips('手机号码格式不正确', '[name=tel]'); return false; }*/ var phonePregSign = false; $.each(phonesParrern, function (index, value) { if (value.test(t.tel)) { phonePregSign = true; return false; } }); if (!phonePregSign) { t.tips('手机号码格式不正确', '[name=tel]'); return false; } if (!t.phone_code) { t.tips('手机验证码不能为空', '[name=phone_code]'); return false; } } else { if (t.password_again != t.password) { t.tips('两次密码不一致', '[name=password_again]'); return false; } } if (!t.validation_picture) { t.tips('图形验证码不能为空', '[name=validation_picture]'); return false; } t.response(ajaxFile, {method: 'validationUserName', val: t.username}, function (param, res) { if (res == 0) { t.tips('用户名已存在请更换!', '[name=username]'); } else { if (t.PSign) { if (reg_mobile_repeat != 0) { t.response(ajaxFile, {method: "checkPhoneRepeat", val: t.tel}, function (param, res) { // 手机号是否可重复 if (res == 2) { t.tips('该手机号码已被注册过了,请更换!', '[name=tel]'); } else if (res == 1) { t.response(ajaxFile, {method: 'checkPhoneCode', val: t.phone_code, phoneCode: t.tel, websiteUserInfo: websiteUserInfo}, function (param, res) { if (res == 0) { t.tips('手机验证码错误', '[name=phone_code]'); } else { userInfoSub(t); } }); } else { t.tips('手机号码有误!', '[name=tel]'); } }); } else { t.response(ajaxFile, {method: 'checkPhoneCode', val: t.phone_code, phoneCode: t.tel, websiteUserInfo: websiteUserInfo}, function (param, res) { if (res == 0) { t.tips('手机验证码错误', '[name=phone_code]'); } else { userInfoSub(t); } }); } } else { userInfoSub(t); } } }); }, tips: function (val, selector, time) { if (!val || !selector) { return false; } layer.tips(val, selector, { tips: [1, 'red'], time: time || 4000 }); }, popClose: function () { if (this.popIndex) { layer.close(this.popIndex); } }, loading: function () { this.popIndex = layer.load(0, {shade: false}); }, response: function (u, param, sfunc, efunc) { if (!param) { return false; } var t = this; t.loading(); $.ajax({ url: u, type: 'POST', dataType: 'json', async: true, data: param, error: function (XMLHttpRequest, textStatus, errorThrown) { t.popClose(); typeof efunc === "function" && efunc(XMLHttpRequest, textStatus, errorThrown); // console.log(XMLHttpRequest, textStatus, errorThrown); }, success: function (response) { t.popClose(); typeof sfunc === "function" && sfunc(param, response); } }); } }; $(function () { if(typeof webTypeTwo!=="undefined" && webTypeTwo == 1){ thisSs = $('.theThirdStep'); ___(thisSs, '.main_register1', 1); $('.step_third').show(); } // 注册 $('.checkRegister.sign_in').click(function() { regFunc.username = $.trim($('input[name=username]').val()); regFunc.password = $('input[name=password]').val(); regFunc.password_again = $('input[name=password_again]').val(); regFunc.validation_picture = $.trim($('input[name=validation_picture]').val()); regFunc.companycn = $.trim($('input[name=companycn]').val()); regFunc.tel = $.trim($('input[name=tel]').val()); regFunc.email = $.trim($('input[name=email]').val()); regFunc.phone_code = $.trim($('input[name=phone_code]').val()); var thisS = $(this); if (thisS.hasClass('phonecode')) { regFunc.PSign = true; } if ($("[name=reg_agreement]").length && $("[name=reg_agreement]:checked").val() != 1) { $("[name=reg_agreement]:checked") return regFunc.tips('必须同意本网站协议', '[name=reg_agreement]'); } regFunc.validation(); }); // 查看密码 $('#open_password').click(function() { var input = $(this).parent().find('input[name=password]'), type = input.attr("type"); if (type == "password") { $(this).find('img').addClass('cur'); input.before(''); } else { $(this).find('img').removeClass('cur'); input.before(''); } $(this).prev().prev().remove(); }); // 短信验证码 $('.sendMobileMessage').click(function() { var thisS = $(this) , tel = $('input[name=tel]').val() // , sign = tel && $.trim($('input[name=username]').val()) && $('input[name=password]').val() && $.trim($('input[name=validation_picture]').val()) ; if (!$.trim($('input[name=username]').val())) { regFunc.tips('请填写用户名', '[name=username]'); return false; } if (!$('input[name=password]').val()) { regFunc.tips('请填写密码', '[name=password]'); return false; } if (!phonesParrern['zh-CN'].test($('input[name=tel]').val())) { regFunc.tips('请填写正确的手机号码', '[name=tel]'); return false; } if (!$.trim($('input[name=validation_picture]').val())) { regFunc.tips('请填写图形验证码', '[name=validation_picture]'); return false; } /*if (!sign) { return false; }*/ if (!tncode_div) { tncode.init('tncode_class', 1); tncode_div = true; } else { tncode.show(); } $TN.onsuccess(function(){ thisS.after('60s后重新发送'); $.post('/dom/ajax_zhuce_code.php', { type: 99, tn_r: tncode._mark_offset, userid: websiteUserInfo[0], mobile: tel, username: websiteUserInfo[1], wap: 1, }, function(data) { thisS.parent().find(".validateInfo").addClass("specialColor").html("验证码发送成功!").css("display", "block"); sendCountDown($('#sendCountDown'), thisS); setTimeout(function () { thisS.parent().find(".validateInfo").removeClass("specialColor").hide(); }, 2000); }); }); }); // 基础信息 $('.baseInfoBtn').click(function() { var t = regFunc; t.PSign = true; t.companycn = $.trim($('input[name=companycn]').val()); t.email = $.trim($('input[name=email]').val()); if (!t.companycn) { t.tips('请为您的网站起个名称吧', '[name=companycn]'); return false; } if (!t.emailPreg.test(t.email)) { t.tips('请填写正确格式邮件', '[name=email]'); return false; } var method = 'sign_up_base_info'; if ($(this).hasClass('goSelectTemplates')) { // 已填写 t.PSign = false; } else { method = 'userWebBaseInfo'; t.tel = $.trim($('input[name=tel]').val()); /*if (!t.telPreg.test(t.tel)) { t.tips('手机号码格式不正确', '[name=tel]'); return false; }*/ var phonePregSign = false; $.each(phonesParrern, function (index, value) { if (value.test(t.tel)) { phonePregSign = true; return false; } }); if (!phonePregSign) { t.tips('手机号码格式不正确', '[name=tel]'); return false; } } baseInfoSub(t, method); }); // 选择类型 $('.checkWebType').click(function(){ $('.checkWebType').removeClass('ok_cur'); $(this).addClass('ok_cur'); }); // 第三步 选择类型 $('.theThirdStep').click(function(){ var webType = 0, thisS = $(this), t = regFunc; $('.checkWebType').each(function(){ if ($(this).hasClass('ok_cur')) { webType = $(this).attr('dataType'); } }); if (webType){ if (!window.userName || !window.regUserName) { hintMessage('参数错误!', 1000, false); return false; } t.response(ajaxFile, {method: 'selectWebType', val: {username: window.regUserName, webtype: webType,handleWebTypeTwo:indexAdd + '&guidanceIndexTmpId=' + tmpId}}, function (param, res) { if (res) { if (webType == 2) { // 门户 初始化最新的论坛门户模板 // console.log(indexAdd + '&guidanceIndexTmpId=' + tmpId); // location.href = indexAdd + '&guidanceIndexTmpId=' + tmpId; layer.msg('正在提交请稍候...', {icon: 16,time: 1000000,shade : [0.5 , '#000' , true]}); location.href = "http:" + officialHost + res.token; return false; var val = {method: 'templatesCopy', postUrl: indexAdd + '&guidanceIndexTmpId=' + tmpId} t.response(getTemplatesDataAjaxFile, {method: 'selectWebType', val: val}, function (param, res) { if (res == 1) { //location.href = "http:" + officialHost + '/user_manage_style.php'; location.href = "http:" + officialHost + res.token; } else { layer.msg('初始化失败!'); setTimeout(function(){ //location.href = "http:" + officialHost + '/user_manage_style.php'; location.href = "http:" + officialHost + res.token; }, 1000); } }); return false; } else if (webType == 7) { // 论坛型 //location.href = "http:" + officialHost + '/user_manage_style.php'; location.href = "http:" + officialHost + res.token; return false; } else if (webType == 69) { // 名片 //location.href = "http:" + officialHost + '/wap_index_style.php?xcx=1&new_style_tag=28'; location.href = "http:" + officialHost + res.token; return false; } else if (webType == 21 || webType == 50) { // 微信万人分销 微圈 //location.href = "http:" + officialHost + '/ct/wap.php'; location.href = "http:" + officialHost + res.token; return false; } else if (webType == 35) { // 小程序 //location.href = "http:" + officialHost + '/ct/xcx.php'; location.href = "http:" + officialHost + res.token; return false; } else if (webType == 80) { // 响应式 console.log(res); console.log(token); console.log('%%%'); // location.href = "http:" + officialHost + '/xys_control_center.php?token=' + token; location.href = "http:" + officialHost + res.token; return false; } ___(thisS, '.main_register1', 1); $('.step_third').show(); } else { layer.msg('参数错误!'); } }); } else { layer.msg('请选择网站类型!'); } }); // 第四步 选择类型 $('.theFourthStep').click(function(){ var thisS = $(this), val = $(this).attr('dataType'), t = regFunc; if (!val || !window.userName) { layer.msg('参数错误!'); return false; } t.response(ajaxFile, {method: 'selectGudianceType', val: {username: window.regUserName, gudiance: val}}, function (param, res) { if (res){ if (val == 3) { location.href = "http:" + officialHost + res.token; } else { location.href = "http:" + officialHost + res.token; } } else { layer.msg('参数错误!'); } }); }); $("[reg_agreement]").click(function () { var val = $("#reg_agreement").html(); layer.open({ type: 1, title: false, area: ['85%', '85%'], shade: 0.4, content: '
' + val + '

', scrollbar: false, }); }); }); function userInfoSub (t) { var data = { templates_type: templatesType, distributor: distributor, username: t.username, password: t.password, validation_picture: t.validation_picture } if (t.PSign) { data.tel = t.tel; data.phone_code = t.phone_code; } else { data.password_again = t.password_again; } t.response(ajaxFile, {method: 'dataActionFun', val: data}, function (param, res) { if (res != 0) { writeCookie('ev_userid', res[0], 30, res[2]); writeCookie('ev_shellCode', res[1], 30, res[2]); t.mng_host = res[4]; window.location.href = res[3]+"&url=%2F%2F"+window.location.host+"%2Fdom%2FagentUserRegister%2Findex.php%3Fusername="+user_name+"%26type="+templatesType+"%26tusername="+tusername+"%26reg_username="+t.username; return true; } else { layer.msg('网络繁忙, 请稍后重试'); } }); } function baseInfoSub (t, method) { if (method == "userWebBaseInfo") { var data = { val: { companycn: t.companycn, username: t.username, email: t.email, tel: t.tel }, method: method } } else { var data = { companycn: t.companycn, uname: t.username, email: t.email, method: method } } t.response(ajaxFile, data, function (param, res) { if (res === 0) { layer.msg("提交失败,请联系管理员"); } else { if (tusername) { if (parseInt(templatesType) === 999) { location.href = "http:" + mng_host +"/xys_control_center.php?t_id=" + tusername; } else { $('body').append('\

\
\
\ 提示信息\ \
\
\ 您好!正在使用“一键复制网站”,大约需要2分钟左右,请不要关闭窗口。\ \
\
\ '); setTimeout(function () { location.href = "http:" + mng_host +"/VNew/pcAndWapCopy.php?copy_user_name=" + tusername + "©_website_type=7&requestSign=" + requestSign; }, 500); } } else { location.href = '/dom/agentUserRegister/index.php?username=' + window.propagandaStationUserName + '&action=regSecond'; } } }); } // 手机号是否可重复 function phoneRepeat (thisS) { var $sign = true; $.ajax({ url: ajaxFile, type: 'POST', dataType: 'json', async: false, data: {method: "checkPhoneRepeat", val: thisS.val()}, success: function(data){ if (data == 2) { $sign = false; thisS.parent().find('.validateInfo').html("该手机号码已被注册过了,请更换").show(); } else if (data == 1) { $sign = true; thisS.parent().find('.validateInfo').html("手机号码有误!").hide(); } else { $sign = false; thisS.parent().find('.validateInfo').html("手机号码有误!").show(); } } }); return $sign; } // 倒计时 function sendCountDown (thisS, t) { var setIntervalFun = null; var i = 60; t.hide(); setIntervalFun = setInterval(function () { i--; if (i <= 0) { thisS.remove(); t.show(); clearInterval(setIntervalFun); } thisS.html(i + "s后重新发送"); }, 1000); } function writeCookie (name, value, hours, d) { if (typeof d == "undefined") { d = '.'; } var expire = ""; if (hours != null) { expire = new Date((new Date()).getTime() + hours * 36000000); // 毫秒 expire = ";expires=" + expire.toGMTString(); } document.cookie = name + "=" + escape(value) + expire + "; path=/; domain="+ d +";"; }