Merge remote-tracking branch 'origin/master'
# Conflicts: # mobile-web/src/api/promotion.js # mobile-web/src/config/request.js
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
/**
|
||||
* 配置编译环境和线上环境之间的切换
|
||||
*
|
||||
*
|
||||
* baseUrl: 域名地址
|
||||
* routerMode: 路由模式
|
||||
* dataSources:数据源
|
||||
*/
|
||||
|
||||
let baseUrl = '';
|
||||
let baseUrl = '';
|
||||
let routerMode = 'hash';
|
||||
let dataSources='local';//local=本地,其他值代表非本地
|
||||
|
||||
@@ -27,4 +27,4 @@ export {
|
||||
baseUrl,
|
||||
routerMode,
|
||||
dataSources,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,8 +135,8 @@ service.interceptors.request.use(
|
||||
const { target, prefix } = serviceRouter(config.url)
|
||||
let url = config.url = config.url.replace(`${prefix}`, target);
|
||||
// TODO 芋艿,这些 url 不用增加认证 token 。可能这么写,有点脏,后面看看咋优化下。
|
||||
if (url.indexOf('user-api/users/passport/mobile/send_register_code') != -1
|
||||
|| url.indexOf('user-api/users/passport/mobile/register') != -1) {
|
||||
if (url.indexOf('user-api/users/passport/mobile/send_register_code') !== -1
|
||||
|| url.indexOf('user-api/users/passport/mobile/register') !== -1) {
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import Vue from 'vue';
|
||||
import Router from 'vue-router';
|
||||
|
||||
import { getAccessToken } from '../utils/cache';
|
||||
|
||||
Vue.use(Router);
|
||||
|
||||
const routes = [
|
||||
@@ -84,7 +86,8 @@ const routes = [
|
||||
path: '/user/coupon',
|
||||
component: () => import('../page/user/coupon/list'),
|
||||
meta: {
|
||||
title: '我的优惠券'
|
||||
title: '我的优惠券',
|
||||
requireAuth: true,
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -192,6 +195,13 @@ const routes = [
|
||||
title: '分类'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/coupon/fetch',
|
||||
component: () => import('../page/coupon/fetch'),
|
||||
meta: {
|
||||
title: '优惠劵领取'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
// add route path
|
||||
@@ -202,10 +212,23 @@ routes.forEach(route => {
|
||||
const router = new Router({ routes });
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
// 判断是否需要认证
|
||||
const requireAuth = to.meta && to.meta.requireAuth;
|
||||
if (requireAuth) {
|
||||
if (!getAccessToken()) { // 未登陆
|
||||
next({
|
||||
path: '/login',
|
||||
query: {redirect: to.fullPath} // 将跳转的路由path作为参数,登录成功后跳转到该路由
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
// 处理标题
|
||||
const title = to.meta && to.meta.title;
|
||||
if (title) {
|
||||
document.title = title;
|
||||
}
|
||||
// 继续路由
|
||||
next();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user