提交 de483cde 编写于 作者: DCloud_JSON's avatar DCloud_JSON

修复成功登陆后返回逻辑

修复因目录结构变化导致的,登陆成功后返回的路由错误
上级 a3cad55d
{ {
"id": "uni-search-template", "id": "uniCloud-base-app",
"displayName": "baseApp", "displayName": "baseApp",
"version": "0.1.4", "version": "1.0.0",
"description": "uniCloud云端一体项目模板,无需再开发服务器代码", "description": "云端一体项目基础功能示例",
"keywords": [ "keywords": [
"baseApp", "baseApp",
"login", "login",
...@@ -13,14 +13,14 @@ ...@@ -13,14 +13,14 @@
"usearch", "usearch",
"unisearch" "unisearch"
], ],
"repository": "https://gitee.com/dcloud/uniCloud-search", "repository": "https://gitee.com/dcloud/base-app",
"engines": { "engines": {
"HBuilderX": "^3.1.0" "HBuilderX": "^3.1.0"
}, },
"dcloudext": { "dcloudext": {
"category": [ "category": [
"uniCloud", "uniCloud",
"云端一体项目模板" "云端一体项目基础功能示例"
], ],
"sale": { "sale": {
"regular": { "regular": {
......
...@@ -2,12 +2,6 @@ const helpPage = '/pages/ucenter/help/help'; // 帮助页面 ...@@ -2,12 +2,6 @@ const helpPage = '/pages/ucenter/help/help'; // 帮助页面
import {mapMutations} from 'vuex'; import {mapMutations} from 'vuex';
import loginSuccess from './loginSuccess.js'; import loginSuccess from './loginSuccess.js';
let mixin = { let mixin = {
// // 监听帮助按钮
// onNavigationBarButtonTap(event) {
// uni.navigateTo({
// url:helpPage
// })
// },
data(){ data(){
return { return {
// 用户协议页面跳转 // 用户协议页面跳转
...@@ -106,24 +100,6 @@ let mixin = { ...@@ -106,24 +100,6 @@ let mixin = {
loginSuccess(result) loginSuccess(result)
delete result.userInfo.token delete result.userInfo.token
this.setUserInfo(result.userInfo) this.setUserInfo(result.userInfo)
// uni.showToast({
// title: '登陆成功',
// icon: 'none'
// });
// 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)
// var delta = 0//判断需要返回几层
// let pages = getCurrentPages();
// pages.forEach((page,index)=>{
// if(pages[pages.length-index-1].route.split('/')[1] == 'uni-login-page'){
// delta ++
// }
// })
// uni.navigateBack({delta})
} }
} }
} }
......
...@@ -14,9 +14,12 @@ export default function(result){ ...@@ -14,9 +14,12 @@ export default function(result){
let pages = getCurrentPages(); let pages = getCurrentPages();
console.log(pages); console.log(pages);
pages.forEach((page,index)=>{ pages.forEach((page,index)=>{
if(pages[pages.length-index-1].route.split('/')[1] == 'uni-login-page'){ console.log(pages[pages.length-index-1].route.split('/')[2]);
pages[pages.length-index-1].route.split('/')
if(pages[pages.length-index-1].route.split('/')[2] == 'login-page'){
delta ++ delta ++
} }
}) })
console.log('判断需要返回几层',delta);
uni.navigateBack({delta}) uni.navigateBack({delta})
} }
\ No newline at end of file
// 上次启动时的用户信息 // 上次启动时的用户信息
let userHistory = uni.getStorageSync('userInfo') || {}; let userInfoHistory = uni.getStorageSync('userInfo') || {};
let state = { let state = {
/* 是否需要强制登录 */ //是否已经登陆
forcedLogin: false, hasLogin: Boolean(Object.keys(userInfoHistory).length),
hasLogin: Boolean(userHistory), //用户信息
info: userHistory info: userInfoHistory
}, },
getters = { getters = {
info(state) { info(state) {
...@@ -16,10 +16,13 @@ let state = { ...@@ -16,10 +16,13 @@ let state = {
} }
}, },
mutations = { mutations = {
login(state, info) { login(state, info) { //登陆成功后的操作
//原有的结合传来的参数
let _info = state.info; let _info = state.info;
state.info = Object.assign({}, _info, info); state.info = Object.assign({}, _info, info);
//设置为已经登陆
state.hasLogin = true; state.hasLogin = true;
//存储最新的用户数据到本地持久化存储
uni.setStorageSync('userInfo', state.info); uni.setStorageSync('userInfo', state.info);
}, },
logout(state) { logout(state) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册