Sfoglia il codice sorgente

推送处理优化

aleyds 3 anni fa
parent
commit
d0affc5dd1
3 ha cambiato i file con 31 aggiunte e 17 eliminazioni
  1. 6 6
      pages/index/index.vue
  2. 9 8
      pages/login/login.vue
  3. 16 3
      utils/pushUtils.js

+ 6 - 6
pages/index/index.vue

@@ -106,12 +106,12 @@
 			this.getLocation();
 		},
 		onBackPress(options) {
-			 uni.showModal({
-			   title: '温馨提示',  
-			   content: '已经到头了',  
-			   showCancel: false,
-			   success: (res) => { }  
-			 })  
+			 // uni.showModal({
+			 //   title: '温馨提示',  
+			 //   content: '已经到头了',  
+			 //   showCancel: false,
+			 //   success: (res) => { }  
+			 // })  
 			 // 禁止默认返回  
 			 return true  
 		},

+ 9 - 8
pages/login/login.vue

@@ -49,22 +49,22 @@
 					this.form.name = res.data.name;
 					this.form.password = res.data.password;
 					this.form.passCheck = res.data.passCheck?res.data.passCheck:false
-					console.log('passWord',res.data)
+					// console.log('passWord',res.data)
 				},
 				fail: (err) => {
-					console.log('passWord err',err)
+					// console.log('passWord err',err)
 				}
 			})
 		
 		},
 		onBackPress(options) {
 			 if (options.from === 'backbutton') {  
-				uni.showModal({  
-				  title: '温馨提示',  
-				  content: '已经到头了',  
-				  showCancel: false,
-				  success: (res) => { }  
-				})  
+				// uni.showModal({  
+				//   title: '温馨提示',  
+				//   content: '已经到头了',  
+				//   showCancel: false,
+				//   success: (res) => { }  
+				// })  
 				// 禁止默认返回  
 				return true  
 			  } 
@@ -99,6 +99,7 @@
 							data:{name:this.form.name}							
 						});
 					};
+					uni.removeStorageSync('pushreg_switch');//删除推送开关,登录成功后允许处理推送
 					// this.$u.route('pages/index/index', {});
 					uni.redirectTo({
 						url:'../index/index'

+ 16 - 3
utils/pushUtils.js

@@ -5,7 +5,10 @@ let speaker = uni.requireNativePlugin("SpeechPlug");
 const _handlePush = function(message) {
 				//{"message":{"__UUID__":"androidPushMsg222631973","appid":"__UNI__29ECCC8","content":"{\"type\":2,\"jumpTo\":\"pages/login/login\"}","payload":{"jumpTo":"pages/login/login","type":2},"title":"智慧停车PDA"}}
 				try {
-					alog.info({msg: '接收到推送信息:' + message.content});
+					const value = uni.getStorageSync('pushreg_switch');
+					if (value) {
+					    return;
+					}
 					let content = JSON.parse(message.content);
 					if (content.type === 1){
 						deviceParkIn(content)
@@ -28,6 +31,11 @@ function deviceParkIn(content){
 	if(content.speakMsg){
 		speaker.speakAction(content.speakMsg)
 	}
+	const value = uni.getStorageSync('pushModel_switch');
+	if (value) {
+	    return;
+	}
+	uni.setStorageSync('pushModel_switch', '1');
 	uni.showModal({
 	  title: '温馨提示',  
 	  content: content.popNode, 
@@ -37,7 +45,10 @@ function deviceParkIn(content){
 			      url: content.jumpTo
 			  });
 		  }
-	  }  
+	  }  ,
+	  complete:()=>{
+		  uni.removeStorageSync('pushModel_switch');
+	  }
 	});
 }
 
@@ -48,7 +59,9 @@ function deviceParkOut(content){
 }
 
 function pushreg(vue){	
-	     alog.info({msg: '推送注册'});
+	     
+		 //添加推送开关
+		uni.setStorageSync('pushreg_switch', '1');
 		//监听系统通知栏消息点击事件
 		plus.push.addEventListener('click', _handlePush, false);
 		//监听接收透传消息事件