shish 4 lat temu
rodzic
commit
32b8f45c42
2 zmienionych plików z 54 dodań i 31 usunięć
  1. 16 31
      ghsApp/src/admin/home/login.vue
  2. 38 0
      hdApp/src/admin/home/login.vue

+ 16 - 31
ghsApp/src/admin/home/login.vue

@@ -57,8 +57,21 @@ export default {
 	},
 	onLoad(){
 		let that = this
-		uni.onNetworkStatusChange(function (res) {
-			console.log(res.networkType);
+		uni.getNetworkType({
+			success: function (res) {
+				that.dealLogin(res)
+			}
+		})
+		uni.onNetworkStatusChange(this.dealLogin)
+	},
+	onUnload(){
+		uni.offNetworkStatusChange(this.dealLogin)
+	},
+	methods: {
+		...mapActions(['setUserShopAll']),
+		dealLogin(res){
+			let that = this
+			console.log(res)
 			switch(res.networkType){
 				case '2g':
 					that.hasMobileNet = true
@@ -75,35 +88,7 @@ export default {
 				default:
 					that.hasMobileNet = false
 			}
-		})
-	
-		uni.getNetworkType({
-			success: function (res) {
-				switch(res.networkType){
-					case '2g':
-						that.hasMobileNet = true
-						break;
-					case '3g':
-						that.hasMobileNet = true
-						break;
-					case '4g':
-						that.hasMobileNet = true
-						break;
-					case '5g':
-						that.hasMobileNet = true
-						break;
-					default:
-						that.hasMobileNet = false
-				}
-			}
-		})
-
-	},
-	onUnload(){
-
-	},
-	methods: {
-		...mapActions(['setUserShopAll']),
+		},
 		wxPhoneLogin(e){
 			let that = this
 			let currentMiniOpenId = uni.getStorageSync('currentMiniOpenId')

+ 38 - 0
hdApp/src/admin/home/login.vue

@@ -56,8 +56,40 @@ export default {
 	},
 	computed: {
 	},
+	onLoad(){
+		let that = this
+		uni.getNetworkType({
+			success: function (res) {
+				that.dealLogin(res)
+			}
+		})
+		uni.onNetworkStatusChange(this.dealLogin)
+	},
+	onUnload(){
+		uni.offNetworkStatusChange(this.dealLogin)
+	},
 	methods: {
 		...mapActions(['setUserShopAll']),
+		dealLogin(res){
+			let that = this
+			console.log(res)
+			switch(res.networkType){
+				case '2g':
+					that.hasMobileNet = true
+					break;
+				case '3g':
+					that.hasMobileNet = true
+					break;
+				case '4g':
+					that.hasMobileNet = true
+					break;
+				case '5g':
+					that.hasMobileNet = true
+					break;
+				default:
+					that.hasMobileNet = false
+			}
+		},
 		wxPhoneLogin(e){
 			let that = this
 			let currentMiniOpenId = uni.getStorageSync('currentMiniOpenId')
@@ -104,6 +136,12 @@ export default {
 		},
 		mobileLogin(){
 			let that = this
+
+			if(this.hasMobileNet == false){
+				that.$msg('登录时,请关闭wifi,打开移动流量')
+				return
+			}
+
 			uni.showLoading({mask:true})
 			uni.preLogin({
 				provider: 'univerify',