// import { runtime } from "webpack"; /** * 初始化加载 */ $(function() { postini(); 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 product = {}; var products = {}; var user = {}; var userid = {} var usermob = {} /** * 页面统一工具 */ var derice = ""; var pattern = /^1[345678]\d{9}$/; //判断联通号码正则表达式 var ncode = false; //用于页面判断验证码超时 //------------------获取页面数据---------------------------- /** * 获取当前url中参数信息 * @param urlprm url中参数名称 * @returns */ function getUrlParam(urlprm) { var reg = new RegExp("(^|&)" + urlprm + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r != null) { return r[2]; } else { //当获取链接中必须要参数未获取到时标示链接错误直接跳转至统一404页面 //if(urlprm=="con"){ // return "1"; // //获取强制页面跳转标示,不跳转至404. //}else { // var url = getRootPath()+"/404.html"; // $(location).attr('href', url); //} switch (urlprm) { case "con": return "1"; break; case "freeflow_token": return ""; break; default: var url = getRootPath() + "/404.html"; $(location).attr('href', url); } } } /** * 获取项目根目录 * @returns */ function getRootPath() { //获取当前网址,如: http://localhost:8080/ems/Pages/Basic/Person.jsp var curWwwPath = window.document.location.href; //获取主机地址之后的目录,如: /ems/Pages/Basic/Person.jsp var pathName = window.document.location.pathname; var pos = curWwwPath.indexOf(pathName); //获取主机地址,如: http://localhost:8080 var localhostPath = curWwwPath.substring(0, pos); //获取带"/"的项目名,如:/ems var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1); return (localhostPath + projectName); } /** * 获取项目根目录 * @returns */ function getHref() { //获取当前网址,如: http://localhost:8080/ems/Pages/Basic/Person.jsp var curWwwPath = window.document.location.href; //获取主机地址之后的目录,如: /ems/Pages/Basic/Person.jsp var pathName = window.document.location.pathname; var pos = curWwwPath.indexOf(pathName); //获取主机地址,如: http://localhost:8080 var localhostPath = curWwwPath.substring(0, pos); //获取带"/"的项目名,如:/ems var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1); return (localhostPath + pathName); } /** * 获取对应标签中value * @param memoid * @param type * @returns */ 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; } } //------------------修改页面样式---------------------------- /** * 验证码走动 * @param product 对应产品名称缩写 */ 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); } //timer处理函数 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--; } } /** * 根据页面加载函数初始化页面图标,页面主题 * 页面中必须有对应标签ID * @param iniJson 后台获取到的页面加载函数 */ 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("免流量看皮皮虾"); } } /** * 页面中样式提醒 * @param inc 事件名称 * @param product 对应产品 * @param message */ function hint(inc, product, message) { $("#warning_" + inc + "_" + product).removeAttr("style"); $("#warning_" + inc + "_" + product).text(message); } /** * 跳转至404页面 */ function goto404() { var url = getRootPath() + "/404.html"; $(location).attr('href', url); } /** * 页面弹框提示 */ function pro_bounced(headmg, textmg, buttonmg, state) { emptyM(); $(".layer").removeAttr("style"); $(".head").append("

" + headmg + "

"); $(".coupon").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;"); } /** * 百度统计组件 */ // var _hmt = _hmt || []; // (function () { // var hm = document.createElement("script"); // hm.src = "https://hm.baidu.com/hm.js?0ece85510b3306c074204023de4e49dc"; // var s = document.getElementsByTagName("script")[0]; // s.parentNode.insertBefore(hm, s); // })(); //------------------请求---------------------------- /*--页面初始化加载--*/ /** * 消息发送获取Josn数据 * @param method 方法名称 * @param data 发送数据 * @returns 返回的json数据 * 此方法需加载页面头信息与页面显示图标: * 页面必须有 title 标签 * id = "icon" 链接地址 * * 加载页面基本信息: * XX 为活动对应产品表中配置标示 * */ 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 || location.href.indexOf('/activate') >= 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(); }, }); } /** * 验证码发送 * @param product */ 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, "手机号码未输入"); } if ('acti' == mode) { WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'active_click_send_sms_code_btn' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(getUrlParam("sou"), 32) }) } else { WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'cancel_click_send_sms_code_btn' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(getUrlParam("sou"), 32) }) } try { window.HtmlPageVisitor && window.HtmlPageVisitor.setMp(getMemoValbyId("tt", "phone")); } catch (e) {} } /** * 数据加载发送信息包装. */ 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; } /** * 订购发送信息包装 * @param product * @returns {___anonymous5356_5582} */ function GetMasData(product, canceltype, cancelmsg) { var data = { "code": getMemoValbyId(product, "code"), "fog": getMemoValbyId(product, "fog"), "usermob": getMemoValbyId(product, "phone"), "useraccount": getMemoValbyId(product, "useraccount"), "canceltype": canceltype, "cancelmsg": cancelmsg, "fes": getUrlParam("fes"), "sou": getUrlParam("sou"), }; return data; } /** * 获取流量 */ function GetFlowJsonData(product) { var data = { "fog": fog, "usermob": phone, }; return data; } /** * 订购发送信息包装 * @param product * @returns {___anonymous5356_5582} */ 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的扩展,将 Date 转化为指定格式的String // 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符, // 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字) // 例子: // (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423 // (new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18 Date.prototype.format = function(fmt) { //author: meizz 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'); // uv var vvid = getCookie('vvid'); // vv 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 == '') { // 页面的埋点不通过/burypoint/logid接口实现,通过文件日志入库方式 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); }); } $('#tiu').unbind('click').on('click', function() { showCancelReasonPage().done(function(cancelReason) { doShowCancelPage(cancelReason) }) }) function showCancelReasonPage() { var reasonUrl; var baseUrl; if (window.location.href.indexOf("https://800.wo.cn/orderchannel") >= 0) { reasonUrl = "https://800.wo.cn/orderchannel/public/libs/cancelreason/index.html"; baseUrl = "https://800.wo.cn/"; } else if (window.location.href.indexOf("https://800.wo.cn/festivalchannel") >= 0) { reasonUrl = "https://800.wo.cn/festivalchannel/public/libs/cancelreason/index.html"; baseUrl = "https://800.wo.cn/"; } else if (window.location.href.indexOf("http://localhost") >= 0) { reasonUrl = "http://localhost:8088/orderchannel/public/libs/cancelreason/index.html"; baseUrl = "http://localhost:8088/"; } else if (window.location.href.indexOf("http://127.0.0.1") >= 0) { reasonUrl = "http://127.0.0.1:8088/orderchannel/public/libs/cancelreason/index.html"; baseUrl = "http://127.0.0.1:8088/"; } else if (window.location.href.indexOf("http://100.0.4.69:3344") >= 0) { reasonUrl = "http://100.0.4.69:3344/orderchannel/public/libs/cancelreason/index.html"; baseUrl = "http://100.0.4.69:3344/"; } else if (window.location.href.indexOf("http://100.0.4.69:8282") >= 0) { reasonUrl = "http://100.0.4.69:8282/orderchannel/public/libs/cancelreason/index.html"; baseUrl = "http://100.0.4.69:8282/"; } else { reasonUrl = "https://operation1.bol.wo.cn/orderchannel/public/libs/cancelreason/index.html"; baseUrl = "https://operation1.bol.wo.cn/"; } window.$capoverlay = $('
'); $capoverlay.appendTo($(document.body)); $("body").css("overflow", "hidden"); var $iframe; if ($('#reasonIframe').length >= 1) { $iframe = $('#reasonIframe').attr('src', reasonUrl); } else { $iframe = $(''); $('body').append($iframe); } $iframe.css({ width: "100%", height: "100%", position: "fixed", top: 0, left: 0, margin: 0, padding: 0, "-webkit-overflow-scrolling": "touch", border: "0px", "z-index": 111, }); var def = $.Deferred(); function messageListener(event) { var data = JSON.parse(event.data); $iframe.remove(); $capoverlay.remove(); $("body").css("overflow", "auto"); window.removeEventListener('message', messageListener); if (data.eventtype != 'close') { def.resolve(data) } else { def.reject(data) } } window.addEventListener('message', messageListener); return def; } function doShowCancelPage(cancelReason) { var k = JSON.stringify(cancelReason) window.localStorage.setItem('kye', k) gotoUrl('tt/cancel') }