浏览代码

检测更新

luyanan 7 年之前
父节点
当前提交
0436531096
共有 1 个文件被更改,包括 0 次插入61 次删除
  1. 0 61
      app/js/index.js

+ 0 - 61
app/js/index.js

@ -8,67 +8,6 @@ mui.plusReady(function() {
8 8
	plus.nativeUI.showWaiting();
9 9
	checkVersion();
10 10
})
11
document.addEventListener("resume", function(){
12
	
13
}, false)
14
function checkVersion(){
15
		mui.plusReady(function(){
16
			// 获取本地应用资源版本号
17
		    plus.runtime.getProperty(plus.runtime.appid,function(inf){
18
			    wgtVer=inf.version;
19
			    console.log("当前应用版本:"+wgtVer);
20
			    mui.ajax(baseUrl + "/data/manager/version.json", {
21
					dataType: 'json', //数据格式类型
22
					type: 'GET', //http请求类型
23
					timeout: 10000, //超时设置
24
					async: false,
25
					success: function(data) {
26
						if (data.version > wgtVer) {
27
							var btn = ["立即更新"];
28
							mui.confirm("有新版本发布了,赶快更新吧", "提示", btn, function(e) {
29
								if(e.index == 0) {
30
									if(mui.os.ios) {
31
										plus.runtime.openURL('https://itunes.apple.com/cn/app/ke-xiu-da-jian-qi-ye-yu-zhuan/id1197110983?l=en&mt=8');
32
										return;
33
									}
34
								try {
35
									     plus.nativeUI.showWaiting("检测更新...");
36
									     //var d="http://192.168.3.233/download/app1.0.6.apk";
37
										 plus.downloader.createDownload( data.wgt, {filename:"_doc/update/"}, function(d,status){
38
									        if ( status == 200 ) { 
39
									            plus.runtime.install(d.filename, {}, function() {
40
													console.log("安装新版本文件成功!");
41
													/*plus.nativeUI.alert("应用资源更新完成,程序需要立即重启", function() {
42
														plus.runtime.restart();
43
													});*/
44
												}, function(e) {
45
													console.log("安装新版文件失败[" + e.code + "]:" + e.message);
46
													plus.nativeUI.toast("安装新版文件失败[" + e.code + "]:" + e.message);
47
												});
48
									            
49
									        } else {
50
									            console.log("下载新版本失败!");
51
									            plus.nativeUI.toast("下载新版本失败!");
52
									        }
53
							       			plus.nativeUI.closeWaiting();
54
							    		}).start();
55
						    		} catch (e) {
56
										console.log(e.message);
57
									}	
58
								}
59
							});
60
						}else{
61
							//plus.nativeUI.toast("您使用的是最新版本,请放心使用!", toastStyle);
62
						}
63
					},
64
					error: function() {
65
						plus.nativeUI.toast("服务器链接超时", toastStyle);
66
						return;
67
					}
68
				});
69
			});
70
		})
71
	}
72 11
document.getElementById("demandP").addEventListener("tap", function() {
73 12
	var userid = plus.storage.getItem('userid');
74 13
	if(userid == null) {