Sfoglia il codice sorgente

fix:拦截返回无效,监听发页面卸载

DaMowang 3 anni fa
parent
commit
0e5e02120f
2 ha cambiato i file con 17 aggiunte e 36 eliminazioni
  1. 15 22
      src/pages/account/consignment.vue
  2. 2 14
      src/pages/szw-order-list/index.vue

+ 15 - 22
src/pages/account/consignment.vue

@@ -105,10 +105,10 @@ import uniPopup from '@/components/uni-popup/uni-popup.vue'
 				pay_way:0 // 操作-0:再次寄售;1:收货
 			};
 		},
-		onLoad:function(){
+		onLoad(){
 			// this.loadAddress()
 		},
-		onShow:function(options){
+		onShow(options){
 			page = 1;
 			this.goods = []
 			this.loadData()
@@ -251,7 +251,7 @@ import uniPopup from '@/components/uni-popup/uni-popup.vue'
 				})
 			},
 		},
-		onShareAppMessage: function () {
+		onShareAppMessage() {
 			let userinfo = uni.getStorageSync('userinfo');
 			var path = '/pages/account/consignment?agentId=1';
 			if (userinfo.user_id) {
@@ -263,10 +263,8 @@ import uniPopup from '@/components/uni-popup/uni-popup.vue'
 		        path: path
 		    }
 		},
-		/**
-		 * 页面上拉触底事件的处理函数
-		 */
-		onReachBottom: function () {
+		//页面上拉触底事件的处理函数
+		onReachBottom() {
 			if (page != -1) {
 				var that = this;
 				setTimeout(function () {
@@ -275,21 +273,16 @@ import uniPopup from '@/components/uni-popup/uni-popup.vue'
 				}, 800);
 			}
 		},
-		onBackPress(options) {
-			//避免死循环
-			if (options.from === 'navigateBack') return false;
-			//自己的判断条件,执行自定义的返回操作
-			// if (你的条件) {
-				//你的自定义操作
-			// }
-			//执行uniapp的返回操作
-			// else uni.navigateBack()
-			
-			this.goto("/pages/my/index")
-				
-			//返回true表示我要自定义onBackPress
-			return true
-		}
+		onUnload(){
+			// #ifdef  H5 || APP-PLUS
+			this.goto("/pages/my/index");
+			// #endif
+			// #ifdef  MP-WEIXIN
+			uni.switchTab({
+				url: "/pages/my/index"
+			});
+			// #endif
+		},
 	}
 </script>
 

+ 2 - 14
src/pages/szw-order-list/index.vue

@@ -256,16 +256,7 @@ export default {
             that.loadData();
         });
     },
-    onBackPress(options) {
-        //避免死循环
-        if (options.from === 'navigateBack') return false;
-        //自己的判断条件,执行自定义的返回操作
-        // if (你的条件) {
-            //你的自定义操作
-        // }
-        //执行uniapp的返回操作
-        // else uni.navigateBack()
-        
+    onUnload(){
         // #ifdef  H5 || APP-PLUS
         this.goto("/pages/my/index");
         // #endif
@@ -274,10 +265,7 @@ export default {
             url: "/pages/my/index"
         });
         // #endif
-            
-        //返回true表示我要自定义onBackPress
-        return true
-    }
+    },
 
 };
 </script>