// 南研一键登录测试程序
import * as compnt from "../../../public/js/compnt.js";
import * as unicom from "../../../public/js/unicom.js";
import "../scss/stackpkg.scss";
import "../../../public/scss/unicom.scss";
init();
function init() {
compnt.showLoading();
unicom.init().then(function(response) {
compnt.hideLoading();
unicom.setProduct(response.product[0]);
unicom.setFesname(response.festival);
var cacheTime = localStorage.getItem(unicom.query.code);
if (new Date().getTime() - cacheTime > 1000 * 60 * 60 * 24 * 30) {
localStorage.removeItem(unicom.query.code)
}
if (!!unicom.query.code && cacheTime == null) {
localStorage.setItem(unicom.query.code, new Date().getTime())
unicom.oneClickLogin(unicom.query.code).then(function(userid) {
orderBack();
}).fail(function(data) {
compnt.hideLoading();
})
}
if (!!unicom.query.tradeno) {
showPayQueryDialog();
}
bindSend();
bindOrder();
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 {
// location.href.indexOf('/index') >= 0
// location.href.indexOf('/order') >= 0
unicom.burypointLogId('110001');// 订购页面pv, pv去重得到uv
}
})
bindShowAgr();
}
function bindSend() {
// @ts-ignore
var $container = $('.section-login').find('.form-group');
$container.find('.sendcode').unbind('click').on('click', function () {
unicom.sendSms($container, 'orderlogin');
})
}
function bindOrder() {
// @ts-ignore
var $container = $('.section-login').find('.form-group');
$container.find('.login').unbind('click').on('click', function () {
/*compnt.showLoading();
unicom.checkCode($container).then(function() {
orderBack();
}).fail(function(data) {
compnt.hideLoading();
})*/
var cbUrl = 'https://800.wo.cn/festivalchannel/back/stackpkg/order.html?fes=9up&sou=49';
window.location.href = 'https://account.bol.wo.cn/cuuser/unity/redirectOnekeyLogin?clientId=directflow&redirectUrl=' + encodeURIComponent(encodeURIComponent(cbUrl))
})
}
function orderBack() {
unicom.orderBack().then(function(response) {
// console.log(response)
compnt.hideLoading();
var data = response;
switch (data.resultCode) {
case "0000":
// compnt.showAlert('领取成功');
// window.location.reload();
// alert(data.web_url + '&redirect_url=' + encodeURIComponent(window.location.href + '&tradeno=' + data.out_trade_no));
data.tradedate = unicom.getNowFormatDate();
data.userid = unicom.user.userid;
pay(data);
break;
default:
compnt.showAlert(response.errorInfo);
break;
}
}).fail(function(data) {
compnt.hideLoading();
})
}
function bindShowAgr() {
$('#btn-showagr').on('click', function() {
showAgr();
})
}
function showAgr() {
var $overlay = $('
');
var $dialog = $(
'' +
'
' +
'
![](./images/close.png)
' +
'
' +
'
' +
'
![](./images/label-active.png)
' +
'
' +
'
' +
'
' +
'
![](./images/label-busi.png)
' +
'
' +
'
' +
'
' +
' - ' +
'
符合订购约定的中国联通手机(除冰激凌套餐、懂我卡)4G套餐用户均可订购“今日头条定向流量10GB月包(后向)”。其中,4G套餐中的全国共享组合套餐、4G全国套餐主副卡用户和智慧沃家共享套餐中手机用户等共享类套餐用户的手机号码不共享后向定向流量包。手机套餐中流量资费、流量使用规则另有约定的,按照手机套餐执行。
' +
' ' +
' - ' +
'
“今日头条定向流量10GB月包(前向)”和“今日头条定向流量10GB月包(后向)”两者可以叠加订购;叠加订购时,先消耗“今日头条定向流量10GB月包(前向)”中的定向流量,再消耗“今日头条定向流量10GB月包(后向)”中的定向流量,都超出后按照用户所选套餐资费或标准资费及联通公司已审批备案公示的资费标准收取。
' +
' ' +
' - ' +
'
用户须处于正常可用状态下才可订购,处于紧急停机(挂失)、欠费停机、停机保号等状态的后付费用户及处于未激活器、充值期、锁定期的预付费用户不可办理。
' +
' ' +
' - ' +
'
UNINET、3GNET 、WONET接入点访问能使用该定向流量,其他接入点不能免流使用。
' +
' ' +
' - ' +
'
国内指中国内地,不包含港、澳、台地区。
' +
' ' +
' - ' +
'
用户成功订购该头条系流量包后,如果遇到页面提示不免流,敬请忽略,正常使用。
' +
' ' +
'
' +
'
' +
'
'
)
$overlay.appendTo($(document.body))
$dialog.appendTo($(document.body))
$dialog.find('img[name="closeBtn"]').on('click', function() {
$dialog.close();
})
$dialog.close = function () {
$overlay.remove();
$dialog.remove();
$dialog = null;
}
}
function showPayQueryDialog() {
var $overlay = $('');
var $dialog = $(
'' +
'
' +
' 请确认微信支付是否已完成' +
'
' +
'
' +
' 已完成支付' +
'
' +
'
' +
' 支付遇到问题,重新支付' +
'
' +
'
');
$overlay.appendTo($(document.body))
$dialog.appendTo($(document.body))
$dialog.find('span[name="finishspan"]').on('click', function() {
queryWxPay(decodeURIComponent(unicom.query.userid));
})
$dialog.find('span[name="repayspan"]').on('click', function() {
var data = {
userid: decodeURIComponent(unicom.query.userid),
web_url: decodeURIComponent(unicom.query.payurl),
out_trade_no: unicom.query.tradeno,
tradedate: unicom.query.tradedate
}
// alert(JSON.stringify(data))
pay(data);
})
}
function pay(data) {
var href = window.location.href;
if (href.indexOf("&tradeno") > 0) {
href = href.substring(0, href.indexOf("&tradeno"));
}
window.location.href = data.web_url +
'&redirect_url=' + encodeURIComponent(href +
'&tradeno=' + data.out_trade_no +
'&tradedate=' + data.tradedate +
'&userid=' + encodeURIComponent(encodeURIComponent(data.userid)) +
'&payurl=' + encodeURIComponent(encodeURIComponent(data.web_url)));
}
function queryWxPay(userid) {
unicom.queryWxPay(unicom.query.tradeno, unicom.query.tradedate, userid).then(function(response) {
var result = response;
if (result.resultCode == "0000" && result.trade_state == "SUCCESS") {
compnt.showAlert('支付成功,请注意接收通知短信。').then(function(response) {
window.location.href = window.location.href.replace("tradeno", "tno");
});
return;
}
$('.dialog-pay').css('display', 'none');
switch(result.trade_state) {
case "REFUND":
compnt.showAlert('订购失败,转入退款').then(function() {
$('.dialog-pay').css('display', 'block');
window.location.href = unicom.root + "-s1api" + '/back/stackpkg/index.html?'
});
break;
case "NOTPAY":
compnt.showAlert('未支付').then(function() {
$('.dialog-pay').css('display', 'block');
});
break;
case "CLOSED":
compnt.showAlert('已关闭').then(function() {
$('.dialog-pay').css('display', 'block');
});
break;
case "REVOKED":
compnt.showAlert('已撤销(付款码支付)').then(function() {
$('.dialog-pay').css('display', 'block');
});
break;
case "USERPAYING":
compnt.showAlert('用户支付中(付款码支付)').then(function() {
$('.dialog-pay').css('display', 'block');
});
break;
case "PAYERROR":
compnt.showAlert('支付失败(其他原因,如银行返回失败)').then(function() {
$('.dialog-pay').css('display', 'block');
});
break;
default:
compnt.showAlert('支付失败,' + result.trade_state).then(function() {
$('.dialog-pay').css('display', 'block');
});
break;
}
});
return;
}