@jx3box/jx3box-common-ui 5.9.5 → 5.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -190,6 +190,10 @@
190
190
  color: #555;
191
191
  }
192
192
  }
193
+
194
+ .u-follow-box {
195
+ .mb(10px);
196
+ }
193
197
  }
194
198
 
195
199
  .c-sidebar-left .c-author {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jx3box/jx3box-common-ui",
3
- "version": "5.9.5",
3
+ "version": "5.9.6",
4
4
  "description": "JX3BOX UI",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -33,7 +33,7 @@
33
33
  "@jx3box/jx3box-comment-ui": "^1.7.0",
34
34
  "@jx3box/jx3box-common": "^7.3.5",
35
35
  "@jx3box/jx3box-data": "^1.10.2",
36
- "@jx3box/jx3box-editor": "^1.3.8",
36
+ "@jx3box/jx3box-editor": "^1.4.0",
37
37
  "axios": "^0.26.1",
38
38
  "dayjs": "^1.11.0",
39
39
  "element-ui": "^2.13.2",
@@ -0,0 +1,52 @@
1
+ import { $next } from "@jx3box/jx3box-common/js/https"
2
+
3
+ /**
4
+ * 关注用户
5
+ * @param {*} userId 用户id
6
+ */
7
+ function follow(userId) {
8
+ return $next().post(`/api/my-userlist/follow/${userId}`)
9
+ }
10
+
11
+ /**
12
+ * 取消关注用户
13
+ * @param {*} userId 用户id
14
+ */
15
+ function unfollow(userId) {
16
+ return $next().delete(`/api/my-userlist/follow/${userId}`)
17
+ }
18
+
19
+ /**
20
+ * 获取我的关注列表
21
+ * @param {*} param 参数
22
+ * @param {*} param.pageIndex 页码
23
+ * @param {*} param.pageSize 每页数量
24
+ * @param {*} param.user_id 用户id
25
+ * @param {*} param.display_name 用户昵称
26
+ */
27
+ function getMyFollowList(params) {
28
+ return $next().get(`/api/my-userlist/follow`, {
29
+ params
30
+ })
31
+ }
32
+
33
+ /**
34
+ * 获取我的粉丝列表
35
+ * @param {*} param 参数
36
+ * @param {*} param.pageIndex 页码
37
+ * @param {*} param.pageSize 每页数量
38
+ * @param {*} param.user_id 用户id
39
+ * @param {*} param.display_name 用户昵称
40
+ */
41
+ function getMyFansList(params) {
42
+ return $next().get(`/api/my-userlist/follow-me`, {
43
+ params
44
+ })
45
+ }
46
+
47
+ export {
48
+ follow,
49
+ unfollow,
50
+ getMyFollowList,
51
+ getMyFansList
52
+ }
package/src/Author.vue CHANGED
@@ -27,6 +27,7 @@
27
27
  </div>
28
28
  </div>
29
29
  <div class="u-bio">{{ data.user_bio }}</div>
30
+ <AuthorFollow v-if="isLogin" class="u-follow-box" :uid="uid" />
30
31
  <div class="u-link" v-if="hasLink">
31
32
  <a v-if="data.weibo_name" class="u-weibo" :href="weiboLink(data.weibo_id)" target="_blank">
32
33
  <img svg-inline src="../assets/img/author/weibo.svg" />
@@ -80,16 +81,18 @@
80
81
  </template>
81
82
 
82
83
  <script>
83
- const liveStatusMap = ["等待开播", "直播中", "直播结束"];
84
- import Avatar from "./author/Avatar.vue";
85
- import Authorposts from "./author/Authorposts.vue";
84
+ // const liveStatusMap = ["等待开播", "直播中", "直播结束"];
86
85
  import { authorLink, tvLink, getLink, getThumbnail } from "@jx3box/jx3box-common/js/utils";
87
86
  import { __server, __imgPath,__userLevelColor } from "@jx3box/jx3box-common/data/jx3box.json";
88
87
  import { getUserInfo, getDouyu, getUserMedals, getUserPublicTeams } from "../service/author";
89
88
  import { user as medal_map } from "@jx3box/jx3box-common/data/medals.json";
90
89
  import User from "@jx3box/jx3box-common/js/user";
91
90
  import { __userLevel } from "@jx3box/jx3box-common/data/jx3box.json";
91
+ // components
92
92
  import medal from './medal/medal.vue'
93
+ import Avatar from "./author/Avatar.vue";
94
+ import Authorposts from "./author/Authorposts.vue";
95
+ import AuthorFollow from "./author/AuthorFollow.vue";
93
96
  export default {
94
97
  name: "Author",
95
98
  props: ["uid"],
@@ -149,6 +152,9 @@ export default {
149
152
  level: function() {
150
153
  return User.getLevel(this.data?.experience);
151
154
  },
155
+ isLogin: function() {
156
+ return User.isLogin();
157
+ },
152
158
  },
153
159
  methods: {
154
160
  loadData: function() {
@@ -215,7 +221,8 @@ export default {
215
221
  components: {
216
222
  Avatar,
217
223
  Authorposts,
218
- medal
224
+ medal,
225
+ AuthorFollow,
219
226
  },
220
227
  };
221
228
  </script>
@@ -0,0 +1,153 @@
1
+ <template>
2
+ <div class="u-follow">
3
+ <el-button
4
+ :class="{ 'is-follow': isFollow }"
5
+ size="mini"
6
+ :icon="btnIcon"
7
+ @click="follow"
8
+ :type="btnType"
9
+ v-if="!isFollow"
10
+ >
11
+ {{ btnText }} {{ formatFansNum(fansNum) }}
12
+ </el-button>
13
+ <el-popover
14
+ v-else
15
+ placement="bottom"
16
+ trigger="hover"
17
+ popper-class="u-follow-popover"
18
+ :visible-arrow="false"
19
+ >
20
+ <div class="u-action-list">
21
+ <div class="u-action-item" v-for="item in actions" :key="item.label" @click.stop="item.action">{{ item.label }}</div>
22
+ </div>
23
+ <el-button class="u-unfollow-btn" size="mini" :type="btnType" slot="reference">{{ btnText }} {{ formatFansNum(fansNum) }}</el-button>
24
+ </el-popover>
25
+ <el-button size="mini" icon="el-icon-message" disabled>私信</el-button>
26
+ </div>
27
+ </template>
28
+
29
+ <script>
30
+ import User from "@jx3box/jx3box-common/js/user";
31
+ import { follow, unfollow, getMyFollowList } from "../../service/follow";
32
+ export default {
33
+ name: "AuthorFollow",
34
+ props: {
35
+ uid: {
36
+ type: Number,
37
+ default: 0,
38
+ },
39
+ },
40
+ data() {
41
+ return {
42
+ isFollow: false,
43
+ fansNum: 0,
44
+ };
45
+ },
46
+ computed: {
47
+ btnText() {
48
+ return this.isFollow ? "已关注" : "关注";
49
+ },
50
+ btnIcon() {
51
+ return this.isFollow ? "" : "el-icon-plus";
52
+ },
53
+ btnType() {
54
+ return this.isFollow ? "info" : "warning"
55
+ },
56
+ actions() {
57
+ return [
58
+ {
59
+ label: "取消关注",
60
+ action: () => {
61
+ this.unfollow();
62
+ },
63
+ },
64
+ ];
65
+ }
66
+ },
67
+ mounted () {
68
+ this.loadMyFollow();
69
+ },
70
+ methods: {
71
+ // 格式化粉丝数
72
+ formatFansNum(num) {
73
+ if (num < 10000) {
74
+ return num;
75
+ } else {
76
+ return (num / 10000).toFixed(1) + "万";
77
+ }
78
+ },
79
+ // 关注
80
+ follow() {
81
+ follow(this.uid)
82
+ .then((res) => {
83
+ this.$message.success("关注成功");
84
+ this.isFollow = true;
85
+ })
86
+ .catch((err) => {
87
+ console.log(err);
88
+ });
89
+ },
90
+ // 取消关注
91
+ unfollow() {
92
+ this.$confirm('确定不再关注此人?', '提示', {
93
+ confirmButtonText: '确定',
94
+ cancelButtonText: '取消',
95
+ type: 'warning'
96
+ }).then(() => {
97
+ unfollow(this.uid)
98
+ .then((res) => {
99
+ this.$message.success("取关成功");
100
+ this.isFollow = false;
101
+ })
102
+ .catch((err) => {
103
+ console.log(err);
104
+ });
105
+ });
106
+ console.log(1)
107
+ },
108
+ // 获取是否已关注
109
+ loadMyFollow() {
110
+ const params = {
111
+ pageIndex: 1,
112
+ pageSize: 10,
113
+ user_id: this.uid,
114
+ };
115
+ getMyFollowList(params)
116
+ .then((res) => {
117
+ if (res.data.data.list.length > 0) {
118
+ this.isFollow = true;
119
+ } else {
120
+ this.isFollow = false;
121
+ }
122
+ })
123
+ .catch((err) => {
124
+ console.log(err);
125
+ });
126
+ },
127
+ // TODO: 获取粉丝数
128
+ },
129
+ };
130
+ </script>
131
+
132
+ <style lang="less">
133
+ .u-follow {
134
+ }
135
+ .u-unfollow-btn {
136
+ margin-right: 10px;
137
+ }
138
+ .u-follow-popover {
139
+ min-width: 100px;
140
+ padding: 0;
141
+ margin: 0;
142
+ .u-action-list {
143
+ .u-action-item {
144
+ text-align: center;
145
+ cursor: pointer;
146
+ padding: 12px 15px;
147
+ &:hover {
148
+ background: rgb(248,248,251);
149
+ }
150
+ }
151
+ }
152
+ }
153
+ </style>