This commit is contained in:
Jerry Yan 2019-10-27 21:34:28 +08:00
parent 9269b33349
commit 674cd7a9c2
4 changed files with 48 additions and 33 deletions

View File

@ -1,10 +1,10 @@
var is_app = 1;
var imgUrl = 'http://img.zgqlg.com.cn/';
// var webUrl = 'http://www.zgqlg.com.cn/';
// var webUrl1 = 'http://www.zgqlg.com.cn/';
var webUrl = 'http://www.zgqlg.com.cn/';
var webUrl1 = 'http://www.zgqlg.com.cn/';
// var imgUrl = 'http://qlg.tsgz.moe:233/';
var webUrl = 'http://qlg.tsgz.moe:233/';
var webUrl1 = 'http://qlg.tsgz.moe:233/';
// var webUrl = 'http://qlg.tsgz.moe:233/';
// var webUrl1 = 'http://qlg.tsgz.moe:233/';
var cssUrl = localStorage.getItem("cssUrl");
var jsUrl = localStorage.getItem("jsUrl");
var version = localStorage.getItem("version");

View File

@ -57,9 +57,8 @@ mui.plusReady(function() {
if (!localStorage.getItem('isFirstDownlodad')) {
localStorage.setItem('isFirstDownlodad', true);
}
mui.ajax('http://qlg.tsgz.moe:233/get_version_new.php?' + Math.random(), {
mui.ajax('http://www.zgqlg.com.cn/get_version_new.php?' + Math.random(), {
data: {},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型

View File

@ -39,40 +39,18 @@ function init(data) {
}
});
} else if(/android/.test(ua)) {
if(apk_version > ver) {
if(must_update == 0) {
if(confirm("发现新版本:V" + apk_version + "是否更新")) {
var dtask = plus.downloader.createDownload(apkUrl, {}, function(d, status) {
if(status == 200) {
plus.nativeUI.toast("正在准备环境,请稍后!");
sleep(1000);
var path = d.filename; //下载apk
plus.runtime.install(path); // 自动安装apk文件
} else {
mui.alert('版本更新失败:' + status);
}
});
dtask.start();
downloadUpdate(apkUrl)
}
} else {
if(confirm("发现新版本:V" + apk_version + "是否更新")) {
var dtask = plus.downloader.createDownload(apkUrl, {}, function(d, status) {
if(status == 200) {
plus.nativeUI.toast("正在准备环境,请稍后!");
sleep(1000);
var path = d.filename; //下载apk
plus.runtime.install(path); // 自动安装apk文件
} else {
mui.alert('版本更新失败:' + status);
}
});
dtask.start();
downloadUpdate(apkUrl)
} else {
plus.runtime.quit();
}
}
} else {
// console.log('当前版本号已是最新');
return;
@ -82,7 +60,44 @@ function init(data) {
})
})
};
function downloadUpdate(apkUrl){
let waiting = plus.nativeUI.showWaiting("正在下载更新包");
var dtask = plus.downloader.createDownload(apkUrl, {}, function(d, status) {
if(status == 200) {
waiting.close()
plus.nativeUI.toast("正在准备环境,请稍后!");
var path = d.filename; //下载apk
plus.runtime.install(path,{},function(){
plus.nativeUI.alert("应用资源更新完成!",function(){
plus.runtime.restart();
});
},function(e){
plus.nativeUI.alert("更新失败["+e.code+"]"+e.message);
}); // 自动安装apk文件
} else {
waiting.setTitle("下载失败")
setTimeout(function(){waiting.close()}, 2000)
mui.alert('版本更新失败:' + status);
}
});
dtask.start();
dtask.addEventListener("statechanged",function(download, status) {
if(download.state != 4){
var text = "("+(download.downloadedSize*100/download.totalSize).toFixed(2)+"%)"
waiting.setTitle('正在下载'+text)
}
if(download.state == 4){
// 下载完成
if(status == 200){
waiting.close()
}else{
waiting.setTitle("下载失败")
setTimeout(function(){waiting.close()}, 2000)
}
console.log("Download success: " + download.getFileName());
}
},false)
}
function jumpPage(ipxSizeBottom) {
//跳转页面

View File

@ -21,8 +21,9 @@
<div class="row shadown_wai" id="myHelpSaleOrder"><img class="img" src="../img/setting_lock1.png" /><span class="r1">我家订单</span><span
class="r2">我家全部订单</span><img class="youjiantou" src="../img/youjiantou.png" /></div>
<div class="row shadown_wai" id="preGetCoupon" style="margin-top: 6px;"><img class="img" src="../img/setting_user1.png" /><span class="r1" id="userName"></span><span
class="r2" id="preGetCouponCount" style="color: #000000;"></span><img class="youjiantou" src="../img/youjiantou.png" /></div>
<div class="row shadown_wai" id="preGetCoupon" style="margin-top: 6px;"><img class="img" src="../img/setting_user1.png" /><span class="r1" id="userName"></div>
<div class="row shadown_wai" id="preGetCoupon" style="margin-top: 6px;"></span><span
class="r1" id="preGetCouponCount" style="color: #000000;"></span><img class="youjiantou" src="../img/youjiantou.png" /></div>
<div id="helpSaleTable">
<div class="row helpSaleTableRow shadown_wai"><span class="c1">助购户</span><span class="c2 ZGYH">助购预获</span>
<span class="c3 btn" id="toHelpSale">助购去</span></div>