Browse Source

增加页面网络监听

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

25
App.vue

@ -18,6 +18,30 @@
} }
addAppCount({channel:channel,is_install:isInstall}); 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') // console.log('App Launch')
uni.hideTabBar() uni.hideTabBar()
// uni.onTabBarMidButtonTap(()=>{ // uni.onTabBarMidButtonTap(()=>{
@ -84,6 +108,7 @@
let extras = result.extras let extras = result.extras
console.log("自定义消息", result) console.log("自定义消息", result)
}) })
//#endif //#endif
}, },

25
pages/index/index.vue

@ -216,7 +216,6 @@
uni.getNetworkType({ uni.getNetworkType({
success: (res) => { success: (res) => {
console.log(res.networkType, s); console.log(res.networkType, s);
if (res.networkType !== 'none') { if (res.networkType !== 'none') {
that.typee = 2; that.typee = 2;
clearInterval(time); clearInterval(time);
@ -228,6 +227,7 @@
this.getMes() this.getMes()
this.getPullMes() this.getPullMes()
this.getInfo() this.getInfo()
this.checkNetwork()
if (this.countdownTime2 != 0) { if (this.countdownTime2 != 0) {
uni.hideTabBar() uni.hideTabBar()
} else if (this.countdownTime2 == 0 || !this.popImg) { } else if (this.countdownTime2 == 0 || !this.popImg) {
@ -244,12 +244,14 @@
}) })
s++; s++;
}, 5000); }, 5000);
}, },
mounted() { mounted() {
this.getimgheight() this.getimgheight()
this.getimgheight1() this.getimgheight1()
this.getimgheight2() this.getimgheight2()
this.checkNetwork()
console.log(this.open_img) console.log(this.open_img)
if (this.open_img) { if (this.open_img) {
setTimeout(() => { setTimeout(() => {
@ -265,11 +267,13 @@
this.getPullMes() this.getPullMes()
this.getimgheight() this.getimgheight()
this.getimgheight2() this.getimgheight2()
this.checkNetwork()
}, },
onShow() { onShow() {
this.isLogin = uni.getStorageSync('isLogin') this.isLogin = uni.getStorageSync('isLogin')
// console.log(this.isLogin) // console.log(this.isLogin)
uni.hideTabBar() uni.hideTabBar()
this.checkNetwork()
this.getList() this.getList()
this.getMes() this.getMes()
this.sum = 0 this.sum = 0
@ -319,6 +323,23 @@
}, },
methods: { 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) { handlechange(e) {
this.mycurrent = e.detail.current this.mycurrent = e.detail.current
}, },
@ -1401,7 +1422,7 @@
<!-- class="item_img"> --> <!-- class="item_img"> -->
<image :src="item1.block_pic" mode="" <image :src="item1.block_pic" mode=""
:style="{width:(item.zone_code=='HONLIST2')?420+'rpx':'',height:item.zone_column+'rpx'}" :style="{width:(item.zone_code=='HONLIST2')?420+'rpx':'',height:item.zone_column+'rpx'}"
@click="imgTo(itesm1)"></image> @click="imgTo(item1)"></image>
</view> </view>
</view> </view>
<!-- 轮播图 --> <!-- 轮播图 -->

4
pages/login/index.vue

@ -207,8 +207,8 @@
uni.setStorageSync('isLogin',1) uni.setStorageSync('isLogin',1)
uni.setStorageSync('user_info',res.data) uni.setStorageSync('user_info',res.data)
uni.switchTab({ uni.switchTab({
delta: 1 // delta: 1
// url:'../index/index' url:'../index/index'
}) })
}else{ }else{
if(res.data){ if(res.data){

Loading…
Cancel
Save