| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 | 
							- export function checkUpdateApp() {
 
- 	plus.runtime.getProperty(plus.runtime.appid, function(widgetinfo) {
 
- 		if (widgetinfo.name == '冷链送药') {
 
- 			uni.request({
 
- 				url: 'https://www.pgyer.com/apiv2/app/check',
 
- 				data: {
 
- 					_api_key: '202eadee73f2051186b26106cc8bfed1',
 
- 					appKey: '3ddb1c783d37ac3d2f979dfa2aa6bc9e '
 
- 				},
 
- 				success: check => {
 
- 					if (check.statusCode == 200 && check.data.code == 0 && check.data.data) {
 
- 						let data = check.data.data;
 
- 						let version = widgetinfo.version,
 
- 							appVersion = data.buildVersion,
 
- 							appName = widgetinfo.name,
 
- 							appurl = data.downloadURL,
 
- 							intro = '发现新的《冷链送药》APP,需要更新APP';
 
- 						if (data && version < appVersion) {
 
- 							uni.showModal({
 
- 								title: '更新提示',
 
- 								confirmText: '立即升级',
 
- 								content: intro,
 
- 								success: res => {
 
- 									if (res.confirm) {
 
- 										uni.showLoading({
 
- 											title: '正在更新',
 
- 											mask: true
 
- 										});
 
- 										uni.downloadFile({
 
- 											url: appurl,
 
- 											success: download => {
 
- 												if (download.statusCode ==
 
- 													200) {
 
- 													plus.runtime.install(
 
- 														download
 
- 														.tempFilePath, {
 
- 															force: false
 
- 														},
 
- 														() => {
 
- 															uni
 
- 														.hideLoading();
 
- 															plus.runtime
 
- 																.restart(); //更新成功启动
 
- 														},
 
- 														err => {
 
- 															uni
 
- 														.hideLoading();
 
- 															uni.showToast({
 
- 																title: '更新失败,将跳转下载页面',
 
- 																icon: 'none',
 
- 																duration: 2000
 
- 															});
 
- 														}
 
- 													);
 
- 													setTimeout(function() {
 
- 														plus.runtime
 
- 															.openURL(
 
- 																appurl
 
- 																);
 
- 													}, 2000);
 
- 												}
 
- 											}
 
- 										});
 
- 									} else if (res.cancel) {
 
- 										console.log('用户点击取消');
 
- 										uni.showToast({
 
- 											title: '低版本无法继续使用,请先升级',
 
- 											icon: 'none',
 
- 											duration: 2000
 
- 										});
 
- 										//退出app
 
- 										setTimeout(function() {
 
- 											plus.runtime.quit();
 
- 										}, 2000);
 
- 									}
 
- 								},
 
- 								fail: () => {
 
- 									uni.hideLoading();
 
- 								}
 
- 							});
 
- 						} else {
 
- 							console.log('暂无新版本=====')
 
- 						}
 
- 					}
 
- 				}
 
- 			});
 
- 		} else {
 
- 			//非安卓
 
- 		}
 
- 	});
 
- }
 
 
  |