123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346 |
- import * as compnt from "../../../../public/js/compnt.js";
- import * as unicom from "../../../../public/js/unicom.js";
- import "../scss/main.scss";
- var douyinProductId = "2018072301";
- var douyinPreProductId = "2020031101";
- var baiduProductId = "2020021201";
- var baiduPreProductId = "2020071301";
- $(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');
- }
- compnt.showLoading();
- unicom.init().then(function(response) {
- compnt.hideLoading();
- unicom.product = unicom.products[douyinProductId];
- unicom.fesname = response.festival;
- unicom.loadUserInfo();
- if (location.href.indexOf("index.html") >= 0) {
- showOrderPage();
- } else {
- openPage();
- }
- if (location.href.indexOf('/cancel') >= 0) {
- unicom.burypointLogId('110002');// 退订页面pv, pv去重得到uv
- } else if (location.href.indexOf('/draw') >= 0) {
- unicom.burypointLogId('110003');// 领取页面pv, pv去重得到uv
- } else if (location.href.indexOf('/flow') >= 0) {
- unicom.burypointLogId('110004');// 流量查询pv, pv去重得到uv
- } else if (location.href.indexOf('/active') >= 0) {
- unicom.burypointLogId('110005');// 激活页面pv, pv去重得到uv
- } else if (location.href.indexOf('/refund') >= 0) {
- unicom.burypointLogId('110006');// 退款
- } else {
- // location.href.indexOf('/index') >= 0
- // location.href.indexOf('/order') >= 0
- unicom.burypointLogId('110001');// 订购页面pv, pv去重得到uv
- }
- })
- }
- 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;
- }
- }
- $('#gotoCancel').unbind('click').on('click', function () {
- if ($douyinItem.hasClass('active')) {
- unicom.product = unicom.products[douyinProductId];
- } else {
- unicom.product = unicom.products[baiduProductId];
- }
- showCancelPage(unicom.product.productid);
- })
- $('.more .text').unbind('click').on('click', function() {
- showDialogAgr()
- })
- 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');
- unicom.product = unicom.products[douyinProductId];
- // console.log(unicom.product);
- })
- $baiduItem.unbind('click').on('click', function() {
- $douyinItem.removeClass('active');
- $baiduItem.addClass('active');
- unicom.product = unicom.products[baiduProductId];
- // console.log(unicom.product);
- })
- 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=" + unicom.query.fes + "&sou=" + unicom.query.sou;
- return;
- }
- $('#btn-order').unbind('click').on('click', function (event) {
- if (!compnt.lockClick()) {
- return;
- }
- if ($douyinItem.hasClass('active')) {
- unicom.product = unicom.products[douyinProductId];
- } else {
- unicom.product = unicom.products[baiduProductId];
- }
- unicom.showCapPage(null, null, false, false, true, null).then(function (data) {
- compnt.unlockClick();
- order(data.userid, data.token, data.usermob);
- }).fail(function(response) {
- compnt.unlockClick();
- })
- })
- $('.modify').unbind('click').on('click', function (event) {
- if (!compnt.lockClick()) {
- return;
- }
- if ($douyinItem.hasClass('active')) {
- unicom.product = unicom.products[douyinPreProductId];
- } else {
- unicom.product = unicom.products[baiduPreProductId];
- }
- unicom.showCapPage(null, null, false, false, true, null).then(function (data) {
- compnt.unlockClick();
- order(data.userid, data.token, data.usermob);
- }).fail(function(response) {
- compnt.unlockClick();
- })
- })
- }
- function showCancelPage(productid) {
- if (location.href.indexOf("cancel.html") < 0) {
- window.location.href = "cancel.html?fes=" + unicom.query.fes + "&sou=" + unicom.query.sou + "&productid=" + productid;
- return;
- }
- unicom.product = unicom.products[unicom.query.productid]
- var $container = $('.sms-form').find('.form-group');
- $container.find('.sendcode').unbind('click').on('click', function () {
- unicom.sendSms($container, 'cancellogin');
- })
- $container.find('.login').unbind('click').on('click', function () {
- compnt.showLoading();
- unicom.checkCode($container).done(function() {
- unicom.choiceCancel().done(function(response) {
- compnt.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) {
- compnt.hideLoading();
- })
- }).fail(function(data) {
- compnt.hideLoading();
- })
- })
- window.scrollTo(0, 0)
- }
- /**
- * 订购
- */
- function order(userid, token, usermob) {
- compnt.showLoading('处理中,请稍后...');
- unicom.choiceOrder(userid, token, usermob).done(function(response) {
- compnt.hideLoading();
- switch (response.resultCode) {
- case "0000": //订购成功!跳转到领取会员页面
- unicom.saveUserInfo();
- showDialogMessage('订购成功');
- return;
- case "0013":
- showDialogMessage('该号码归属省分2/3G暂未开通此产品!');
- break;
- case "6611":
- showDialogMessage('错误代码(6611),订购失败,请重试!');
- break;
- case "6615":
- showDialogMessage('订购失败,请确定用户套餐!');
- break;
- case "6622": // 用户已订购过此产品!跳转到流量查页面
- unicom.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) {
- compnt.hideLoading();
- console.log(error);
- });
- }
- function showDialogMessage(message) {
- var replaceString = '';
- if (unicom.product.productid == baiduPreProductId
- || unicom.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 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;
- }
|