|
发表于 2016-6-14 18:10:54
|
显示全部楼层
VersionChecker.prototype.checkAppVersion = function() {
var self = this;
if (cordova && cordova.getAppVersion) {
cordova.getAppVersion.getVersionNumber(function(currentVersion) {
if (self.appInfo[self.env] && self.versionCompare(currentVersion,self.appInfo[self.env].version) && window.localStorage && localStorage.getItem('versionIgnore') !== self.appInfo[self.env].version) {
self.versionMsg.show({
type : "YesNoCancel",
title : "版本更新",
message : self.appInfo[self.env].changeLog
});
}
});
}
};
VersionChecker.prototype.versionCompare = function(currentVersion,newVersion) {
if(currentVersion && newVersion){
var currVerArr = currentVersion.split(".");
var newVerArr = newVersion.split(".");
var len = Math.max(currVerArr.length, newVerArr.length);
for (var i = 0; i < len; i++) {
var newVal = ~~newVerArr[i],
curVal = ~~currVerArr[i];
if (newVal < curVal) {
return false;
} else if (newVal > curVal) {
return true;
}
}
}
return false;
};
试试这个代码 看看行不 |
|