; (function() { /** * 功能:获取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 unescape(str[2]); return null; } window.registerConfig = window.registerConfig || {}; //post提交开关 window.registerConfig.postEloquaByFormMethod = ($.trim($("#postEloquaByFormMethod").val())=="ajax")?false:true; /** * 配置表单字段 * key为form中的name值(不能改,没有就删除,) * value为提交的字段 * */ registerConfig.eloquaParams = { v_id: "v_id", //id Gender: "Gender", //性别 LastName: "LastName", // 姓 FirstName: "FirstName", // 名 Email: "Email", // 邮箱 Telephone: "Telephone", // 电话 CompanyName: "CompanyName", // 公司名称 "buyFeedBackVO.idataCityName": "City", // 城市 "buyFeedBackVO.idataCityId": "CityID", // 城市ID "buyFeedBackVO.idataCountryName": "Country", // 国家 "buyFeedBackVO.idataCountryId": "CountryID", // 国家id "buyFeedBackVO.idataProvinceName": "StateorProvince", //省份 "buyFeedBackVO.idataProvinceId": "StateorProvinceID", //省份ID JobTitle: "JobTitle", // 职位 "JobTitleID": // 职位ID { mapName: "JobTitleID", handle: function() { var $jobTitle = $("input[name='JobTitle']") var $options = $jobTitle.parent().find(".option[data-value='" + $jobTitle.val() + "']") return $options.data("id") } }, Industry: "Industry", //第一行业 IndustryID: { mapName: "IndustryID", handle: function() { var $parentIndustry = $("input[name='Industry']") var $options = $parentIndustry.parent().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.parent().find(".option[data-value='" + $Industry.val() + "']") return $options.data("id") } }, //子行业第二行业ID Address: "Address", // 地址 subscription: "subscription", // 是否同意华为联系 PrivacyPolicyVersion: "PrivacyPolicyVersion",//隐私声明版本号 policyagree:{ mapName: "AuthorizedPrivacyPolicy", handle: function(val) { if(val){ return "Y" } } }, tacticcode: "tacticcode", InterestedProduct: "InterestedProduct", //感兴趣产品(用户自己填写) RelationswithHuawei: "RelationswithHuawei", // 与华为关系 brief_project_description:"brief_project_description", GOTOURL: { mapName: "GOTOURL", handle: function(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(); } }, // 下载:Download the material、 // 注册:Register to join the event、 // 注册观看直播 Register for a webinar、 // 注册问卷调查 Submit a survey 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", "Question1": "Question1", "Question2": "Question2", "Question3": "Question3", "Question4": "Question4", "Question5": "Question5", "Question6": "Question6", "Question7": "Question7", "Question8": "Question8" } registerConfig.afterParseParams = function (postParams) { var data = { tealium_event: "register_from", eventCat: "register from", action_location_url: location.href, eventAct: $("#Action").val(), eventLbl: $("#OfferName").val(), content_id: $("#OfferID").val(), content_name: $("#OfferName").val(), campaign_tag: "", topic_tag: "", industry_tag: "", product_tag: "", solution_tag: "", tactic_code: $("#tacticcode").val(), customer_telephone: (typeof ($("input[name='Telephone']").val()) == "undefined" ? "" : $("input[name='Telephone']").val()), customer_email: (typeof ($("input[name='Email']").val()) == "undefined" ? "" : $("input[name='Email']").val()), customer_first_name: (typeof ($("input[name='FirstName']").val()) == "undefined" ? "" : $("input[name='FirstName']").val()), customer_last_name: (typeof ($("input[name='LastName']").val()) == "undefined" ? "" : $("input[name='LastName']").val()), customer_job_title: (typeof ($("input[name='JobTitle']").val()) == "undefined" ? "" : $("input[name='JobTitle']").val()), customer_company: (typeof ($("input[name='CompanyName']").val()) == "undefined" ? "" : $("input[name='CompanyName']").val()), customer_country: $("#txtidataCountryName").val(), customer_province: $("#txtidataProvinceName").val(), customer_city: $("#txtidataCityName").val(), customer_industry_category: (typeof ($("input[name='Industry']").val()) == "undefined" ? "" : $("input[name='Industry']").val()), customer_industry: (typeof ($("input[name='SubIndustry']").val()) == "undefined" ? "" : $("input[name='SubIndustry']").val()), click_name: $("#Action").val(), click_type: "action" } utagEvent(data); } /** * 配置表单字段 * 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]||""; } } }) })()