Kaynağa Gözat

判断进入pc移入到mixin中的onload

jwyu 3 yıl önce
ebeveyn
işleme
6813662d38
3 değiştirilmiş dosya ile 55 ekleme ve 31 silme
  1. 20 20
      App.vue
  2. 25 1
      mixin/index.js
  3. 10 10
      pages/activity/activity.vue

+ 20 - 20
App.vue

@@ -6,27 +6,27 @@
 			this.$store.dispatch('getTabBar')
 		},
 		onShow: function(options) {
-			console.log('App Show:',options)
+			// console.log('App Show:',options)
 			hasUpdate()
-			uni.getSystemInfo({
-				success: function (res) {
-					console.log('宽度:',res.windowWidth);
-					console.log('设备:',res.platform);
-					if (res.windowWidth > 600||['windows','mac'].includes(res.platform)) {
-						const params=options.query//此处的query就是在pc分享钩子函数中拼接的参数
-						let paramsStr=`xcxPath=${decodeURIComponent(options.path)}`
-						for(const key in params){
-							paramsStr=`${paramsStr}&${key}=${params[key]}`
-						}
-						console.log('进入pc');
-						uni.reLaunch({
-							url: `/pages/pc?${paramsStr}`,
-						});
-					}
-				},
-				fail:function(res){
-				}
-			})
+			// uni.getSystemInfo({
+			// 	success: function (res) {
+			// 		console.log('宽度:',res.windowWidth);
+			// 		console.log('设备:',res.platform);
+			// 		if (res.windowWidth > 600||['windows','mac'].includes(res.platform)) {
+			// 			const params=options.query//此处的query就是在pc分享钩子函数中拼接的参数
+			// 			let paramsStr=`xcxPath=${decodeURIComponent(options.path)}`
+			// 			for(const key in params){
+			// 				paramsStr=`${paramsStr}&${key}=${params[key]}`
+			// 			}
+			// 			console.log('进入pc');
+			// 			uni.reLaunch({
+			// 				url: `/pages/pc?${paramsStr}`,
+			// 			});
+			// 		}
+			// 	},
+			// 	fail:function(res){
+			// 	}
+			// })
 		},
 		onHide: function() {
 			console.log('App Hide')

+ 25 - 1
mixin/index.js

@@ -60,7 +60,31 @@ module.exports = {
       globalBgMusic:uni.getBackgroundAudioManager()
     };
   },
-  onLoad() {},
+  onLoad(options) {
+    console.log('mixin onLoad',options);
+    const page = this.$mp&&this.$mp.page
+    console.log('当前页面路由',page.route);
+    uni.getSystemInfo({
+      success: function (res) {
+        console.log('宽度:',res.windowWidth);
+        console.log('设备:',res.platform);
+        if(page.route=='pages/login'||page.route=='pages/pc') return
+        if (res.windowWidth > 600||['windows','mac'].includes(res.platform)) {
+          const params=options
+          let paramsStr=`xcxPath=${decodeURIComponent(page.route)}`
+          for(const key in params){
+            paramsStr=`${paramsStr}&${key}=${params[key]}`
+          }
+          console.log('进入pc');
+          uni.reLaunch({
+            url: `/pages/pc?${paramsStr}`,
+          });
+        }
+      },
+      fail:function(res){
+      }
+    })
+  },
   onShow(){
     this.handleActivityListPageRefresh()
 

+ 10 - 10
pages/activity/activity.vue

@@ -327,16 +327,16 @@ export default {
             this.allRefresh()
         }
         this.initAudio()
-        uni.getSystemInfo({
-			success: function (res) {
-				if (res.windowWidth > 600||['windows','mac'].includes(res.platform)) {
-					console.log('跳转启动页判断进入pc');
-					uni.reLaunch({
-						url: "/pages/pc",
-					});
-				}
-			},
-		})
+        // uni.getSystemInfo({
+		// 	success: function (res) {
+		// 		if (res.windowWidth > 600||['windows','mac'].includes(res.platform)) {
+		// 			console.log('跳转启动页判断进入pc');
+		// 			uni.reLaunch({
+		// 				url: "/pages/pc",
+		// 			});
+		// 		}
+		// 	},
+		// })
     },
     onHide(){
         this.showPoster=false