<template>
<transition :name="transitionName">
<router-view></router-view>
</transition>
</template>
<script>
export default {
name: 'app',
data () {
return {
transitionName: 'fade'
}
},
watch: {
'$route' (to, from) {
let toDepth = to.meta
let fromDepth = from.meta
if (fromDepth > toDepth) {
this.transitionName = 'fade-left'
} else if (fromDepth < toDepth) {
this.transitionName = 'fade-right'
} else {
this.transitionName = 'fade'
}
}
}
}
</script>
<style>
</style>
<template>
<div class="content">
<!--<transition name="fade" mode="out-in">-->
<router-view></router-view>
<!--</transition>-->
<Tabbar
:routers="[
{path: '/index/home', icon: 'icon-home', name: '首页'},
{path: '/index/loading', icon: 'icon-course', name: '加载'},
{path: '/index/message', icon: 'icon-info', name: '信息'}
]"
>
</Tabbar>
</div>
</template>
<script>
export default {
name: 'Index',
components: {Tabbar: require('components/Tabbar')},
data () {
return {
}
}
}
</script>
<style lang="scss" scoped>
.content{
background-color: #eee;
}
</style>
import fetch from 'isomorphic-fetch'
import store from 'store'
import router from './router'
var env = process.env.NODE_ENV
var rootUrl
if (env === 'development') {
rootUrl = ''
}
if (env === 'production') {
rootUrl = ''
}
const post = function (url, params = {}) {
return fetch(rootUrl + url, {
method: 'post',
headers: {
'Content-type': 'application/json; charset=utf-8',
'Authorization': store.get('token')
},
body: JSON.stringify(params)
}).then(function (res) {
if (res.status === 401) {
// 没有权限
api.logout()
} else {
return res.json()
}
})
}
const urls = [
'classAtCurDate' // 普通接口列表
]
var api = {}
for (var url of urls) {
(function (url) {
api[url] = (params) => {
console.log(url)
return post('course/' + url, params)
}
})(url)
}
// 需要特殊处理的接口
api.logout = () => {
store.clearAll()
router.push('login')
}
api.login = (params) => {
store.set('id', 1)
store.set('token', 2)
return Promise.resolve({params})
}
export default api
// 在main.js中导入api接口 import api from '../src/api' Vue.$api = Vue.prototype.$api = api
router.beforeEach((to, from, next) => {
if (cache.get('id') && to.path === '/login') {
next('/index')
} else if (!cache.get('id') && to.path !== '/login') {
next('/login')
} else {
next()
}
})
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有