Browse Source

增加页面网络监听

master
zhengshuiqi 3 years ago
parent
commit
26a9b512bb
  1. 27
      App.vue
  2. 25
      pages/index/index.vue
  3. 4
      pages/login/index.vue

27
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);
// // wifi2g3g4gethernetunknownnone
// 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')
},
}
</script>

25
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 @@
<!-- class="item_img"> -->
<image :src="item1.block_pic" mode=""
:style="{width:(item.zone_code=='HONLIST2')?420+'rpx':'',height:item.zone_column+'rpx'}"
@click="imgTo(itesm1)"></image>
@click="imgTo(item1)"></image>
</view>
</view>
<!-- 轮播图 -->

4
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){

Loading…
Cancel
Save