Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cust-app
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李伟
cust-app
Commits
3918d90d
Commit
3918d90d
authored
Jan 17, 2025
by
liwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成了基础评论功能
parent
c22294db
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
172 deletions
+90
-172
index.js
api/article/index.js
+10
-1
articleDetail.vue
pagesArticle/articleDetail.vue
+80
-171
No files found.
api/article/index.js
View file @
3918d90d
...
...
@@ -39,7 +39,16 @@ export function getOssUrl(id) {
//查看动态详情
export
function
articleDetail
(
articleId
){
return
request
({
url
:
'/
opma
rticle/detail/'
+
articleId
,
url
:
'/
app/open/opmA
rticle/detail/'
+
articleId
,
method
:
'GET'
,
})
}
//动态评论
export
function
comment
(
data
)
{
return
request
({
url
:
'/opmarticle/comment'
,
data
:
data
,
method
:
'POST'
,
})
}
pagesArticle/articleDetail.vue
View file @
3918d90d
<
template
>
<
div
>
<
view
style=
"margin-bottom: 150rpx"
>
<view>
<ArticleItem
@
delete=
"deleteFn"
:info=
"articleInfo"
@
selectShare=
"selectShare(item)"
@
praise=
"praise"
<ArticleItem
@
delete=
"deleteFn"
:info=
"articleInfo"
@
praise=
"praise"
@
close=
"close"
@
open=
"open"
/>
</view>
<view
class=
"commentTitle"
>
...
...
@@ -25,26 +25,25 @@
<div
class=
"c-comment"
>
{{
info
.
content
}}
</div>
<div
class=
"c-actions"
>
<div
class=
"c-time"
>
{{
info
.
createDate
}}
</div>
<div
class=
"action-item"
>
<image
:src=
"baseUrl+'/article/104.png'"
@
click=
"btnComment(info)"
></image>
<text>
{{
info
.
replyCount
}}
</text>
</div>
<div
class=
"action-item"
>
<image
@
click=
"btnPrarse(info)"
:src=
"
info.praise
? baseUrl+'/article/105.png'
: baseUrl+'/article/105-no.png'
"
></image>
{{
info
.
likeCount
}}
</div>
<!--
<div
class=
"action-item"
>
-->
<!--
<image-->
<!-- :src="baseUrl+'/article/104.png'"-->
<!-- @click="btnComment(info)"-->
<!-- >
</image>
-->
<!--
<text>
-->
<!--
{{
info
.
replyCount
}}
-->
<!--
</text>
-->
<!--
</div>
-->
<!--
<div
class=
"action-item"
>
-->
<!--
<image-->
<!-- @click="btnPrarse(info)"-->
<!-- :src="info.isLike == '0'-->
<!-- ? baseUrl+'/article/105.png'-->
<!-- : baseUrl+'/article/105-no.png'-->
<!-- "-->
<!-- >
</image>
-->
<!--
{{
info
.
likeCount
}}
-->
<!--
</div>
-->
</div>
<!--
<div
v-if=
"info.childrenCommentInfos.length > 0"
>
-->
<!--
<div
v-if=
"info.contentAll"
>
-->
...
...
@@ -158,7 +157,7 @@
placeholder=
"走心,说点好听的"
border=
"surround"
v-model=
"commentValue"
@
c
hange=
"change
"
@
c
onfirm=
"handleEnter
"
customStyle=
"border-radius:36rpx;height:45rpx;background-color:rgb(249, 250, 251);width:60%"
></u--input>
<view
class=
"bottom-button-area"
>
...
...
@@ -179,7 +178,7 @@
<view
class=
"bottom-button"
>
<image
@
click=
""
:src=
"
info.praise
:src=
"
articleInfo.isLike == '0'
? baseUrl+'/article/105.png'
: baseUrl+'/article/105-no.png'"
></image>
...
...
@@ -187,12 +186,12 @@
</view>
</view>
</view>
</
div
>
</
view
>
</
template
>
<
script
>
import
ArticleItem
from
'./components/articleItem.vue'
import
{
articleDetail
}
from
'../api/article/index'
import
{
articleDetail
,
comment
,
getOssUrl
}
from
'../api/article/index'
import
{
getCity
,
getValue
}
from
"../common/options"
;
import
{
calculateAge
,
parseDate
}
from
"../common"
;
export
default
{
...
...
@@ -203,83 +202,8 @@ export default{
return
{
//图片路径
baseUrl
:
this
.
$IMG_URL
,
item
:{
createTime
:
'2024-12-28 15:02:01'
,
headPortrait
:
'http://192.168.1.80/upload/CmsBanner/20241230/18E63B570FF04DB3A8EFE277D58256C4.jpg'
,
//头像
nickName
:
'不爱吃辣的小王'
,
//nickName
gender
:
'MALE'
,
//性别
information
:
'02·重庆市·硕士·互联网'
,
//个人信息
content
:
'昨天的快乐留在今天发,那就是100%'
,
//动态内容
time
:
'2024-11-11 15:02:01'
,
//发布动态的时间
commentCount
:
'10'
,
//评论数
likeCount
:
'11'
,
//点赞数
img
:[
'http://192.168.1.80/upload/CmsBanner/20241230/18E63B570FF04DB3A8EFE277D58256C4.jpg'
,
'http://192.168.1.80/upload/CmsBanner/20241230/18E63B570FF04DB3A8EFE277D58256C4.jpg'
]
},
//评论值
commentValue
:
''
,
commentChildren
:[
{
id
:
'1'
,
avatar
:
'http://192.168.1.80/upload/CmsBanner/20241230/18E63B570FF04DB3A8EFE277D58256C4.jpg'
,
nickName
:
'不吃鱼的猫'
,
content
:
'11111111111111111111'
,
createTime
:
'2024-05-02 15:24:01'
,
likesNumber
:
'1'
,
contentAll
:
false
,
childrenCommentInfos
:[
{
id
:
'1'
,
avatar
:
'http://192.168.1.80/upload/CmsBanner/20241230/18E63B570FF04DB3A8EFE277D58256C4.jpg'
,
nickName
:
'不吃鱼的猫11111'
,
content
:
'111111111111111111111111111'
,
createTime
:
'2024-05-02 15:24:01'
,
likesNumber
:
'1'
,
beRepliedName
:
'不吃鱼的猫'
},
{
id
:
'1'
,
avatar
:
'http://192.168.1.80/upload/CmsBanner/20241230/18E63B570FF04DB3A8EFE277D58256C4.jpg'
,
nickName
:
'不吃鱼的猫11111'
,
content
:
'111111111111111111111111111'
,
createTime
:
'2024-05-02 15:24:01'
,
likesNumber
:
'1'
,
beRepliedName
:
'不吃鱼的猫'
},
{
id
:
'1'
,
avatar
:
'http://192.168.1.80/upload/CmsBanner/20241230/18E63B570FF04DB3A8EFE277D58256C4.jpg'
,
nickName
:
'不吃鱼的猫11111'
,
content
:
'111111111111111111111111111'
,
createTime
:
'2024-05-02 15:24:01'
,
likesNumber
:
'1'
,
beRepliedName
:
'不吃鱼的猫'
}
]
},
{
id
:
'1'
,
avatar
:
'http://192.168.1.80/upload/CmsBanner/20241230/18E63B570FF04DB3A8EFE277D58256C4.jpg'
,
nickName
:
'不吃鱼的猫'
,
content
:
'11111111111111111111'
,
createTime
:
'2024-05-02 15:24:01'
,
likesNumber
:
'1'
,
contentAll
:
false
,
childrenCommentInfos
:[
{
id
:
'1'
,
avatar
:
'http://192.168.1.80/upload/CmsBanner/20241230/18E63B570FF04DB3A8EFE277D58256C4.jpg'
,
nickName
:
'不吃鱼的猫11111'
,
content
:
'111111111111111111111111111'
,
createTime
:
'2024-05-02 15:24:01'
,
likesNumber
:
'1'
,
beRepliedName
:
'不吃鱼的猫'
}
]
}
],
flag
:
false
,
//动态id
articleId
:
''
,
//动态详情
...
...
@@ -291,93 +215,78 @@ export default{
this
.
getArticleDetail
()
},
methods
:
{
//评论回车事件
handleEnter
(
value
){
if
(
this
.
commentValue
===
''
){
uni
.
showToast
({
title
:
'评论内容不能为空'
,
icon
:
'none'
})
return
;
}
this
.
commentValue
=
''
const
params
=
{
articleId
:
this
.
articleInfo
.
businessId
,
commentContent
:
value
}
comment
(
params
).
then
(
res
=>
{
if
(
res
.
data
.
code
==
200
){
this
.
getArticleDetail
()
}
}).
catch
(
err
=>
{
uni
.
showToast
({
title
:
'评论失败,请稍后再试'
,
icon
:
'none'
})
})
},
getArticleDetail
(){
articleDetail
(
this
.
articleId
).
then
(
res
=>
{
this
.
articleInfo
=
res
.
data
.
data
//处理动态图片
if
(
res
.
data
.
data
.
url
!=
null
){
this
.
articleInfo
.
url
=
res
.
data
.
data
.
url
.
replace
(
/
\\
/g
,
'/'
).
split
(
','
)
if
(
res
.
data
.
data
.
pictureId
!=
null
){
const
urlArray
=
JSON
.
parse
(
res
.
data
.
data
.
pictureId
)
let
arr
=
[]
urlArray
.
id
.
forEach
(
item
=>
{
getOssUrl
(
item
).
then
(
res
=>
{
arr
.
push
(
res
.
data
.
data
)
})
})
this
.
articleInfo
.
url
=
arr
}
//处理头像
if
(
res
.
data
.
data
.
memAvatar
!=
null
){
this
.
articleInfo
.
memAvatar
=
res
.
data
.
data
.
memAvatar
.
replace
(
/
\\
/g
,
'/'
).
split
(
','
)
if
(
res
.
data
.
data
.
avatarId
!=
null
){
getOssUrl
(
res
.
data
.
data
.
avatarId
).
then
(
res
=>
{
this
.
articleInfo
.
memAvatar
=
res
.
data
.
data
})
}
//处理学历
if
(
res
.
data
.
data
.
memMaxEducation
!=
null
&&
res
.
data
.
data
.
memMaxEducation
!==
''
){
this
.
articleInfo
.
memMaxEducation
=
getValue
(
'education'
,
res
.
data
.
data
.
memMaxEducation
)
}
//处理性别
if
(
res
.
data
.
data
.
memSex
!=
null
&&
res
.
data
.
data
.
memSex
!==
''
){
this
.
articleInfo
.
memSex
=
getValue
(
'sex'
,
res
.
data
.
data
.
memSex
)
}
//处理地址
if
(
res
.
data
.
data
.
memResidenceProvince
!=
null
&&
res
.
data
.
data
.
memResidenceProvince
!=
''
&&
res
.
data
.
data
.
memResidenceCity
!=
null
&&
res
.
data
.
data
.
memResidenceCity
!=
''
){
this
.
articleInfo
.
city
=
getCity
(
res
.
data
.
data
.
memResidenceProvince
,
res
.
data
.
data
.
memResidenceCity
)
}
//通过生日计算年龄
if
(
res
.
data
.
data
.
memBirthday
!=
null
&&
res
.
data
.
data
.
memBirthday
!=
''
){
const
dataItem
=
parseDate
(
res
.
data
.
data
.
memBirthday
)
this
.
articleInfo
.
memAge
=
calculateAge
(
dataItem
.
year
,
dataItem
.
month
,
dataItem
.
day
)
}
//处理评论的头像
if
(
this
.
articleInfo
.
articleCommentVOList
!=
null
&&
this
.
articleInfo
.
articleCommentVOList
.
length
>
0
){
this
.
articleInfo
.
articleCommentVOList
.
forEach
(
item
=>
{
item
.
avatarUrl
=
item
.
avatarUrl
.
replace
(
/
\\
/g
,
'/'
)
getOssUrl
(
item
.
avatarId
).
then
(
res
=>
{
item
.
avatarUrl
=
res
.
data
.
data
})
})
}
})
},
changeAllFun
(
info
)
{
// console.log(info)
// let list = this.commentChildren
// console.log(list)
// list.forEach((elem) => {
// console.log(elem.id == info.id)
// if (elem.id == info.id) {
// elem.contentAll = !elem.contentAll
// }
// })
// uni.setStorageSync("commentList", list)
// bus.$emit('resComList');
},
btnComment
(
item
)
{
// bus.$emit('item', item);
},
btnPrarse
(
info
)
{
// let list = uni.getStorageSync('commentList')
// let optType = null
// info.praise ? optType = 1 : optType = 0
// let parmars = {
// optType: optType,
// strategyCommentId: info.id,
// }
//
// likeOrDislikeStrategy(parmars).then(res => {
// if (res.code == 200) {
// this.seachId(list, info.id)
// }
// else {
// this.$toast(res.msg)
// }
// })
},
seachId
(
list
,
id
)
{
// let result = null
// for (let i = 0; i
<
list
.
length
;
i
++
)
{
// if (result !== null) {
// break //跳出循环的关键
// }
// if (list[i].id === id) {
// let res = list[i].nickName;
// result = res //取值关键
// list[i].praise = !list[i].praise
// if (list[i].praise) {
// list[i].likesNumber++
// } else {
// list[i].likesNumber--
// }
// break
// } else if (list[i].childrenCommentInfos) {//递归条件
// this.seachId(list[i].childrenCommentInfos, id);
// } else {
// continue
// }
// }
// uni.setStorageSync("commentList", list)
// bus.$emit('resComList');
}
},
}
</
script
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment