提交 a3d70aad 编写于 作者: L linju

123

上级 2b257a59
......@@ -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() {
......
......@@ -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
......@@ -10,13 +10,36 @@ export default function() {
//自定义路由拦截
const {"router":{needLogin}} = baseappConfig //需要登陆的页面
changeAction(["navigateTo", "redirectTo", "reLaunch", "switchTab"], {
before_action: e => {
// 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')
if (needLogin.includes(e.url) && token == '') {
let url = e.url.split('?')[0]
if (needLogin.includes(url) && token == '') {
console.log('该页面需要登陆,即将跳转到login页面');
uni.showToast({title:'该页面需要登陆,即将跳转到login页面',icon:'none'})
uni.redirectTo({
uni.navigateTo({
url:"/uni_modules/uni-login-page/pages/index/index"
})
return false
......@@ -24,6 +47,8 @@ export default function() {
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) {
......
......@@ -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)
}
})
......
......@@ -23,15 +23,15 @@
"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"
// }]
// }
}
}
......
......@@ -22,6 +22,26 @@
}
},
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.先检测手机的该模块是否打开
......
<template>
<view class="aboutus">
<view class="about">
<view class="logo">
<image class="logoImg" src="@/static/logo.png"></image>
<text class="tip appName">{{aboutus.appName}}</text>
<text class="tip appName">{{about.appName}}</text>
<text class="tip" style="font-size:24upx;">Version {{version}}</text>
</view>
<view class="copyright">
<text class="agreement" @click="navigateTo(aboutus.agreement.privacy,'用户服务协议')">《用户服务协议》</text>
<text class="hint"></text>
<text class="agreement" @click="navigateTo(aboutus.agreement.business,'隐私政策')">《隐私政策》</text>
<template v-for="(agreement,index) in about.agreements">
<text class="agreement" @click="navigateTo(agreement)">{{agreement.title}}</text>
<text class="hint" v-if="about.agreements.length-1>index"></text>
</template>
<text class="hint">Copyright © {{year}}</text>
<text class="hint">{{aboutus.company}}</text>
<text class="hint">{{about.company}}</text>
</view>
</view>
</template>
......@@ -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';
}
</script>
<style lang="scss" scoped>
.aboutus {
.about {
width: 750upx;
flex-direction: column;
}
......
<template>
<view class="content">
<!-- 功能列表 -->
<uni-list class="content">
<uni-list-item v-for="(item,index) in agreeList" :key="index" :title="item.title"
:clickable="true" @click="itemClick(item)" :showSwitch="item.showSwitch" :switchChecked="item.isChecked"
:link="!item.showSwitch"></uni-list-item>
</uni-list>
<!-- 退出按钮 -->
<view class="bottom-back" @click="clickLogout">
<text class="bottom-back-text" v-if="userInfo">退出登录</text>
<text class="bottom-back-text" v-else>登录</text>
</view>
</view>
</template>
<script>
import {isOn,setting} from './dc-push/push.js';
import {mapMutations,mapGetters} from 'vuex';
export default {
data() {
return {
agreeList: [{
title: '个人资料',
event:'toEdit'
},
{
title: '修改密码',
event:'changePwd'
},
// {
// title: '注销用户',
// event: ''
// },
//#ifdef APP-PLUS
{
title: '推送功能',
name: 'push',
event: 'openSetting',
isChecked: false,
showSwitch: true
},
// {
// title: '清理缓存',
// event: ''
// },
//#endif
]
}
},
computed:{
...mapGetters({
'userInfo':'user/info'
})
},
onLoad() {
this.initSoterAuthentication();
},
onShow() {
this.checkPush();
},
methods: {
...mapMutations({
logout: 'user/logout'
}),
toEdit(){
uni.navigateTo({
url: '/pages/ucenter/edit/edit'
});
},
changePwd(){
uni.navigateTo({
url:'/uni_modules/uni-login-page/pages/index/pwd-retrieve?phoneNumber='+ (this.userInfo?this.userInfo.phone:'') +'&phoneArea=+86'
});
},
checkPush(){
// 手机端获取推送是否开启
//#ifdef APP-PLUS
let pushIsOn = isOn();
this.agreeList.forEach(item => {
item.name == 'push' ? (item.isChecked = pushIsOn) : '';
})
//#endif
},
/**
* 添加生物认证选项
*/
initSoterAuthentication() {
// #ifdef APP-PLUS || MP-WEIXIN
let checkAuthModeList = [{
title: '指纹解锁',
name: 'fingerPrint',
event: 'startSoterAuthentication'
}, {
title: '人脸解锁',
name: 'facial',
event: 'startSoterAuthentication'
}];
uni.checkIsSupportSoterAuthentication({
success: (res) => {
res.supportMode.forEach(item => {
this.agreeList.push(checkAuthModeList.find(mode => mode.name == item));
})
},
fail: (err) => {
reject(err);
}
})
// #endif
},
/**
* 开始生物认证
*/
startSoterAuthentication(item) {
// 检查是否开启认证
this.checkIsSoterEnrolledInDevice(item)
.then(()=>{
// 开始认证
uni.startSoterAuthentication({
requestAuthModes: [item.name],
challenge: '123456', // 微信端挑战因子
authContent: `请用${item.title}`,
success:(res)=> {
if(res.errCode == 0){
/**
* 验证成功后开启自己的业务逻辑
*
* app端以此为依据 验证成功
*
* 微信小程序需要再次通过后台验证resultJSON与resultJSONSignature获取最终结果
*/
return uni.showToast({
title: `${item.title}成功`,
icon: 'none'
});
}
uni.showToast({
title: '认证失败请重试',
icon: 'none'
});
},
fail:(err)=> {
uni.showToast({
title: `认证失败:${err.errCode}`,
icon: 'none'
});
}
})
})
},
checkIsSoterEnrolledInDevice(mode){
return new Promise((resolve, reject)=>{
uni.checkIsSoterEnrolledInDevice({
checkAuthMode:mode.name,
success: (res) => {
if(res.isEnrolled){
return resolve(res);
}
uni.showToast({
title: `设备未开启${mode.title}`,
icon: 'none'
});
reject(res);
},
fail: (err) => {
uni.showToast({
title: `${mode.title}失败`,
icon: 'none'
});
reject(err);
}
})
})
},
clickLogout() {
if(this.userInfo){
uni.showModal({
title: '提示',
content: '是否退出登录',
cancelText: '取消',
confirmText: '确定',
success: res => {
if(res.confirm){
this.logout();
uni.navigateBack();
}
},
fail: () => {},
complete: () => {}
});
}else{
uni.navigateTo({
url: '/uni_modules/uni-login-page/pages/index/index'
});
}
},
itemClick(item) {
if (!item.to && item.event) {
this[item.event](item);
}
},
/**
* 打开设置页面
*/
openSetting() {
setting();
}
}
}
</script>
<style>
/* #ifndef APP-NVUE */
page {
flex: 1;
width: 100%;
height: 100%;
}
uni-button:after{
border: none;
border-radius: 0;
}
/* #endif */
.content {
/* #ifndef APP-NVUE */
display: flex;
width: 100%;
height: 100%;
/* #endif */
flex-direction: column;
flex: 1;
}
.bottom-back {
width: 750rpx;
height: 120rpx;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: column;
justify-content: center;
align-items: center;
/* #ifndef APP-NVUE */
border: none;
/* #endif */
border-width: 0;
border-radius: 0;
background-color: #007AFF;
}
.bottom-back-text {
font-size: 40rpx;
color: #FFFFFF;
}
</style>
......@@ -15,14 +15,8 @@
</template>
<script>
import {
isOn,
setting
} from './dc-push/push.js';
import {
mapMutations,
mapGetters
} from 'vuex';
import {isOn,setting} from './dc-push/push.js';
import {mapMutations,mapGetters} from 'vuex';
export default {
data() {
return {
......@@ -77,18 +71,8 @@
},
changePwd(){
uni.navigateTo({
url:'/uni_modules/uni-login-page/pages/index/pwd-retrieve?phoneNumber='+ (this.userInfo.phone||'') +'&phoneArea=+86'
url:'/uni_modules/uni-login-page/pages/index/pwd-retrieve?phoneNumber='+ (this.userInfo?this.userInfo.phone:'') +'&phoneArea=+86'
});
// if(this.userInfo){
// uni.navigateTo({
// url:'/uni_modules/uni-login-page/pages/index/pwd-retrieve?phoneNumber='+ (this.userInfo.phone||'') +'&phoneArea=+86'
// });
// } else {
// uni.showToast({
// title: '请先登录',
// icon: 'none'
// });
// }
},
checkPush(){
// 手机端获取推送是否开启
......
<template>
<view class="center">
<navigator url="/pages/ucenter/settings/settings" class="userInfo">
<view class="userInfo" @click="toSettings">
<image class="logo-img" :src="login ? (userInfo.avatar || avatarUrl) :avatarUrl"></image>
<view class="logo-title">
<text class="uer-name">{{login ? userInfo.username||userInfo.mobile : '未登录'}}</text>
<text class="go-login-navigat-arrow navigat-arrow" v-if="!login">&#xe65e;</text>
</view>
</navigator>
</view>
<uni-grid class="grid" :column="5" :showBorder="false" :square="true">
<uni-grid-item class="item" v-for="({text,icon},index) in gridList" @click.native="tapGrid(index)">
<uni-icons class="icon" color="#5d5e64" :type="icon" size="28"></uni-icons>
......@@ -14,13 +14,8 @@
</uni-grid-item>
</uni-grid>
<uni-list class="center-list" v-for="(sublist , index) in ucenterList">
<uni-list-item v-for="item in sublist"
:title="item.title"
link :rightText="item.rightText"
:clickable="true"
:to="item.to"
@click="ucenterListClick(item)"
>
<uni-list-item v-for="item in sublist" :title="item.title" link :rightText="item.rightText"
:clickable="true" :to="item.to" @click="ucenterListClick(item)">
<view v-if="item.showBadge" class="item-footer" slot="footer">
<text class="item-footer-text">{{item.rightText}}</text>
<view class="item-footer-badge"></view>
......@@ -69,29 +64,23 @@
title: '我的积分',
to: ''
}],
[{
title: '政策与协议',
to: '/pages/ucenter/agree-list/agree-list'
}, {
title: '关于',
to: '/pages/ucenter/about/about'
},
[
//#ifdef APP-PLUS
{
title: '检查更新',
rightText: `V${getApp().appVersion.version}_${getApp().appVersion.versionCode}`,
event:'checkVersion',
showBadge:true
}
event: 'checkVersion',
showBadge: true
},
//#endif
],
[{
{
title: '反馈',
to: '/uni_modules/opendb-feedback/pages/opendb-feedback/list' // /pages/ucenter/uni-feedback/uni-feedback uni_modules/opendb-feedback/pages/opendb-feedback/list
}, {
title: '设置',
to: '/pages/ucenter/settings/settings'
}]
},{
title: '关于',
to: '/pages/ucenter/about/about'
}
]
]
}
},
......@@ -108,6 +97,11 @@
...mapMutations({
logout: 'user/logout'
}),
toSettings(){
uni.navigateTo({
url:"/pages/ucenter/settings/settings"
})
},
/**
* 个人中心项目列表点击事件
*/
......@@ -132,9 +126,9 @@
})
}
},
tapGrid(index){
tapGrid(index) {
uni.showToast({
title: '你点击了,第'+index+'',
title: '你点击了,第' + index + '',
icon: 'none'
});
}
......@@ -174,7 +168,7 @@
.userInfo {
width: 750rpx;
padding: 20rpx;
padding-top:50px;
padding-top: 50px;
background-color: #2F85FC;
flex-direction: column;
align-items: center;
......@@ -233,10 +227,11 @@
height: 40rpx;
}
.grid{
.grid {
background-color: #FFFFFF;
margin:25rpx 0;
margin: 25rpx 0;
}
.uni-grid .text {
font-size: 26rpx;
color: #817f82;
......@@ -248,25 +243,28 @@
}
/*修改边线粗细示例*/
/* #ifndef APP-NVUE */
/*修改边线粗细示例*/
/* #ifndef APP-NVUE */
.center-list /deep/ .uni-list--border:after,
.center-list /deep/ .uni-list--border-top ,
.center-list /deep/ .uni-list--border-bottom{
.center-list /deep/ .uni-list--border-top,
.center-list /deep/ .uni-list--border-bottom {
-webkit-transform: scaleY(0.2);
transform: scaleY(0.2);
}
/* #endif */
.item-footer{
/* #endif */
.item-footer {
flex-direction: row;
align-items: center;
}
.item-footer-text{
}
.item-footer-text {
color: #999;
font-size: 24rpx;
padding-right: 10rpx;
}
.item-footer-badge{
}
.item-footer-badge {
width: 20rpx;
height: 20rpx;
/* #ifndef APP-NVUE */
......@@ -276,6 +274,5 @@
border-radius: 10rpx;
/* #endif */
background-color: #DD524D;
}
}
</style>
......@@ -157,5 +157,25 @@
}
}
}
},
"opendb-app-versions":{
"data":[
{
"is_silently": false,
"is_mandatory": false,
"appid": "__UNI__03B096E",
"name": "base-app",
"title": "新增升级中心",
"contents": "新增升级中心",
"platform": [
"Android"
],
"version": "1.0.1",
"url": "https://vkceyugu.cdn.bspapp.com/VKCEYUGU-3469aac7-a663-4c5d-8ee8-94275f8c09ab/3128d010-01c5-4121-a1d6-f3f919944a23.apk",
"stable_publish": false,
"type": "native_app",
"create_date": 1616771628150
}
]
}
}
......@@ -41,10 +41,12 @@ page {
padding-top: 50rpx;
}
/* #ifndef APP-NVUE */
.hidden,
page {
background-color: transparent;
}
/* #endif */
.login-iknow {
padding-top: 24rpx;
......
......@@ -4,12 +4,12 @@ import {
mapMutations
} from 'vuex';
let mixin = {
// 监听帮助按钮
onNavigationBarButtonTap(event) {
uni.navigateTo({
url:helpPage
})
},
// // 监听帮助按钮
// onNavigationBarButtonTap(event) {
// uni.navigateTo({
// url:helpPage
// })
// },
data(){
return {
// 用户协议页面跳转
......
......@@ -96,7 +96,7 @@
let oauthService = this.oauthServices.find((service) => service.id == type)
// #ifdef APP-PLUS
//uni.showLoading({mask: true});
console.log(type,231);
console.log(type);
//请勿直接使用前端获取的unionid或openid直接用于登陆,前端的数据都是不可靠的
if(type=='weixin'){
oauthService.authorize(({code})=>{
......@@ -104,6 +104,7 @@
this.quickLogin({code},type)
},
err=>{
uni.hideLoading()
console.log(err);
})
}
......@@ -122,11 +123,24 @@
fail: (err) => {
uni.hideLoading()
console.log(err);
if(err.errCode===30002){
switch (err.errCode){
case 30002:
console.log('在一键登陆界面,点击其他登陆方式');
}
if(err.errCode===30003){
break;
case 30003:
console.log('关闭了登陆');
uni.navigateBack()
break;
case 30006:
uni.showModal({
title: "登陆服务初始化错误",
content:err.metadata.error_data,
showCancel: false,
confirmText: '知道了',
});
break;
default:
break;
}
}
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册