Showing
3 changed files
with
89 additions
and
84 deletions
| ... | @@ -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-08 12:21:53 | 5 | + * @LastEditTime: 2022-06-10 11:29:45 |
| 6 | * @FilePath: /tswj/src/api/C/me.js | 6 | * @FilePath: /tswj/src/api/C/me.js |
| 7 | * @Description: 我的页面接口操作 | 7 | * @Description: 我的页面接口操作 |
| 8 | */ | 8 | */ |
| ... | @@ -15,6 +15,7 @@ const Api = { | ... | @@ -15,6 +15,7 @@ const Api = { |
| 15 | MY_LIKE: '/srv/?a=my_like', | 15 | MY_LIKE: '/srv/?a=my_like', |
| 16 | MY_FAVOR: '/srv/?a=my_favor', | 16 | MY_FAVOR: '/srv/?a=my_favor', |
| 17 | MY_COMMENT: '/srv/?a=my_comment', | 17 | MY_COMMENT: '/srv/?a=my_comment', |
| 18 | + MY_ATME: '/srv/?a=my_atme', | ||
| 18 | DEL_COMMENT: '/srv/?a=del_comment', | 19 | DEL_COMMENT: '/srv/?a=del_comment', |
| 19 | } | 20 | } |
| 20 | 21 | ||
| ... | @@ -67,3 +68,11 @@ export const myCommentAPI = (params) => fn(fetch.get(Api.MY_COMMENT, params)); | ... | @@ -67,3 +68,11 @@ export const myCommentAPI = (params) => fn(fetch.get(Api.MY_COMMENT, params)); |
| 67 | * @returns | 68 | * @returns |
| 68 | */ | 69 | */ |
| 69 | export const delCommentAPI = (params) => fn(fetch.post(Api.DEL_COMMENT, params)); | 70 | export const delCommentAPI = (params) => fn(fetch.post(Api.DEL_COMMENT, params)); |
| 71 | + | ||
| 72 | +/** | ||
| 73 | + * @description: /@/我的列表 | ||
| 74 | + * @param {string} limit | ||
| 75 | + * @param {string} offset | ||
| 76 | + * @returns | ||
| 77 | + */ | ||
| 78 | +export const myAtmeAPI = (params) => fn(fetch.get(Api.MY_ATME, params)); | ... | ... |
| 1 | +/* | ||
| 2 | + * @Author: hookehuyr hookehuyr@gmail.com | ||
| 3 | + * @Date: 2022-05-26 21:16:59 | ||
| 4 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 5 | + * @LastEditTime: 2022-06-10 11:49:04 | ||
| 6 | + * @FilePath: /tswj/src/api/C/perf.js | ||
| 7 | + * @Description: 用户相关API | ||
| 8 | + */ | ||
| 1 | import { fn, fetch } from '@/api/fn'; | 9 | import { fn, fetch } from '@/api/fn'; |
| 2 | 10 | ||
| 3 | const Api = { | 11 | const Api = { |
| 4 | PERF_INFO: '/srv/?a=perf_info', | 12 | PERF_INFO: '/srv/?a=perf_info', |
| 5 | ADD_FOLLOW: '/srv/?a=add_follow', | 13 | ADD_FOLLOW: '/srv/?a=add_follow', |
| 14 | + ADD_COMMENT: '/srv/?a=add_comment', | ||
| 15 | + ADD_REPLY: '/srv/?a=add_reply', | ||
| 6 | } | 16 | } |
| 7 | 17 | ||
| 8 | /** | 18 | /** |
| ... | @@ -18,3 +28,17 @@ export const perfInfoAPI = (params) => fn(fetch.post(Api.PERF_INFO, params)); | ... | @@ -18,3 +28,17 @@ export const perfInfoAPI = (params) => fn(fetch.post(Api.PERF_INFO, params)); |
| 18 | * @returns | 28 | * @returns |
| 19 | */ | 29 | */ |
| 20 | export const addFollowAPI = (params) => fn(fetch.post(Api.ADD_FOLLOW, params)); | 30 | export const addFollowAPI = (params) => fn(fetch.post(Api.ADD_FOLLOW, params)); |
| 31 | + | ||
| 32 | +/** | ||
| 33 | + * @description: 用户新增评论操作 | ||
| 34 | + * @param {String} prod_id 作品ID | ||
| 35 | + * @returns | ||
| 36 | + */ | ||
| 37 | +export const addCommentAPI = (params) => fn(fetch.post(Api.ADD_COMMENT, params)); | ||
| 38 | + | ||
| 39 | +/** | ||
| 40 | + * @description: 用户新增回复操作 | ||
| 41 | + * @param {String} comment_id 评论ID | ||
| 42 | + * @returns | ||
| 43 | + */ | ||
| 44 | +export const addReplyAPI = (params) => fn(fetch.post(Api.ADD_REPLY, params)); | ... | ... |
| ... | @@ -12,7 +12,10 @@ | ... | @@ -12,7 +12,10 @@ |
| 12 | <p>{{ item.kg_name }}</p> | 12 | <p>{{ item.kg_name }}</p> |
| 13 | </van-col> | 13 | </van-col> |
| 14 | <van-col span="4" style="text-align: center;"> | 14 | <van-col span="4" style="text-align: center;"> |
| 15 | - <p style="color: #333333;" @click="setComment(item, 'reply')">回复</p> | 15 | + <p style="color: #333333; position: relative; text-align: right;" @click="setComment(item, 'reply')"> |
| 16 | + 回复 | ||
| 17 | + <span class="spot">·</span> | ||
| 18 | + </p> | ||
| 16 | <p>2-25</p> | 19 | <p>2-25</p> |
| 17 | </van-col> | 20 | </van-col> |
| 18 | </van-row> | 21 | </van-row> |
| ... | @@ -27,8 +30,7 @@ | ... | @@ -27,8 +30,7 @@ |
| 27 | <div style="padding: 1rem; background-color: #F7F7F7;" @click="onClick(item)"> | 30 | <div style="padding: 1rem; background-color: #F7F7F7;" @click="onClick(item)"> |
| 28 | <van-row> | 31 | <van-row> |
| 29 | <van-col span="8" style="position: relative;"> | 32 | <van-col span="8" style="position: relative;"> |
| 30 | - <van-image width="8rem" height="5rem" fit="cover" :src="item.cover" | 33 | + <van-image width="8rem" height="5rem" fit="cover" :src="item.cover" style="vertical-align: text-bottom;"> |
| 31 | - style="vertical-align: text-bottom;"> | ||
| 32 | <template #error>加载失败</template> | 34 | <template #error>加载失败</template> |
| 33 | </van-image> | 35 | </van-image> |
| 34 | <!-- <div style="position: absolute; top: 2rem; left: 3rem;"> | 36 | <!-- <div style="position: absolute; top: 2rem; left: 3rem;"> |
| ... | @@ -52,81 +54,57 @@ | ... | @@ -52,81 +54,57 @@ |
| 52 | 54 | ||
| 53 | <script setup> | 55 | <script setup> |
| 54 | import { mainStore } from '@/store' | 56 | import { mainStore } from '@/store' |
| 55 | - | ||
| 56 | // import icon_player from '@images/bofang@2x.png' | 57 | // import icon_player from '@images/bofang@2x.png' |
| 57 | -import no_image from '@images/que-shuju@2x.png' | 58 | +import { no_image, icon_avatar } from '@/utils/generateIcons.js' |
| 58 | import CommentBox from '@/components/CommentBox/index.vue' | 59 | import CommentBox from '@/components/CommentBox/index.vue' |
| 59 | -import icon_avatar from '@images/que-touxiang@2x.png' | ||
| 60 | - | ||
| 61 | import { ref, onActivated } from 'vue' | 60 | import { ref, onActivated } from 'vue' |
| 62 | import { useRoute, useRouter } from 'vue-router' | 61 | import { useRoute, useRouter } from 'vue-router' |
| 63 | import axios from '@/utils/axios'; | 62 | import axios from '@/utils/axios'; |
| 64 | import _ from 'lodash' | 63 | import _ from 'lodash' |
| 65 | import { Toast } from 'vant'; | 64 | import { Toast } from 'vant'; |
| 66 | import { addPages, store } from '@/hooks/useKeepAlive' | 65 | import { addPages, store } from '@/hooks/useKeepAlive' |
| 66 | +import { myAtmeAPI } from '@/api/C/me' | ||
| 67 | +import { addCommentAPI, addReplyAPI } from '@/api/C/perf' | ||
| 67 | 68 | ||
| 68 | const $route = useRoute(); | 69 | const $route = useRoute(); |
| 69 | const $router = useRouter(); | 70 | const $router = useRouter(); |
| 70 | 71 | ||
| 71 | -// @我的接口联调 | ||
| 72 | const loading = ref(false); | 72 | const loading = ref(false); |
| 73 | const finished = ref(false); | 73 | const finished = ref(false); |
| 74 | const commentList = ref([]) | 74 | const commentList = ref([]) |
| 75 | let limit = ref(10); | 75 | let limit = ref(10); |
| 76 | let offset = ref(0) | 76 | let offset = ref(0) |
| 77 | - | ||
| 78 | // 因为不能让空图标提前出来的写法 | 77 | // 因为不能让空图标提前出来的写法 |
| 79 | const finishedTextStatus = ref(false); | 78 | const finishedTextStatus = ref(false); |
| 80 | const emptyStatus = ref(false); | 79 | const emptyStatus = ref(false); |
| 81 | - | 80 | +// |
| 82 | -const onLoad = () => { | 81 | +const onLoad = async () => { |
| 83 | - axios.get('/srv/?a=my_atme', { | 82 | + const { data } = await myAtmeAPI({ limit: limit.value, offset: offset.value }); |
| 84 | - params: { | 83 | + _.each(data, item => { |
| 85 | - limit: limit.value, | 84 | + let arr = _.split(item.target_name, '@'); // 分割评论的动作和姓名 |
| 86 | - offset: offset.value | 85 | + item.c_action = arr[0]; // 评论动作 |
| 87 | - } | 86 | + item.c_name = arr[1]; // 评论姓名 |
| 88 | - }) | ||
| 89 | - .then(res => { | ||
| 90 | - if (res.data.code === 1) { | ||
| 91 | - _.each(res.data.data, item => { | ||
| 92 | - let arr = _.split(item.target_name, '@'); // 分割评论的动作和姓名 | ||
| 93 | - item.c_action = arr[0]; // 评论动作 | ||
| 94 | - item.c_name = arr[1]; // 评论姓名 | ||
| 95 | - }) | ||
| 96 | - commentList.value = _.concat(commentList.value, res.data.data); | ||
| 97 | - offset.value = commentList.value.length; | ||
| 98 | - loading.value = false; | ||
| 99 | - // 数据全部加载完成 | ||
| 100 | - if (!res.data.data.length) { | ||
| 101 | - // 加载状态结束 | ||
| 102 | - finished.value = true; | ||
| 103 | - } | ||
| 104 | - if (!commentList.value.length) { | ||
| 105 | - finishedTextStatus.value = false; | ||
| 106 | - emptyStatus.value = true; | ||
| 107 | - } else { | ||
| 108 | - emptyStatus.value = false; | ||
| 109 | - } | ||
| 110 | - } else { | ||
| 111 | - console.warn(res); | ||
| 112 | - if (!res.data.show) return false; | ||
| 113 | - Toast({ | ||
| 114 | - icon: 'close', | ||
| 115 | - message: res.data.msg | ||
| 116 | - }); | ||
| 117 | - } | ||
| 118 | - }) | ||
| 119 | - .catch(err => { | ||
| 120 | - console.error(err); | ||
| 121 | }) | 87 | }) |
| 88 | + commentList.value = [...commentList.value, ...data]; | ||
| 89 | + offset.value = commentList.value.length; | ||
| 90 | + loading.value = false; | ||
| 91 | + // 数据全部加载完成 | ||
| 92 | + if (!data.length) { | ||
| 93 | + // 加载状态结束 | ||
| 94 | + finished.value = true; | ||
| 95 | + } | ||
| 96 | + if (!commentList.value.length) { | ||
| 97 | + finishedTextStatus.value = false; | ||
| 98 | + emptyStatus.value = true; | ||
| 99 | + } else { | ||
| 100 | + emptyStatus.value = false; | ||
| 101 | + } | ||
| 122 | } | 102 | } |
| 123 | -// 立即执行一次 | ||
| 124 | -// onLoad(); | ||
| 125 | 103 | ||
| 126 | /******** 留言框相关操作 START *******/ | 104 | /******** 留言框相关操作 START *******/ |
| 127 | // 回复评论控件 | 105 | // 回复评论控件 |
| 128 | const showCommentBoxPopup = ref(false); | 106 | const showCommentBoxPopup = ref(false); |
| 129 | -const commentType = ref('comment'); // 类型 comment 为评论/类型 reply 为回复 | 107 | +const commentType = ref(''); // 类型 comment 为评论 / 类型 reply 为回复 |
| 130 | 108 | ||
| 131 | /** | 109 | /** |
| 132 | * 回复/评论 功能 | 110 | * 回复/评论 功能 |
| ... | @@ -135,6 +113,7 @@ const commentType = ref('comment'); // 类型 comment 为评论/类型 reply 为 | ... | @@ -135,6 +113,7 @@ const commentType = ref('comment'); // 类型 comment 为评论/类型 reply 为 |
| 135 | */ | 113 | */ |
| 136 | const commentId = ref('') | 114 | const commentId = ref('') |
| 137 | const replayUser = ref('') | 115 | const replayUser = ref('') |
| 116 | +// 打开评论弹框组件 | ||
| 138 | const setComment = (v, type) => { | 117 | const setComment = (v, type) => { |
| 139 | showCommentBoxPopup.value = true; | 118 | showCommentBoxPopup.value = true; |
| 140 | commentType.value = type; | 119 | commentType.value = type; |
| ... | @@ -143,45 +122,31 @@ const setComment = (v, type) => { | ... | @@ -143,45 +122,31 @@ const setComment = (v, type) => { |
| 143 | } | 122 | } |
| 144 | 123 | ||
| 145 | /** | 124 | /** |
| 146 | - * 提交留言回调 | 125 | + * 留言/回复 回调 |
| 147 | * @param {*} note 留言内容 | 126 | * @param {*} note 留言内容 |
| 127 | + * @param {*} prod_id 作品ID | ||
| 128 | + * @param {*} comment_id 评论ID | ||
| 148 | */ | 129 | */ |
| 149 | -const submitCommentBox = (note) => { | 130 | +const submitCommentBox = async (note) => { |
| 150 | - let url = ''; | 131 | + let params = { note }; |
| 151 | - let data = {} | ||
| 152 | - // 判断是留言还是回复 动态调整接口名称 | ||
| 153 | if (commentType.value === 'comment') { | 132 | if (commentType.value === 'comment') { |
| 154 | - url = 'add_comment'; | 133 | + params.prod_id = $route.query.prod_id; |
| 155 | - data = { | 134 | + const { msg } = await addCommentAPI(params); |
| 156 | - prod_id: $route.query.prod_id, | 135 | + if (msg === 'OK') { |
| 157 | - note | 136 | + Toast.success('发布成功') |
| 158 | - } | 137 | + // 刷新列表 |
| 159 | - } else { | 138 | + location.reload() |
| 160 | - url = 'add_reply'; | ||
| 161 | - data = { | ||
| 162 | - comment_id: commentId.value, | ||
| 163 | - note | ||
| 164 | } | 139 | } |
| 165 | } | 140 | } |
| 166 | - axios.post(`/srv/?a=${url}`, data) | 141 | + if (commentType.value === 'reply') { |
| 167 | - .then(res => { | 142 | + params.comment_id = commentId.value; |
| 168 | - showCommentBoxPopup.value = false; | 143 | + const { msg } = await addReplyAPI(params); |
| 169 | - if (res.data.code === 1) { | 144 | + if (msg === 'OK') { |
| 170 | Toast.success('发布成功') | 145 | Toast.success('发布成功') |
| 171 | // 刷新列表 | 146 | // 刷新列表 |
| 172 | location.reload() | 147 | location.reload() |
| 173 | - } else { | ||
| 174 | - console.warn(res); | ||
| 175 | - if (!res.data.show) return false; | ||
| 176 | - Toast({ | ||
| 177 | - icon: 'close', | ||
| 178 | - message: res.data.msg | ||
| 179 | - }); | ||
| 180 | } | 148 | } |
| 181 | - }) | 149 | + } |
| 182 | - .catch(err => { | ||
| 183 | - console.error(err); | ||
| 184 | - }) | ||
| 185 | } | 150 | } |
| 186 | 151 | ||
| 187 | const closeCommentBox = (v) => { // 关闭留言框 | 152 | const closeCommentBox = (v) => { // 关闭留言框 |
| ... | @@ -234,7 +199,7 @@ export default { | ... | @@ -234,7 +199,7 @@ export default { |
| 234 | color: #999999; | 199 | color: #999999; |
| 235 | padding: 1rem; | 200 | padding: 1rem; |
| 236 | line-height: 1.75; | 201 | line-height: 1.75; |
| 237 | - | 202 | + position: relative; |
| 238 | .reply-wrapper { | 203 | .reply-wrapper { |
| 239 | background: #F7F7F7; | 204 | background: #F7F7F7; |
| 240 | border-radius: 10px; | 205 | border-radius: 10px; |
| ... | @@ -246,5 +211,12 @@ export default { | ... | @@ -246,5 +211,12 @@ export default { |
| 246 | color: #222222; | 211 | color: #222222; |
| 247 | } | 212 | } |
| 248 | } | 213 | } |
| 214 | + .spot { | ||
| 215 | + color: red; | ||
| 216 | + font-size: 2rem; | ||
| 217 | + position: absolute; | ||
| 218 | + right: -0.5rem; | ||
| 219 | + top: -1.75rem; | ||
| 220 | + } | ||
| 249 | } | 221 | } |
| 250 | </style> | 222 | </style> | ... | ... |
-
Please register or login to post a comment