Przeglądaj źródła

feat: 小程序前后台版本判断

From-wh 2 lat temu
rodzic
commit
fc3296f871
2 zmienionych plików z 55 dodań i 34 usunięć
  1. 45 33
      template/uni-app/App.vue
  2. 10 1
      template/uni-app/api/public.js

+ 45 - 33
template/uni-app/App.vue

@@ -3,24 +3,22 @@
 		checkLogin
 	} from './libs/login';
 	import {
-		HTTP_REQUEST_URL
+		HTTP_REQUEST_URL,
+		SYSTEM_VERSION
 	} from './config/app';
 	import {
 		getShopConfig,
-		silenceAuth
+		silenceAuth,
+		getSystemVersion
 	} from '@/api/public';
 	import Auth from '@/libs/wechat.js';
 	import Routine from './libs/routine.js';
 	import {
 		silenceBindingSpread
 	} from "@/utils";
-	import {
-		getCartCounts,
-	} from '@/api/order.js';
 	import {
 		colorChange,
 		getCrmebCopyRight,
-
 	} from '@/api/api.js';
 	import {
 		getLangJson,
@@ -83,6 +81,7 @@
 			}
 		},
 		onShow() {
+			console.log(this.globalData.cccc)
 			const queryData = uni.getEnterOptionsSync() // uni-app版本 3.5.1+ 支持
 			if (queryData.query.spread) {
 				this.$Cache.set('spread', queryData.query.spread);
@@ -97,33 +96,33 @@
 				silenceBindingSpread(this.globalData)
 			}
 			// #ifdef MP
-			if (queryData.query.scene) {
-				let param = this.$util.getUrlParams(decodeURIComponent(queryData.query.scene))
-				console.log(queryData.query.scene)
-				console.log(param)
-				if(param.pid){
-					this.$Cache.set('spread', param.pid);
-					this.globalData.spid = param.pid;
-					this.globalData.pid = param.pid;
-				}else{
-					switch (queryData.scene) {
-						//扫描小程序码
-						case 1047:
-							this.globalData.code = queryData.query.scene;
-							break;
-							//长按图片识别小程序码
-						case 1048:
-							this.globalData.code = queryData.query.scene;
-							break;
-							//手机相册选取小程序码
-						case 1049:
-							this.globalData.code = queryData.query.scene;
-							break;
-							//直接进入小程序
-						case 1001:
-							this.globalData.spid = queryData.query.scene;
-							break;
-					}
+			if (queryData.query.scene) {
+				let param = this.$util.getUrlParams(decodeURIComponent(queryData.query.scene))
+				console.log(queryData.query.scene)
+				console.log(param)
+				if (param.pid) {
+					this.$Cache.set('spread', param.pid);
+					this.globalData.spid = param.pid;
+					this.globalData.pid = param.pid;
+				} else {
+					switch (queryData.scene) {
+						//扫描小程序码
+						case 1047:
+							this.globalData.code = queryData.query.scene;
+							break;
+							//长按图片识别小程序码
+						case 1048:
+							this.globalData.code = queryData.query.scene;
+							break;
+							//手机相册选取小程序码
+						case 1049:
+							this.globalData.code = queryData.query.scene;
+							break;
+							//直接进入小程序
+						case 1001:
+							this.globalData.spid = queryData.query.scene;
+							break;
+					}
 				}
 				silenceBindingSpread(this.globalData)
 			}
@@ -282,6 +281,19 @@
 			getCrmebCopyRight().then(res => {
 				uni.setStorageSync('copyRight', res.data)
 			})
+			// #ifdef MP
+			getSystemVersion().then(res => {
+				if (res.data.version_code < SYSTEM_VERSION) {
+					uni.showModal({
+						title: '提示',
+						content: '请重新打包并上传小程序',
+						success: function(res) {
+							if (res.confirm) {}
+						}
+					});
+				}
+			})
+			// #endif
 		},
 		// #ifdef H5
 		onHide() {

+ 10 - 1
template/uni-app/api/public.js

@@ -221,7 +221,7 @@ export function getCategoryVersion(name) {
 		noAuth: true
 	});
 }
-
+
 /**
  * 配置信息
  * 
@@ -231,3 +231,12 @@ export function basicConfig(name) {
 		noAuth: true
 	});
 }
+/**
+ * 后台版本信息
+ * 
+ */
+export function getSystemVersion() {
+	return request.get(`version`, {}, {
+		noAuth: true
+	});
+}