12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022 |
- 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('draw202204.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("draw202204.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/draw202204.html?fes=9ur&sou=26'
- // gotoUrl('douyin/15/draw202204')
- // })
- $('#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 3:
- showAlerta('芒果TV PC移动影视会员周卡')
- break;
- case 4:
- showAlerta('美团外卖5元红包')
- break;
- case 5:
- 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 3:
- var vipcode = 50001
- break;
- case 4:
- var vipcode = 13004
- break;
- default:
- // console.log(call)
- break;
- }
- if (vipcode == 60001) {
- compnt.showAlert('权益已领完,请选择其他权益!');
- $overlay.remove();
- $dialog.remove();
- $dialog = null;
- } else {
- console.log(account, vipcode, usermob, name_b, unicom.name_a)
- deaw(account, vipcode, usermob, name_b, unicom.name_a)
- $("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);
- });
- }
|