前端:增加注册登陆
前端:个人信息修改
This commit is contained in:
@@ -12,13 +12,13 @@ let dataSources='local';//local=本地,其他值代表非本地
|
||||
|
||||
|
||||
if (process.env.NODE_ENV == 'development') {
|
||||
baseUrl='';
|
||||
|
||||
baseUrl='http://127.0.0.1';
|
||||
}else if(process.env.NODE_ENV == 'production'){
|
||||
baseUrl = '';
|
||||
baseUrl = 'http://http://180.167.213.26:18099';
|
||||
}
|
||||
|
||||
baseUrl = 'http://127.0.0.1';
|
||||
// baseUrl = 'http://127.0.0.1';
|
||||
baseUrl = 'http://http://180.167.213.26:18099';
|
||||
dataSources = 'remote';
|
||||
// dataSources = 'local';
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import axios from 'axios'
|
||||
import {baseUrl, dataSources} from './env';
|
||||
import datas from '../data/data';
|
||||
import { getAccessToken } from '../utils/cache.js';
|
||||
import { Dialog } from 'vant';
|
||||
|
||||
const service = axios.create({
|
||||
baseURL: baseUrl, // api 的 base_url
|
||||
@@ -45,7 +46,15 @@ service.interceptors.request.use(
|
||||
// config.headers['X-Token'] = getToken()
|
||||
// }
|
||||
|
||||
debugger;
|
||||
// debugger;
|
||||
let url = config.url;
|
||||
// TODO 芋艿,这些 url 不用增加认证 token 。可能这么写,有点脏,后面看看咋优化下。
|
||||
if (url === 'user-api/users/passport/mobile/send_register_code'
|
||||
|| url === 'user-api/users/passport/mobile/register') {
|
||||
return config;
|
||||
}
|
||||
|
||||
// debugger;
|
||||
if (getAccessToken()) {
|
||||
config.headers['Authorization'] = `Bearer ${getAccessToken()}`;
|
||||
}
|
||||
@@ -71,12 +80,9 @@ service.interceptors.response.use(
|
||||
response => {
|
||||
// debugger;
|
||||
const res = response.data;
|
||||
if (res.code !== 0) {
|
||||
// Message({
|
||||
// message: res.message,
|
||||
// type: 'error',
|
||||
// duration: 5 * 1000
|
||||
// })
|
||||
const code = res.code;
|
||||
if (code !== 0) {
|
||||
|
||||
// // 50008:非法的token; 50012:其他客户端登录了; 50014:Token 过期了;
|
||||
// if (res.code === 50008 || res.code === 50012 || res.code === 50014) {
|
||||
// // 请自行在引入 MessageBox
|
||||
@@ -91,6 +97,32 @@ service.interceptors.response.use(
|
||||
// })
|
||||
// })
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// TODO token 过期
|
||||
// TODO 需要拿 refresh token 置换
|
||||
if (code === 1001001012) {
|
||||
Dialog.confirm({
|
||||
title: '系统提示',
|
||||
message: res.message,
|
||||
confirmButtonText: '重新登陆',
|
||||
beforeClose: function (action, done) {
|
||||
done();
|
||||
if (action === 'confirm') {
|
||||
// debugger;
|
||||
// this.$router.push({ path: '/login' })
|
||||
// TODO 跳转到登陆页.不是很优雅
|
||||
location.replace('/#login');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Dialog.alert({
|
||||
title: '系统提示',
|
||||
message: res.message,
|
||||
});
|
||||
}
|
||||
console.log(1);
|
||||
return Promise.reject('error')
|
||||
} else {
|
||||
|
||||
@@ -17,32 +17,32 @@ const routes = [
|
||||
},
|
||||
{
|
||||
path: '/login',
|
||||
component: () => import('../page/account/login'),
|
||||
meta: {
|
||||
title: '登录'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/login/password',
|
||||
component: () => import('../page/account/password'),
|
||||
meta: {
|
||||
title: '登录'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/login/phone',
|
||||
component: () => import('../page/account/phonelogin'),
|
||||
meta: {
|
||||
title: '手机号登录'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/login/register',
|
||||
component: () => import('../page/account/register'),
|
||||
meta: {
|
||||
title: '注册'
|
||||
title: '登录'
|
||||
}
|
||||
},
|
||||
// {
|
||||
// path: '/login/password',
|
||||
// component: () => import('../page/account/password'),
|
||||
// meta: {
|
||||
// title: '登录'
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// path: '/login/phone',
|
||||
// component: () => import('../page/account/phonelogin'),
|
||||
// meta: {
|
||||
// title: '手机号登录'
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// path: '/login/register',
|
||||
// component: () => import('../page/account/register'),
|
||||
// meta: {
|
||||
// title: '注册'
|
||||
// }
|
||||
// },
|
||||
{
|
||||
path: '/user/index',
|
||||
component: () => import('../page/user/index'),
|
||||
@@ -56,7 +56,7 @@ const routes = [
|
||||
component: () => import('../page/user/info/detail'),
|
||||
name: 'user',
|
||||
meta: {
|
||||
title: '账号管理'
|
||||
title: '个人信息'
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user