123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- // The Vue build version to load with the `import` command
- // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
- import Vue from 'vue'
- import App from './App'
- import router from './router'
- import store from './config/config'
- import ajax from './common/axios.config'
- import { Message } from 'element-ui'
- Vue.config.productionTip = false
- import { Form } from 'element-ui'
- Vue.prototype.$store = store;// 将store实例挂在vue原型上
- Vue.prototype.ajax = ajax
- Vue.prototype.$message = Message
- /* eslint-disable no-new */
- new Vue({
- el: '#app',
- router,
- components: { App },
- template: '<App/>'
- })
- router.beforeEach((to, from, next) => {
- console.log('1');
- ajax
- .get(`${store.state.server}getcookieuserid`)
- .then((res) => {
- var userid = res.data[0][0].userid
- store.commit("update", ["userId", userid]);
- ajax
- .get(
- `${store.state.edu}admin/userinfo/userinfoById/${userid}/`
- )
- .then((r) => {
- let data = r.data[0][0];
- console.log(data);
- store.commit("update", ["userName", data.alias || data.username]);
- });
- })
- .catch((err) => {
- // window.location.href = "https://edu.cocorobo.cn/course/login?type=1";
- var type = localStorage.getItem("type")
- window.location.href = "https://edu.cocorobo.cn/course/login?type=1&UnityType=" + type;
- });
- next();
- })
|