123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877 |
- import * as compnt from "../../../public/js/compnt";
- import * as unicom from "../../../public/js/unicom.js";
- import * as weibo from "./weibo.js";
- import "../scss/main.scss";
- weibo.checkClientEnvironment();
- compnt.showLoading();
- var message = localStorage.getItem('message');
- if (message != null && message != '') {
- compnt.showAlert(message);
- localStorage.removeItem('message');
- }
- $('#btn-cancel').unbind('click').on('click', function() {
- showCancelReasonPage().done(function(cancelReason) {
- var k = JSON.stringify(cancelReason)
- window.localStorage.setItem('kye', k)
- showCancelPage()
- })
- })
- $('#btn-draw').unbind('click').on('click', function() {
- if (!checkEquip('draw')) return;
- showDrawPage();
- })
- $('#btn-active').unbind('click').on('click', function() {
- if (!checkEquip('active')) return;
- showActivePage();
- })
- if (weibo.app.weibo) {
- function bridgeReady() {
- if (weibo.checkWeiboVersion()) {
- weibo.getUserInfo().then(function() {
- init();
- }).fail(function(data) {
- init();
- });
- } else {
- weibo.getUserInfo();
- init();
- }
- }
- if (window.WeiboJSBridge) {
- bridgeReady();
- } else {
- document.addEventListener('WeiboJSBridgeReady', function() {
- bridgeReady();
- });
- }
- } else {
- // 不的app中
- // 1、如果没有fes和sou参数
- // 2、code
- init();
- }
- function showCancelReasonPage() {
- var reasonUrl;
- var baseUrl;
- if (window.location.href.indexOf("https://800.wo.cn/orderchannel") >= 0) {
- reasonUrl = "https://800.wo.cn/orderchannel/public/libs/cancelreason/index.html";
- baseUrl = "https://800.wo.cn/";
- } else if (window.location.href.indexOf("https://800.wo.cn/festivalchannel") >= 0) {
- reasonUrl = "https://800.wo.cn/festivalchannel/public/libs/cancelreason/index.html";
- baseUrl = "https://800.wo.cn/";
- } else if (window.location.href.indexOf("http://localhost") >= 0) {
- reasonUrl = "http://localhost:8088/orderchannel/public/libs/cancelreason/index.html";
- baseUrl = "http://localhost:8088/";
- } else if (window.location.href.indexOf("http://127.0.0.1") >= 0) {
- reasonUrl = "http://127.0.0.1:8088/orderchannel/public/libs/cancelreason/index.html";
- baseUrl = "http://127.0.0.1:8088/";
- } else if (window.location.href.indexOf("http://100.0.4.69:3344") >= 0) {
- reasonUrl = "http://100.0.4.69:3344/orderchannel/public/libs/cancelreason/index.html";
- baseUrl = "http://100.0.4.69:3344/";
- } else if (window.location.href.indexOf("http://100.0.4.69:8282") >= 0) {
- reasonUrl = "http://100.0.4.69:8282/orderchannel/public/libs/cancelreason/index.html";
- baseUrl = "http://100.0.4.69:8282/";
- } else {
- reasonUrl = "https://800.wo.cn/orderchannel/public/libs/cancelreason/index.html";
- baseUrl = "https://800.wo.cn/";
- }
- window.$capoverlay = $('<div class="overlay" style="z-index: 0; background-color: rgba(0,0,0,0.4);"></div>');
- $capoverlay.appendTo($(document.body));
- $("body").css("overflow", "hidden");
- var $iframe;
- if ($('#reasonIframe').length >= 1) {
- $iframe = $('#reasonIframe').attr('src', reasonUrl);
- } else {
- $iframe = $('<iframe id="reasonIframe" src="' + reasonUrl + '"></iframe>');
- $('body').append($iframe);
- }
- $iframe.css({
- width: "100%",
- height: "100%",
- position: "fixed",
- top: 0,
- left: 0,
- margin: 0,
- padding: 0,
- "-webkit-overflow-scrolling": "touch",
- border: "0px",
- "z-index": 111,
- });
- var def = $.Deferred();
- function messageListener(event) {
- var data = JSON.parse(event.data);
- $iframe.remove();
- $capoverlay.remove();
- $("body").css("overflow", "auto");
- window.removeEventListener('message', messageListener);
- if (data.eventtype != 'close') {
- def.resolve(data)
- } else {
- def.reject(data)
- }
- }
- window.addEventListener('message', messageListener);
- return def;
- }
- function init() {
- unicom.init().then(function(response) {
- unicom.product = response.product[0];
- unicom.fesname = response.festival;
- loadUserInfo();
- // compnt.showAlert(JSON.stringify(unicom.user))
- // compnt.showAlert(weibo.uid)
- // weibo.uid = "2245755811"; // 未订购
- // weibo.uid = "5345323620"; // 已经订购
- if (location.href.indexOf("index.html") >= 0) {
- if (unicom.user.userid) {
- openPage("flow");
- } else if (weibo.uid) {
- unicom.queryMember(null, null, weibo.uid).then(function(response) {
- if (response.resultCode == "0000") {
- unicom.user.userid = response.userid;
- // 已经领取微博会员的手机号码
- unicom.user.usermob = response.usermob;
- unicom.user.usertime = new Date().getTime();
- showFlowPage(response);
- compnt.hideLoading();
- }
- }).fail(function() {
- // compnt.showAlert("asdasd");
- });
- }
- compnt.hideLoading();
- showOrderPage();
- } else {
- openPage(unicom.query.page);
- compnt.hideLoading();
- }
- /*unicom.user.userid = "18674842761";
- unicom.user.usermob = '17610768237'
- showFlowPage();*/
- 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 ||
- location.href.indexOf('/weibo1') >= 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) })
- }
- }).fail(function() {
- compnt.hideLoading();
- })
- }
- function openPage(pageName) {
- switch (pageName) {
- case "active":
- showActivePage();
- break;
- case "cancel":
- showCancelPage();
- break;
- case "draw":
- weibo.getUserInfo().then(function() {
- document.getElementById('name').innerHTML = weibo.screen_name
- })
- showDrawPage();
- break;
- case "flow":
- showFlowPage();
- break;
- default:
- showOrderPage();
- break;
- }
- }
- function loadUserInfo() {
- if (unicom.query.userid) {
- unicom.user.userid = unicom.query.userid;
- unicom.user.usermob = unicom.query.usermob;
- return;
- }
- try {
- var time = localStorage.getItem('time');
- if (time) {
- var curr = new Date().getTime();
- if (curr <= parseFloat(time) + (1000 * 60 * 60)) {
- var userString = localStorage.getItem("user");
- var user = JSON.parse(userString);
- unicom.user.userid = user.userid;
- unicom.user.usermob = user.usermob;
- if (unicom.user.usermob == "18674842761") {
- setTimeout(function() {
- alert(time + (1000 * 60 * 60))
- }, 100);
- }
- } else {
- localStorage.removeItem("time")
- localStorage.removeItem("user")
- }
- }
- } catch (e) {
- }
- }
- /**
- * 显示流量查询页面
- */
- function showFlowPage() {
- if (location.href.indexOf("flow.html") < 0) {
- window.location.href = "flow.html?fes=" +
- unicom.query.fes + "&sou=" + unicom.query.sou + "&F=" + unicom.query.F +
- "&userid=" + unicom.user.userid + "&usermob=" + unicom.user.usermob +
- "&usertime=" + (unicom.user.usertime || (new Date().getTime())) + "&page=flow";
- return;
- }
- if (localStorage.getItem('action') == 'draw') {
- if (!checkEquip('draw')) return;
- unicom.can(weibo.uid).then(function(response) {
- if (response.resultCode == "0000") {
- draw();
- }
- });
- localStorage.removeItem('action');
- }
- var $container = $('#section-flow');
- $container.find('.phone').html('流量专属号码:' + unicom.user.usermob);
- queryFlow();
- $container.find('.btn').unbind('click').on('click', function(event) {
- if (!compnt.lockClick()) {
- return;
- }
- queryFlow().then(function(message) {
- compnt.unlockClick()
- if (message != null && message != "") {
- compnt.showAlert(message);
- }
- });
- })
- $container.find('.member a').unbind('click').on('click', function() {
- if (!checkEquip('draw')) return;
- // alert(weibo.screen_name)
- // 如果有用户号码,直接打开领取会员二次确认的提示
- unicom.can(weibo.uid).then(function(response) {
- switch (response.resultCode) {
- case "0000":
- if (unicom.user.userid) {
- draw();
- } else {
- showDrawPage();
- }
- break;
- case "1003":
- compnt.showAlert('当前微博账号已开通了新浪微博包月会员,请切换领取会员的账号~');
- break;
- default:
- compnt.showAlert(response.resultInfo);
- break;
- }
- });
- })
- if (weibo.app.weibo && weibo.checkWeiboVersion() && (weibo.uid == null || weibo.uid == '')) {
- weibo.getUserInfo().then(function() {
- unicom.queryMember().then(function(response) {
- showMemberInfo(response)
- });
- })
- } else {
- unicom.queryMember().then(function(response) {
- showMemberInfo(response)
- });
- }
- function showMemberInfo(response) {
- switch (response.resultCode) {
- case "0000":
- switch (response.sync_code) {
- case "0": // 订购关系退订同步成功
- case "2": // 订购关系订购同步成功
- if (response.screen_name) {
- $container.find('.member').html('微博账号:' + decodeURIComponent(response.screen_name));
- } else {
- $container.find('.member').html('微博会员:已领取');
- }
- $container.find('.vflag').css({ "display": "block" });
- $container.find('.member a').unbind('click');
- weibo.active(); // 静默激活
- break;
- default:
- $container.find('.member a').html('请点此领取微博会员');
- // 隐藏微博会员图标
- $container.find('.vflag').css({ "display": "none" })
- break;
- }
- break;
- case "1015": //{"resultCode":"1015","errorInfo":"用户未订购此产品!"}
- compnt.showAlert("未订购此产品!").then(function(message) {
- localStorage.removeItem('time');
- localStorage.removeItem('user')
- showOrderPage();
- $container.find('.phone').html('用户未订购此产品!');
- });
- break;
- default:
- break;
- }
- }
- }
- /**
- * 查询用户剩余流量
- */
- function queryFlow() {
- var $container = $('#section-flow');
- var def = $.Deferred();
- unicom.queryFlow().then(function(response) {
- switch (response.resultCode) {
- case "0000":
- var surplus = compnt.returnFloat(JSON.parse(response.data).surplusFlow / 1024 / 1024);
- $container.find('.suplus').html('本月剩余<br>' + 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>10.00GB');
- break;
- default:
- break;
- }
- })
- return def;
- }
- /**
- * 打开退订页面
- */
- function showCancelPage() {
- var cancelReason = JSON.parse(window.localStorage.getItem('kye'))
- if (location.href.indexOf("cancel.html") < 0) {
- window.location.href = "cancel.html?fes=" + unicom.query.fes + "&sou=" +
- unicom.query.sou + "&F=" + unicom.query.F + '&page=cancel';
- return;
- }
- var $container = $('#section-cancel').find('.form-group');
- $container.find('.sendcode').unbind('click').on('click', function() {
- unicom.sendSms($container, 'cancellogin');
- //unicom.sendSms($container, '212');
- 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).then(function() {
- unicom.cancel(null, null, cancelReason.canceltype, cancelReason.cancelmsg).then(function(response) {
- compnt.hideLoading();
- switch (response.resultCode) {
- case "0000":
- compnt.showAlert('退订成功').then(function(message) {
- window.localStorage.clear()
- 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 showDrawPage() {
- if (location.href.indexOf("draw.html") < 0 &&
- location.href.indexOf("weibo1.html") < 0) {
- window.location.href = "draw.html?fes=" + unicom.query.fes + "&sou=" +
- unicom.query.sou + "&F=" + unicom.query.F + '&page=draw';
- return;
- }
- var $container = $('#section-draw').find('.form-group');
- compnt.showLoading();
- unicom.queryMember(null, null, weibo.uid).then(function(response) {
- if (response.resultCode == "0000") {
- switch (response.sync_code) {
- case "0": // 订购关系退订同步成功
- case "2": // 订购关系订购同步成功
- localStorage.setItem("message", "当前微博账号已经领取了会员~");
- unicom.user.userid = response.userid;
- unicom.user.usermob = response.usermob;
- unicom.user.usertime = new Date().getTime();
- showFlowPage();
- break;
- }
- } else {
- unicom.can(weibo.uid).then(function(response) {
- compnt.hideLoading();
- var hasMonthVip = false;
- switch (response.resultCode) {
- case "0000":
- hasMonthVip = false;
- break;
- case "1003":
- compnt.showAlert('当前微博账号已开通了新浪微博包月会员,请切换领取会员的账号~');
- hasMonthVip = true;
- break;
- default:
- compnt.showAlert(response.resultInfo);
- break;
- }
- $container.find('.sendcode').unbind('click').on('click', function() {
- if (!checkEquip()) return;
- if (hasMonthVip) {
- compnt.showAlert('当前微博账号已开通了新浪微博包月会员,请切换领取会员的账号~');
- return;
- }
- unicom.sendSms($container, 'drawlogin');
- // unicom.sendSms($container, '210');
- 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() {
- if (hasMonthVip) {
- compnt.showAlert('当前微博账号已开通了新浪微博包月会员,请切换领取会员的账号~');
- return;
- }
- unicom.checkCode($container).then(function() {
- draw()
- })
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'draw_click_confirm_btn' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- })
- }).fail(function(error) {
- // alert(JSON.stringify(error))
- })
- }
- })
- }
- function draw() {
- var $dialog = showConfirmDialog();
- $dialog.find('.btn-no').on('click', function() {
- compnt.showAlert('请切换登录的微博账号后,再领取会员')
- })
- $dialog.find('.btn-ok').on('click', function(event) {
- if (!compnt.lockClick()) return;
- unicom.drawMember(weibo.uid, weibo.screen_name).then(function(response) {
- compnt.unlockClick();
- switch (response.resultCode) {
- case "0000":
- weibo.active(); // 领取成功,静默激活
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'draw_success' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- compnt.showAlert('微博会员领取成功!').then(function() {
- showFlowPage();
- });
- break;
- case "1020":
- // 已经领取,领取的账号与当前微博账号一致,静默激活
- unicom.queryMember().then(function(response) {
- if (response.resultCode == "0000") {
- if (response.uid == weibo.uid) {
- weibo.active();
- compnt.showAlert('已领取过会员~').then(function(message) {
- showFlowPage();
- });
- } else { // 领取到了其他微博账号
- compnt.showAlert('该手机号已将会员领取到其他微博账号~')
- }
- } else { // 查询失败
- compnt.showAlert('已领取过会员~');
- }
- }).fail(function() {
- // 查询失败
- compnt.showAlert('已领取过会员~');
- })
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'draw_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
- break;
- default:
- 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;
- }
- }).fail(function() {
- compnt.unlockClick();
- });
- })
- }
- /**
- * 打开激活免流的页面
- * 客户端中才能激活
- */
- function showActivePage() {
- if (location.href.indexOf("active.html") < 0) {
- window.location.href = "active.html?fes=" + unicom.query.fes + "&sou=" +
- unicom.query.sou + "&F=" + unicom.query.F + "&page=active";
- return;
- }
- var $container = $('#section-active').find('.form-group');
- $container.find('.sendcode').unbind('click').on('click', function() {
- if (!checkEquip('active')) return;
- unicom.sendSms($container, 'activelogin');
- //unicom.sendSms($container, '209');
- })
- $container.find('.login').unbind('click').on('click', function(event) {
- if (!checkEquip('active')) return;
- if (!compnt.lockClick()) {
- return;
- }
- unicom.checkCode($container).then(function() {
- compnt.unlockClick()
- active()
- }).fail(function() {
- compnt.unlockClick();
- });
- })
- window.scrollTo(0, 0)
- }
- function checkEquip(action) {
- if (action == 'active') {
- if (!weibo.app.weibo) {
- compnt.showAlert('请到新浪微博客户端中激活免流~')
- return false;
- }
- if (!weibo.checkWeiboVersion()) {
- compnt.showAlert('请到升级到最新版新浪微博客户端后激活免流~')
- return false;
- }
- } else {
- if (!weibo.app.weibo && !unicom.query.code) {
- compnt.showAlert('请到新浪微博客户端中领取会员激活免流~')
- return false;
- }
- if (!weibo.checkWeiboVersion() && !unicom.query.code) {
- compnt.showAlert('请到升级到最新版新浪微博客户端后领取会员激活免流~')
- return false;
- }
- }
- return true;
- }
- function active() {
- unicom.queryMember().then(function(response) {
- switch (response.resultCode) {
- case "0000":
- break;
- case "0002":
- compnt.showAlert('激活失败,未领取新浪微博会员~');
- return;
- default:
- compnt.showAlert('激活失败,未领取新浪微博会员~');
- return;
- }
- if (weibo.uid != response.uid) {
- compnt.showAlert('激活失败,激活免流的微博账号与领取会员的微博账号不一致~');
- return;
- }
- switch (response.sync_code) {
- case "0": // 订购关系退订同步成功
- case "2": // 订购关系订购同步成功
- weibo.active().then(function() {
- //checkActiveResult();
- compnt.showAlert('激活成功').then(function() {
- localStorage.setItem('user', JSON.stringify(unicom.user));
- localStorage.setItem('time', new Date().getTime());
- showFlowPage();
- });
- })
- break;
- case "1": // 订购关系退订同步失败
- case "3": // 订购关系订购同步失败
- compnt.showAlert("请领取会员以后再进行激活操作~");
- break;
- }
- });
- }
- /**
- * 打开订购页面
- */
- function showOrderPage() {
- $('.section-banner').removeClass('section-banner-small');
- $('#btn-order').unbind('click').on('click', function(event) {
- if (!compnt.lockClick()) {
- //alert(1)
- return;
- }
- unicom.showCapPage().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 order(userid, token, usermob) {
- compnt.showLoading();
- unicom.order(userid, token, usermob).then(function(response) {
- // console.log(response)
- compnt.hideLoading();
- switch (response.resultCode) {
- case "0000": //订购成功!跳转到领取会员页面
- // compnt.showAlert('unicom.user.userid:' + unicom.user.userid)
- // var versionFulfil = weibo.checkWeiboVersion();
- // alert('checkWeiboVersion()' + versionFulfil);
- localStorage.setItem('user', JSON.stringify(unicom.user));
- localStorage.setItem('time', new Date().getTime());
- // 客户端中进入领取页面,非客户端中,提示用户到客户端中去领取
- if (weibo.app.weibo && weibo.checkWeiboVersion()) {
- // 如果有用户号码,直接打开领取会员二次确认的提示
- compnt.showAlert('订购成功~').then(function(message) {
- localStorage.setItem('action', 'draw');
- showFlowPage();
- });
- } else {
- compnt.showAlert('订购成功,请到新浪微博客户端中领取会员开启免流~').then(function() {
- showFlowPage();
- })
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_success' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) });
- return;
- }
- break;
- case "0013":
- showOrderDialog('该号码归属省分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":
- showOrderDialog('错误代码(6611),' + '订购失败,请重试!');
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) });
- break;
- case "6615":
- showOrderDialog('订购失败,请确定用户套餐!');
- 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', '您已经订购了本产品~');
- localStorage.setItem('user', JSON.stringify(unicom.user));
- localStorage.setItem('time', new Date().getTime());
- showFlowPage();
- WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) });
- break;
- default:
- showOrderDialog(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) {});
- }
- function showOrderDialog(message) {
- var $overlay = $('<div class="overlay"></div>');
- var $dialog = $(
- '<div class="dialog dialog-order">' +
- ' <div class="face">' +
- ' <img src="images/face-sad.png">' +
- ' </div>' +
- ' <h2>对不起,订购失败!</h2>' +
- ' <p>' + message + '</p>' +
- ' <div class="btn">我知道了</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 showConfirmDialog() {
- var message = '确认将新浪微博会员领取到您当前登录的账号中吗?';
- if (weibo.screen_name) {
- message = '请确认将新浪微博会员领取到账号:' + weibo.screen_name
- }
- var $overlay = $('<div class="overlay"></div>');
- var $dialog = $(
- '<div class="dialog dialog-confirm">' +
- ' <h2>领取会员</h2>' +
- ' <p>' + message + '</p>' +
- ' <div class="actions" style="display: flex;">' +
- ' <div class="btn btn-no">其他账号</div>' +
- ' <div class="btn btn-ok">确认</div>' +
- ' </div>' +
- '</div>');
- $overlay.appendTo($(document.body))
- $dialog.appendTo($(document.body))
- $dialog.find('.btn').on('click', function() {
- $dialog.close()
- })
- $dialog.close = function() {
- $overlay.remove();
- $dialog.remove();
- $dialog = null;
- }
- return $dialog;
- }
|