hookehuyr

🦄 refactor: 写法优化

...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
2 * @Author: hookehuyr hookehuyr@gmail.com 2 * @Author: hookehuyr hookehuyr@gmail.com
3 * @Date: 2022-05-18 22:16:10 3 * @Date: 2022-05-18 22:16:10
4 * @LastEditors: hookehuyr hookehuyr@gmail.com 4 * @LastEditors: hookehuyr hookehuyr@gmail.com
5 - * @LastEditTime: 2022-06-24 21:34:23 5 + * @LastEditTime: 2022-06-24 22:18:36
6 * @FilePath: /tswj/src/api/C/me.js 6 * @FilePath: /tswj/src/api/C/me.js
7 * @Description: 我的页面接口操作 7 * @Description: 我的页面接口操作
8 */ 8 */
...@@ -18,6 +18,7 @@ const Api = { ...@@ -18,6 +18,7 @@ const Api = {
18 MY_ATME: '/srv/?a=my_atme', 18 MY_ATME: '/srv/?a=my_atme',
19 DEL_COMMENT: '/srv/?a=del_comment', 19 DEL_COMMENT: '/srv/?a=del_comment',
20 MY_SUBSCRIBE: '/srv/?a=my_subscribe', 20 MY_SUBSCRIBE: '/srv/?a=my_subscribe',
21 + MY_FOLLOW: '/srv/?a=my_follow',
21 } 22 }
22 23
23 /** 24 /**
...@@ -83,3 +84,9 @@ export const myAtmeAPI = (params) => fn(fetch.get(Api.MY_ATME, params)); ...@@ -83,3 +84,9 @@ export const myAtmeAPI = (params) => fn(fetch.get(Api.MY_ATME, params));
83 * @returns 84 * @returns
84 */ 85 */
85 export const mySubscribeAPI = (params) => fn(fetch.get(Api.MY_SUBSCRIBE, params)); 86 export const mySubscribeAPI = (params) => fn(fetch.get(Api.MY_SUBSCRIBE, params));
87 +
88 +/**
89 + * @description: 我的关注
90 + * @returns
91 + */
92 +export const myFollowAPI = (params) => fn(fetch.get(Api.MY_FOLLOW, params));
......
1 +<!--
2 + * @Date: 2022-04-28 18:37:45
3 + * @LastEditors: hookehuyr hookehuyr@gmail.com
4 + * @LastEditTime: 2022-06-24 22:23:24
5 + * @FilePath: /tswj/src/views/me/followList.vue
6 + * @Description: 文件描述
7 +-->
1 <template> 8 <template>
2 <div class="follow-list-page"> 9 <div class="follow-list-page">
3 - <template v-for="(item, key) in followList" :key="key"> 10 + <template v-for="(item) in followList" :key="item.id">
4 - <div @click="getUserInfo(item)" class="info van-hairline--bottom"> 11 + <div class="info van-hairline--bottom"
12 + @click="go('/client/personIndex', { perf_id: item.id, type: 'read-only' })">
5 <van-row> 13 <van-row>
6 <van-col> 14 <van-col>
7 - <van-image v-if="item.avatar" round width="50" height="50" :src="item.avatar" style="padding-right: 1rem;" /> 15 + <van-image round width="50" height="50" :src="item.avatar ? item.avatar : icon_avatar"
8 - <van-image v-else round width="50" height="50" :src="icon_avatar" style="padding-right: 1rem;" /> 16 + style="padding-right: 1rem;" />
9 </van-col> 17 </van-col>
10 <van-col class="text-wrapper" span="18"> 18 <van-col class="text-wrapper" span="18">
11 - <div> 19 + <div class="user-wrapper">
12 <div class="username">{{ item.name }}</div> 20 <div class="username">{{ item.name }}</div>
13 <div class="user-status">已关注</div> 21 <div class="user-status">已关注</div>
14 </div> 22 </div>
...@@ -17,81 +25,28 @@ ...@@ -17,81 +25,28 @@
17 </van-row> 25 </van-row>
18 </div> 26 </div>
19 </template> 27 </template>
20 - <van-empty v-if="emptyStatus" 28 + <van-empty v-if="emptyStatus" class="custom-image" :image="no_image" description="暂无关注" />
21 - class="custom-image"
22 - :image="no_image"
23 - description="暂无关注"
24 - />
25 </div> 29 </div>
26 - <div style="height: 2rem;"></div> 30 + <div style="height: 2rem;" />
27 </template> 31 </template>
28 32
29 <script setup> 33 <script setup>
30 import no_image from '@images/que-shuju@2x.png' 34 import no_image from '@images/que-shuju@2x.png'
31 - 35 +import { ref, onMounted } from 'vue'
32 -import { ref, reactive, onMounted } from 'vue'
33 -import { useRoute, useRouter } from 'vue-router'
34 -import axios from '@/utils/axios';
35 -import { Toast } from 'vant';
36 import icon_avatar from '@images/que-touxiang@2x.png' 36 import icon_avatar from '@images/que-touxiang@2x.png'
37 +import { myFollowAPI } from '@/api/C/me'
38 +import { useGo } from '@/hooks/useGo'
37 39
38 -const $router = useRouter(); 40 +const go = useGo()
39 -
40 -// 因为不能让空图标提前出来的写法
41 const emptyStatus = ref(false); 41 const emptyStatus = ref(false);
42 -// 关注列表联调
43 const followList = ref([]) 42 const followList = ref([])
44 -axios.get('/srv/?a=my_follow') 43 +onMounted(async () => {
45 -.then(res => { 44 + const { code, data } = await myFollowAPI()
46 - if (res.data.code === 1) { 45 + if (code) {
47 - followList.value = res.data.data; 46 + followList.value = data;
48 - if (!res.data.data.length) { 47 + emptyStatus.value = data.length ? false : true;
49 - emptyStatus.value = true;
50 - } else {
51 - emptyStatus.value = false;
52 - }
53 - } else {
54 - console.warn(res);
55 - if (!res.data.show) return false;
56 - Toast({
57 - icon: 'close',
58 - message: res.data.msg
59 - });
60 } 48 }
61 -})
62 -.catch(err => {
63 - console.error(err);
64 }); 49 });
65 -
66 -const getUserInfo = (v) => {
67 - // 从个人头像进入的,不能再往下级进入
68 - $router.push({
69 - path: '/client/personIndex',
70 - query: {
71 - perf_id: v.id,
72 - type: 'read-only'
73 - }
74 - })
75 -}
76 -</script>
77 -
78 -<script>
79 -import mixin from 'common/mixin';
80 -
81 -export default {
82 - mixins: [mixin.init],
83 - data () {
84 - return {
85 -
86 - }
87 - },
88 - mounted () {
89 -
90 - },
91 - methods: {
92 -
93 - }
94 -}
95 </script> 50 </script>
96 51
97 <style lang="less" scoped> 52 <style lang="less" scoped>
......
...@@ -2,16 +2,16 @@ ...@@ -2,16 +2,16 @@
2 * @Author: hookehuyr hookehuyr@gmail.com 2 * @Author: hookehuyr hookehuyr@gmail.com
3 * @Date: 2022-05-26 23:52:36 3 * @Date: 2022-05-26 23:52:36
4 * @LastEditors: hookehuyr hookehuyr@gmail.com 4 * @LastEditors: hookehuyr hookehuyr@gmail.com
5 - * @LastEditTime: 2022-06-09 16:13:33 5 + * @LastEditTime: 2022-06-24 22:12:20
6 * @FilePath: /tswj/src/views/me/like.vue 6 * @FilePath: /tswj/src/views/me/like.vue
7 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE 7 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
8 --> 8 -->
9 <template> 9 <template>
10 <div class="book-video-list"> 10 <div class="book-video-list">
11 - <template v-for="item in prodList" :key="item" style="height: 3rem;"> 11 + <template v-for="item in prodList" :key="item">
12 - <video-card :item="item"></video-card> 12 + <video-card :item="item" />
13 </template> 13 </template>
14 - <div style="height: 2rem;"></div> 14 + <div style="height: 2rem;" />
15 </div> 15 </div>
16 <van-empty v-if="emptyStatus" 16 <van-empty v-if="emptyStatus"
17 class="custom-image" 17 class="custom-image"
......