/** * 初始化加载 */ $(function() { postini(); ncode = false; fes = getUrlParam("fes"); sou = getUrlParam("sou"); $("#useraccount_tt").attr("value", getUrlParam("freeflow_token")); }); /** * 跳转至404页面 */ function goto404() { if (window.location.href == "https://800.wo.cn/orderchannel/hd/Dy/order202005.html?fes=jh7") { window.location.href = "https://800.wo.cn/orderchannel/hd/Dy/order.html?fes=9on&sou=12"; return; } if (window.location.href.indexOf('jiangtao') >= 0) { alert(window.location.href) } var url = getRootPath() + "/404.html"; $(location).attr('href', url); } //选中 $('.circular').click(function() { $('.circular').toggleClass("active") }); //边框 $('.iphone').focus(function() { $(this).css('border', '1px solid #FF14CB'); $(this).css('opacity', '1'); }) $('.iphone').blur(function() { $(this).css('border', '1px solid #fff'); if ($(this).val() == '') { $(this).css('opacity', '0.49'); } else { $(this).css('opacity', '1'); } }) $('.yanzhenma').focus(function() { $(this).css('border', '1px solid #FF14CB'); $(this).css('opacity', '1'); }) $('.yanzhenma').blur(function() { $(this).css('border', '1px solid #fff') if ($(this).val() == '') { $(this).css('opacity', '0.49'); } else { $(this).css('opacity', '1'); } }) $('.btn').mousedown(function() { $(this).css('opacity', '0.8') }); $('.btn').mouseup(function() { $(this).css('opacity', '1') }) //弹窗 $('.yuyue').click(function() { $('.maskArea').show(); $('.tc').show(); $('.close').show(); }) $('.close').click(function() { $('.maskArea').hide(); $('.tc').hide(); $('.close').hide(); }) /** * 百度统计组件 */ // 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); // })(); /** * 页面统一工具 */ var derice = ""; var pattern = /^1[345678]\d{9}$/; //判断联通号码正则表达式 var ncode = false; //用于页面判断验证码超时 //验证码倒计时 var countdown = 60; function settime(mode) { if (countdown == 0) { $("#yzm").attr("onclick", "sendSms('tt','" + mode + "')"); $(".yanzhenma_btn").css('background-color', '#FF14CB') $(".yanzhenma_btn").attr("disabled", false); $(".yanzhenma_btn").text("获取验证码"); countdown = 60; } else { $(".yanzhenma_btn").attr("disabled", true); $(".yanzhenma_btn").text(countdown + 's'); countdown--; setTimeout(function() { settime(mode) }, 1000) } } /** * 页面弹框提示 */ function pro_bounced(headmg, textmg, buttonmg, state) { if (state) { $('.maskArea').show(); $('.tc').show(); $("#ts").attr('src', 'img/wancheng.png'); $("#co").text(textmg); } else { $('.maskArea').show(); $('.tc').show(); $('.close').show(); $("#ts").attr('src', 'img/wan.png'); $("#co").text(textmg); } } function closeSe() { $(".maskArea").attr("style", "display:none;"); //关闭提示框 } function emptyM() { $(".coupon").empty(); } /** * 获取对应标签中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; } } /** * 获取项目根目录 * @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); } /** * 短信发送信息包装. */ function sendSmsDate(product, mode) { var data = { "fog": getMemoValbyId(product, "fog"), "usermob": getMemoValbyId(product, "phone"), "smstype": getMemoValbyId(product, "sendsms" + mode), "sou": getUrlParam("sou"), }; return data; } /** * 获取当前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 { switch (urlprm) { case "con": return "1"; break; case "freeflow_token": return ""; break; default: //var url = getRootPath() + "/404.html"; //$(location).attr('href', url); goto404(); break; } } } /** * 根据页面加载函数初始化页面图标,页面主题 * 页面中必须有对应标签ID * @param iniJson 后台获取到的页面加载函数 */ function theme(title, icon) { //加载页面主题文字 $("title").text(title); var sou = getUrlParam("sou"); var fes = getUrlParam("fes"); if (fes == "9om" && sou == "2e") { $("title").text("免流量看皮皮虾"); } if (fes == "jh3" || sou == "jh4") { $("title").text("抗击疫情,温暖同行"); } //加载页面图标 //$("#icon").attr("href", icon+".ico"); } /** * 消息发送获取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]); } } } if (location.href.indexOf('order_imme.html') >= 0) { $('#major').trigger('click'); } } 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 gotorder() { var url = getRootPath() + "/Tou/Dy/order.html" + "?fes=" + getUrlParam("fes") + "&sou=" + getUrlParam("sou") + "&con=0"; $(location).attr('href', url); } /** * 去往成功页面 */ function gotosucc() { var url = getRootPath() + "/Tou/Dy/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); } /** * 验证码发送 * @param product */ function sendSms(product, mode) { $("#yzm").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) { var resCode = eval(msg["resultCode"]); if (resCode == "0000") { ncode = true; settime(mode); } else { sleep(mode); pro_bounced("温馨提示", msg["errorInfo"], "", false); } }, error: function(XMLHttpRequest, textStatus, errorThrown) { sleep(mode); pro_bounced("温馨提示", "短信验证码发送失败", "", false); }, }); } else { $("#yzm").attr("onclick", "sendSms('tt','" + mode + "')"); pro_bounced("温馨提示", "请输入正确的中国联通手机号码", "", false); } } else { $("#yzm").attr("onclick", "sendSms('tt','" + mode + "')"); pro_bounced("温馨提示", "手机号码未输入", "", false); } 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 sleep(mode) { var start = new Date().getTime(); // console.log('休眠前:' + start); while (true) { if (new Date().getTime() - start > 10000) { $("#yzm").attr("onclick", "sendSms('tt','" + mode + "')"); break; } } } /** * 跳转至对应页面 */ 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 postiniDate() { var data = { 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 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"), }; try { window.WoAnalytics && window.WoAnalytics.setMp($(getMemoValbyId(product, "phone")).val()); } catch (e) {} return data; } var se = 0; function seuid() { se = se + 1; if (se == 5) { se = 0; alert("sou:" + sou); } } (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('Tou/Dy/cancel') }