| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- import Vue from 'vue'
- // import http from '@/plugins/http'
- // mixin
- Vue.mixin({
- async fetch({ $axios, store, req }) {
- let headers = req && req.headers
- let res = await $axios.$get('/api/user/getInfo', {headers});
- console.log(res.data)
- if(res && res.data) {
- store.commit('updateUserinfo', { userinfo: res.data || {} })
- }
- },
- components: {
- },
- data() {
- return {
- }
- },
- mounted() {},
- computed: {
- userinfo() {
- return this.$store.state.userinfo
- },
- hasLogined() {
- return !!this.userinfo.uid
- },
- },
- methods: {
- needLogin() {
- this.$axios.$get(
- `/api/user/getInfo`
- ).then(res => {
- }).catch(err => {
- this.goLogin();
- })
- },
- goLogin(e, noAlert) {
- if(noAlert) {
- location.href = `https://www.proginn.com/?loginbox=show`
- }else {
- this.$alert('未登录, 前往登录', '提示', {
- confirmButtonText: '确定',
- callback: action => {
- location.href = `https://www.proginn.com/?loginbox=show`
- }
- })
- }
- },
- noCompetence(title = "没有权限") {
- this.$alert(title, '提示', {
- confirmButtonText: '确定',
- callback: action => {
- location.go(-1)
- }
- })
- },
- }
- })
|