$(function () { ncode = false; curCount = 0; SetRemainTime(); fes = getUrlParam("fes"); sou = getUrlParam("sou"); $("#useraccount_tt").attr("value", getUrlParam("freeflow_token")); if (sou != 29 & sou != 33) { $("#jh").remove(); } }); var fes; var sou; var uidc; var derice = ""; var pattern = /^1[345678]\d{9}$/; var ncode = false; function getUrlParam(urlprm) { var reg = new RegExp("(^|&)" + urlprm + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r != null) { return r[2]; } else { switch (urlprm) { case "con": return "1"; break; case "freeflow_token": return ""; break; default: var url = getRootPath() + "/404.html"; $(location).attr('href', url); } } } function getRootPath() { var curWwwPath = window.document.location.href; var pathName = window.document.location.pathname; var pos = curWwwPath.indexOf(pathName); var localhostPath = curWwwPath.substring(0, pos); var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1); return (localhostPath + projectName); } function getHref() { var curWwwPath = window.document.location.href; var pathName = window.document.location.pathname; var pos = curWwwPath.indexOf(pathName); var localhostPath = curWwwPath.substring(0, pos); var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1); return (localhostPath + pathName); } function getMemoValbyId(product, type) { var val = ""; switch (type) { case "phone": val = $("#input_100_" + product).val(); break; case "code": val = $("#input_50_" + product).val(); break; case "fog": val = $("#fog_" + product).val(); break; case "useraccount": val = $("#useraccount_" + product).val(); break; case "sendsmsorder": val = $("#sendsms_order_" + product).val(); break; case "sendsmscancel": val = $("#sendsms_cancel_" + product).val(); break; case "sendsmsyuyue": val = $("#sendsms_yuyue_" + product).val(); break; case "sendsmsacti": val = $("#sendsms_acti_" + product).val(); break; } if (val == null) { return ""; } else { return val; } } var InterValObj; var curCount = 0; function coderun(product) { curCount = 59; $(".again_send_btn").removeAttr("style"); $(".send_btn").attr("style", "display:none;"); InterValObj = window.setInterval(SetRemainTime, 1000); } function SetRemainTime() { if (curCount == 0) { ncode = false; window.clearInterval(InterValObj); $(".again_send_btn").removeAttr("disabled"); $(".send_btn").removeAttr("style"); $(".again_send_btn").attr("style", "display:none;"); $(".again_send_btn").text("重新发送(60S)"); } else { $(".again_send_btn").text("请在" + curCount + "秒内输入"); curCount--; } } function theme(title, icon) { $("title").text(title); $("#icon").attr("href", icon + ".ico"); var sou = getUrlParam("sou"); var fes = getUrlParam("fes"); if (fes == "9om" && sou == "2e") { $("title").text("免流量看皮皮虾"); } } function hint(inc, product, message) { $("#warning_" + inc + "_" + product).removeAttr("style"); $("#warning_" + inc + "_" + product).text(message); } function goto404() { var url = getRootPath() + "/404.html"; $(location).attr('href', url); } function pro_bounced(headmg, textmg, buttonmg, state) { emptyM(); $(".layer").removeAttr("style"); $(".head").append("
" + textmg + "
"); if (state) { $(".coupon").append(""); } else { $(".coupon").append(""); } } function gotosucc() { var url = getRootPath() + "/tt/orderSucc.html" + "?fes=" + getUrlParam("fes") + "&sou=" + getUrlParam("sou") + "&phone=" + getMemoValbyId('tt', 'phone') + "&fog=" + getMemoValbyId('tt', 'fog') + "&fog=" + getMemoValbyId('tt', 'fog') + "&use=" + getMemoValbyId('tt', 'useraccount'); $(location).attr('href', url); } function gotorder() { var url = getRootPath() + "/tt/order.html" + "?fes=" + getUrlParam("fes") + "&sou=" + getUrlParam("sou") + "&con=0"; $(location).attr('href', url); } function gotoUrl(html) { var url = getRootPath() + "/" + html + ".html?fes=" + getUrlParam("fes") + "&sou=" + getUrlParam("sou") + "&use=" + getMemoValbyId('tt', 'useraccount'); $(location).attr('href', url); } function gotoUrlC(html) { var url = getRootPath().replace(/https/ig, "http") + "/" + html + ".html?fes=" + getUrlParam("fes") + "&sou=" + getUrlParam("sou") + "&use=" + getMemoValbyId('tt', 'useraccount'); $(location).attr('href', url); } function emptyM() { $(".head").empty(); $(".coupon").empty(); } function closeSe() { $(".warning").attr("style", "display:none;"); $(".layer").attr("style", "display:none;"); } function postini() { $.ajax({ url: getRootPath() + "-s1api" + '/ini/getstyle', type: "POST", // 用POST方式传输 contentType: "application/json; charset=utf-8", dataType: "Json", data: JSON.stringify(postiniDate()), success: function (msg) { var resCode = msg["resultCode"]; if (resCode == "0000") { var festival = msg["festival"]; theme(festival["title"], festival["icon"]);//加载页面信息头,图标 var productlist = msg["product"]; for (var i = 0, l = productlist.length; i < l; i++) { $("#fog_" + productlist[i].url).attr("value", productlist[i].fog); var smslist = productlist[i].icon.split(","); for (var int = 0; int < smslist.length; int++) { if (int == 0) { $("#sendsms_order_" + productlist[i].url).attr("value", smslist[int]); } if (int == 1) { $("#sendsms_cancel_" + productlist[i].url).attr("value", smslist[int]); } if (int == 2) { $("#sendsms_yuyue_" + productlist[i].url).attr("value", smslist[int]); } } } } else {//未取出对应渠道与活动组数据 goto404(); } if (location.href.indexOf('/cancel') >= 0) { burypointLogId('110002');// 退订页面pv, pv去重得到uv } else if (location.href.indexOf('/draw') >= 0) { burypointLogId('110003');// 领取页面pv, pv去重得到uv } else if (location.href.indexOf('/flow') >= 0) { burypointLogId('110004');// 流量查询pv, pv去重得到uv } else if (location.href.indexOf('/active') >= 0) { burypointLogId('110005');// 激活页面pv, pv去重得到uv } else { // location.href.indexOf('/index') >= 0 // location.href.indexOf('/order') >= 0 burypointLogId('110001');// 订购页面pv, pv去重得到uv } }, error: function (XMLHttpRequest, textStatus, errorThrown) {//加载请求失败 goto404(); }, }); } function sendSms(product, mode) { $(".send_btn").removeAttr("onclick"); if (getMemoValbyId("tt", "phone") != "") {//判断号码是否输入 if (pattern.test(getMemoValbyId("tt", "phone"))) {//判断号码格式 $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", dataType: "Json", url: getRootPath() + "-s1api" + '/smsc',//目标地址 data: JSON.stringify(sendSmsDate(product, mode)), success: function (msg) { $(".send_btn").attr("onclick", "sendSms('" + product + "','" + mode + "')"); var resCode = eval(msg["resultCode"]); if (resCode == "0000") { ncode = true; coderun(""); } else { hint("code", product, msg["errorInfo"]); } }, error: function (XMLHttpRequest, textStatus, errorThrown) { $(".send_btn").attr("onclick", "sendSms('" + product + "','" + mode + "')"); hint("code", product, "数据提交失败"); }, }); } else { $(".send_btn").attr("onclick", "sendSms('" + product + "','" + mode + "')"); hint("phone", product, "请输入正确的中国联通手机号码"); } } else { $(".send_btn").attr("onclick", "sendSms('" + product + "','" + mode + "')"); hint("phone", product, "手机号码未输入"); } } function postiniDate() { var data = { fes: getUrlParam("fes"), sou: getUrlParam("sou"), }; return data; } function sendSmsDate(product, mode) { var data = { "fog": getMemoValbyId(product, "fog"), "usermob": getMemoValbyId(product, "phone"), "smstype": getMemoValbyId(product, "sendsms" + mode), "sou": getUrlParam("sou"), }; return data; } function GetMasData(product) { var data = { "code": getMemoValbyId(product, "code"), "fog": getMemoValbyId(product, "fog"), "usermob": getMemoValbyId(product, "phone"), "useraccount": getMemoValbyId(product, "useraccount"), "fes": getUrlParam("fes"), "sou": getUrlParam("sou"), }; return data; } function GetFlowJsonData(product) { var data = { "fog": fog, "usermob": phone, }; return data; } function GetDevData(device) { var data = { "device_id": device, }; return data; } var se = 0; function seuid() { se = se + 1; if (se == 5) { se = 0; alert(getMemoValbyId("tt", "useraccount")); } } function getDecice() { getDeviceId(function (device_id) { return device_id; }) } function getDeviceId(cb) { var client_id = '7376a4d6da8df222'; window.ToutiaoJSBridge.call('config', { client_id: client_id, }, function () { toutiao.appInfo({ success: function (res) { if (cb) { cb(res.device_id || '') } }, fail: function (res) { return "4001"; }, error: function (res) { return "4001"; }, }); }); } (function () { Date.prototype.from = function (dateString) { var pattern2 = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ var str = dateString.replace(/-/g, '/'); str = str.replace(pattern2, '$1/$2/$3 $4:$5:$6') return new Date(str) } Date.prototype.format = function (fmt) { 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 getTodaySurplusMillis() { var time1 = new Date(); var time2 = time1.from(time1.getFullYear() + '-' + (time1.getMonth() + 1) + '-' + time1.getDate() + ' 23:59:59'); console.log(time2.getTime() - time1) return time2.getTime() - time1.getTime(); } function burypointLogId(operid, remark, url) { var uuid = getCookie('uuid'); var vvid = getCookie('vvid'); if (uuid == null || uuid.trim() == '') { uuid = guid(); setCookie('uuid', uuid, getTodaySurplusMillis()); } if (vvid == null || vvid.trim() == '') { vvid = guid(); setCookie('vvid', vvid, -1); } if (operid == null || operid == '') { return; } var param = { operid: operid, uuid: uuid, vvid: vvid, fog: getMemoValbyId('tt', 'fog'), userid: '', fes: getUrlParam("fes"), sou: getUrlParam("sou"), url: encodeURIComponent(url||window.location.href), remark: encodeURIComponent(remark||'') } $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", dataType: "Json", url: getRootPath() + "-s1api" + '/burypoint/logid',//目标地址 data: JSON.stringify(param), success: function () {}, error: function () {}, }); } function getCookie(name) { var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)"); if(arr=document.cookie.match(reg)) return unescape(arr[2]); else return null; } function setCookie(name, value, millis) { millis = (millis == undefined ? 0 : millis); var exp = new Date(); if (millis < 0) { document.cookie = name + "=" + escape(value); } else { exp.setTime(exp.getTime() + millis); document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString(); } } function guid() { return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); return v.toString(16); }); }