Explorar el Código

Merge branch 'master' of http://git.izouma.com/xiongzhu/9th

xuqiang hace 4 años
padre
commit
28843ad156

+ 5 - 0
src/main/pc-space/src/components/PageHeader.vue

@@ -54,6 +54,11 @@ export default {
         };
         };
     },
     },
     computed: { ...mapState(['userInfo']) },
     computed: { ...mapState(['userInfo']) },
+    mounted() {
+        this.$EventBus.$on('login', () => {
+            this.show = true;
+        });
+    },
     methods: {
     methods: {
         tab(item) {
         tab(item) {
             this.active = item;
             this.active = item;

+ 2 - 0
src/main/pc-space/src/eventBus.js

@@ -0,0 +1,2 @@
+import Vue from 'vue';  
+export default new Vue(); 

+ 3 - 0
src/main/pc-space/src/main.js

@@ -9,6 +9,7 @@ import common from './mixins/common';
 ElementUI.Dialog.props.closeOnClickModal.default = false;
 ElementUI.Dialog.props.closeOnClickModal.default = false;
 import './styles/font.less';
 import './styles/font.less';
 import './styles/app.less';
 import './styles/app.less';
+import eventBus from './eventBus';
 
 
 Vue.prototype.$colors = {
 Vue.prototype.$colors = {
     prim: '#FF7F1F',
     prim: '#FF7F1F',
@@ -18,6 +19,8 @@ Vue.use(ElementUI);
 Vue.use(http);
 Vue.use(http);
 Vue.mixin(common);
 Vue.mixin(common);
 
 
+Vue.prototype.$EventBus = eventBus;
+
 Vue.config.productionTip = false;
 Vue.config.productionTip = false;
 
 
 new Vue({
 new Vue({

+ 1 - 1
src/main/pc-space/src/mixins/common.js

@@ -83,7 +83,7 @@ export default {
                 this.$confirm('用户未登录,是否立即登录', '提示', {
                 this.$confirm('用户未登录,是否立即登录', '提示', {
                     confirmButtonText: '立即登录'
                     confirmButtonText: '立即登录'
                 }).then(() => {
                 }).then(() => {
-                    this.$router.push('/login');
+                    this.$EventBus.$emit('login');
                 });
                 });
                 return Promise.reject();
                 return Promise.reject();
             }
             }

+ 2 - 2
src/main/pc-space/src/mixins/user.js

@@ -7,7 +7,7 @@ export default {
     methods: {
     methods: {
         like(info) {
         like(info) {
             this.checkLogin().then(() => {
             this.checkLogin().then(() => {
-                if (!this.info.follow) {
+                if (!info.follow) {
                     this.$http.get(`/user/${info.id}/follow`).then(res => {
                     this.$http.get(`/user/${info.id}/follow`).then(res => {
                         this.$message.success('关注成功');
                         this.$message.success('关注成功');
                         this.changeInfo({
                         this.changeInfo({
@@ -29,7 +29,7 @@ export default {
             });
             });
         },
         },
         changeInfo(info) {
         changeInfo(info) {
-            if (this.isList) {
+            if (!this.isList) {
                 let list = [...this.list];
                 let list = [...this.list];
 
 
                 list.forEach(item => {
                 list.forEach(item => {

+ 29 - 1
src/main/pc-space/src/router/index.js

@@ -1,11 +1,14 @@
 import Vue from 'vue';
 import Vue from 'vue';
 import VueRouter from 'vue-router';
 import VueRouter from 'vue-router';
+import store from '../store';
+import { MessageBox } from 'element-ui';
 // 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
 // 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
 const originalPush = VueRouter.prototype.push;
 const originalPush = VueRouter.prototype.push;
 VueRouter.prototype.push = function push(location) {
 VueRouter.prototype.push = function push(location) {
     return originalPush.call(this, location).catch(err => err);
     return originalPush.call(this, location).catch(err => err);
 };
 };
 Vue.use(VueRouter);
 Vue.use(VueRouter);
+import eventBus from '../eventBus';
 
 
 const routes = [
 const routes = [
     {
     {
@@ -69,7 +72,8 @@ const routes = [
                 name: 'my',
                 name: 'my',
                 component: () => import('../views/My.vue'),
                 component: () => import('../views/My.vue'),
                 meta: {
                 meta: {
-                    title: '我的NFT'
+                    title: '我的NFT',
+                    checkLogin: true
                 }
                 }
             }
             }
         ]
         ]
@@ -95,4 +99,28 @@ const router = new VueRouter({
     }
     }
 });
 });
 
 
+router.beforeEach((to, from, next) => {
+    if (!store.state.userInfo) {
+        store
+            .dispatch('getUserInfo')
+            .then(() => {
+                next();
+            })
+            .catch(() => {
+                if (to.meta.checkLogin) {
+                    MessageBox('用户未登录,是否立即登录', '提示', {
+                        confirmButtonText: '立即登录'
+                    }).then(() => {
+                        eventBus.$emit('login');
+                    });
+                    next('/');
+                } else {
+                    next();
+                }
+            });
+    } else {
+        next();
+    }
+});
+
 export default router;
 export default router;

+ 7 - 1
src/main/pc-space/src/views/Casting.vue

@@ -49,7 +49,9 @@
                         <div class="text3">{{ item.followers }}</div>
                         <div class="text3">{{ item.followers }}</div>
                         <div class="text4">粉丝</div>
                         <div class="text4">粉丝</div>
                     </div>
                     </div>
-                    <div class="follow" @click.prevent="like(item)">{{ item.follow ? '已关注' : '关注' }}</div>
+                    <div class="follow" :class="{ followed: item.follow }" @click.prevent="like(item)">
+                        {{ item.follow ? '已关注' : '关注' }}
+                    </div>
                 </div>
                 </div>
             </router-link>
             </router-link>
 
 
@@ -117,4 +119,8 @@ export default {
 </script>
 </script>
 <style lang="less" scoped>
 <style lang="less" scoped>
 @import url('../styles/list.less');
 @import url('../styles/list.less');
+.followed {
+    border-color: #939599;
+    color: #939599 !important;
+}
 </style>
 </style>