From 5be43ca2c23d22e54043a45aaf39e196183a3d0e Mon Sep 17 00:00:00 2001 From: linju-json Date: Wed, 21 Apr 2021 22:33:47 +0800 Subject: [PATCH] 312 --- common/appInit.js | 79 +++++++++++++------ pages.json | 36 ++++----- pages/list/list.vue | 1 - .../networkErr.vue} | 53 +++++-------- .../database/uni-id-scores.schema.json | 5 +- .../uni-list-item/uni-list-item.vue | 2 +- 6 files changed, 95 insertions(+), 81 deletions(-) rename pages/{list/networkErr/networkErr.nvue => networkErr/networkErr.vue} (52%) diff --git a/common/appInit.js b/common/appInit.js index 42f42d1..7b5c233 100644 --- a/common/appInit.js +++ b/common/appInit.js @@ -90,7 +90,13 @@ export default function() { }); } } - }) + }) + +// #ifdef APP-PLUS +// 设备网络状态变化事件 + eventListenerNetwork() +// #endif + } /** * // 初始化appVersion @@ -126,31 +132,52 @@ function initAppVersion() { // 设备网络状态变化事件 function eventListenerNetwork() { - uni.onNetworkStatusChange(function(res) { - console.log(res.isConnected); - console.log(res.networkType); - if (!res.isConnected) { - uni.showModal({ - content: "你未打开网络连接", - confirmText: "前往打开", - complete: (e) => { - console.log(e); - if (uni.getSystemInfoSync().platform == "ios") { - plus.runtime.launchApplication({ - action: 'App-Prefs:root=WIFI' - }, function(e) { - console.log(JSON.stringify(e)); - }); - } else { - var main = plus.android.runtimeMainActivity(); - var Intent = plus.android.importClass("android.content.Intent"); - var mIntent = new Intent('android.settings.DATA_ROAMING_SETTINGS'); - main.startActivity(mIntent); - } - } - }); - } - }); + //网络掉线 + uni.getNetworkType({ + success:res=>{ + console.log(res); + if(res.networkType=='none'){ + showNetworkErrPage() + } + uni.showToast({ + title:'当前网络类型:'+res.networkType, + icon:'none', + duration:3000 + }) + } + }); + //监听网络变化 + uni.onNetworkStatusChange(res=> { + console.log(res.isConnected); + console.log(res.networkType); + if(res.networkType!='none'){ + uni.showToast({ + title:'当前网络类型:'+res.networkType, + icon:'none', + duration:3000 + }) + }else{ + showNetworkErrPage() + uni.showToast({ + title:'网络类型:'+res.networkType, + icon:'none', + duration:3000 + }) + } + }); + + function showNetworkErrPage(){ + let pages = getCurrentPages(); + console.log('pages.length',pages.length); + if(pages.length===0|| pages[pages.length - 1].route!='/pages/networkErr/networkErr.vue'){ + uni.navigateTo({ + url:'/pages/networkErr/networkErr' + }) + }else{ + console.log('已经打开'); + } + } + } function openAppPermissionSetting(){ diff --git a/pages.json b/pages.json index 0bd55de..873dddd 100644 --- a/pages.json +++ b/pages.json @@ -5,22 +5,21 @@ //#ifndef MP "navigationStyle": "custom", //#endif - "enablePullDownRefresh": true, - "app-plus":{ - "subNVues":[ - { - "id":"networkErr", - "path":"pages/list/networkErr/networkErr", - "style":{ - "height":"0", - "width":"100%", - "background":"transparent" - } - } - ] - } + "enablePullDownRefresh": true } - }, + }, + { + "path": "pages/networkErr/networkErr", + "style": { + "navigationStyle": "custom", + "backgroundColor": "transparent", + "app-plus": { + "animationType": "fade-in", + "background": "transparent", + "popGesture": "none" + } + } + }, { "path": "pages/list/news-list", "style": { @@ -219,8 +218,7 @@ "backgroundColor": "#F8F8F8" }, "condition": { - "list": [ - { + "list": [{ "path": "pages/list/list" }, { @@ -234,7 +232,7 @@ } ], "current": 0 -}, + }, "tabBar": { "color": "#7A7E83", "selectedColor": "#007AFF", @@ -257,4 +255,4 @@ "text": "我的" }] } -} +} diff --git a/pages/list/list.vue b/pages/list/list.vue index 3039f90..16794e0 100644 --- a/pages/list/list.vue +++ b/pages/list/list.vue @@ -20,7 +20,6 @@ }, onLoad() { checkIsAgree(); - uni.getSubNVueById('networkErr').show() }, onShow(options) { this.searchText = getApp().globalData.searchText; diff --git a/pages/list/networkErr/networkErr.nvue b/pages/networkErr/networkErr.vue similarity index 52% rename from pages/list/networkErr/networkErr.nvue rename to pages/networkErr/networkErr.vue index 559ff98..6c594f5 100644 --- a/pages/list/networkErr/networkErr.nvue +++ b/pages/networkErr/networkErr.vue @@ -1,7 +1,9 @@ @@ -13,42 +15,17 @@ } }, mounted() { - this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight; - const getCurrentSubNVue = uni.getCurrentSubNVue(); - getCurrentSubNVue.setStyle({ - "height":this.statusBarHeight+60+'px' - }) - uni.getNetworkType({ - success:res=>{ - console.log(res); - if(res.networkType!='none'){ - getCurrentSubNVue.hide() - }else{ - getCurrentSubNVue.show() - } - } - }); uni.onNetworkStatusChange(res=> { console.log(res.isConnected); console.log(res.networkType); - - if(res.networkType!='none'){ uni.showToast({ title:'当前网络类型:'+res.networkType, icon:'none', duration:3000 }) - if(this.old=='none'){ - this.$parent.reLink(); - } - getCurrentSubNVue.hide() - }else{ - getCurrentSubNVue.show() - uni.showToast({ - title:'网络类型:'+res.networkType, - icon:'none', - duration:3000 + uni.navigateBack({ + animationType:'fade-out' }) } }); @@ -72,10 +49,20 @@ } - diff --git a/uniCloud-aliyun/database/uni-id-scores.schema.json b/uniCloud-aliyun/database/uni-id-scores.schema.json index 69577c8..7d5715a 100644 --- a/uniCloud-aliyun/database/uni-id-scores.schema.json +++ b/uniCloud-aliyun/database/uni-id-scores.schema.json @@ -1,6 +1,9 @@ { "bsonType": "object", - "required": ["user_id", "score", "balance"], + "required": ["user_id", "score", "balance"], + "permission":{ + "read":true + }, "properties": { "_id": { "description": "ID,系统自动生成" diff --git a/uni_modules/uni-list/components/uni-list-item/uni-list-item.vue b/uni_modules/uni-list/components/uni-list-item/uni-list-item.vue index 7f1eced..f5d744a 100644 --- a/uni_modules/uni-list/components/uni-list-item/uni-list-item.vue +++ b/uni_modules/uni-list/components/uni-list-item/uni-list-item.vue @@ -370,7 +370,7 @@ $list-item-pd: $uni-spacing-col-lg $uni-spacing-row-lg; /* #endif */ height: $uni-img-size-base; width: $uni-img-size-base; - marin-right: 10px; + margin-right: 10px; } .uni-icon-wrapper { -- GitLab