xiaol 1 mēnesi atpakaļ
vecāks
revīzija
3d4841fadc
1 mainītis faili ar 45 papildinājumiem un 45 dzēšanām
  1. 45 45
      pages/index/index.vue

+ 45 - 45
pages/index/index.vue

@@ -389,7 +389,7 @@
 				const appType = uni.getSystemInfoSync().platform;
 				if (plus != null) {
 					plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
-						//获取苹果当前系统版本号
+						let versionCode = wgtinfo.versionCode;
 						let arr1 = wgtinfo.version.split('.');
 						uni.setStorageSync("showData", false)
 						if (appType == "ios") {
@@ -398,56 +398,57 @@
 							uni.setStorageSync("showData", true)
 					      uni.request({
 								url: getIosUpAppUrl,
-								method: 'get',
+								method: 'POST',
 								data: {},
 								success: res => {
-									//获取苹果商城系统版本号
-									let arr = r.results[0].version.split('.');
+									let arr = res.results[0].version.split('.');
 									for (let i = 0; i < arr.length; i++) {
 										// 线上版本号
 										const x = +arr[i];
 										// 本地版本号
 										const y = +arr1[i];
+										// 判断线上版本是否小于本地版本
 										if (x < y) {
-											uni.setStorageSync("showData", false)
+											// 设置显示数据
+											uni.setStorageSync("showData",false)
 											return
 										}
+										// 判断线上版本是否大于本地版本
 										else if (x > y) {
-											uni.setStorageSync("showData", false)
-											plus.runtime.openURL(
-												iosAppStroeUrl
-											);
+											uni.setStorageSync("showData",false)
+											uni.showModal({
+												title: '提示',
+												content: '请更新应用',
+												showCancel: false,
+												success(e) {
+													plus.runtime.openURL(
+														iosAppStroeUrl
+													);
+												}
+											});
 											return
 										} 
 										// 判断是否本地版本等于线上版本
 										else if (x == y && i == arr.length - 1) {
-											uni.setStorageSync("showData", true)
+											uni.setStorageSync("showData",true)
 											return
 										}
 									}
 								},
 								fail: res => {
-									// store.commit('changeState', true);
 									console.log(res, 'shib');
 								}
 							});
 						} else {
 							this.request.post("sysInit", {
-								code: versionCode
-							}).then(res => {
-								console.log(res, 'res')
-								if (res.code == 200) {
-									this.setSys(res.data);
-									let arr = res.data.app_code.split('.');
-									for (let i = 0; i < arr.length; i++) {
-										const x = +arr[i];
-										const y = +arr1[i];
-										if (x < y) {
-											uni.setStorageSync("showData", false)
-											return
-										}
-										else if (x > y) {
-											uni.setStorageSync("showData", false)
+									code: versionCode
+								})
+								.then(res => {
+									console.log(res, 'res')
+									if (res.code == 200) {
+										this.setSys(res.data);
+										if (wgtinfo.versionCode < res.data.app_code) {
+											uni.setStorageSync("showData", true)
 											const upDater = uni.requireNativePlugin("CL-UpDater");
 											let options = {
 												title: "升级",
@@ -466,29 +467,28 @@
 											};
 											//必需提供下载地址;
 											upDater.startUpdate(options, () => {});
-											return
-										} 
-										// 判断是否本地版本等于线上版本
-										else if (x == y && i == arr.length - 1) {
+										} else if (wgtinfo.versionCode > res.data.app_code) {
+											uni.setStorageSync("showData", false)
+										} else {
 											uni.setStorageSync("showData", true)
-											return
+										}
+										if (res.data.is_audit == 0) {
+											this.getGps({
+												page: this,
+												fn: (res) => {
+													console.log(res);
+													this.getData(true);
+												},
+												err: (err) => {
+													this.getData(true);
+												}
+											});
 										}
 									}
-									if (res.data.is_audit == 0) {
-										this.getGps({
-											page: this,
-											fn: (res) => {
-												console.log(res);
-												this.getData(true);
-											},
-											err: (err) => {
-												this.getData(true);
-											}
-										});
-									}
-								}
-							});
+								});
 						}
+						
+
 					});
 				}
 			},