提交 f763279a 编写于 作者: L linju

23

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