Commit c3f0af3d authored by 上官's avatar 上官

更新同步

parent 269631f3
......@@ -148,6 +148,7 @@ function getUpdateData(){
* @return {Boolean}
*/
function compareVersion(ov,nv){
if(!ov || !nv || ov == "" || nv == ""){
return false;
}
......@@ -179,6 +180,7 @@ function compareVersion(ov,nv){
* @return {Boolean}
*/
function compareVersion_big(ov,nv){
console.log("new " + nv + "old " + ov)
if(!ov || !nv || ov == "" || nv == ""){
return "9.9.9.9";
}
......
......@@ -90,11 +90,15 @@
};
//--------------------------------------
var wgtVer=null;
var checkUrl="http://11wangjp.oss-cn-shanghai.aliyuncs.com/ftt_mes/version.txt";
var myDate=new Date()
myDate.toLocaleString( )
console.log(myDate)
var checkUrl="http://11wangjp.oss-cn-shanghai.aliyuncs.com/ftt_mes/version.txt?t=" + myDate;
// 下载wgt文件
var wgtUrl="http://11wangjp.oss-cn-shanghai.aliyuncs.com/ftt_mes/ftt_mes_hot.wgt";
function downWgtHot(){
plus.nativeUI.showWaiting("下载wgt文件...");
plus.nativeUI.showWaiting("下载wgt文件...");
plus.downloader.createDownload( wgtUrl, {filename:"_doc/update/"}, function(d,status){
if ( status == 200 ) {
console.log("下载wgt成功:"+d.filename);
......@@ -106,8 +110,34 @@
plus.nativeUI.closeWaiting();
}).start();
}
function compareVersion(ov,nv){
if(!ov || !nv || ov == "" || nv == ""){
return false;
}
var b = false,
ova = ov.split(".",4),
nva = nv.split(".",4),
j = ova.length,
k = nva.length;
// console.log("ova:"+ova+"nva:"+nva);
for(var i =0;i < j && i < k;i += 1){
var so = ova[i],
no = parseInt(so),
sn = nva[i],
nn = parseInt(sn);
if(nn > no || sn.length > so.length){
return true;
}else if(nn < no){
return false;
}
}
if(k > j && 0 == nv.indexOf(ov)){
return true;
}
}
function checkUpdateHot(){
plus.nativeUI.showWaiting("检测更新...");
// plus.nativeUI.showWaiting("检测更新...");
var xhr=new XMLHttpRequest();
xhr.onreadystatechange=function(){
switch(xhr.readyState){
......@@ -116,7 +146,14 @@
if(xhr.status==200){
console.log("检测更新成功:"+xhr.responseText);
var newVer=xhr.responseText;
if(wgtVer&&newVer&&(wgtVer!=newVer)){
// if(wgtVer&&newVer&&(wgtVer!=newVer)){
//
// downWgtHot(); // 下载升级包
// }
if(compareVersion(wgtVer,newVer)){
downWgtHot(); // 下载升级包
}else{
//plus.nativeUI.alert("无新版本可更新!");
......
......@@ -3,8 +3,8 @@
"id" : "H544710A8", /*应用的标识,创建应用时自动生成,勿手动修改*/
"name" : "飞天兔MES", /*应用名称,程序桌面图标名称*/
"version" : {
"name" : "1.0.0.39", /*应用版本名称*/
"code" : "338"
"name" : "1.0.0.52", /*应用版本名称*/
"code" : 338
},
"description" : "飞天兔MES平板版", /*应用描述信息*/
"icons" : {
......
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