if(wgtVer&&newVer&&(wgtVer!=newVer))这个判断这里,前面获得的是当前版本,后面获得的一直是null值,请问怎么破?
- 发布:2018-03-13 11:47
- 更新:2018-03-13 14:08
- 阅读:1862
1***@qq.com (作者) - 前端开发
//关于版本更新问题
var wgtVer=null;
function plusReady(){
plus.runtime.getProperty(plus.runtime.appid,function(inf){
wgtVer=inf.version;
// alert(wgtVer);
checkUpdate();
});
}
if(window.plus){
plusReady();
}else{
document.addEventListener('plusready',plusReady,false);
}
var checkUrl="http://192.168.0.126/Square/data/check.php?vison=" + wgtVer;
function checkUpdate(){
plus.nativeUI.showWaiting("检测更新...");
var xhr=new plus.net.XMLHttpRequest();
xhr.onreadystatechange=function(){
switch(xhr.readyState){
case 4:
plus.nativeUI.closeWaiting();
if(xhr.status==200){
var newVer=xhr.responseText;
alert(wgtVer + " " + newVer);
// if(wgtVer&&newVer&&(wgtVer!=newVer)){
// alert(wgtVer + " " + newVer);
//// $("#gengxin").append("<i>new</i>");
// // console.log("检测更新成功:"+xhr.responseText);
// }else{
// plus.nativeUI.alert("无新版本可更新!");
// }
}else{
console.log("检测更新失败!");
plus.nativeUI.alert("检测更新失败!");
}
break;
default:
break;
}
}
xhr.open('GET',wgtUrl);
xhr.send();
}
var wgtUrl="http://192.168.0.126/Square/data/H5676DDD5.wgt";
1***@qq.com (作者)
//关于版本更新问题
var wgtVer=null;
function plusReady(){
plus.runtime.getProperty(plus.runtime.appid,function(inf){
wgtVer=inf.version;
// alert(wgtVer);
checkUpdate();
});
2018-03-13 12:17
1***@qq.com (作者)
整体就是这样子的,我要获取本来的版本号和更新包的版本号,判断两个不同版本号时执行a,两个版本号相同时执行b;
2018-03-13 12:19
1***@qq.com (作者)
可是我获取的两个一直都不同,第二个,一直是null
2018-03-13 12:20
1***@qq.com (作者)
哦哦,还掉了一点var checkUrl="http://192.168.0.126/Square/data/check.php?vison=" + wgtVer;
2018-03-13 12:22