|
|
@@ -4,18 +4,17 @@ import Vue from 'vue'
|
|
|
Vue.mixin({
|
|
|
async fetch({ $axios, store, req }) {
|
|
|
let headers = req && req.headers
|
|
|
- let res = await $axios.$get('/api/user/getInfo', {headers});
|
|
|
- if(res && res.data) {
|
|
|
+ let res = await $axios.$get('/api/user/getInfo', { headers });
|
|
|
+ if (res && res.data) {
|
|
|
store.commit('updateUserinfo', { userinfo: res.data || {} })
|
|
|
}
|
|
|
},
|
|
|
- components: {
|
|
|
- },
|
|
|
+ components: {},
|
|
|
data() {
|
|
|
- return {
|
|
|
- }
|
|
|
+ return {}
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
},
|
|
|
- mounted() {},
|
|
|
computed: {
|
|
|
userinfo() {
|
|
|
return this.$store.state.userinfo
|
|
|
@@ -31,6 +30,25 @@ Vue.mixin({
|
|
|
this.goLogin();
|
|
|
}
|
|
|
},
|
|
|
+ async checkLogin(goLogin = false) {
|
|
|
+ const userInfo = await this.getUserInfo();
|
|
|
+ if (!userInfo || !userInfo.nickname) {
|
|
|
+ this.$message.error('请先登录!')
|
|
|
+ if (goLogin) {
|
|
|
+ const { app } = this.$deviceType
|
|
|
+
|
|
|
+ if (app) {
|
|
|
+ location.href = 'proginn://login'
|
|
|
+ } else if (location.origin.indexOf('local') !== 1 || location.origin.indexOf('dev') !== 1 ) {
|
|
|
+ location.href = 'https://dev.test.proginn.com/?loginbox=show'
|
|
|
+ } else {
|
|
|
+ location.href = 'https://www.proginn.com/?loginbox=show'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ },
|
|
|
async needVerify() {
|
|
|
const userInfo = await this.getUserInfo();
|
|
|
// 1是待审核,2审核通过,3是拒绝
|
|
|
@@ -56,9 +74,9 @@ Vue.mixin({
|
|
|
location.href = 'https://www.proginn.com/';
|
|
|
},
|
|
|
goLogin(e, noAlert) {
|
|
|
- if(noAlert) {
|
|
|
+ if (noAlert) {
|
|
|
location.href = `https://www.proginn.com/?loginbox=show`
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
this.$message.closeAll()
|
|
|
this.$alert('未登录, 前往登录', '提示', {
|
|
|
confirmButtonText: '确定',
|
|
|
@@ -79,7 +97,7 @@ Vue.mixin({
|
|
|
async updateUserInfo() {
|
|
|
let res = await this.$axios.$get('/api/user/getInfo');
|
|
|
console.log('res', res.data)
|
|
|
- if(res && res.data) {
|
|
|
+ if (res && res.data) {
|
|
|
this.$store.commit('updateUserinfo', { userinfo: res.data || {} })
|
|
|
}
|
|
|
},
|