123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309 |
- import * as compnt from "../../../../public/js/compnt.js";
- import * as unicom from "../../../../public/js/unicom.js";
- import "../scss/main.scss";
- $(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 != '') {
- 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.query.ringid = '';
- unicom.loadUserInfo();
- if (location.href.indexOf("/index") >= 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 showAlertDialog(message) {
- var $overlay = $('<div class="overlay"></div>');
- var $dialog = $(
- '<div class="dialog dialog-message">' +
- ' <div class="status"></div>' +
- ' <div class="title"></div>' +
- ' <div class="content">' +
- ' <img src="./v1/images/order-success.jpg">' +
- ' </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;
- $('body').css('overflow', 'auto')
- }
- $('body').css('overflow', 'hidden')
- return $dialog;
- }
- function showPlayerDialog(src, poster) {
- var $dialog = $(
- '<div class="dialog-player">' +
- ' <div class="content">' +
- ' <div class="close"></div>' +
- ' <video id="video1" src="' + src + '" poster="' + poster + '"' +
- ' controls ' +
- ' playsinline="true"' +
- ' webkit-playsinline="true"' +
- ' x-webkit-airplay="true"' +
- ' x5-video-player-type="h5"' +
- ' x5-video-player-fullscreen="true"' +
- ' x5-video-ignore-metadata="true">' +
- ' </video>' +
- ' </div>' +
- '</div>');
- $dialog.appendTo($(document.body))
- $dialog.find('.close').unbind('click').on('click', function () {
- $dialog.close()
- })
- $dialog.close = function () {
- $dialog.remove();
- $dialog = null;
- $('body').css('overflow', 'auto')
- }
- $('body').css('overflow', 'hidden')
- var video = document.getElementById("video1");
- video.play();
- return $dialog;
- }
- function openPage(pageName) {
- if (pageName == null) {
- if (location.href.indexOf("index.html") >= 0) pageName = "order";
- if (location.href.indexOf("cancel.html") >= 0) pageName = "cancel";
- if (location.href.indexOf("draw.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":
- showDrawPage();
- break;
- case "flow":
- showFlowPage();
- break;
- default:
- showOrderPage();
- break;
- }
- }
- $('#btn-cancel').unbind('click').on('click', function () {
- showCancelPage();
- })
- function showOrderPage(backPage) {
- if (location.href.indexOf('/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) {
- if (!compnt.lockClick()) {
- return;
- }
- unicom.showCapPage().then(function (data) {
- compnt.unlockClick();
- order(data.userid, data.token, data.usermob, unicom.query.ringid);
- }).fail(function(response) {
- compnt.unlockClick();
- })
- })
- $('.rbt-item').find('.status').on('click', function(obj) {
- if (unicom.query.ringid == $(obj.currentTarget).attr('ringid')) {
- return;
- }
- $('.rbt-item').find('.status').each(function(i, item) {
- if ($(item).hasClass('status-checked')) {
- $(item).removeClass('status-checked').addClass('status-unchecked')
- } else {
- $(item).removeClass('status-unchecked').addClass('status-checked')
- unicom.query.ringid = $(item).attr('ringid')
- }
- });
- })
- $('.rbt-item').find('.rbt-cover').each(function(i, item) {
- $(item).on('click', function(obj) {
- var src = $(obj.currentTarget).attr('src');
- var poster = $(obj.currentTarget).attr('poster');
- showPlayerDialog(src, poster);
- })
- })
- }
- function showCancelPage() {
- if (location.href.indexOf("cancel.html") < 0) {
- window.location.href = "cancel.html?fes=" + unicom.query.fes + "&sou=" + unicom.query.sou;
- return;
- }
- var $container = $('.sms-form');
- $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.cancel().done(function(response) {
- compnt.hideLoading();
- switch (response.resultCode) {
- case "0000":
- compnt.showAlert('退订成功');//.then(function(message) {
- //showFlowPage();
- //});
- break;
- case "7605": //应该是已经退订了吧,因此不需要在重复退订啦
- compnt.showAlert(response.errorInfo);//.then(function(message) {
- //showFlowPage();
- //});
- break;
- default:
- var prefix = '';
- if (response.errorInfo.indexOf('退订失败') < 0) {
- prefix = '退订失败,';
- }
- compnt.showAlert(prefix + response.errorInfo);
- break;
- }
- }).fail(function(data) {
- compnt.hideLoading();
- })
- }).fail(function(data) {
- compnt.hideLoading();
- })
- })
- window.scrollTo(0, 0)
- }
- /**
- * 订购
- */
- function order(userid, token, usermob, ringid) {
- compnt.showLoading('处理中,请稍后...');
- unicom.order(userid, token, usermob).done(function(response) {
- compnt.hideLoading();
- switch (response.resultCode) {
- case "0000": //订购成功!跳转到领取会员页面
- unicom.saveUserInfo();
- compnt.showAlert('订购成功!');
- return;
- case "0013":
- compnt.showAlert('该号码归属省分2/3G暂未开通此产品!');
- break;
- case "6611":
- compnt.showAlert('错误代码(6611),订购失败,请重试!');
- break;
- case "6615":
- compnt.showAlert('订购失败,请确定用户套餐!');
- break;
- case "6622": // 用户已订购过此产品!跳转到流量查页面
- // localStorage.setItem('message', '您已经订购了本产品~');
- compnt.showAlert('您已经订购了本产品~')
- unicom.saveUserInfo();
- break;
- default:
- compnt.showAlert(response.errorInfo + ',订购失败,请确定用户套餐!');
- break;
- }
- }).fail(function (error) {
- compnt.hideLoading();
- console.log(error);
- });
- }
|