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

修复成功登陆后返回逻辑

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