zhongtianhaoyuan 2 lat temu
rodzic
commit
c710f715dc
2 zmienionych plików z 47 dodań i 35 usunięć
  1. 32 29
      config/componentConfig.js
  2. 15 6
      pages/mine/index.vue

+ 32 - 29
config/componentConfig.js

@@ -28,39 +28,42 @@ export default {
 		 */
 		/****************以下是示例*******************/
 		// 可以用自己项目的请求方法(接口自己找后台要,插件不提供)
-		const baseUrlNew = config.def().baseUrlNew
-		uni.request({
-			url: baseUrlNew + '/appVersion/selectInfo',
-			data: {
-				appid: plus.runtime.appid,
-				version: plus.runtime.version,
-				imei: "1",
-				type: 'sj'
-			},
-			method: 'GET',
-			success: (res) => {
-				if (res.data.data && res.data.data.wgtUrl) {
-					res.data.data.versionName = res.data.data.version
-					res.data.data.versionInfo = res.data.data.note
-					res.data.data.downloadUrl = res.data.data.wgtUrl
-					// 兼容之前的版本(updateType是新版才有的参数)
-					if (res.data.data.updateType) {
-						callback && callback(res.data.data);
-					} else {
-						if (res.forceUpdate) {
-							res.updateType = "forcibly";
+		plus.runtime.getProperty(plus.runtime.appid, (info) => {
+			const baseUrlNew = config.def().baseUrlNew
+			uni.request({
+				url: baseUrlNew + '/appVersion/selectInfo',
+				data: {
+					appid: plus.runtime.appid,
+					version: info.version,
+					imei: "1",
+					type: 'sj'
+				},
+				method: 'GET',
+				success: (res) => {
+					if (res.data.data && res.data.data.wgtUrl) {
+						res.data.data.versionName = res.data.data.version
+						res.data.data.versionInfo = res.data.data.note
+						res.data.data.downloadUrl = res.data.data.wgtUrl
+						// 兼容之前的版本(updateType是新版才有的参数)
+						if (res.data.data.updateType) {
+							callback && callback(res.data.data);
 						} else {
-							res.updateType = "solicit";
+							if (res.forceUpdate) {
+								res.updateType = "forcibly";
+							} else {
+								res.updateType = "solicit";
+							}
+							callback && callback(res.data.data);
 						}
-						callback && callback(res.data.data);
+					} else if (isPrompt) {
+						uni.showToast({
+							title: "暂无新版本",
+							icon: "none"
+						});
 					}
-				} else if (isPrompt) {
-					uni.showToast({
-						title: "暂无新版本",
-						icon: "none"
-					});
 				}
-			}
+		})
+		
 		})
 		//      $http.get("api/common/v1/app_version", httpData,{
 		//          isPrompt: isPrompt

+ 15 - 6
pages/mine/index.vue

@@ -198,8 +198,16 @@
 		},
 		onShow() {
 			// #ifdef APP-PLUS
-			this.version = plus.runtime.version
-			this.checkVersion()
+			plus.runtime.getProperty(plus.runtime.appid, (info) => {
+				//版本号
+				this.version = info.version;
+				console.log("当前版本为:", this.version)
+				this.checkVersion()
+				//appid
+				// this.appID = info.appid;
+			})
+			// this.version = plus.runtime.version
+			// this.checkVersion()
 			// #endif
 			uni.setTabBarItem({
 				index: 0,
@@ -287,15 +295,16 @@
 					url: baseUrlNew + '/appVersion/selectInfo',
 					data: {
 						appid: plus.runtime.appid,
-						version: plus.runtime.version,
+						version: this.version,
 						imei: "1",
 						type: 'sj'
 					},
 					method: 'GET',
 					success: (res) => {
-						var versionNo = plus.runtime.version
-						if (versionNo == res.data.data.version) {
-							this.version = "当前为最新版" + res.data.data.version
+						console.log("查看1111",this.version)
+						console.log("查看11111",res)
+						if (!res.data.data.version) {//有返回值证明需要更新   没有则不需要
+							this.version = "当前为最新版" + this.version
 						} else {
 							this.version = "发现新版本,立即更新"
 						}