; (function () { var lang = $.trim($("#gLanguageCurrent").val()); lang = lang == "zh" ? "cn" : lang; /** * 功能:获取cookie */ function getCookie(name) { var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)")); if (arr != null) return decodeURIComponent(arr[2]); return null; } function isEmpty(e) { $.trim(e); return !e || "" == e || "null" == e || "undefined" == e } /** * 设置domain cookie * */ function setCookie(name, value, domain, hours) { var exp = new Date(); exp.setTime(exp.getTime() + hours * 60 * 60 * 1000); if (domain == null || domain == '') { document.cookie = name + "=" + encodeURIComponent(value) + ";path=/; expires=" + exp.toGMTString(); } else { document.cookie = name + "=" + encodeURIComponent(value) + ";path=/; domain=" + domain + ";expires=" + exp.toGMTString(); } } /** * 取URL上的参数 * */ function GetQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var str = window.location.search.substr(1).match(reg); if (str != null) return decodeURIComponent(str[2]); return null; } function statisticFieldChange($target, value) { if (value) { var preValue = $target.data("prevalue"); if (preValue) { preValue = preValue.toString(); if (value != preValue) { $target.data("prevalue", value); utEnter('common_from_filed_input', 'input', $target.data("utaglabel"), '1'); console.log($target.data("utaglabel") + ", value:" + value); } } else { $target.data("prevalue", value); utEnter('common_from_filed_input', 'input', $target.data("utaglabel"), '1'); console.log($target.data("utaglabel") + " first, value:" + value); } } } function getReservedInfo() { var obj = null; var value = $.cookie("reservedinfo"); if (value) { try { obj = JSON.parse(value); } catch (e) { console.log(e); } } return obj; } function setReservedInfo(eloquaParams) { if (eloquaParams) { var matids = []; var oldInfo = getReservedInfo(); var mId = $("#hidMaterialId").val(); if (mId == "") { if (oldInfo && oldInfo.matids) matids = oldInfo.matids; } else { if (oldInfo) { if (oldInfo.matids) { matids = oldInfo.matids.slice(0, 20); var index = matids.indexOf(mId); if (index >= 0) matids.splice(index, 1); var total = matids.unshift(mId); if (total > 20) matids.pop(); } else matids.unshift(mId); } else matids.unshift(mId); //删除旧的cookie $.cookie("reservedinfo", "obsoleting", { expires: -1, path: "/" }); } var info = { email: CryptoJS.SHA1(eloquaParams.Email).toString(CryptoJS.enc.Hex), country: eloquaParams.Country, matids: matids }; $.cookie("reservedinfo", JSON.stringify(info), { expires: 365, domain: ".huawei.com", path: "/" }); } } window.registerConfig = window.registerConfig || {}; //post提交开关 window.registerConfig.postEloquaByFormMethod = false; /** * 配置表单字段 * key为form中的name值(不能改,没有就删除,) * value为提交的字段 * */ registerConfig.eloquaParams = { LastName: "LastName", // 姓 FirstName: "FirstName", // 名 Email: "Email", // 邮箱 Telephone: "Telephone", // 电话 CompanyName: "CompanyName", // 公司名称 CityName: "City", // 城市 CityId: "CityID", // 城市ID CountryName: "Country", // 国家 CountryId: "CountryID", // 国家id ProvinceName: "StateorProvince", //省份 ProvinceId: "StateorProvinceID", //省份ID Industry: "Industry", //第一行业 IndustryID: { mapName: "IndustryID", handle: function () { var $parentIndustry = $("input[name='Industry']") var $options = $parentIndustry.parents(".J-select").find(".option-group-title[data-name='" + $parentIndustry.val() + "']") return $options.data("id") } }, //第一行业ID SubIndustry: "SubIndustry", //子行业第二行业 SubIndustryID: { mapName: "SubIndustryID", handle: function () { var $Industry = $("input[name='SubIndustry']") var $options = $Industry.parents(".J-select").find(".option[data-value='" + $Industry.val() + "']") return $options.data("id") } }, //子行业第二行业ID Subscription: "subscription", // 是否同意华为联系 PrivacyPolicyVersion: "PrivacyPolicyVersion",//隐私声明版本号 policyagree: { mapName: "AuthorizedPrivacyPolicy", handle: function (val) { if (val) { return "Y" } } }, TacticCode: "tacticcode", RelationswithHuawei: "RelationswithHuawei", // 与华为关系 ProjectDescription: "brief_project_description", GOTOURL: { mapName: "GOTOURL", handle: function (val) { val = decodeURIComponent(val); if (isEmpty(val)) { return ""; } else if (/^((https?):\/\/)|^\/\//.test(val)) { return val; } else { return location.protocol + "//" + location.host + val; } } }, SubmitTime: { //注册时间/下载时间/提交时间 mapName: "SubmitTime", handle: function () { return new Date(); } }, Action: "Action", ActionLocationType: "ActionLocationType", ActionLocationName: "ActionLocationName", ActionLocationAddress: { mapName: "ActionLocationAddress", handle: function (val) { if (val) { return val } var referrerHref = document.referrer; if (referrerHref == '') { referrerHref = ((window.location.href).split('?'))[0]; } else { if (referrerHref.indexOf('?')) { referrerHref.substr(0, referrerHref.indexOf('?')) } } return referrerHref; } }, OfferType: "OfferType", //资料、问卷、展台、Webinar、Video、EDM、表单 OfferID: "OfferID", //资料下载必填,例:Webinar id、Video id、资料 id、问卷 id OfferName: "OfferName", }; registerConfig.afterParseParams = function (eloquaParams) { var data = { tealium_event: "register_from", eventCat: "register from", action_location_url: location.href, eventAct: eloquaParams.Action, eventLbl: eloquaParams.OfferName, content_id: eloquaParams.OfferID, content_name: eloquaParams.OfferName, campaign_tag: "", topic_tag: "", industry_tag: "", product_tag: "", solution_tag: "", tactic_code: eloquaParams.tacticcode, customer_telephone: eloquaParams.Telephone || "", customer_email: eloquaParams.Email || "", customer_first_name: eloquaParams.FirstName || "", customer_last_name: eloquaParams.LastName || "", //customer_job_title: (typeof ($("input[name='JobTitle']").val()) == "undefined" ? "" : $("input[name='JobTitle']").val()), customer_company: eloquaParams.CompanyName || "", customer_country: eloquaParams.Country || "", customer_province: eloquaParams.StateorProvince || "", customer_city: eloquaParams.City || "", customer_industry_category: eloquaParams.Industry || "", customer_industry: eloquaParams.SubIndustry || "", click_name: eloquaParams.Action, //agree_to_receive_info: eloquaParams.subscription == "Y" ? "yes" : "no", click_type: "action" } utagEvent(data); } var perEmail; registerConfig.validSuccess = function ($target, $form) { var value = $target.val(); var elemType = $target.attr("type"); if (elemType == "radio" || elemType == "checkbox") value = $target.prop("checked").toString(); //statisticFieldChange($target, value); //邮箱通过验证之后,请求服务 if ($target.hasClass("J-email")) { if (value && perEmail != value) { var resInfo = getReservedInfo(); if (resInfo && resInfo.email == CryptoJS.SHA1(value).toString(CryptoJS.enc.Hex)) { $(".J-step-email").hide(); $(".J-tips-email").show(); removeValidFromItem($(".J-step-email")); addValidFromItem($(".J-tips-email")); if (resInfo.country) { var $country = $(".minisiteRegisterForm input[name='CountryName']"); if ($country.length > 0 && $country.val() == "") $country.val(resInfo.country); } } else { $(".J-step-email").show(); $(".J-tips-email").hide(); addValidFromItem($(".J-step-email")); removeValidFromItem($(".J-tips-email")); } } perEmail = $target.val(); } }; //提交成功,记录当前提交的邮箱 registerConfig.postEloquaSuccess = function (ret, eloquaParams, dialog) { //if (eloquaParams && eloquaParams.Email) $.cookie("reservedinfo-m", CryptoJS.SHA1(eloquaParams.Email).toString(CryptoJS.enc.Hex), { expires: 730, path: "/" }); setReservedInfo(eloquaParams); return true; } /** * 配置表单字段 * key url字段 (不能改,没有就删除,新增可以添加),如果有那么就从cookie里面找 * value为提交的字段 * 如果有handle表示mapName为url的参数名,handle对url中的值进行处理,最终得到的value是hanlde的返回值 * 默认?source=1&utm_campaign=2&utm_source=3&utm_medium=4&utm_content=5 * */ //ic_campaign对应utm_campaign , ic_medium 对应 utm_medium , ic_source 对应 utm_source , source 对应 source, registerConfig.urlParams = {}; var setSitecode_register_parma; var setSiteCode_register_parma_old; $.each(["source", "utm_campaign", "utm_source", "utm_medium", "utm_content", "utm_term", "utm_object"], function (idx, val) { if (GetQueryString(val)) { setSitecode_register_parma = setSitecode_register_parma || {}; setSitecode_register_parma[val] = GetQueryString(val); } }) $.each(["ic_campaign", "ic_medium", "ic_source"], function (idx, val) { var urlValue = GetQueryString(val); setSiteCode_register_parma_old = setSiteCode_register_parma_old || {}; val = val.replace("ic", "utm"); if (urlValue) { setSiteCode_register_parma_old[val] = urlValue; } //如果ic_source是这个_形式表示组合键ic_source + ic_campaign var sourceValue = GetQueryString("ic_source"); if (val == "utm_source" && (!isEmpty(sourceValue) && sourceValue.indexOf("_") != -1)) { setSiteCode_register_parma_old[val] = sourceValue.slice(0, sourceValue.lastIndexOf("_")) } if ((isEmpty(urlValue)) && val == "utm_campaign" && (!isEmpty(sourceValue) && sourceValue.indexOf("_") != -1)) { setSiteCode_register_parma_old[val] = sourceValue.slice(sourceValue.lastIndexOf("_") + 1) } }) if (setSitecode_register_parma && !$.isEmptyObject(setSitecode_register_parma)) { //setCookie("sitecode_register_parma", JSON.stringify(setSitecode_register_parma), ".huawei.com", 2); } else if (setSiteCode_register_parma_old && !$.isEmptyObject(setSiteCode_register_parma_old)) { setSitecode_register_parma = setSiteCode_register_parma_old; //setCookie("sitecode_register_parma", JSON.stringify(setSiteCode_register_parma_old), ".huawei.com", 2); } else { try { setSitecode_register_parma = JSON.parse(getCookie("source_parameter")); } catch (e) { setSitecode_register_parma = {}; } } $.each(["source", "utm_campaign", "utm_source", "utm_medium", "utm_content", "utm_term", "utm_object"], function (idx, val) { registerConfig.urlParams[val] = { mapName: val, handle: function () { return setSitecode_register_parma && setSitecode_register_parma[val] || ""; } } }); //去除校验 function removeValidFromItem($target) { $target.find("input").addClass("noCheck"); $target.find("textarea").addClass("noCheck"); $target.find("select").addClass("noCheck"); $target.find(".J-validItem").removeClass("validError"); } //添加校验 function addValidFromItem($target) { $target.find("input").removeClass("noCheck"); $target.find("textarea").removeClass("noCheck"); $target.find("select").removeClass("noCheck"); } //显示联系方式 $(".J-trigger-email").on("click", function () { $(".J-step-email").show(); addValidFromItem($(".J-step-email")) $(".J-tips-email").hide(); removeValidFromItem($(".J-tips-email")) }) //显示联系方式 $(".J-trigger-contact").on("change", function () { if ($(this).prop("checked")) { $(".J-step-contact").show(); addValidFromItem($(".J-step-contact")) } else { $(".J-step-contact").hide(); removeValidFromItem($(".J-step-contact")) } }) })()