diff --git a/App.vue b/App.vue index 64bdde6..e2799f8 100644 --- a/App.vue +++ b/App.vue @@ -17,6 +17,30 @@ uni.setStorageSync('firstTime','1'); } addAppCount({channel:channel,is_install:isInstall}); + + // uni.getNetworkType({ + // success: function(res) { + // console.log(res.networkType); + // //网络类型 wifi、2g、3g、4g、ethernet、unknown、none + // setTimeout(function() { + // if (res.networkType === "none") { + // console.log("当前无网络", that.typee); + // uni.showToast({ + // title: '网络不佳,请重新打开........', + // duration: 20000 + // }); + // } else { + // console.log("有网络", that.typee); + // uni.showToast({ + // title: '网络不佳,请重新打开........', + // duration: 2000 + // }); + // } + // }, 1) + // } + // }); + + // console.log('App Launch') uni.hideTabBar() @@ -84,6 +108,7 @@ let extras = result.extras console.log("自定义消息", result) }) + //#endif }, @@ -94,7 +119,7 @@ onHide: function() { // console.log('App Hide') }, - + } diff --git a/pages/index/index.vue b/pages/index/index.vue index 022a7b1..7c16d1d 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -216,7 +216,6 @@ uni.getNetworkType({ success: (res) => { console.log(res.networkType, s); - if (res.networkType !== 'none') { that.typee = 2; clearInterval(time); @@ -228,6 +227,7 @@ this.getMes() this.getPullMes() this.getInfo() + this.checkNetwork() if (this.countdownTime2 != 0) { uni.hideTabBar() } else if (this.countdownTime2 == 0 || !this.popImg) { @@ -244,12 +244,14 @@ }) s++; }, 5000); + }, mounted() { this.getimgheight() this.getimgheight1() this.getimgheight2() + this.checkNetwork() console.log(this.open_img) if (this.open_img) { setTimeout(() => { @@ -265,11 +267,13 @@ this.getPullMes() this.getimgheight() this.getimgheight2() + this.checkNetwork() }, onShow() { this.isLogin = uni.getStorageSync('isLogin') // console.log(this.isLogin) uni.hideTabBar() + this.checkNetwork() this.getList() this.getMes() this.sum = 0 @@ -319,6 +323,23 @@ }, methods: { + checkNetwork(){ + uni.getNetworkType({ + complete:function(res){ + // console.log(res.networkType) + if(res.networkType=='none'){ + setTimeout(()=>{ + uni.showToast({ + icon:'none', + title:'Please connect to the network', + duration:3000, + }) + },200) + // return false + } + } + }); + }, handlechange(e) { this.mycurrent = e.detail.current }, @@ -1401,7 +1422,7 @@ + @click="imgTo(item1)"> diff --git a/pages/login/index.vue b/pages/login/index.vue index 3926142..3670b4e 100644 --- a/pages/login/index.vue +++ b/pages/login/index.vue @@ -207,8 +207,8 @@ uni.setStorageSync('isLogin',1) uni.setStorageSync('user_info',res.data) uni.switchTab({ - delta: 1 - // url:'../index/index' + // delta: 1 + url:'../index/index' }) }else{ if(res.data){