hwq před 4 roky
rodič
revize
44a19931dc
1 změnil soubory, kde provedl 30 přidání a 14 odebrání
  1. 30 14
      utils/upApp.js

+ 30 - 14
utils/upApp.js

@@ -1,5 +1,6 @@
 import store from '../store/index.js'
 const getUpAppUrl = 'https://itunes.apple.com/cn/lookup?id=1524593346'
+const getUpAppUrl1 = 'http://po.frp.liuniu946.com/api/version'
 const iosAppStroeUrl =
 	'https://apps.apple.com/cn/app/%E6%BB%A1%E5%9B%AD%E6%98%A5%E7%BA%BF%E4%B8%8A%E5%95%86%E5%9F%8E/id1524593346';
 
@@ -13,31 +14,41 @@ export function getUpApp () {
 	if (hj === 'android') {
 		// 设置默认显示数据
 		app = true;
-		store.commit('changeState', {
-			name: 'app',
-			value: app
-		});
+		// store.commit('changeState', {
+		// 	name: 'app',
+		// 	value: app
+		// });
 	}
+	let token = uni.getStorageSync('token') || '';
 	uni.request({
-		url: getUpAppUrl,
-		method: 'POST',
+		url: getUpAppUrl1,
+		method: 'GET',
+		header:{
+			"Authori-zation": 'Bearer ' + token,
+		},
 		data: {},
 		success: res => {
-			let r = res.data;
+			let r = res.data.data;
+			console.log(r)
 			plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo) {
 				// 保存线上版本号
-				let version = r.results[0].version;
+				let version = r.apk;
+				console.log(version,'version+++++++++++++++++++++++1+')
 				// 获取线上版本
-				const arr = r.results[0].version.split('.');
+				const arr = r.version_code.split('.');
 				// 获取当前系统
 				const arr1 = wgtinfo.version.split('.');
+				console.log(wgtinfo.version,'wgtinfo.version+++++++++++')
 				for (let i = 0; i < arr.length; i++) {
 					// 线上版本号
 					const x = +arr[i];
 					// 线下版本号
 					const y = +arr1[i];
+					console.log(arr,arr1,"版本号")
 					// 判断当前版本是否为小于等于线上版本
-					if (x <= y) {
+					if (x >= y) {
+						console.log('dashabi2020')
+						console.log(x,y)
 						// 只有ios才需要显示
 						if (hj === 'ios') {
 							// 设置显示数据
@@ -48,7 +59,7 @@ export function getUpApp () {
 							});
 						}
 						// 当版本较低时更新数据
-						if (x < y) {
+						if (x > y) {
 							uni.showModal({
 								title: '提示',
 								content: '请更新应用',
@@ -61,23 +72,28 @@ export function getUpApp () {
 									}
 									if (hj === 'android') {
 										// plus.runtime.openURL('http://lxscimg.liuniu946.com/lxscV' + version + '.apk');
-										_self.downApp(version);
+										downApp(version);
+										
 									}
 								}
 							});
+							return;
 						}
-						return;
 					}
 				}
 			});
 		},
+		fail:e =>{
+			console.log(e,"失败")
+		}
 	});
 }
 // 下载app
 export function downApp (version) {
+	console.log(version,"版本号")
 	plus.nativeUI.showWaiting('下载升级包...');
 	plus.downloader
-		.createDownload('http://lxscimg.liuniu946.com/lxscV' + version + '.apk', {}, (d, status) => {
+		.createDownload('http://www.lalanft.net' + version, {}, (d, status) => {
 			if (status == 200) {
 				installApp(d.filename); // 安装app
 			} else {