diff --git a/common/appInit.js b/common/appInit.js
index 4ab33a68d3fe5d329c73df7c7fdab49f1ca38ff4..42f42d1273f3788f118bd68dc6db87a5f6b367b9 100644
--- a/common/appInit.js
+++ b/common/appInit.js
@@ -1,129 +1,196 @@
-import baseappConfig from '@/baseapp.config.js';
-// #ifdef APP-PLUS
-import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
-import callCheckVersion from '@/uni_modules/uni-upgrade-center-app/utils/call-check-version';
-// #endif
-export default function() {
- // 初始化appVersion(仅app生效)
- initAppVersion();
-
- //自定义路由拦截
- const {"router":{needLogin,login}} = baseappConfig //需要登陆的页面
- //uni.addInterceptor的写法
- let list = ["navigateTo", "redirectTo", "reLaunch", "switchTab"];
- list.forEach(item=>{
- uni.addInterceptor(item,{
- invoke(e){// 调用前拦截
- //console.log(e);
- const token = uni.getStorageSync('uni_id_token')
- // console.log(token);
- const url = e.url.split('?')[0]
- //拦截强制登陆页面
- if (needLogin.includes(url) && token == '') {
- console.log('该页面需要登陆,即将跳转到login页面');
- uni.showToast({title:'该页面需要登陆,即将跳转到login页面',icon:'none'})
- uni.navigateTo({
- url:"/uni_modules/uni-login-page/pages/index/index"
- })
- return false
- }
- //控制登陆优先级
- if(url=='/uni_modules/uni-login-page/pages/index/index'){
- //一键登录(univerify)、密码登陆(username)、快捷登录&验证码登陆(!univerify&password)
- if(login[0]=='univerify'){
- // console.log(e.url,url);
- if(e.url==url){ e.url+= '?' }
- e.url += "univerify_first=true"
- }else if(login[0]=='username'){
- e.url = "/uni_modules/uni-login-page/pages/pwd-login/pwd-login"
- }else{
- //默认即是
+import baseappConfig from '@/baseapp.config.js';
+// #ifdef APP-PLUS
+import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
+import callCheckVersion from '@/uni_modules/uni-upgrade-center-app/utils/call-check-version';
+// #endif
+export default function() {
+ // 初始化appVersion(仅app生效)
+ initAppVersion();
+
+ //自定义路由拦截
+ const {
+ "router": {
+ needLogin,
+ login
+ }
+ } = baseappConfig //需要登陆的页面
+ //uni.addInterceptor的写法
+ let list = ["navigateTo", "redirectTo", "reLaunch", "switchTab"];
+ list.forEach(item => {
+ uni.addInterceptor(item, {
+ invoke(e) { // 调用前拦截
+ //console.log(e);
+ const token = uni.getStorageSync('uni_id_token')
+ // console.log(token);
+ const url = e.url.split('?')[0]
+ //拦截强制登陆页面
+ if (needLogin.includes(url) && token == '') {
+ console.log('该页面需要登陆,即将跳转到login页面');
+ uni.showToast({
+ title: '该页面需要登陆,即将跳转到login页面',
+ icon: 'none'
+ })
+ uni.navigateTo({
+ url: "/uni_modules/uni-login-page/pages/index/index"
+ })
+ return false
+ }
+ //控制登陆优先级
+ if (url == '/uni_modules/uni-login-page/pages/index/index') {
+ //一键登录(univerify)、密码登陆(username)、快捷登录&验证码登陆(!univerify&password)
+ if (login[0] == 'univerify') {
+ // console.log(e.url,url);
+ if (e.url == url) {
+ e.url += '?'
+ }
+ e.url += "univerify_first=true"
+ } else if (login[0] == 'username') {
+ e.url = "/uni_modules/uni-login-page/pages/pwd-login/pwd-login"
+ } else {
+ //默认即是
+ }
+ }
+ return true
+ },
+ fail(err) { // 失败回调拦截
+ console.log(err);
+ },
+ })
+ })
+
+ //当应用无访问摄像头/相册权限,引导跳到设置界面
+ uni.addInterceptor('chooseImage', {
+ fail(e) { // 失败回调拦截
+ console.log(e);
+ if (
+ e.errCode === 11 && uni.getSystemInfoSync().platform == "android" ||
+ e.errCode === 2 && uni.getSystemInfoSync().platform == "ios"
+ ){
+ uni.showModal({
+ title:"无法访问摄像头",
+ content: "当前无摄像头访问权限,建议前往设置",
+ confirmText: "前往设置",
+ success(e) {
+ if (e.confirm) {
+ openAppPermissionSetting()
+ }
}
- }
- return true
- },
- success(){ // 成功回调拦截
-
- },
- fail(err){ // 失败回调拦截
- console.log(err);
- },
- complete(e){ // 完成回调拦截
- //console.log(e);
- },
- returnValue(){// 返回结果拦截
-
+ });
}
- })// 移除拦截器API removeInterceptor('request')
- })
-
- //提示网络变化
- eventListenerNetwork()
- /*
- 当某个权限调用失败
- 1.先检测手机的该模块是否打开
- 2.检测当前应用是否被授权了该模块对应的权限
- 提示,并点击跳转到设置
- */
-}
-/**
- * // 初始化appVersion
- */
-function initAppVersion() {
- // #ifdef APP-PLUS
- let appid = plus.runtime.appid;
- plus.runtime.getProperty(appid, (wgtInfo) => {
- let appVersion = plus.runtime;
- let currentVersion = appVersion.versionCode > wgtInfo.versionCode ? appVersion : wgtInfo;
- getApp({
- allowDefault: true
- }).appVersion = {
- ...currentVersion,
- appid,
- hasNew:false
- }
- // 检查更新小红点
- callCheckVersion().then(res=>{
- console.log('检查是否有可以更新的版本',res);
- if(res.result.code>0){
- // 有新版本
- getApp({
- allowDefault: true
- }).appVersion.hasNew = true;
+ if(e.errCode === 12 && uni.getSystemInfoSync().platform == "android"){
+ uni.showModal({
+ title:"无法访问相册",
+ content: "当前无系统相册访问权限,建议前往设置",
+ confirmText: "前往设置",
+ success(e) {
+ if (e.confirm) {
+ openAppPermissionSetting()
+ }
+ }
+ });
}
- })
- });
-
- // 检查更新
- checkUpdate();
- // #endif
+ }
+ })
+}
+/**
+ * // 初始化appVersion
+ */
+function initAppVersion() {
+ // #ifdef APP-PLUS
+ let appid = plus.runtime.appid;
+ plus.runtime.getProperty(appid, (wgtInfo) => {
+ let appVersion = plus.runtime;
+ let currentVersion = appVersion.versionCode > wgtInfo.versionCode ? appVersion : wgtInfo;
+ getApp({
+ allowDefault: true
+ }).appVersion = {
+ ...currentVersion,
+ appid,
+ hasNew: false
+ }
+ // 检查更新小红点
+ callCheckVersion().then(res => {
+ console.log('检查是否有可以更新的版本', res);
+ if (res.result.code > 0) {
+ // 有新版本
+ getApp({
+ allowDefault: true
+ }).appVersion.hasNew = true;
+ }
+ })
+ });
+ // 检查更新
+ checkUpdate();
+ // #endif
+}
+
+// 设备网络状态变化事件
+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);
+ }
+ }
+ });
+ }
+ });
}
-// 设备网络状态变化事件
-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);
- }
- }
- });
- }
- });
-}
\ No newline at end of file
+function openAppPermissionSetting(){
+ // 跳转到**应用**的权限页面
+ if (uni.getSystemInfoSync().platform == "ios") {
+ var UIApplication = plus.ios.import("UIApplication");
+ var application2 = UIApplication.sharedApplication();
+ var NSURL2 = plus.ios.import("NSURL");
+ // var setting2 = NSURL2.URLWithString("prefs:root=LOCATION_SERVICES");
+ var setting2 = NSURL2.URLWithString("app-settings:");
+ application2.openURL(setting2);
+ plus.ios.deleteObject(setting2);
+ plus.ios.deleteObject(NSURL2);
+ plus.ios.deleteObject(application2);
+ } else {
+ // console.log(plus.device.vendor);
+ var Intent = plus.android.importClass("android.content.Intent");
+ var Settings = plus.android.importClass("android.provider.Settings");
+ var Uri = plus.android.importClass("android.net.Uri");
+ var mainActivity = plus.android.runtimeMainActivity();
+ var intent = new Intent();
+ intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
+ var uri = Uri.fromParts("package", mainActivity.getPackageName(), null);
+ intent.setData(uri);
+ mainActivity.startActivity(intent);
+ }
+}
+/*
+ uni.addInterceptor(item, {
+ invoke(e) { // 调用前拦截
+ },
+ success() { // 成功回调拦截
+ },
+ fail(err) { // 失败回调拦截
+ console.log(err);
+ },
+ complete(e) { // 完成回调拦截
+ //console.log(e);
+ },
+ returnValue() { // 返回结果拦截
+ }
+ }) // 移除拦截器API removeInterceptor('request')
+*/
\ No newline at end of file
diff --git a/manifest.json b/manifest.json
index ca7c8b529f55f102be8476369b9794ed1be04fff..7123ad98809610a694842db812000ac18484b1df 100644
--- a/manifest.json
+++ b/manifest.json
@@ -101,6 +101,6 @@
"enable" : false
},
"h5" : {
- "template" : "template.h5.html"
+ "template" : ""
}
}
diff --git a/pages.json b/pages.json
index c3d1e8cc444ee9ca0ddb61750e6829bfa9c56f47..0ddbe4f77f47c52c13641ae7df8ee497bbb20fa5 100644
--- a/pages.json
+++ b/pages.json
@@ -1,17 +1,31 @@
{
"pages": [{
"path": "pages/list/list",
- "style": {
+ "style": {
//#ifndef MP
- "navigationStyle": "custom",
+ "navigationStyle": "custom",
//#endif
- "enablePullDownRefresh": true
+ "enablePullDownRefresh": true,
+ "app-plus":{
+ "subNVues":[
+ {
+ "id":"networkErr",
+ "path":"pages/list/networkErr/networkErr",
+ "style":{
+ "height":"0",
+ "width":"100%",
+ "background":"transparent"
+ }
+ }
+ ]
+ }
}
- }, {
+ },
+ {
"path": "pages/list/news-list",
"style": {
- //#ifndef MP
- "navigationStyle": "custom",
+ //#ifndef MP
+ "navigationStyle": "custom",
//#endif
"enablePullDownRefresh": true
}
@@ -19,8 +33,8 @@
{
"path": "pages/grid/grid",
"style": {
- //#ifndef MP
- "navigationStyle": "custom"
+ //#ifndef MP
+ "navigationStyle": "custom"
//#endif
}
}, {
@@ -35,8 +49,8 @@
}, {
"path": "pages/list/search/search",
"style": {
- //#ifndef MP
- "navigationStyle": "custom"
+ //#ifndef MP
+ "navigationStyle": "custom"
//#endif
}
}, {
@@ -226,7 +240,6 @@
"path": "pages/ucenter/settings/settings"
}
],
-
"current": 0
},
"tabBar": {
diff --git a/pages/list/list.vue b/pages/list/list.vue
index 16794e08f174bb16b30ecb162037d72488b46425..3039f908f70d12980e65543bc378bfbb4b6d1bbe 100644
--- a/pages/list/list.vue
+++ b/pages/list/list.vue
@@ -20,6 +20,7 @@
},
onLoad() {
checkIsAgree();
+ uni.getSubNVueById('networkErr').show()
},
onShow(options) {
this.searchText = getApp().globalData.searchText;
diff --git a/pages/list/networkErr/networkErr.nvue b/pages/list/networkErr/networkErr.nvue
new file mode 100644
index 0000000000000000000000000000000000000000..559ff98b4f016b93691d11dd4294f7ade2a66024
--- /dev/null
+++ b/pages/list/networkErr/networkErr.nvue
@@ -0,0 +1,81 @@
+
+