Commit ebcadfea authored by 上官's avatar 上官

app 内更新同步

parent b8fa5a5a
(function($){
var wgtVer=null;
var checkUrl="http://11wangjp.oss-cn-shanghai.aliyuncs.com/ftt_mes/version.txt";
// 下载wgt文件
var wgtUrl="http://11wangjp.oss-cn-shanghai.aliyuncs.com/ftt_mes/ftt_mes_hot.wgt";
function downWgtHot(){
plus.nativeUI.showWaiting("下载wgt文件...");
plus.downloader.createDownload( wgtUrl, {filename:"_doc/update/"}, function(d,status){
if ( status == 200 ) {
console.log("下载wgt成功:"+d.filename);
installWgtHOt(d.filename); // 安装wgt包
} else {
console.log("下载wgt失败!");
plus.nativeUI.alert("下载wgt失败!");
}
plus.nativeUI.closeWaiting();
}).start();
}
$.initUpdateHot = function checkUpdateHot(){
plus.nativeUI.showWaiting("检测更新...");
var xhr=new XMLHttpRequest();
xhr.onreadystatechange=function(){
switch(xhr.readyState){
case 4:
plus.nativeUI.closeWaiting();
if(xhr.status==200){
console.log("检测更新成功:"+xhr.responseText);
var newVer=xhr.responseText;
if(wgtVer&&newVer&&(wgtVer!=newVer)){
downWgtHot(); // 下载升级包
}else{
//plus.nativeUI.alert("无新版本可更新!");
}
}else{
console.log("检测更新失败!");
plus.nativeUI.alert("检测更新失败!");
}
break;
default:
break;
}
}
xhr.open('GET',checkUrl);
xhr.send();
}
function installWgtHOt(path){
plus.nativeUI.showWaiting("安装wgt文件...");
plus.runtime.install(path,{},function(){
plus.nativeUI.closeWaiting();
console.log("安装wgt文件成功!");
plus.nativeUI.alert("应用资源更新完成!",function(){
plus.runtime.restart();
});
},function(e){
plus.nativeUI.closeWaiting();
console.log("安装wgt文件失败["+e.code+"]:"+e.message);
plus.nativeUI.alert("安装wgt文件失败["+e.code+"]:"+e.message);
});
}
})(mui);
...@@ -88,8 +88,88 @@ ...@@ -88,8 +88,88 @@
} }
return result; return result;
}; };
//--------------------------------------
var wgtVer=null;
var checkUrl="http://11wangjp.oss-cn-shanghai.aliyuncs.com/ftt_mes/version.txt";
// 下载wgt文件
var wgtUrl="http://11wangjp.oss-cn-shanghai.aliyuncs.com/ftt_mes/ftt_mes_hot.wgt";
function downWgtHot(){
plus.nativeUI.showWaiting("下载wgt文件...");
plus.downloader.createDownload( wgtUrl, {filename:"_doc/update/"}, function(d,status){
if ( status == 200 ) {
console.log("下载wgt成功:"+d.filename);
installWgtHOt(d.filename); // 安装wgt包
} else {
console.log("下载wgt失败!");
plus.nativeUI.alert("下载wgt失败!");
}
plus.nativeUI.closeWaiting();
}).start();
}
function checkUpdateHot(){
plus.nativeUI.showWaiting("检测更新...");
var xhr=new XMLHttpRequest();
xhr.onreadystatechange=function(){
switch(xhr.readyState){
case 4:
plus.nativeUI.closeWaiting();
if(xhr.status==200){
console.log("检测更新成功:"+xhr.responseText);
var newVer=xhr.responseText;
if(wgtVer&&newVer&&(wgtVer!=newVer)){
downWgtHot(); // 下载升级包
}else{
//plus.nativeUI.alert("无新版本可更新!");
}
}else{
console.log("检测更新失败!");
plus.nativeUI.alert("检测更新失败!");
}
break;
default:
break;
}
}
xhr.open('GET',checkUrl);
xhr.send();
}
// 更新应用资源
function installWgtHOt(path){
plus.nativeUI.showWaiting("安装wgt文件...");
plus.runtime.install(path,{},function(){
plus.nativeUI.closeWaiting();
console.log("安装wgt文件成功!");
plus.nativeUI.alert("应用资源更新完成!",function(){
plus.runtime.restart();
});
},function(e){
plus.nativeUI.closeWaiting();
console.log("安装wgt文件失败["+e.code+"]:"+e.message);
plus.nativeUI.alert("安装wgt文件失败["+e.code+"]:"+e.message);
});
}
mui.plusReady(function(){ mui.plusReady(function(){
//------------------------------------------
// 获取本地应用资源版本号
plus.runtime.getProperty(plus.runtime.appid,function(inf){
wgtVer=inf.version;
console.log("当前应用版本:"+wgtVer);
checkUpdateHot()
});
// if(window.plus){
// plusReady();
// }else{
// document.addEventListener('plusready',plusReady,false);
// }
// console.log("end end end end ")
// return
//-----------------------------------------------------
var mineView = mui.preload({ var mineView = mui.preload({
url:'html/application.html', url:'html/application.html',
id:'application', id:'application',
......
...@@ -213,7 +213,7 @@ function checkUpdate(){ ...@@ -213,7 +213,7 @@ function checkUpdate(){
if(wgtVer&&newVer&&(wgtVer!=newVer)){ if(wgtVer&&newVer&&(wgtVer!=newVer)){
downWgt(); //下载升级包 downWgt(); //下载升级包
}else{ }else{
plus.nativeUI.console.log("无版本可更新!"); //plus.nativeUI.console.log("无版本可更新!");
} }
}else{ }else{
console.log("检测更新失败!"); console.log("检测更新失败!");
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
"id" : "H544710A8", /*应用的标识,创建应用时自动生成,勿手动修改*/ "id" : "H544710A8", /*应用的标识,创建应用时自动生成,勿手动修改*/
"name" : "飞天兔MES", /*应用名称,程序桌面图标名称*/ "name" : "飞天兔MES", /*应用名称,程序桌面图标名称*/
"version" : { "version" : {
"name" : "1.0.0.5", /*应用版本名称*/ "name" : "1.0.0.25", /*应用版本名称*/
"code" : "338" "code" : "338"
}, },
"description" : "飞天兔MES平板版", /*应用描述信息*/ "description" : "飞天兔MES平板版", /*应用描述信息*/
...@@ -77,9 +77,6 @@ ...@@ -77,9 +77,6 @@
"Barcode" : { "Barcode" : {
"description" : "管理二维码扫描插件" "description" : "管理二维码扫描插件"
}, },
"Maps" : {
"description" : "管理地图插件"
},
"Speech" : {}, "Speech" : {},
"Webview" : { "Webview" : {
"description" : "窗口管理" "description" : "窗口管理"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment