You've already forked qlg.tsgz.moe
103 lines
2.9 KiB
JavaScript
Executable File
103 lines
2.9 KiB
JavaScript
Executable File
var wgtVer = null;
|
|
var is_juzi_online = 0;
|
|
|
|
function plusReady() { // 获取本地应用资源版本号
|
|
plus.runtime.getProperty(plus.runtime.appid, function(inf) {
|
|
wgtVer = inf.version;
|
|
});
|
|
}
|
|
//休眠方法
|
|
var ver;
|
|
//获取数据
|
|
|
|
function sleep(numberMillis) {
|
|
var now = new Date();
|
|
var exitTime = now.getTime() + numberMillis;
|
|
while (true) {
|
|
now = new Date();
|
|
if (now.getTime() > exitTime)
|
|
return;
|
|
}
|
|
}
|
|
|
|
mui.init({
|
|
swipeBack: true
|
|
});
|
|
var firstBackbutton = null;
|
|
mui.back = function() {
|
|
if (!firstBackbutton) {
|
|
window.plus.nativeUI.toast('再按一次退出应用');
|
|
firstBackbutton = new Date().getTime();
|
|
setTimeout(function() {
|
|
firstBackbutton = null
|
|
}, 2000);
|
|
return false;
|
|
} else {
|
|
if (new Date().getTime() - firstBackbutton < 2000){
|
|
if (mui.os.ios){
|
|
const threadClass = plus.ios.importClass("NSThread");
|
|
const mainThread = plus.ios.invoke(threadClass, "mainThread");
|
|
plus.ios.invoke(mainThread, "exit");
|
|
} else{
|
|
plus.runtime.quit();
|
|
}
|
|
}
|
|
}
|
|
};
|
|
//获取cid用于推送
|
|
mui.plusReady(function() {
|
|
// var cid = plus.push.getClientInfo().clientid;
|
|
// var timer = 0;
|
|
// timer = setInterval(function() {
|
|
// getData();
|
|
// }, 3000)
|
|
getData();
|
|
|
|
function getData() {
|
|
|
|
if (!localStorage.getItem('isFirstDownlodad')) {
|
|
localStorage.setItem('isFirstDownlodad', true);
|
|
|
|
}
|
|
mui.ajax('http://qlg.tsgz.moe:233/get_version_new.php?' + Math.random(), {
|
|
data: {},
|
|
dataType: 'json', //服务器返回json格式数据
|
|
type: 'post', //HTTP请求类型
|
|
timeout: 10000, //超时时间设置为10秒;
|
|
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;clearInterval(timer)
|
|
// clearInterval(timer);
|
|
localStorage.setItem('version', data.version);
|
|
if (0 == is_juzi_online) {
|
|
localStorage.setItem('cssUrl', "../css/");
|
|
localStorage.setItem('jsUrl', "../js/");
|
|
} else {
|
|
localStorage.setItem('cssUrl', data.cssUrl ? data.cssUrl : "../css/");
|
|
localStorage.setItem('jsUrl', data.jsUrl ? data.jsUrl : "../js/");
|
|
}
|
|
$('nav').css('display', 'block');
|
|
$('#bg').css('display', 'none');
|
|
var ipxSizeTop = 0;
|
|
var ipxSizeBottom = 0;
|
|
if (/iphone/gi.test(navigator.userAgent) && ((screen.height == 812 && screen.width == 375) || (screen.height ==
|
|
896 && screen.width == 414) || (screen.height == 1792 / 3 && screen.width == 828 / 3))) {
|
|
|
|
ipxSizeTop = 24;
|
|
ipxSizeBottom = 34;
|
|
//$('.mui-bar').attr('style', "bottom: 34px;")
|
|
};
|
|
|
|
localStorage.setItem('ipxSizeTop', ipxSizeTop);
|
|
localStorage.setItem('ipxSizeBottom', ipxSizeBottom);
|
|
init(data);
|
|
jumpPage(ipxSizeBottom);
|
|
nav(0);
|
|
},
|
|
error: function(xhr, type, errorThrown) { //异常处理;
|
|
// mui.alert(errorThrown);
|
|
mui.toast("网络异常,请检查网络设置!");
|
|
}
|
|
});
|
|
}
|
|
|
|
})
|