Commit c3f0af3d authored by 上官's avatar 上官

更新同步

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