-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdateApp.html
51 lines (49 loc) · 1.35 KB
/
updateApp.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
</body>
<script type="text/javascript">
//当地版本号
//document.addEventListener('plusready',getVersion,false);
function getVersion() {
Versionlocal = plus.runtime.version;
//发布前显示,hbuilder版本号,发布后正常
//如果服务器版本大于当地版本则update
// console.log(VersionServer + "," + Versionlocal);
if(VersionServer * 1 > Versionlocal * 1) {
alert("有新版本可用,即将升级");
if(window.plus) {
Update();
} else {
document.addEventListener("plusready", Update, false);
}
} else {
setTimeout(showcolse, 3000);
//数据检测取消,仅保留版本更新
//getFileVersion();
}
};
//更新程序
function Update() {
var url = checkurl + "/Files/" + VersionServer + ".apk";
//下载更新程序的地址
var path;
var dtast = plus.downloader.createDownload(url, {}, function(d, status) {
var nwaiting = plus.nativeUI.showWaiting("更新中...");
if(status == 200) { //下载成功
path = d.filename; //filename 下载时保存的路径
//安装下载的程序
alert("下载成功");
plus.runtime.install(path);
} else {
alert("下载程序时出错:" + status)
}
});
dtast.start();
}
</script>
</html>