1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015 |
- import * as compnt from "../../../../public/js/compnt.js";
- import * as unicom from "../../../../public/js/unicom.js";
- import "../scss/order.scss";
- var usermob = '';
- usermob = getQueryString("userid");
- $(function() {
- var isPageHide = false;
- window.addEventListener('pageshow', function() {
- if (isPageHide) {
- window.location.reload();
- }
- });
- window.addEventListener('pagehide', function() {
- isPageHide = true;
- });
- if (window.location.href.indexOf('draw20220313.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 != '') {
- compnt.showAlert(message);
- localStorage.removeItem('message');
- }
- compnt.showLoading();
- unicom.init().then(function(response) {
- compnt.hideLoading();
- unicom.product = response.product[0];
- unicom.fesname = response.festival;
- unicom.loadUserInfo();
- if (location.href.indexOf("15/index") >= 0) {
- showOrderPage();
- } else {
- openPage();
- }
- if (location.href.indexOf('/cancel') >= 0) {
- unicom.burypointLogId('110002'); // 退订页面pv, pv去重得到uv
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'open', ea: 'cancel_open' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- } else
- if (location.href.indexOf('/draw') >= 0) {
- unicom.burypointLogId('110003'); // 领取页面pv, pv去重得到uv
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'open', ea: 'draw_open' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- } else
- if (location.href.indexOf('/flow') >= 0) {
- unicom.burypointLogId('110004'); // 流量查询pv, pv去重得到uv
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'open', ea: 'flow_open' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- } else if (location.href.indexOf('/active') >= 0) {
- unicom.burypointLogId('110005'); // 激活页面pv, pv去重得到uv
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'open', ea: 'active_open' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- } else if (location.href.indexOf('/refund') >= 0) {
- unicom.burypointLogId('110006'); // 退款
- } else {
- unicom.burypointLogId('110001'); // 订购页面pv, pv去重得到uv
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'open', ea: 'order_open' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- }
- })
- }
- function openPage(pageName) {
- if (pageName == null) {
- if (location.href.indexOf("index.html") >= 0) pageName = "order";
- if (location.href.indexOf("cannel20220313.html") >= 0) pageName = "cancel";
- if (location.href.indexOf("draw20220313.html") >= 0) pageName = "draw";
- if (location.href.indexOf("active.html") >= 0) pageName = "active";
- if (location.href.indexOf("flow.html") >= 0) pageName = "flow";
- }
- switch (pageName) {
- case "active":
- showActivePage();
- break;
- case "cancel":
- showCancelPage();
- break;
- case "draw":
- unicom.queryWeiboUserInfoak(usermob).done(function(response) {
- console.log(response)
- if (response.status == "1" && response.vipstatu == '0') {
- $('#information').html('已订购,未领取权益!');
- } else if (response.resultCode == "1102") {
- $('#information').html('权益以领取!');
- $(".order_a").attr("class", "order_b")
- } else if (response.status == "0" && response.vipstatu == '0') {
- $('#information').html('未订购此产品!');
- $('.order_a').css('display', 'none')
- $('.ordersak').css('display', 'block')
- $('#btn-order').unbind('click').on('click', function(event) {
- //compnt.showAlert('退订成功');
- // return;
- // console.log(1)
- if (!compnt.lockClick()) {
- return;
- }
- unicom.showCapPage(null, null, false, false, true).then(function(data) {
- compnt.unlockClick();
- order(data.userid, data.token, data.usermob);
- }).fail(function(response) {
- compnt.unlockClick();
- })
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_click_order_btn' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- })
- } else if (response.status == "1" && response.vipstatu == '1') {
- $('#information').html('已订购,权益已领取!');
- $(".order_a").attr("class", "order_b")
- } else if (response.status == "0" && response.vipstatu == '1') {
- $('#information').html('权益已领取!');
- $(".order_a").attr("class", "order_b")
- } else if (response.resultCode == "1067") {
- $('#information').html('领取失败,已领取或领取时间结束!');
- } else {
- $('#information').html(response.errorInfo);
- }
- })
- showDrawPage();
- break;
- case "flow":
- showFlowPage();
- break;
- default:
- showOrderPage();
- break;
- }
- }
- $('#btn_cannel').unbind('click').on('click', function() {
- gotoUrl('douyin/15/cannel20220313')
- })
- // $('#btn_l').unbind('click').on('click', function() {
- // window.location.href = 'https://account.bol.wo.cn/cuuser/unity/redirectOnekeyLogin?clientId=directflow&redirectUrl=' + 'http://100.0.4.69:3344/orderchannel/douyin/15/draw20220313.html?fes=9ur&sou=26'
- // gotoUrl('douyin/15/draw20220313')
- // })
- $('#btn-cancel').unbind('click').on('click', function() {
- showCancelPage();
- })
- $('#btn-active').unbind('click').on('click', function() {
- showActivePage();
- })
- $('#gotoDrawPage').unbind('click').on('click', function() {
- showDrawPage(window.location.href.substring(window.location.href.lastIndexOf('/') + 1, window.location.href.lastIndexOf('.')))
- })
- function showDrawPage(back) {
- // if (location.href.indexOf("draw202203013.html") < 0) {
- // window.location.href = "draw202203013.html?fes=" + unicom.query.fes + "&sou=" + unicom.query.sou + '&back=' + (back == null ? '' : back);
- // return;
- // }
- var $container = $('.section-login').find('.form-group');
- $container.find('.sendcode').unbind('click').on('click', function() {
- var account = $container.find('.account').val();
- var arr = new Array()
- arr = account.split(' ')
- if (arr.length != 1) {
- compnt.showAlert('抖音短视频账号不能含有空格');
- return
- }
- if (account == null || account == "") {
- compnt.showAlert('请输入抖音短视频账号');
- return;
- }
- unicom.sendSms($container, 'drawlogin');
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'draw_click_send_sms_code_btn' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- })
- $container.find('.login').unbind('click').on('click', function() {
- var usermob = $container.find('.usermob').val();
- var account = $container.find('.account').val();
- var smscode = $container.find('.smscode').val();
- if (usermob == null || usermob == "") {
- compnt.showAlert('请输入联通手机号');
- return;
- }
- var arr = new Array()
- arr = account.split(' ')
- if (arr.length != 1) {
- compnt.showAlert('抖音短视频账号不能含有空格');
- return
- }
- if (account == null || account == "") {
- compnt.showAlert('请输入抖音短视频账号');
- return;
- }
- if (account == null || account == "") {
- compnt.showAlert('请输入抖音短视频账号');
- return;
- }
- if (smscode == null || smscode == "") {
- compnt.showAlert('请输入验证码');
- return;
- }
- var $comfirm = showConfirmDialog(account);
- $comfirm.find('.cancel').on('click', function() {
- compnt.hideLoading();
- });
- $comfirm.find('.okay').on('click', function() {
- unicom.checkCode($container, true).done(function() {
- /*unicom.canDrawCoin(account).then(function (response) {
- if (response.resultCode != "0000") {
- compnt.hideLoading();
- compnt.showAlert(response.errorInfo);
- return;
- }
-
- drawCoin(account)
- })*/
- drawCoin(account);
- }).fail(function(data) {
- compnt.hideLoading();
- })
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'draw_click_confirm_btn' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- });
- })
- }
- function drawCoin(account) {
- // var $comfirm = showConfirmDialog(account);
- // $comfirm.find('.cancel').on('click', function() {
- // compnt.hideLoading();
- // });
- //$comfirm.find('.okay').on('click', function() {
- // var $container = $('.section-login').find('.form-group');
- // $container.find('.usermob').val('')
- // $container.find('.usermob').val('')
- // $container.find('.account').val('');
- compnt.showLoading();
- unicom.drawCoin(account, '').done(function(response) {
- compnt.hideLoading();
- switch (response.resultCode) {
- case "0000":
- var $container = $('.section-login').find('.form-group');
- $container.find('.usermob').val('');
- $container.find('.smscode').val('');
- $container.find('.account').val('');
- compnt.showAlert('抖币充值中,详情结果以短信形式告知').then(function() {
- if (unicom.query.back != null && unicom.query.back != '') {
- showOrderPage(unicom.query.back + ".html");
- }
- });
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'draw_success' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- break;
- case "7605":
- compnt.showAlert(response.errorInfo);
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'draw_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- break;
- case '6776':
- var prefix = '';
- compnt.showAlert(prefix + response.errorInfo);
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'draw_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- break;
- default:
- var prefix = '';
- if (response.errorInfo.indexOf('领取失败') < 0) {
- prefix = '领取失败,';
- }
- compnt.showAlert(prefix + response.errorInfo);
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'draw_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- break;
- }
- }).fail(function(data) {
- compnt.hideLoading();
- })
- }
- function showOrderPage(backPage) {
- // if (location.href.indexOf('15/index') < 0) {
- // if (backPage == null || backPage == '') {
- // backPage = 'index.html';
- // }
- // window.location.href = backPage + "?fes=" + unicom.query.fes + "&sou=" + unicom.query.sou;
- // return;
- // }
- $('#btn-order').unbind('click').on('click', function(event) {
- //compnt.showAlert('退订成功');
- // return;
- // console.log(1)
- if (!compnt.lockClick()) {
- return;
- }
- unicom.showCapPage(null, null, false, false, true).then(function(data) {
- compnt.unlockClick();
- order(data.userid, data.token, data.usermob);
- }).fail(function(response) {
- compnt.unlockClick();
- })
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_click_order_btn' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- })
- }
- function showFlowPage() {
- if (location.href.indexOf("flow.html") < 0) {
- window.location.href = "flow.html?fes=" +
- unicom.query.fes + "&sou=" + unicom.query.sou +
- "&userid=" + unicom.user.userid + "&usermob=" + unicom.user.usermob +
- "&usertime=" + (unicom.user.usertime || (new Date().getTime()));
- return;
- }
- var $container = $('.section-flow');
- var usermob = unicom.user.usermob;
- $container.find('.phone').html(usermob.substring(0, 3) + 'xxxx' + usermob.substring(7, 11));
- $container.find('.btn').unbind('click').on('click', function() {
- //if (!compnt.lockClick()) {
- // return;
- //}
- queryFlow().then(function(message) {
- compnt.unlockClick()
- if (message != null && message != "") {
- compnt.showAlert(message);
- }
- }).fail(function() {
- compnt.unlockClick();
- });
- })
- queryFlow();
- }
- function showActivePage() {
- if (location.href.indexOf("active.html") < 0) {
- window.location.href = "active.html?fes=" + unicom.query.fes + "&sou=" +
- unicom.query.sou;
- return;
- }
- var $container = $('.section-login').find('.form-group');
- $container.find('.sendcode').unbind('click').on('click', function() {
- if (!checkEquip()) return;
- unicom.sendSms($container, 'activelogin');
- })
- $container.find('.login').unbind('click').on('click', function(event) {
- if (!checkEquip()) return;
- if (!compnt.lockClick()) {
- return;
- }
- unicom.checkCode($container).then(function() {
- compnt.unlockClick()
- active()
- }).fail(function() {
- compnt.unlockClick();
- });
- })
- window.scrollTo(0, 0)
- }
- function showCancelPage() {
- if (location.href.indexOf("cannel20220313.html") < 0) {
- window.location.href = "cannel20220313.html?fes=" + unicom.query.fes + "&sou=" + unicom.query.sou;
- return;
- }
- var $container = $('.section-login').find('.form-group');
- $container.find('.sendcode').unbind('click').on('click', function() {
- unicom.sendSms($container, 'cancellogin');
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'cancel_click_send_sms_code_btn' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- })
- $container.find('.login').unbind('click').on('click', function() {
- compnt.showLoading();
- unicom.checkCode($container).done(function() {
- unicom.cancel().done(function(response) {
- compnt.hideLoading();
- switch (response.resultCode) {
- case "0000":
- compnt.showAlert('退订成功'); //.then(function(message) {
- //showFlowPage();
- //});
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'cancel_success' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- break;
- case "7605": //应该是已经退订了吧,因此不需要在重复退订啦
- compnt.showAlert(response.errorInfo); //.then(function(message) {
- //showFlowPage();
- //});
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'cancel_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- break;
- default:
- var prefix = '';
- if (response.errorInfo.indexOf('退订失败') < 0) {
- prefix = '退订失败,';
- }
- compnt.showAlert(prefix + response.errorInfo);
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'cancel_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- break;
- }
- }).fail(function(data) {
- compnt.hideLoading();
- })
- }).fail(function(data) {
- compnt.hideLoading();
- })
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'cancel_click_confirm_btn' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- })
- window.scrollTo(0, 0)
- }
- function checkEquip() {
- /*if (!baidu.app.baidu) {
- compnt.showAlert('请到百度产品客户端中激活免流~')
- return false;
- }
- if (!baidu.checkWeiboVersion()) {
- compnt.showAlert('请到升级到最新版百度产品客户端后激活免流~')
- return false;
- }*/
- return true;
- }
- /**
- * 订购
- */
- function order(userid, token, usermob) {
- compnt.showLoading('处理中,请稍后...');
- unicom.order(userid, token, usermob).done(function(response) {
- compnt.hideLoading();
- switch (response.resultCode) {
- case "0000": //订购成功!跳转到领取会员页面
- unicom.saveUserInfo();
- showAlert('订购成功');
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_success' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- return;
- case "0013":
- //showAlertDialog('orderFailure','该号码归属省分2/3G暂未开通此产品!');
- compnt.showAlert('该号码归属省分2/3G暂未开通此产品!');
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- break;
- case "6611":
- // showAlertDialog('orderFailure','错误代码(6611),' + '订购失败,请重试!');
- compnt.showAlert('错误代码(6611),订购失败,请重试!');
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- break;
- case "6615":
- //showAlertDialog('orderFailure', '订购失败,请确定用户套餐!');
- showAlerts('订购失败,请确定用户套餐!');
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- break;
- case "6622": // 用户已订购过此产品!跳转到流量查页面
- // localStorage.setItem('message', '您已经订购了本产品~');
- compnt.showAlert('您已经订购了本产品~');
- unicom.saveUserInfo();
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- // showFlowPage();
- break;
- default:
- //showAlertDialog('orderFailure', response.errorInfo + ',订购失败,请确定用户套餐!');
- showAlerts(response.errorInfo + '订购失败,请确定用户套餐!');
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- break;
- }
- }).fail(function(error) {
- compnt.hideLoading();
- console.log(error);
- });
- }
- function showAlert(message, hideButton, buttonLabel, hideTitle) {
- var title = '';
- if (hideTitle == undefined || hideTitle == false) {
- title = message;
- }
- var $overlay = $('<div class="overlay overlay-alert"></div>');
- var $dialog = $(
- '<div class="dialog-alerts dialog-alert">' +
- '<h1>' + title + '</h1>' +
- '<div class="contents">' + '</div>' +
- '<div class="actionss 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 showAlerak(message, hideButton, buttonLabel, hideTitle) {
- var title = '';
- if (hideTitle == undefined || hideTitle == false) {
- title = message;
- }
- var $overlay = $('<div class="overlay overlay-alert"></div>');
- var $dialog = $(
- '<div class="dialog-alerts dialog-alert">' +
- '<h1>' + title + '</h1>' +
- '<div class="contentsak">' + '</div>' +
- '<div class="actionss 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 showAlerts(message, hideButton, buttonLabel, hideTitle) {
- var title = '';
- if (hideTitle == undefined || hideTitle == false) {
- title = message;
- }
- var $overlay = $('<div class="overlay overlay-alert"></div>');
- var $dialog = $(
- '<div class="dialog-alerts dialog-alert">' +
- '<h1>' + title + '</h1>' +
- '<div class="contentss">' + '</div>' +
- '<div class="actionss 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 showAlertDialog(action, message) {
- var className = '';
- switch (action) {
- case 'orderSuccess':
- className = 'dialog-message-order-success';
- break;
- case 'orderFailure':
- className = 'dialog-message-order-failure';
- break;
- case 'activeSuccess':
- className = 'dialog-message-active-success';
- break;
- case 'activeFailure':
- className = 'dialog-message-active-failure';
- break;
- case 'cancelSuccess':
- className = 'dialog-message-cancel-success';
- break;
- case 'cancelFailure':
- className = 'dialog-message-cancel-failure';
- break;
- default:
- break;
- }
- var $overlay = $('<div class="overlay"></div>');
- var $dialog = $(
- '<div class="dialog dialog-message ' + className + '">' +
- ' <div class="title"></div>' +
- ' <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').unbind('click').on('click', function() {
- $dialog.close()
- })
- $dialog.close = function() {
- $overlay.remove();
- $dialog.remove();
- $dialog = null;
- }
- return $dialog;
- }
- /**
- * 查询用户剩余流量
- */
- function queryFlow() {
- var $container = $('.section-flow');
- //return new Promise(function(resolve, reject) {
- var def = $.Deferred();
- unicom.queryFlow().then(function(response) {
- // var response = JSON.parse(responseText);
- // console.log("流量剩余情况:" + response.data)
- switch (response.resultCode) {
- case "0000":
- //compnt.showAlert(JSON.stringify(response.data));
- //console.log(response.data)
- //console.log(JSON.parse(response.data).surplusFlow)
- var surplus = compnt.returnFloat(JSON.parse(response.data).surplusFlow / 1024 / 1024);
- $container.find('.surplus').html(surplus + 'GB');
- var usedFlowKb = parseInt(JSON.parse(response.data).usedFlow);
- if (usedFlowKb > 0 && usedFlowKb < 1024) {
- def.resolve("剩余流量更新成功,为您免流了" + usedFlowKb + "KB~");
- } else if (usedFlowKb > 1024) {
- var useedFlow = compnt.returnFloat(usedFlowKb / 1024);
- def.resolve("剩余流量更新成功,为您免流了" + useedFlow + "MB~");
- } else {
- def.resolve("剩余流量更新成功~");
- }
- break;
- case "9201": //{"resultCode":"9201","errorInfo":"查询失败,请检查是否有订购关系!"}
- def.resolve("您未订购百度定向流量包~")
- $container.find('.phone').html('用户未订购此产品!');
- break;
- case "9203": //{"resultCode":"9203","errorInfo":"流量查询失败,没有获取到用户所使用流量信息!"}
- //compnt.showAlert("没有获取到用户所使用流量信息!");
- def.resolve("剩余流量更新成功~")
- $container.find('.suplus').html('本月剩余<br>8.00GB');
- break;
- default:
- def.resolve("剩余流量更新成功~")
- break;
- }
- })
- return def;
- //})
- }
- function active() {
- baidu.active().then(function() {
- //checkActiveResult();
- compnt.showAlert('激活成功').then(function() {
- unicom.saveUserInfo()
- // showFlowPage();
- });
- })
- }
- $('.section-agr').find('.footer').on('click', function() {
- if ($($('.section-agr .scope').find('li')[2]).hasClass('hidden')) {
- $('.section-agr .scope').find('li').each(function(i, ele) {
- $(ele).removeClass('hidden');
- })
- $('.section-agr').find('.footer').html('隐藏<span class="arrow">>');
- } else {
- $('.section-agr .scope').find('li').each(function(i, ele) {
- if (i >= 1) {
- $(ele).addClass('hidden');
- }
- })
- $('.section-agr').find('.footer').html('查看更多专属流量适用范围<span class="arrow">>');
- }
- });
- function showConfirmDialog(account) {
- var $overlay = $('<div class="overlay"></div>')
- var $dialog = $(
- '<div class="dialog dialog-confirm">' +
- ' <div class="content">请确认是否领取抖音币到' + account + '账号?</div>' +
- ' <div class="actions">' +
- ' <div class="btn cancel">取消</div>' +
- ' <div class="btn okay">确认</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;
- }
- var call = 0
- $(".beijing_a").click(function() {
- if ($(this)) {
- $(this).addClass("beijing_b").siblings().removeClass('beijing_b');
- call = $(this).index()
- // console.log($(this).index())
- }
- });
- $('.order_a').click(function() {
- // console.log(call)
- switch (call) {
- case 0:
- showAlerta('优酷视频会员周卡')
- break;
- case 1:
- showAlerta('爱奇艺视频会员周卡')
- break;
- case 2:
- showAlerta('腾讯视频会员周卡')
- break;
- case 3:
- showAlerta('蜻蜓FM超级会员周卡')
- break;
- case 4:
- showAlerta('芒果TV PC移动影视会员周卡')
- break;
- case 5:
- showAlerta('美团外卖5元红包')
- break;
- case 6:
- showAlertat('抖音币50个')
- break;
- default:
- // console.log(call)
- break;
- }
- })
- function showAlerta(message, hideButton, buttonLabel, hideTitle) {
- var title = '';
- var text = '';
- if (hideTitle == undefined || hideTitle == false) {
- title = '您选择的是:';
- text = message
- }
- var $overlay = $('<div class="overlay overlay-alert"></div>');
- var $dialog = $(
- '<div class="dialog-alerttt">' +
- '<h1 class="text_nn">' + '<span class="text_mm ">' + title + '</span>' + text + '</h1>' +
- '<input class="inputot" type="tel" maxlength="11" name="phone" placeholder="请输入领取权益的手机号码"/>' +
- // '<button class="content">' + message + '</button>' +
- '<div class="actions">' +
- ' <div class="btns">' + (buttonLabel == null || buttonLabel == "" ? "关闭" : buttonLabel) + '</div>' +
- ' <div id="btn_orderss" class="btn btn_orderss">' + (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();
- }
- $(".btns").click(function() {
- $("body").css("overflow", "auto");
- $overlay.remove();
- $dialog.remove();
- $dialog = null;
- })
- $("#btn_orderss").click(function() {
- var account = $dialog.find('.inputot').val();
- if (account == null || account == "") {
- compnt.showAlert('请输入手机号码');
- return;
- }
- // console.log(account)
- // console.log(usermob, account)
- switch (call) {
- case 0:
- var vipcode = 10001
- break;
- case 1:
- var vipcode = 20001
- break;
- case 2:
- var vipcode = 30001
- break;
- case 3:
- var vipcode = 60001
- break;
- case 4:
- var vipcode = 50001
- break;
- case 5:
- var vipcode = 13004
- break;
- default:
- // console.log(call)
- break;
- }
- console.log(account, vipcode, usermob)
- deaw(account, vipcode, usermob)
- $("body").css("overflow", "auto");
- $overlay.remove();
- $dialog.remove();
- $dialog = null;
- })
- }
- function showAlertat(message, hideButton, buttonLabel, hideTitle) {
- var title = '';
- var text = '';
- if (hideTitle == undefined || hideTitle == false) {
- title = '您选择的是:';
- text = message
- }
- var $overlay = $('<div class="overlay overlay-alert"></div>');
- var $dialog = $(
- '<div class="dialog-alerttt">' +
- '<h1 class="text_nn">' + '<span class="text_mm ">' + title + '</span>' + text + '</h1>' +
- '<input class="inputot" placeholder="请输入抖音号"/>' +
- // '<button class="content">' + message + '</button>' +
- '<div class="actions">' +
- ' <div class="btns">' + (buttonLabel == null || buttonLabel == "" ? "关闭" : buttonLabel) + '</div>' +
- ' <div id="btn_orderss" class="btn btn_orderss">' + (buttonLabel == null || buttonLabel == "" ? "确定" : buttonLabel) + '</div>' +
- '</div>' +
- '</div>');
- $("body").css("overflow", "hidden");
- $overlay.appendTo($(document.body));
- $dialog.appendTo($(document.body));
- $(".btns").click(function() {
- $("body").css("overflow", "auto");
- $overlay.remove();
- $dialog.remove();
- $dialog = null;
- })
- $("#btn_orderss").click(function() {
- var account = $dialog.find('.inputot').val();
- // console.log(account)
- var arr = new Array()
- arr = account.split(' ')
- if (arr.length != 1) {
- compnt.showAlert('抖音短视频账号不能含有空格');
- return
- }
- if (account == null || account == "") {
- compnt.showAlert('请输入抖音短视频账号');
- return;
- } else {
- var vipcodes = '20200310'
- console.log(account, vipcodes, usermob)
- deaw(account, vipcodes, usermob)
- $("body").css("overflow", "auto");
- $overlay.remove();
- $dialog.remove();
- $dialog = null;
- }
- })
- }
- function getQueryString(name) {
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
- var r = window.location.search.substr(1).match(reg);
- if (r != null) return unescape(r[2]);
- return null;
- }
- function deaw(userid, token, usermob) {
- compnt.showLoading('处理中,请稍后...');
- unicom.deaw(userid, token, usermob).done(function(response) {
- compnt.hideLoading();
- // console.log(response.resultCode)
- switch (response.resultCode) {
- case "0000": //订购成功!跳转到领取会员页面
- unicom.saveUserInfo();
- showAlerak('领取结果以短信为准!');
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_success' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- return;
- case "1102":
- //showAlertDialog('orderFailure','该号码归属省分2/3G暂未开通此产品!');
- compnt.showAlert('用户已领取过权益,不能再领取!');
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- break;
- case "1015":
- // showAlertDialog('orderFailure','错误代码(6611),' + '订购失败,请重试!');
- compnt.showAlert('用户未订购此产品!');
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- break;
- // case "6615":
- // //showAlertDialog('orderFailure', '订购失败,请确定用户套餐!');
- // showAlerts('订购失败,请确定用户套餐!');
- // WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- // break;
- // case "6622": // 用户已订购过此产品!跳转到流量查页面
- // // localStorage.setItem('message', '您已经订购了本产品~');
- // compnt.showAlert('您已经订购了本产品~');
- // unicom.saveUserInfo();
- // WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- // // showFlowPage();
- // break;
- default:
- //showAlertDialog('orderFailure', response.errorInfo + ',订购失败,请确定用户套餐!');
- showAlerts(response.errorInfo + ',订购失败,请确定用户套餐!');
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- break;
- }
- }).fail(function(error) {
- compnt.hideLoading();
- console.log(error);
- });
- }
|