提交 f763279a 编写于 作者: L linju

23

上级 c5128ca7
{
module.exports = {
"router":{
"needLogin":[
"needLogin":[ //配置需要路由拦截的页面地址,在打开这些页面之前会自动检查(不联网)uni_id_token的值是否存在/过期等
"/pages/ucenter/edit/edit",
"/pages/ucenter/settings/settings",
"/uni_modules/uni-login-page/pages/index/pwd-retrieve"
],
"login":["univerify","password","weixin","apple","code"]
......
import baseappConfig from '@/baseapp.config.json';
import baseappConfig from '@/baseapp.config.js';
// #ifdef APP-PLUS
import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
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
initAppVersion();
// #endif
export default function() {
// 初始化appVersion
initAppVersion();
//自定义路由拦截
const {"router":{needLogin,login}} = baseappConfig //需要登陆的页面
......@@ -50,11 +50,11 @@ export default function() {
if(url=='/uni_modules/uni-login-page/pages/index/index'){
//一键登录(univerify)、密码登陆(password)、快捷登录&验证码登陆(!univerify&password)
if(login[0]=='univerify'){
console.log(e.url,url);
// console.log(e.url,url);
if(e.url==url){ e.url+= '?' }
e.url += "univerify_first=true"
}else if(login[0]=='password'){
e.url = "/uni_modules/uni-login-page/pages/index/pwd-login"
e.url = "/uni_modules/uni-login-page/pages/pwd-login/pwd-login"
}else{
//默认即是
}
......@@ -64,8 +64,8 @@ export default function() {
success(){ // 成功回调拦截
},
fail(){ // 失败回调拦截
fail(err){ // 失败回调拦截
console.log(err);
},
complete(e){ // 完成回调拦截
//console.log(e);
......@@ -105,22 +105,22 @@ export default function() {
// }
// })
// #endif
}
/**
* // 初始化appVersion
*/
function initAppVersion() {
// #ifdef APP-PLUS
let appid = plus.runtime.appid;
plus.runtime.getProperty(appid, (wgtInfo) => {
}
/**
* // 初始化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
let currentVersion = appVersion.versionCode > wgtInfo.versionCode ? appVersion : wgtInfo;
getApp({
allowDefault: true
}).appVersion = {
...currentVersion,
appid,
hasNew:true
...currentVersion,
appid,
hasNew:true
}
// 检查更新小红点
callCheckVersion()
......@@ -131,13 +131,13 @@ function initAppVersion() {
allowDefault: true
}).appVersion.hasNew = true;
}
})
})
});
// 检查更新
checkUpdate();
// #endif
}
checkUpdate();
// #endif
}
// 设备网络状态变化事件
function eventListenerNetwork () {
......@@ -172,9 +172,9 @@ function eventListenerNetwork () {
function changeAction(actions, {before_action,after_action}) {
if(typeof actions == 'string'){
actions = [actions]
}
if (!before_action) {
before_action = () => true
}
if (!before_action) {
before_action = () => true
}
actions.forEach(action=>{
let old_action = uni[action]
......
......@@ -7,9 +7,9 @@
"transformPx" : false,
/* 5+App特有相关 */
"app-plus" : {
"compatible": {
"ignoreVersion": true //true表示忽略版本检查提示框,HBuilderX1.9.0及以上版本支持
},
"compatible" : {
"ignoreVersion" : true //true表示忽略版本检查提示框,HBuilderX1.9.0及以上版本支持
},
"usingComponents" : true,
"nvueStyleCompiler" : "uni-app",
"compilerVersion" : 3,
......
......@@ -23,17 +23,9 @@
"navigationBarTitleText": "",
"app-plus": {
"animationType": "none",
"popGesture": "none",
"navigationStyle": "custom",
"backgroundColor": "transparent"
// "titleNView": {
// "buttons": [{
// "text": "帮助",
// "type": "none",
// "fontSize": "16px",
// "width": "60px"
// }]
// }
"popGesture": "none"
// "navigationStyle": "custom",
// "backgroundColor": "transparent",
}
}
}, {
......@@ -159,7 +151,6 @@
"navigationBarTitleText": "帮助",
"enablePullDownRefresh": false
}
}
,{
"path" : "pages/test/test",
......@@ -186,20 +177,20 @@
"navigationBarBackgroundColor": "#FFFFFF",
"backgroundColor": "#F8F8F8"
},
// "condition": {
// "list": [
// {
// "path": "uni_modules/uni-login-page/pages/index/index"
// },
// {
// "path": "pages/test/test"
// },
// {
// "path":"pages/ucenter/settings/settings"
// }
// ],
// "current":1
// },
"condition": {
"list": [
{
"path": "uni_modules/uni-login-page/pages/index/index"
},
{
"path": "pages/test/test"
},
{
"path":"pages/ucenter/settings/settings"
}
],
"current":0
},
"tabBar": {
"color": "#7A7E83",
"selectedColor": "#007AFF",
......
......@@ -16,7 +16,7 @@
</view>
</template>
<script>
import baseappConfig from '@/baseapp.config.json';
import baseappConfig from '@/baseapp.config.js';
export default {
onLoad() {
// #ifdef APP-PLUS
......
<template>
<view class="content">
<!-- 功能列表 -->
<uni-list class="content">
<uni-list>
<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>
:link="!item.showSwitch"
></uni-list-item>
</uni-list>
<!-- 退出按钮 -->
<view class="bottom-back" @click="clickLogout">
......@@ -71,7 +72,10 @@
},
changePwd(){
uni.navigateTo({
url:'/uni_modules/uni-login-page/pages/index/pwd-retrieve?phoneNumber='+ (this.userInfo?this.userInfo.phone:'') +'&phoneArea=+86'
url:'/uni_modules/uni-login-page/pages/pwd-retrieve/pwd-retrieve?phoneNumber='+ (this.userInfo&&this.userInfo.phone?this.userInfo.phone:'') +'&phoneArea=+86',
fail:err=> {
console.log(err);
}
});
},
checkPush(){
......@@ -198,7 +202,8 @@
}
},
itemClick(item) {
if (!item.to && item.event) {
console.log(item);
if (item.event) {
this[item.event](item);
}
},
......@@ -227,11 +232,12 @@
.content {
/* #ifndef APP-NVUE */
display: flex;
width: 100%;
height: 100%;
width: 750rpx;
height: 100vh;
/* #endif */
flex-direction: column;
flex: 1;
background-color: #E5E5E5;
}
.bottom-back {
......@@ -248,11 +254,11 @@
/* #endif */
border-width: 0;
border-radius: 0;
background-color: #007AFF;
background-color: #FFFFFF;
}
.bottom-back-text {
font-size: 40rpx;
color: #FFFFFF;
color: #999999;
}
</style>
<template>
<view class="content">
<view class="content">
<!-- 功能列表 -->
<uni-list class="content">
<uni-list-item v-for="(item,index) in agreeList" :key="index" :title="item.title"
<uni-list :border="false" class="mb10" v-for="(sublist,index) in agreeList">
<uni-list-item :border="false" class="mb1" v-for="(item,index) in sublist" :key="index" :title="item.title"
:clickable="true" @click="itemClick(item)" :showSwitch="item.showSwitch" :switchChecked="item.isChecked"
:link="!item.showSwitch"></uni-list-item>
</uni-list>
<!-- 退出按钮 -->
<button class="bottom-back" @click="clickLogout">
<text class="bottom-back-text" v-if="userInfo">退出登录</text>
<text class="bottom-back-text" v-else>登录</text>
</button>
</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';
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
agreeList: [
[{
title: '个人资料',
event: 'toEdit'
},
{
title: '修改密码',
event: 'changePwd'
}
],
[
//#ifdef APP-PLUS
{
title: '推送功能',
name: 'push',
event: 'openSetting',
isChecked: false,
showSwitch: true
},
{
title: '清理缓存',
event: 'clearTmp'
},
//#endif
]
]
}
},
computed:{
...mapGetters({
'userInfo':'user/info'
})
},
computed: {
...mapGetters({
'userInfo': 'user/info'
})
},
onLoad() {
this.initSoterAuthentication();
......@@ -63,25 +68,29 @@
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
}),
toEdit() {
uni.navigateTo({
url: '/uni_modules/uni-id-users/pages/uni-id-users/edit'
});
},
changePwd() {
uni.navigateTo({
url: '/uni_modules/uni-login-page/pages/pwd-retrieve/pwd-retrieve?phoneNumber=' + (this
.userInfo && this.userInfo.phone ? this.userInfo.phone : '') + '&phoneArea=+86',
fail: err => {
console.log(err);
}
});
},
checkPush() {
// 手机端获取推送是否开启
//#ifdef APP-PLUS
let pushIsOn = isOn();
this.agreeList.forEach(item => {
item.name == 'push' ? (item.isChecked = pushIsOn) : '';
})
//#endif
},
/**
* 添加生物认证选项
......@@ -101,7 +110,7 @@
uni.checkIsSupportSoterAuthentication({
success: (res) => {
res.supportMode.forEach(item => {
this.agreeList.push(checkAuthModeList.find(mode => mode.name == item));
this.agreeList.push([checkAuthModeList.find(mode => mode.name == item)]);
})
},
fail: (err) => {
......@@ -109,98 +118,124 @@
}
})
// #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'
});
}
})
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) => {
console.log(`认证失败:${err.errCode}`);
uni.showToast({
title: `认证失败`,
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);
}
})
})
},
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'
});
}
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) {
itemClick(item) {
console.log(item);
if (item.event) {
this[item.event](item);
}
},
clearTmp() {
uni.showLoading({
title: '清除中',
mask: true
});
uni.getSavedFileList({
success:res=>{
if (res.fileList.length > 0) {
uni.removeSavedFile({
filePath: res.fileList[0].filePath,
complete:res=>{
console.log(res);
uni.hideLoading()
}
});
}else{
uni.hideLoading()
}
},
complete:e=>{
console.log(e);
}
});
},
/**
* 打开设置页面
*/
......@@ -217,25 +252,29 @@
flex: 1;
width: 100%;
height: 100%;
}
uni-button:after{
border: none;
border-radius: 0;
}
uni-button:after {
border: none;
border-radius: 0;
}
/* #endif */
.content {
/* #ifndef APP-NVUE */
display: flex;
width: 100%;
height: 100%;
width: 750rpx;
height: 100vh;
/* #endif */
flex-direction: column;
flex: 1;
flex: 1;
background-color: #F9F9F9;
}
.bottom-back {
margin-top: 10px;
width: 750rpx;
height: 120rpx;
height: 44px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
......@@ -246,12 +285,23 @@
border: none;
/* #endif */
border-width: 0;
border-radius: 0;
background-color: #007AFF;
border-radius: 0;
background-color: #FFFFFF;
}
.bottom-back-text {
font-size: 40rpx;
color: #FFFFFF;
font-size: 33rpx;
}
.mb10 {
margin-bottom: 10px;
}
.content /deep/ .uni-list {
background-color: #F9F9F9;
}
.mb1 {
margin-bottom: 1px;
}
</style>
......@@ -28,6 +28,7 @@ let state = {
state.info = null;
state.hasLogin = false;
uni.setStorageSync('userInfo', null);
uni.setStorageSync('uni_id_token', '');
}
},
actions = {
......
......@@ -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 {
......
<template>
<view class="wrap">
<view class="wrap">
<!-- <uni-nav-bar left-icon="back" left-text="返回" right-text="菜单" title="导航栏组件"></uni-nav-bar> -->
<view class="wrap-content">
<view class="content">
......@@ -27,10 +27,10 @@
<text class="tip-text">未注册的手机号验证通过后将自动注册</text>
<!-- 其他登录方式 -->
<view class="auth-box" v-if="loginList.includes('password')">
<!-- <view class="auth-box" v-if="loginList.includes('password')">
<text class="login-text" hover-class="hover" @click="toPwdLogin">密码登录</text>
<!-- <text class="login-text" hover-class="hover" @click="openLoginList">其他登录方式</text> -->
</view>
<text class="login-text" hover-class="hover" @click="openLoginList">其他登录方式</text>
</view> -->
</view>
</view>
<!-- 登录按钮弹窗 -->
......@@ -39,9 +39,9 @@
</view>
</template>
<script>
var univerify_first,currentWebview;//是否一键登陆优先
import baseappConfig from '@/baseapp.config.json';
<script>
var univerify_first,currentWebview;//是否一键登陆优先
import baseappConfig from '@/baseapp.config.js';
import mixin from '../../common/loginPage.mixin.js';
var currentPage;
export default {
......@@ -49,38 +49,44 @@ import baseappConfig from '@/baseapp.config.json';
data() {
return {
phoneArea: ['+86'],
currenPhoneArea: '+86',
loginList:[]
currenPhoneArea: '+86',
// loginList:[]
}
},
onLoad(e) {
this.loginList = baseappConfig.router.login
univerify_first = e.univerify_first
//#ifdef APP-PLUS
if(univerify_first){
const pages = getCurrentPages();
currentWebview = pages[pages.length - 1].$getAppWebview();
currentWebview.hide();
},
onLoad(e) {
// this.loginList = baseappConfig.router.login
univerify_first = e.univerify_first
//#ifdef APP-PLUS
if(univerify_first){
const pages = getCurrentPages();
currentWebview = pages[pages.length - 1].$getAppWebview();
currentWebview.setStyle({
"top":"2000px"
})
}
//#endif
},
onReady() {
//#ifdef APP-PLUS
if(univerify_first){
console.log('开始一键登陆');
this.$refs.uniQuickLogin.login('univerify')
setTimeout(() => {
currentWebview.setStyle({
titleNView:{
autoBackButton:true,
backgroundColor:"#FFFFFF"
}
})
currentWebview.show()
}, 1500);
}
//#endif
},
//#endif
},
onReady() {
//#ifdef APP-PLUS
if(univerify_first){
console.log('开始一键登陆');
setTimeout(()=>{
this.$refs.uniQuickLogin.login('univerify')
},100)
setTimeout(() => {
currentWebview.setStyle({
titleNView:{
autoBackButton:true,
backgroundColor:"#FFFFFF"
}
})
currentWebview.setStyle({
"top":"0"
})
}, 1500);
}
//#endif
},
computed: {
canGetShortMsg() {
return this.isPhone;
......@@ -112,7 +118,7 @@ import baseappConfig from '@/baseapp.config.json';
*/
toPwdLogin() {
uni.navigateTo({
url: './pwd-login'
url: '../pwd-login/pwd-login'
})
},
openLoginList() {
......
......@@ -8,6 +8,9 @@
<!-- 登录框 (选择手机号所属国家和地区需要另行实现) -->
<uni-forms ref="form" :value="formData" :rules="rules">
<uni-forms-item name="phone">
<!-- <uni-easyinput type="number" class="phone-input-box" :inputBorder="false"
v-model="formData.phone" maxlength="11" placeholder="请输入手机号码">
</uni-easyinput> -->
<uni-easyinput type="number" class="phone-input-box" :inputBorder="false"
v-model="formData.code" maxlength="6" placeholder="请输入验证码">
<template slot="right">
......@@ -112,6 +115,6 @@
<style>
@import url("../../common/loginPage.css");
.phone-input-box{
margin-top: 20rpx;
}
margin-top: 10px;
}
</style>
......@@ -3,13 +3,13 @@
<view class="wrap-content">
<view class="content">
<!-- 顶部文字 -->
<text class="content-top-title">手机号密码登录</text>
<text class="content-top-title">用户名密码登录</text>
<login-ikonw class="login-iknow" :link="link" text="登录即表示同意用户协议和隐私政策"></login-ikonw>
<!-- 登录框 (选择手机号所属国家和地区需要另行实现) -->
<uni-forms ref="form" :value="formData" :rules="rules">
<uni-forms-item name="phone">
<uni-easyinput type="number" class="phone-input-box" :inputBorder="false"
v-model="formData.phone" maxlength="11" placeholder="请输入手机号">
v-model="formData.phone" maxlength="11" placeholder="请输入手机号/用户名/邮箱">
<template slot="left">
<!-- 当前仅支持中国大陆手机号 -->
<!-- <picker mode="selector" :range="phoneArea" @change="selectPhoneArea"> -->
......@@ -59,9 +59,8 @@
title: '请输入正确的手机号',
icon: 'none'
});
uni.navigateTo({
url: './pwd-retrieve?phoneNumber=' + this.formData.phone + '&phoneArea=' + this.currenPhoneArea
url: '../pwd-retrieve/pwd-retrieve?phoneNumber=' + this.formData.phone + '&phoneArea=' + this.currenPhoneArea
})
},
/**
......@@ -134,16 +133,13 @@
<style>
@import url("../../common/loginPage.css");
.phone-input-box {
margin-top: 20rpx;
}
.auth-box {
justify-content: flex-start;
margin-top: 20rpx;
}
.login-text-sub {
color: #8a8f8b;
}
......
<template>
<view class="quick-login-box">
<view class="item" v-for="({id},index) in oauthServices" :key="index" @click="login(id)" v-if="config[id].isChecked">
<image class="logo" :src="config[id].logo" mode="widthFix"></image>
<text class="login-title">{{config[id].text}}</text>
<view class="item" v-for="({id,logo,text,path},index) in servicesList" :key="index" @click="path?to(path):login(id,false)">
<image class="logo" :src="logo" mode="widthFix"></image>
<text class="login-title">{{text}}</text>
</view>
</view>
</template>
<script>
import {
mapGetters,
mapMutations
} from 'vuex';
import {mapGetters,mapMutations} from 'vuex';
//前一个窗口的页面地址。控制点击切换快捷登陆方式是创建还是返回
export default {
data() {
return {
......@@ -41,25 +38,49 @@
"logo": "../../static/login/img/qq.png",
"isChecked":false //暂未提供该登陆方式的接口示例
},
"sinaweibo": {
"text": "微博登录",
"sinaweibo": {
"text": "微博登录",
"logo": "../../static/login/img/sinaweibo.png",
"isChecked":false //暂未提供该登陆方式的接口示例
}
"isChecked":false //暂未提供该登陆方式的接口示例
}
},
providerList: [],
oauthServices:[],
univerifyStyle: {
servicesList:[
{
"text": "账号登陆",
"logo": "../../static/login/img/username.png",
"path":"/uni_modules/uni-login-page/pages/pwd-login/pwd-login"
},
{
"text": "短信登陆",
"logo": "../../static/login/img/smsCode.png",
"path":"/uni_modules/uni-login-page/pages/index/index"
}
],
univerifyStyle: { //一键登陆弹出窗的样式配置参数
"fullScreen": true, // 是否全屏显示,true表示全屏模式,false表示非全屏模式,默认值为false。
"backgroundColor": "#ffffff", // 授权页面背景颜色,默认值:#ffffff
}
}
},
created() {
let servicesList = this.servicesList
//去掉当前页面对应的登陆选项
for (var i = 0; i < servicesList.length; i++) {
if(servicesList[i].path == this.getRoute(1)){
servicesList.splice(i,1)
}
}
},
mounted() {
//获取当前环境能用的快捷登陆方式
// #ifdef APP-PLUS
plus.oauth.getServices(oauthServices=>{
this.oauthServices = oauthServices
oauthServices.forEach(({id})=>{
if(this.config[id].isChecked){
this.servicesList.push({...this.config[id],id})
}
})
// console.log(oauthServices);
},err=>{
uni.hideLoading()
......@@ -71,27 +92,28 @@
console.error('获取服务供应商失败:' + JSON.stringify(err));
})
// #endif
/*
uni.getProvider({
"service": "oauth",
success: res => {
this.providerList = res.provider.map((name) => {
return {...this.config[name],name}
})
this.login('univerify')
},
fail: (err) => {
console.error('获取服务供应商失败:' + JSON.stringify(err));
}
})
*/
},
methods: {
...mapMutations({
setUserInfo: 'user/login'
}),
login(type) {
}),
getRoute(n=0){
let pages = getCurrentPages();
console.log('route-pages-length',pages.length);
if(n>pages.length){ return '' }
return '/'+pages[pages.length - n].route
},
to(path){
console.log('比较',this.getRoute(2),path)
if(this.getRoute(2)==path){ // 控制路由是重新打开还是返回,避免重复打开页面
uni.navigateBack();
}else{
uni.navigateTo({url:path})
}
},
login(type,navigateBack=true) {
console.log(arguments);
console.log('services',services);
let oauthService = this.oauthServices.find((service) => service.id == type)
// #ifdef APP-PLUS
//uni.showLoading({mask: true});
......@@ -122,24 +144,33 @@
fail: (err) => {
uni.hideLoading()
console.log(err);
switch (err.errCode){
case 30002:
console.log('在一键登陆界面,点击其他登陆方式');
break;
case 30003:
console.log('关闭了登陆');
uni.navigateBack()
break;
case 30006:
uni.showModal({
title: "登陆服务初始化错误",
content:err.metadata.error_data,
showCancel: false,
confirmText: '知道了',
if(type=='univerify'){
if(err.metadata.error_data){
uni.showToast({
title: "一键登陆:"+err.metadata.error_data,
icon: 'none'
});
break;
default:
break;
}
switch (err.errCode){
case 30002:
console.log('在一键登陆界面,点击其他登陆方式');
break;
case 30003:
console.log('关闭了登陆');
if(navigateBack){ uni.navigateBack() }
break;
case 30006:
uni.showModal({
title: "登陆服务初始化错误",
content:err.metadata.error_data,
showCancel: false,
confirmText: '知道了',
});
break;
default:
break;
}
}
}
})
......@@ -153,7 +184,7 @@
uni.setStorageSync('uni_id_uid', result.uid)
uni.setStorageSync('uni_id_token', result.token)
uni.setStorageSync('uni_id_token_expired', result.tokenExpired)
delete result.userInfo.token
this.setUserInfo(result.userInfo)
if(type=='univerify'){
......@@ -164,7 +195,18 @@
icon: 'none'
});
uni.hideLoading()
uni.navigateBack()
var delta = 0
//判断需要返回几层
let pages = getCurrentPages();
console.log(pages);
pages.forEach((page,index)=>{
console.log(pages[pages.length-index-1].route.split('/'));
if(pages[pages.length-index-1].route.split('/')[1] == 'uni-login-page'){
delta ++
}
})
console.log('delta:'+delta);
uni.navigateBack({delta})
}
})
},
......@@ -195,7 +237,6 @@
width: 750rpx;
justify-content: space-around;
}
.item {
flex-direction: column;
justify-content: center;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册