From a3d70aad7341b5a0c681565eaeedc18f98dd8c37 Mon Sep 17 00:00:00 2001 From: linju <8432241+linjuDcloud@user.noreply.gitee.com> Date: Thu, 15 Apr 2021 22:13:35 +0800 Subject: [PATCH] 123 --- App.vue | 39 +-- baseapp.config.json | 16 +- common/appInit.js | 51 +++- js_sdk/request.js | 16 +- pages.json | 68 ++--- pages/test/test.vue | 22 +- pages/ucenter/about/about.vue | 21 +- pages/ucenter/settings/settings.nvue | 257 ++++++++++++++++++ pages/ucenter/settings/settings.vue | 22 +- pages/ucenter/ucenter.vue | 129 +++++---- uniCloud-aliyun/database/db_init.json | 20 ++ .../uni-login-page/common/loginPage.css | 4 +- .../uni-login-page/common/loginPage.mixin.js | 12 +- .../uni-quick-login/uni-quick-login.vue | 26 +- 14 files changed, 524 insertions(+), 179 deletions(-) create mode 100644 pages/ucenter/settings/settings.nvue diff --git a/App.vue b/App.vue index 4c4f50c1..ee9513aa 100644 --- a/App.vue +++ b/App.vue @@ -8,24 +8,31 @@ onLaunch: function() { console.log('App Launch') initApp(); + //预加载设置页面 + uni.preloadPage({ + url: "/pages/ucenter/settings/settings", + complete:e=>{ + console.log(e); + } + }); // #ifdef APP-PLUS //预加载一键登录 - // plus.oauth.getServices(oauthServices=>{ - // oauthServices.forEach(({_id},item)=>{ - // if(_id=='provider'){ - // uni.preLogin({ - // provider:item, - // complete:e=>{ - // console.log(e); - // } - // }) - // } - // }) - - // uni.preloadPage({url: "/uni_modules/uni-login-page/pages/index/index"}); - // },err=>{ - // console.error('获取服务供应商失败:' + JSON.stringify(err)); - // }) + plus.oauth.getServices(oauthServices=>{ + console.log(oauthServices); + oauthServices.forEach(({_id},item)=>{ + if(_id=='provider'){ + uni.preLogin({ + provider:item, + complete:e=>{ + console.log(e); + } + }) + } + }) + uni.preloadPage({url: "/uni_modules/uni-login-page/pages/index/index"}); + },err=>{ + console.error('获取服务供应商失败:' + JSON.stringify(err)); + }) // #endif }, onShow: function() { diff --git a/baseapp.config.json b/baseapp.config.json index afac6d82..980a5983 100644 --- a/baseapp.config.json +++ b/baseapp.config.json @@ -5,13 +5,19 @@ "/uni_modules/uni-login-page/pages/index/pwd-retrieve" ] }, - "aboutus":{ + "about":{ "appName":"base-app", "company":"数字天堂(北京)网络技术有限公司", "slogan":"为开发而生", - "agreement":{ - "privacy":"https://uniapp.dcloud.io/", - "business":"https://uniapp.dcloud.io/" - } + "agreements":[ + { + "title":"用户服务协议", + "url":"https://uniapp.dcloud.io/" + }, + { + "title":"隐私政策", + "url":"https://uniapp.dcloud.io/" + } + ] } } \ No newline at end of file diff --git a/common/appInit.js b/common/appInit.js index af310b35..6d3b1270 100644 --- a/common/appInit.js +++ b/common/appInit.js @@ -10,21 +10,46 @@ export default function() { //自定义路由拦截 const {"router":{needLogin}} = baseappConfig //需要登陆的页面 - changeAction(["navigateTo", "redirectTo", "reLaunch", "switchTab"], { - before_action: e => { - let token = uni.getStorageSync('uni-id-token') - if (needLogin.includes(e.url) && token == '') { - console.log('该页面需要登陆,即将跳转到login页面'); - uni.showToast({title:'该页面需要登陆,即将跳转到login页面',icon:'none'}) - uni.redirectTo({ - url:"/uni_modules/uni-login-page/pages/index/index" - }) - return false + + // changeAction(["navigateTo", "redirectTo", "reLaunch", "switchTab"], { + // before_action: e => { + // let token = uni.getStorageSync('uni-id-token') + // let 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 + // } + // return true + // } + // }) + + //uni.addInterceptor的写法 + + let list = ["navigateTo", "redirectTo", "reLaunch", "switchTab"]; + list.forEach(item=>{ + uni.addInterceptor(item,{ + invoke(e){// 调用前拦截 + //console.log(e); + let token = uni.getStorageSync('uni-id-token') + let 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 + } + return true } - return true - } + }) }) + //提示网络变化 eventListenerNetwork() @@ -128,7 +153,7 @@ function changeAction(actions, {before_action,after_action}) { let old_action = uni[action] uni[action] = e => { if (before_action(e)) { - console.log(after_action); + // console.log(after_action); if (after_action) { var compose = function(f, g) { return function(x) { diff --git a/js_sdk/request.js b/js_sdk/request.js index 0f71c30c..244d9b2f 100644 --- a/js_sdk/request.js +++ b/js_sdk/request.js @@ -28,12 +28,24 @@ export default function request(name,params,callback=false,{showLoading=false,lo resolve(e) return callback(data,e.result,e) } - debug? uni.showModal({content: JSON.stringify(e)}) :''; + if(debug){ + uni.showModal({ + content: JSON.stringify(e), + showCancel: false, + confirmText: '知道了' + }) + } }, fail(err){ reject(err) console.log(err); - debug? uni.showModal({content: JSON.stringify(err)}) :''; + if(debug){ + uni.showModal({ + content: JSON.stringify(err), + showCancel: false, + confirmText: '知道了' + }) + } fail(err) } }) diff --git a/pages.json b/pages.json index cb3914c5..4a3f1c6e 100644 --- a/pages.json +++ b/pages.json @@ -19,19 +19,19 @@ } }, { "path": "uni_modules/uni-login-page/pages/index/index", - "style": { + "style": { "navigationBarTitleText": "", "app-plus": { "animationType": "none", - "popGesture": "none", - "titleNView": { - "buttons": [{ - "text": "帮助", - "type": "none", - "fontSize": "16px", - "width": "60px" - }] - } + "popGesture": "none" + // "titleNView": { + // "buttons": [{ + // "text": "帮助", + // "type": "none", + // "fontSize": "16px", + // "width": "60px" + // }] + // } } } }, { @@ -139,14 +139,14 @@ "style": { "navigationBarTitleText": "", "app-plus": { - "titleNView": { - "buttons": [{ - "text": "帮助", - "type": "none", - "fontSize": "16px", - "width": "60px" - }] - } + // "titleNView": { + // "buttons": [{ + // "text": "帮助", + // "type": "none", + // "fontSize": "16px", + // "width": "60px" + // }] + // } } } }, { @@ -154,14 +154,14 @@ "style": { "navigationBarTitleText": "", "app-plus": { - "titleNView": { - "buttons": [{ - "text": "帮助", - "type": "none", - "fontSize": "16px", - "width": "60px" - }] - } + // "titleNView": { + // "buttons": [{ + // "text": "帮助", + // "type": "none", + // "fontSize": "16px", + // "width": "60px" + // }] + // } } } }, { @@ -169,14 +169,14 @@ "style": { "navigationBarTitleText": "", "app-plus": { - "titleNView": { - "buttons": [{ - "text": "帮助", - "type": "none", - "fontSize": "16px", - "width": "60px" - }] - } + // "titleNView": { + // "buttons": [{ + // "text": "帮助", + // "type": "none", + // "fontSize": "16px", + // "width": "60px" + // }] + // } } } diff --git a/pages/test/test.vue b/pages/test/test.vue index f84fe7e0..1c253787 100644 --- a/pages/test/test.vue +++ b/pages/test/test.vue @@ -21,7 +21,27 @@ } }, - onLoad() { + onLoad() { + uni.addInterceptor('showToast',{ + invoke(e){// 调用前拦截 + console.log(e) + e.title = "645" + }, + success(e){// 成功回调拦截 + console.log(e) + }, + fail(e){// 失败回调拦截 + console.log(e) + }, + complete(e){ + console.log(e) + }, + returnValue(e){// 返回结果拦截 + console.log(e) + } + }) + + return /* 当某个权限调用失败 1.先检测手机的该模块是否打开 diff --git a/pages/ucenter/about/about.vue b/pages/ucenter/about/about.vue index eea75a83..878761b5 100644 --- a/pages/ucenter/about/about.vue +++ b/pages/ucenter/about/about.vue @@ -1,16 +1,17 @@ @@ -26,15 +27,15 @@ import baseappConfig from '@/baseapp.config.json'; return { version:"V1.0.0", year:"2020", - aboutus:{} + about:{} }; }, created() { - this.aboutus = baseappConfig.aboutus + this.about = baseappConfig.about this.year = (new Date).getFullYear() }, methods:{ - navigateTo(url,title){ + navigateTo({url,title}){ uni.navigateTo({ url: '/pages/common/webview/webview?url='+url+'&title='+title, success: res => {}, @@ -46,7 +47,7 @@ import baseappConfig from '@/baseapp.config.json'; } diff --git a/pages/ucenter/settings/settings.vue b/pages/ucenter/settings/settings.vue index 393248a8..0e42d044 100644 --- a/pages/ucenter/settings/settings.vue +++ b/pages/ucenter/settings/settings.vue @@ -15,14 +15,8 @@