12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220 |
- var douyinProductId = "2018072301";
- var douyinPreProductId = "2020031101";
- var baiduProductId = "2020021201";
- var baiduPreProductId = "2020071301";
- var query = {};
- var product = {};
- var products = {};
- var fesname = {};
- var user = {};
- var root = null;
- var productsr = {};
- $(function() {
- var isPageHide = false;
- window.addEventListener('pageshow', function() {
- if (isPageHide) {
- window.location.reload();
- }
- });
- window.addEventListener('pagehide', function() {
- isPageHide = true;
- });
- if (window.location.href.indexOf('draw.html') >= 0) {
- var user = JSON.parse(localStorage.getItem('user'));
- if (user != null) {
- $('.usermob').val(user.usermob);
- }
- }
- })
- init();
- function init() {
- var message = localStorage.getItem('message');
- if (message != null && message != '') {
- showDialogMessage(message);
- localStorage.removeItem('message');
- }
- showLoading();
- inits().then(function(response) {
- hideLoading();
- product = douyinProductId;
- fesname = response.festival;
- loadUserInfo();
- if (location.href.indexOf("index.html") >= 0) {
- showOrderPage();
- } else {
- openPage();
- }
- if (location.href.indexOf('/cancel') >= 0) {
- burypointLogIds('110002');
- } else if (location.href.indexOf('/draw') >= 0) {
- burypointLogId('110003');
- } else if (location.href.indexOf('/flow') >= 0) {
- burypointLogId('110004');
- } else if (location.href.indexOf('/active') >= 0) {
- burypointLogId('110005');
- } else if (location.href.indexOf('/refund') >= 0) {
- burypointLogId('110006');
- } else {
- burypointLogId('110001'); // pv去重得到uv
- }
- })
- // WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'open', ea: 'order_open' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- }
- var $douyinItem = $($('.products').find('.item')[0]);
- var $baiduItem = $($('.products').find('.item')[1]);
- $douyinItem.unbind('click').on('click', function(e) {
- $douyinItem.addClass('active');
- $baiduItem.removeClass('active');
- product = douyinProductId;
- })
- $baiduItem.unbind('click').on('click', function() {
- $douyinItem.removeClass('active');
- $baiduItem.addClass('active');
- product = baiduProductId;
- })
- function inits() {
- getRootPath();
- parseQueryParms();
- $("#useraccount_tt").attr("value", getUrlParam("freeflow_token"));
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "orderId": query.orderId,
- }
- var def = $.Deferred();
- $.ajax({
- url: root + "-s1api" + "/ini/getstyle",
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param),
- timeout: 10000
- })
- .then(function(responseText) {
- var response = JSON.parse(responseText);
- if (response.resultCode != "0000") {
- def.reject();
- return def;
- }
- product = response.product[0];
- var abt = ''
- for (i = 0; i < response.product.length; i++) {
- products[response.product[i].productid] = response.product[i]
- abt += response.product[i].fog + ','
- }
- if ($douyinItem.hasClass('active')) {
- productsr = douyinProductId;
- } else {
- productsr = baiduProductId;
- }
- if (productsr == 2018072301) {
- window.localStorage.setItem('kye', abt)
- }
- $("#fog_" + product.url).attr("value", product.fog);
- var smslist = product.icon.split(",");
- for (var i = 0; i < smslist.length; i++) {
- if (i == 0) {
- $("#sendsms_order_" + product.url).attr("value", smslist[i]);
- }
- if (i == 1) {
- $("#sendsms_cancel_" + product.url).attr("value", smslist[i]);
- }
- if (i == 2) {
- $("#sendsms_yuyue_" + product.url).attr("value", smslist[i]);
- }
- }
- def.resolve(response);
- }, function(jqXHR, textStatus, errorThrown) {
- if (textStatus === "timeout") {
- window.location.href = getRootPath() + "/hot.html?cb=" + encodeURIComponent(window.location.href);
- }
- })
- return def;
- }
- $('.more .text').unbind('click').on('click', function() {
- showDialogAgr()
- })
- function showDialogAgr() {
- var $overlay = $('<div class="overlay"></div>')
- var $dialog = $(
- '<div class="dialog-agr">' +
- ' <div class="head">' +
- ' <div class="title"></div>' +
- ' <div class="close"></div>' +
- ' </div>' +
- ' <ul>' +
- ' <li>1)此产品包含9元10G今日头条定向流量包、9元8GB百度定向流量包两款服务,任选一款产品订购、使用业务以本机实际使用号码为准。资费9元/月,按自然月收费,下月自动续订;退订次月生效,当月仍享受免流权益,次月不再享受免流服务;</li>' +
- ' <li>2)本产品立即预约,次月生效,预约成功后将退订当前订购的产品;例如:如果用户当月订购的是今日头条定向流量包,点击预约变更,预约成功后,退订当前的头条包,次月生效百度包,且头条包免流可使用到月底,反之一样;</li>' +
- ' <li>3)预约成功后,当月不能再次预约变更产品,且不支持取消已预约的产品;</li>' +
- ' <li>4)本产品支持3G/4G用户使用,但4G套餐中的共享类套餐不共享该月包,需单独预约订购,给您带来的不便敬请谅解;</li>' +
- ' <li>5)建议使用最新版本今日头条、百度系列手机客户端,如果您更换其他系统手机或使用较低版本客户端,请谨慎使用您的流量;</li>' +
- ' <li>6)今日头条定向流量包的免流范围包括:抖音APP、今日头条、西瓜视频、火山小视频、多闪、懂车帝、图虫、皮皮虾APP;</li>' +
- ' <li>百度定向流量包产品的免流范围包括:百度后视镜、百度 APP 、好看视频、 全民小视频、 百度贴吧、 百度地图、百度网盘(会员);</li>' +
- ' <li>7)订购今日头条包的用户,如您为头条相关免流卡用户,如蚂蚁宝卡、阿里宝卡、钉钉宝卡或工商银行e卡等其他免头条系产品卡类,将优先使用免流卡产品的流量,免流卡流量用罄后将消耗今日头条定向流量包的流量;</li>' +
- ' <li>8)订购成功后,请在对应视频客户端内登录使用,联通3G/4G网络下观看,免流内容不包含第三方提供的广告、视频、图片及直播类视频上传/下载/缓存第三方视频所产生的流量;</li>' +
- ' <li>9)请务必使用3GNET接入点访问本产品,使用其他接入点观看视频会照常收取流量费用。请不要安装和使用任何流量监控、上网代理及VPN类软件和插件,可能会引起免流量策略失效而产生高额流量费用;</li>' +
- ' <li>10)以下地区暂不支持产品订购及免流业务:港、澳、台及国际漫游;</li>' +
- ' <li>11)如果遇到困难,请拨打10010联系联通客服解决。</li>' +
- ' </ul>' +
- '</div>');
- $overlay.appendTo($(document.body))
- $dialog.appendTo($(document.body))
- $dialog.find('.btn').on('click', function() {
- $overlay.remove();
- $dialog.remove();
- $dialog = null;
- })
- $dialog.find('.close').on('click', function() {
- $overlay.remove();
- $dialog.remove();
- $dialog = null;
- })
- $dialog.close = function() {
- $overlay.remove();
- $dialog.remove();
- $dialog = null;
- }
- return $dialog;
- }
- $('#gotoCancel').unbind('click').on('click', function() {
- if ($douyinItem.hasClass('active')) {
- product = douyinProductId;
- } else {
- product = baiduProductId;
- }
- showCancelPage(product);
- })
- function showCancelPage(productid) {
- if (location.href.indexOf("cancel.html") < 0) {
- window.location.href = "cancel.html?fes=" + query.fes + "&sou=" + query.sou + "&productid=" + productid;
- return;
- }
- product = products[query.productid]
- var $container = $('.sms-form').find('.form-group');
- $container.find('.sendcode').unbind('click').on('click', function() {
- sendSms($container, 'cancellogin');
- })
- $container.find('.login').unbind('click').on('click', function() {
- showLoading();
- checkCode($container).done(function() {
- choiceCancel().done(function(response) {
- hideLoading();
- switch (response.resultCode) {
- case "0000":
- showDialogMessage('退订成功');
- break;
- case "7605": //应该是已经退订了吧,因此不需要在重复退订啦
- showDialogMessage(response.errorInfo);
- break;
- default:
- var prefix = '';
- if (response.errorInfo.indexOf('退订失败') < 0) {
- prefix = '退订失败,';
- }
- showDialogMessage(prefix + response.errorInfo);
- break;
- }
- }).fail(function(data) {
- hideLoading();
- })
- }).fail(function(data) {
- hideLoading();
- })
- })
- window.scrollTo(0, 0)
- }
- function unlockClick(element) {
- $(element || document.body).data('use', '0');
- }
- function lockClick(element) {
- if ($(element || document.body).data('use') == '1') {
- return false;
- }
- $(element || document.body).data('use', '1');
- return true;
- }
- var historyBackExecuted = true;
- function showCapPage(fog, productName, scrollable, hasNetNumber, decryptUsermob, capTemplet) {
- historyBackExecuted = false;
- if (!scrollable) {
- $("body").css("overflow", "hidden");
- }
- var capUrl;
- var baseUrl;
- if (window.location.href.indexOf("https://800.wo.cn/orderchannel") >= 0) {
- capUrl = "https://800.wo.cn/cap/CAP-AUTH.html";
- baseUrl = "https://800.wo.cn/";
- } else if (window.location.href.indexOf("https://800.wo.cn/festivalchannel") >= 0) {
- capUrl = "https://800.wo.cn/festivalcap/CAP-AUTH.html";
- baseUrl = "https://800.wo.cn/";
- } else if (window.location.href.indexOf("http://localhost") >= 0) {
- capUrl = "http://localhost:8088/cap/CAP-AUTH.html";
- baseUrl = "http://localhost:8088/";
- } else if (window.location.href.indexOf("http://127.0.0.1") >= 0) {
- capUrl = "http://127.0.0.1:8088/cap/CAP-AUTH.html";
- baseUrl = "http://127.0.0.1:8088/";
- } else if (window.location.href.indexOf("http://100.0.4.69:3344") >= 0) {
- capUrl = "http://100.0.4.69:3344/cap/CAP-AUTH.html";
- baseUrl = "http://100.0.4.69:3344/";
- } else if (window.location.href.indexOf("http://100.0.4.69:8282") >= 0) {
- capUrl = "http://100.0.4.69:8282/cap/CAP-AUTH.html";
- baseUrl = "http://100.0.4.69:8282/";
- } else {
- capUrl = "https://800.wo.cn/festivalcap/CAP-AUTH.html";
- baseUrl = "https://800.wo.cn/";
- }
- if ($("#nanyanad").val() != null) {
- capUrl += '?ad=' + $("#nanyanad").val()
- }
- var $iframe;
- if ($('#uniauthframe').length >= 1) {
- $iframe = $('#uniauthframe').attr('src', capUrl);
- } else {
- $iframe = $('<iframe id="uniauthframe" src="' + capUrl + '"></iframe>');
- }
- $iframe.css({
- width: "100%",
- height: "100%",
- position: "fixed",
- top: 0,
- left: 0,
- margin: 0,
- padding: 0,
- "-webkit-overflow-scrolling": "touch",
- border: "0px",
- })
- showLoading();
- $iframe.on('load', function() {
- $capoverlay.remove();
- generClientSecret(fog).then(function(response) {
- hideLoading();
- response.orderChannel = query.fes + "_" + query.sou;
- if (productName != null && productName != '') {
- response.productName = productName;
- }
- if (capTemplet != null && capTemplet != '') {
- response.capTemplet = capTemplet
- }
- try {
- } catch (e) {
- }
- try {
- $iframe[0].contentWindow.postMessage(JSON.stringify(response), baseUrl)
- } catch (e) {}
- })
- })
- if (navigator.userAgent.indexOf("MicroMessenger") >= 0) {
- var currentPosition;
- var speed = 1;
- window.capTimer = setInterval(function() {
- currentPosition = document.documentElement.scrollTop || document.body.scrollTop;
- currentPosition -= speed;
- window.top.scrollTo(0, currentPosition);
- currentPosition += speed;
- window.top.scrollTo(0, currentPosition);
- }, 200);
- }
- window.$capoverlay = $('<div class="overlay" style="z-index: 0"></div>');
- $capoverlay.appendTo($(document.body));
- if ($('#uniauthframe').length == 0) {
- $('body').append($iframe);
- } else {
- $iframe.css('position', 'unset')
- .css('min-height', '10rem')
- }
- var def = $.Deferred();
- function messageListener(event) {
- var data = JSON.parse(event.data);
- switch (data.resultcode) {
- case "0": //处理成功
- $iframe.remove();
- $capoverlay.remove();
- window.removeEventListener('message', messageListener);
- $("body").css("overflow", "auto");
- clearInterval(window.capTimer)
- user.token = data.token;
- user.userid = decodeURIComponent(data.userid);
- user.userid1 = data.userid1;
- user.usermob = data.usermob;
- user.usertime = new Date().getTime();
- var poc = window.localStorage.getItem('kye').split(',')
- if (!!decryptUsermob && fog == poc[1] || fog == poc[0]) {
- decodeUsermob()
- } else if (!!decryptUsermob && fog == poc[2] || fog == poc[3]) {
- decodeUsermoob(null, fog)
- }
- def.resolve(user);
- break;
- case "9001": //关闭页面
- $iframe.remove();
- $capoverlay.remove();
- window.removeEventListener('message', messageListener);
- clearInterval(window.capTimer);
- $("body").css("overflow", "auto");
- def.reject(data);
- if (hasNetNumber != null && !!hasNetNumber && !historyBackExecuted) {
- if (query.test == '1') {
- alert(navigator.userAgent);
- }
- //火狐浏览器
- if (isChromeKernelBrowser()) {
- historyBackExecuted = true;
- history.back();
- }
- }
- break;
- case "0001": //auth_no无效
- case "0003": //client_id不存在
- case "0006": //验证码不正确
- case "4444": //服务暂时不可用(系统忙/系统队列满)
- break;
- case "99999": // 埋点信号
- if (data.operid) {
- burypointLogId(data.operid);
- }
- if (data.ea) {
- //埋点的东西吧不注销报错 WoAnalytics不存在
- // WoAnalytics.addPoint({ ad: $("#nanyanad").val(), ett: 'open', ea: data.ea + $("#nanyanlabel").val(), ct: 'web', pm: parseInt(getUrlParam("sou"), 32) })
- }
- try {
- window.WoAnalytics && window.WoAnalytics.setMp(data.usermob);
- } catch (e) {}
- break;
- default:
- $iframe.remove();
- $capoverlay.remove();
- window.removeEventListener('message', messageListener);
- $("body").css("overflow", "auto");
- clearInterval(window.capTimer)
- showAlert(data.errorinfo)
- def.reject(data)
- break;
- }
- }
- window.addEventListener('message', messageListener);
- return def;
- }
- function showLoading(message) {
- if (window.$loading) {
- window.$loading.trigger('close');
- }
- $("body").css('overflow', 'hidden');
- var msg = (message || '处理中,请稍后...');
- var $overlay = $('<div class="overlay overlay-loading"></div>');
- var $loading = $(
- '<div class="loading">' +
- ' <div class="content">' + msg + '</div>' +
- '</div>');
- $overlay.appendTo($(document.body))
- $loading.appendTo($(document.body))
- $loading.on('close', function() {
- $("body").css('overflow', 'auto');
- $overlay.remove();
- $loading.remove();
- $loading = null;
- })
- window.$loading = $loading;
- return $loading;
- }
- function generClientSecret(fog) {
- var pog = window.localStorage.getItem('kye').split(',')
- if (product == 2018072301) {
- var pog_fog = pog[2]
- } else if (product == 2020021201) {
- var pog_fog = pog[3]
- }
- var param = {
- "fog": pog_fog || fog || "",
- "channel": ""
- }
- return $.ajax({
- url: root + "-s1api" + '/ini/gensign',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- })
- }!(function() {
- Date.remainMillis = function() {
- var now = new Date();
- return (23 - now.getHours()) * 60 * 60 * 1000 +
- (59 - now.getMinutes()) * 60 * 1000 +
- (59 - now.getSeconds()) * 1000;
- }
- Date.remainMillisMonth = function() {
- var curDate = new Date();
- var curMonth = curDate.getMonth(); //当前月份 需要加1
- curDate.setMonth(curMonth + 1);
- curDate.setDate(0) // 关键
- curDate.getDate(); // 计算的当月总天数
- return curDate.getDate() - new Date().getDate()
- }
- /**
- * 将字符串转换为Date对象
- */
- Date.from = function(dateString) {
- var pattern = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/
- var str = dateString.replace(/-/g, '/');
- str = str.replace(pattern, '$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 burypointLogId(operid, remark, url, productid) {
- var uuid = getCookie('uuid'); // uv
- var vvid = getCookie('vvid'); // vv
- if (uuid == null || uuid.trim() == '') {
- uuid = guid();
- setCookie('uuid', uuid, Date.remainMillis());
- }
- if (vvid == null || vvid.trim() == '') {
- vvid = guid();
- setCookie('vvid', vvid, -1);
- }
- if (operid == null || operid == '') {
- // 页面的埋点通过通过文件日志入库方式
- return;
- }
- var pog = window.localStorage.getItem('kye').split(',')
- if (product == 2018072301) {
- var pog_fog = pog[0]
- } else if (product == 2020021201) {
- var pog_fog = pog[1]
- }
- var param = {
- operid: operid,
- uuid: uuid,
- vvid: vvid,
- fog: pog_fog,
- userid: user.userid,
- fes: query.fes,
- sou: query.sou,
- url: encodeURIComponent(url || window.location.href),
- remark: encodeURIComponent(remark || '')
- }
- $.ajax({
- url: root + "-s1api" + '/burypoint/logid',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- }).then(function(responseText) {
- })
- }
- function burypointLogIds(operid, remark, url, productid) {
- var uuid = getCookie('uuid'); // uv
- var vvid = getCookie('vvid'); // vv
- if (uuid == null || uuid.trim() == '') {
- uuid = guid();
- setCookie('uuid', uuid, Date.remainMillis());
- }
- 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: product.fog,
- userid: user.userid,
- fes: query.fes,
- sou: query.sou,
- url: encodeURIComponent(url || window.location.href),
- remark: encodeURIComponent(remark || '')
- }
- $.ajax({
- url: root + "-s1api" + '/burypoint/logid',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- }).then(function(responseText) {
- })
- }
- 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);
- root = (localhostPath + projectName);
- return (localhostPath + projectName);
- }
- function parseQueryParms() {
- var QUERY_SEPARATOR = '&',
- VALUE_SEPARATOR = '=';
- var queryStr = window.location.search.substring(1);
- var startIndex = 0,
- vIndex, qIndex;
- while (queryStr.length > 0) {
- vIndex = queryStr.indexOf(VALUE_SEPARATOR, startIndex);
- if (vIndex == -1) {
- break;
- }
- qIndex = queryStr.indexOf(QUERY_SEPARATOR, vIndex + 1);
- if (qIndex == -1) {
- qIndex = queryStr.length;
- }
- var key = queryStr.substring(startIndex, vIndex);
- var value = queryStr.substring(vIndex + 1, qIndex);
- query[key] = decodeURIComponent(value);
- startIndex = qIndex + 1;
- }
- }
- function getUrlParam(urlprm) {
- if (window.location.href.indexOf('jiangtao') >= 0) {
- alert(window.location.href);
- }
- 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";
- case "freeflow_token":
- return "";
- default:
- var url = getRootPath() + "/404.html";
- $(location).attr('href', url);
- }
- }
- }
- function hideLoading($loading) {
- if ($loading) {
- $loading.trigger('close');
- return;
- } else if (window.$loading) {
- window.$loading.trigger('close');
- return;
- }
- }
- function loadUserInfo(duration) {
- if (query.userid) {
- user.userid = query.userid;
- user.usermob = query.usermob;
- return;
- }
- try {
- var time = localStorage.getItem('time' + product.productid);
- if (time) {
- var curr = new Date().getTime();
- // 默认有效期是1小时
- if (curr <= parseFloat(time) + (duration || (1000 * 60 * 60))) {
- var userString = localStorage.getItem("user" + product.productid);
- if (userString != null) {
- user = JSON.parse(userString);
- user.userid = user.userid;
- user.usermob = user.usermob;
- }
- } else {
- // 超过1小时删除缓存数据
- localStorage.removeItem("time" + product.productid)
- localStorage.removeItem("user" + product.productid)
- }
- return user;
- } else {
- localStorage.removeItem("time" + product.productid)
- localStorage.removeItem("user" + product.productid)
- }
- } catch (e) {
- }
- }
- function showOrderPage(backPage) {
- if (location.href.indexOf('index.html') < 0 && location.href.indexOf('15/20200') < 0) {
- if (backPage == null || backPage == '') {
- backPage = 'index.html';
- }
- window.location.href = backPage + "?fes=" + query.fes + "&sou=" + query.sou;
- return;
- }
- $('#btn-order').unbind('click').on('click', function(event) {
- if (!lockClick()) {
- return;
- }
- if ($douyinItem.hasClass('active')) {
- product = douyinProductId;
- } else {
- product = baiduProductId;
- }
- var product_fog = window.localStorage.getItem('kye').split(',')
- var fog_a = product_fog
- if (product == 2018072301) {
- showCapPage(fog_a[0], null, false, false, true, null).then(function(data) {
- unlockClick();
- order(data.userid, data.token, data.usermob);
- WoAnalytics.setMp(data.usermob)
- }).fail(function(response) {
- unlockClick();
- })
- } else if (product == 2020021201) {
- showCapPage(fog_a[1], null, false, false, true, null).then(function(data) {
- unlockClick();
- order(data.userid, data.token, data.usermob);
- }).fail(function(response) {
- unlockClick();
- })
- }
- })
- $('.modify').unbind('click').on('click', function(event) {
- if (!lockClick()) {
- return;
- }
- if ($douyinItem.hasClass('active')) {
- product = douyinPreProductId;
- } else {
- product = baiduPreProductId;
- }
- var product_fag = window.localStorage.getItem('kye').split(',')
- var fog_b = product_fag
- if (product == 2020031101) {
- showCapPage(fog_b[2], null, false, false, true, null).then(function(data) {
- unlockClick();
- order(data.userid, data.token, data.usermob);
- }).fail(function(response) {
- unlockClick();
- })
- } else if (product == 2020071301) {
- showCapPage(fog_b[3], null, false, false, true, null).then(function(data) {
- unlockClick();
- order(data.userid, data.token, data.usermob);
- }).fail(function(response) {
- unlockClick();
- })
- }
- })
- }
- function getCookie(name) {
- var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
- if (arr = document.cookie.match(reg))
- return unescape(arr[2]);
- else
- return null;
- }
- 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);
- });
- }
- 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 showAlert(message, hideButton, buttonLabel, hideTitle) {
- var title = '';
- if (hideTitle == undefined || hideTitle == false) {
- title = '温馨提示';
- }
- var $overlay = $('<div class="overlay overlay-alert"></div>');
- var $dialog = $(
- '<div class="dialog-alert">' +
- '<h1>' + title + '</h1>' +
- '<div class="content">' + message + '</div>' +
- '<div class="actions">' +
- ' <div class="btn">' + (buttonLabel == null || buttonLabel == "" ? "关闭" : buttonLabel) + '</div>' +
- '</div>' +
- '</div>');
- $("body").css("overflow", "hidden");
- $overlay.appendTo($(document.body));
- $dialog.appendTo($(document.body));
- if (hideButton == true) {
- $dialog.find('.btn').remove();
- }
- $dialog.close = function() {
- $("body").css("overflow", "auto");
- $overlay.remove();
- $dialog.remove();
- $dialog = null;
- }
- var def = $.Deferred();
- $dialog.find('.btn').on('click', function() {
- $dialog.close()
- def.resolve($dialog);
- })
- return def;
- }
- // 验证码
- function sendSms($container, smstype, currentProduct) {
- var def = $.Deferred();
- if ($container.attr('n') != null && $container.attr('n') > 0) {
- return;
- }
- var usermob = $container.find('.usermob').val();
- if (usermob == null || usermob.trim() == "") {
- showAlert('请输入联通手机号码');
- def.reject();
- return def;
- }
- if (!usermob.startsWith("1") || usermob.length != 11) {
- showAlert('手机号码格式不正确');
- def.reject();
- return def;
- }
- console.log(usermob)
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "usermob": usermob,
- "smstype": smstype
- }
- user.usermob = usermob
- var count = 60;
- $container.attr('n', count);
- $.ajax({
- url: root + "-s1api" + '/sms/send',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- }).then(function(response) {
- if (response.resultCode != "0000") {
- count = 0;
- $container.attr('n', count);
- showAlert(response.errorInfo);
- return;
- }
- var $sendcode = $container.find('.sendcode')
- var template = '{}s'
- if ($sendcode.is('input')) {
- $sendcode.val(template.replace('{}', count));
- } else {
- $sendcode.text(template.replace('{}', count));
- }
- $sendcode.addClass('sendcode-wait');
- var timer = setInterval(function() {
- count -= 1;
- $container.attr('n', count);
- if ($sendcode.is('input')) {
- $sendcode.val(template.replace('{}', count));
- } else {
- $sendcode.text(template.replace('{}', count));
- }
- if (count === 0) {
- clearInterval(timer);
- if ($sendcode.is('input')) {
- $sendcode.val('获取验证码');
- } else {
- $sendcode.text('获取验证码');
- }
- $container.attr('n', count);
- $sendcode.removeClass('sendcode-wait');
- }
- }, 1000);
- })
- try {
- window.WoAnalytics && window.WoAnalytics.setMp(usermob);
- } catch (e) {}
- }
- function openPage(pageName) {
- if (pageName == null) {
- if (location.href.indexOf("index.html") >= 0) pageName = "order";
- if (location.href.indexOf("cancel.html") >= 0) pageName = "cancel";
- }
- switch (pageName) {
- case "cancel":
- showCancelPage();
- break;
- default:
- showOrderPage();
- break;
- }
- }
- function checkCode($container, keepUserInfo) {
- var def = $.Deferred();
- var usermob = $container.find('.usermob').val();
- var smscode = $container.find('.smscode').val();
- if (keepUserInfo == null) keepUserInfo = false;
- if (usermob == null || usermob.trim() == "") {
- showAlert('请输入联通手机号码');
- def.reject()
- return def;
- }
- if (smscode == null || smscode.trim() == "") {
- showAlert('请输入验证码');
- def.reject()
- return def;
- }
- if (smscode.length != 6) {
- showAlert('短信验证码不正确');
- def.reject()
- return def;
- }
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "code": smscode,
- "usermob": usermob,
- }
- $.ajax({
- url: root + "-s1api" + '/checkvercode',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- }).then(function(response) {
- $container.find('.smscode').val('')
- switch (response.resultCode) {
- case "0000":
- user.userid = response.userid;
- user.usermob = usermob;
- user.usertime = new Date().getTime();
- if (!keepUserInfo) {
- $container.find('.usermob').val('')
- $container.find('.usermob').val('')
- }
- def.resolve(response.userid);
- break;
- default:
- showAlert(response.errorInfo)
- def.reject(response);
- break;
- }
- }).fail(function(error) {
- def.reject('服务调用异常')
- })
- return def;
- }
- function order(userid, token, usermob) {
- showLoading('处理中,请稍后...');
- choiceOrder(userid, token, usermob).done(function(response) {
- hideLoading();
- switch (response.resultCode) {
- case "0000": //订购成功!跳转到领取会员页面
- saveUserInfo();
- showDialogMessage('订购成功');
- return;
- case "0013":
- showDialogMessage('该号码归属省分2/3G暂未开通此产品!');
- break;
- case "6611":
- showDialogMessage('错误代码(6611),订购失败,请重试!');
- break;
- case "6615":
- showDialogMessage('订购失败,请确定用户套餐!');
- break;
- case "6622": // 用户已订购过此产品!跳转到流量查页面
- saveUserInfo('用户已订购过此产品!跳转到流量查页面');
- break;
- // case "1078": //{"resultCode":"1078","errorInfo":"预约失败,请直接订购此产品!"}
- // showDialogMessage('预约变更失败,请先订购本产品!');
- // showDialogMessage('预约变更失败,请先订购本产品!');
- break;
- // case "1077": //{"resultCode":"1077","errorInfo":"订购失败,您已订购过二选一产品,请预约订购!"}
- // showDialogMessage('订购失败,您已订购过二选一产品,请预约变更!');
- // break;
- // case "1079": // {"resultCode":"1079","errorInfo":"预约失败,请先订购百度产品!"}
- // showDialogMessage('预约变更失败,与当前生效的专属流量流量相同!');
- // break;
- default:
- showDialogMessage(response.errorInfo);
- break;
- }
- }).fail(function(error) {
- hideLoading();
- });
- }
- function choiceOrder(userid, token, usermob) {
- var product_fog = window.localStorage.getItem('kye').split(',')
- if (product == 2018072301) {
- var bat = product_fog[0]
- } else if (product == 2020021201) {
- var bat = product_fog[1]
- } else if (product == 2020031101) {
- var bat = product_fog[2]
- } else if (product == 2020071301) {
- var bat = product_fog[3]
- }
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": bat,
- "token": token,
- "userid": userid || user.userid,
- "usermob": usermob || user.usermob,
- "useraccount": ""
- }
- return $.ajax({
- url: root + "-s1api" + '/choiceorder/order',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- });
- }
- function saveUserInfo(duration) {
- localStorage.setItem('user' + product.productid, JSON.stringify(user));
- localStorage.setItem('time' + product.productid, duration || ((new Date().getTime()) + ""));
- }
- function choiceCancel(userid, usermob, canceltype, cancelmsg) {
- var param = {
- "fes": query.fes,
- "sou": query.sou,
- "fog": product.fog,
- "userid": userid || user.userid,
- "usermob": usermob || user.usermob,
- "canceltype": encodeURIComponent(canceltype),
- "cancelmsg": encodeURIComponent(cancelmsg),
- "useraccount": ""
- }
- return $.ajax({
- url: root + "-s1api" + '/choiceorder/cancel',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- });
- }
- function showDialogMessage(message) {
- var replaceString = '';
- if (product.productid == baiduPreProductId ||
- product.productid == douyinPreProductId) {
- message = message.replace('订购失败', '预约变更失败')
- .replace('订购成功', '预约变更成功');
- }
- var $overlay = $('<div class="overlay"></div>')
- var $dialog = $(
- '<div class="dialog-meesage">' +
- ' <div class="content">' + message + '</div>' +
- ' <div class="actions">' +
- ' <div class="btn"></div>' +
- ' </div>' +
- '</div>');
- $overlay.appendTo($(document.body))
- $dialog.appendTo($(document.body))
- $dialog.find('.btn').on('click', function() {
- $overlay.remove();
- $dialog.remove();
- $dialog = null;
- })
- $dialog.close = function() {
- $overlay.remove();
- $dialog.remove();
- $dialog = null;
- }
- return $dialog;
- }
- // 订购
- function decodeUsermob(userid) {
- var poa = window.localStorage.getItem('kye').split(',')
- if (product == 2018072301) {
- var pog_foa = poa[0]
- } else if (product == 2020021201) {
- var pog_foa = poa[1]
- }
- var param = {
- "fog": pog_foa || fog || "",
- "userid": userid || user.userid
- }
- $.ajax({
- url: root + "-s1api" + '/decodeUserid',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- }).then(function(data) {
- if (data.resultCode == '0') {
- user.usermob = data.usermob;
- }
- });
- }
- //预约变更:
- function decodeUsermoob(userid, aug) {
- var psa = window.localStorage.getItem('kye').split(',')
- if (aug == psa[2]) {
- var pog_foa = psa[2]
- } else if (aug == psa[3]) {
- var pog_foa = psa[3]
- }
- var param = {
- "fog": pog_foa || fog || "",
- "userid": userid || user.userid
- }
- $.ajax({
- url: root + "-s1api" + '/decodeUserid',
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(param)
- }).then(function(data) {
- if (data.resultCode == '0') {
- user.usermob = data.usermob;
- }
- });
- }
|