Browse Source

添加关注和发送消息接口

reghao 2 years ago
parent
commit
b1242bdffd
1 changed files with 22 additions and 2 deletions
  1. 22 2
      src/views/user/Home.vue

+ 22 - 2
src/views/user/Home.vue

@@ -13,14 +13,16 @@
               <el-button
                 type="danger"
                 size="mini"
-                icon="el-icon-plus"
+                :icon="followButton.icon"
+                @click="followUser(user.userId)"
               >
-                <span>关注</span>
+                <span>{{followButton.text}}</span>
               </el-button>
               <el-button
                 type="danger"
                 size="mini"
                 icon="el-icon-message"
+                @click="sendMessage(user.userId)"
               >
                 <span>发消息</span>
               </el-button>
@@ -91,6 +93,10 @@ export default {
       screenWidth: document.body.clientWidth,
       user: null,
       userId: null,
+      followButton: {
+        icon: 'el-icon-check',
+        text: '已关注'
+      },
       activeName: 'home',
       currentPage: 1,
       pageSize: 12,
@@ -148,6 +154,20 @@ export default {
         console.log('获取视频')
       }
     },
+    followUser(userId) {
+      if (this.followButton.text === '关注') {
+        console.log('关注用户')
+        this.followButton.text = '已关注'
+        this.followButton.icon = 'el-icon-check'
+      } else {
+        console.log('取消关注用户')
+        this.followButton.text = '关注'
+        this.followButton.icon = 'el-icon-plus'
+      }
+    },
+    sendMessage(userId) {
+      console.log('发送消息')
+    },
     userVideoListWrapper(pageNumber, userId) {
       userVideoList(pageNumber, userId).then(res => {
         if (res.code === 0) {