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
cadb56f7
Commit
cadb56f7
authored
Jan 11, 2025
by
liwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
对接了点赞接口
parent
fe9f2328
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
14 deletions
+60
-14
index.js
api/article/index.js
+3
-3
Item.vue
pages/components/article/Item.vue
+29
-6
List.vue
pages/components/article/List.vue
+27
-4
article.vue
pages/tab/article.vue
+1
-1
No files found.
api/article/index.js
View file @
cadb56f7
...
@@ -20,10 +20,10 @@ export function publishArticle(data) {
...
@@ -20,10 +20,10 @@ export function publishArticle(data) {
}
}
// 点赞
// 点赞
export
function
praise
(
id
)
{
export
function
like
(
data
)
{
return
request
({
return
request
({
url
:
'/
opmarticle/likeAdd/'
+
id
,
url
:
'/
app/opmArticle/like?articleId='
+
data
.
id
+
'&praiseType='
+
data
.
praiseType
,
data
:
id
,
data
:
{}
,
method
:
'POST'
,
method
:
'POST'
,
})
})
}
}
...
...
pages/components/article/Item.vue
View file @
cadb56f7
...
@@ -81,7 +81,7 @@
...
@@ -81,7 +81,7 @@
<text>
{{info.commentCount}}
</text>
<text>
{{info.commentCount}}
</text>
</view>
</view>
<view
class=
"btn"
@
click=
"praise(info)"
>
<view
class=
"btn"
@
click=
"praise(info)"
>
<image
v-if=
"
!info.isLike
"
:src=
"baseUrl+'/article/105.png'"
mode=
""
></image>
<image
v-if=
"
info.isLike == '0'
"
:src=
"baseUrl+'/article/105.png'"
mode=
""
></image>
<image
v-else
:src=
"baseUrl+'/article/105-no.png'"
mode=
""
></image>
<image
v-else
:src=
"baseUrl+'/article/105-no.png'"
mode=
""
></image>
<text>
{{info.likeCount}}
</text>
<text>
{{info.likeCount}}
</text>
</view>
</view>
...
@@ -99,13 +99,14 @@
...
@@ -99,13 +99,14 @@
<!-- 右上角三个点的选项-->
<!-- 右上角三个点的选项-->
<u-action-sheet
:actions=
"list"
:closeOnClickOverlay=
"true"
:safeAreaInsetBottom=
"true"
cancelText=
"取消"
<u-action-sheet
:actions=
"list"
:closeOnClickOverlay=
"true"
:safeAreaInsetBottom=
"true"
cancelText=
"取消"
@
select=
"selectClick"
@
close=
"show = false"
:show=
"show"
></u-action-sheet>
@
select=
"selectClick"
@
close=
"show = false"
:show=
"show"
></u-action-sheet>
<!-- 登录弹窗-->
<login
@
change=
"getToLogin"
:isLoginPop=
"isLoginPop"
class=
"my-select"
></login>
</view>
</view>
</template>
</template>
<
script
>
<
script
>
import
imageAdaptation
from
'@/components/images-adaptation/imageAdaptation.vue'
import
imageAdaptation
from
'@/components/images-adaptation/imageAdaptation.vue'
import
xzjReadMore
from
"@/components/xzj-readMore/xzj-readMore.vue"
import
xzjReadMore
from
"@/components/xzj-readMore/xzj-readMore.vue"
import
{
praise
}
from
"../../../api/article"
;
export
default
{
export
default
{
name
:
'ArticleItem'
,
name
:
'ArticleItem'
,
options
:
{
options
:
{
...
@@ -144,6 +145,8 @@
...
@@ -144,6 +145,8 @@
},
},
data
()
{
data
()
{
return
{
return
{
//登录弹窗
isLoginPop
:
false
,
//图片路径
//图片路径
baseUrl
:
this
.
$store
.
state
.
imgUrl
,
baseUrl
:
this
.
$store
.
state
.
imgUrl
,
imgs
:
[],
imgs
:
[],
...
@@ -159,7 +162,6 @@
...
@@ -159,7 +162,6 @@
// name: "举报"
// name: "举报"
// }
// }
],
],
isConfirm
:
false
}
}
},
},
methods
:
{
methods
:
{
...
@@ -180,9 +182,30 @@
...
@@ -180,9 +182,30 @@
},
},
// 点赞
// 点赞
praise
(
item
)
{
praise
(
item
)
{
praise
(
item
.
businessId
).
then
(
res
=>
{
const
token
=
uni
.
getStorageSync
(
'token'
)
//校验token 如果没有token,跳到登录页进行登录
if
(
token
&&
token
!==
''
&&
token
!=
null
){
//已登录
//0:取消点赞/未点赞 1:点赞
item
.
isLike
=
item
.
isLike
==
'0'
?
'1'
:
'0'
this
.
$emit
(
'praise'
,
item
)
}
else
{
//未登录
this
.
isLoginPop
=
true
}
},
//登录弹窗
getToLogin
(
e
)
{
if
(
e
==
0
)
{
//取消登录
this
.
isLoginPop
=
false
;
}
else
{
this
.
isLoginPop
=
false
;
//立即登录
uni
.
navigateTo
({
url
:
'/pageslogin/index'
})
})
}
},
},
// 删除
// 删除
selectClick
(
item
)
{
selectClick
(
item
)
{
...
...
pages/components/article/List.vue
View file @
cadb56f7
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
</u-tabs>
</u-tabs>
</view>
</view>
<view
v-for=
"(item,index) in dataList"
:key=
"item.id"
>
<view
v-for=
"(item,index) in dataList"
:key=
"item.id"
>
<ItemVue
:info=
"item"
/>
<ItemVue
:info=
"item"
@
praise=
"praise"
/>
</view>
</view>
<empty
v-if=
"firstLoaded && !dataList.length"
/>
<empty
v-if=
"firstLoaded && !dataList.length"
/>
</z-paging>
</z-paging>
...
@@ -34,10 +34,10 @@
...
@@ -34,10 +34,10 @@
</
template
>
</
template
>
<
script
>
<
script
>
import
ItemVue
from
'./Item.vue'
import
ItemVue
from
'./Item.vue'
;
import
empty
from
'@/components/empty.vue'
import
empty
from
'@/components/empty.vue'
;
import
{
topicList
}
from
"../../../api/topic"
;
import
{
topicList
}
from
"../../../api/topic"
;
import
{
articleList
}
from
"../../../api/article"
;
import
{
articleList
,
like
}
from
"../../../api/article"
;
import
{
getCity
,
getValue
}
from
"../../../common/options"
;
import
{
getCity
,
getValue
}
from
"../../../common/options"
;
import
{
calculateAge
,
parseDate
}
from
"../../../common"
;
import
{
calculateAge
,
parseDate
}
from
"../../../common"
;
export
default
{
export
default
{
...
@@ -48,6 +48,8 @@
...
@@ -48,6 +48,8 @@
},
},
data
()
{
data
()
{
return
{
return
{
//登录弹窗
isLoginPop
:
''
,
//话题id
//话题id
topicId
:
0
,
topicId
:
0
,
//当前的tab
//当前的tab
...
@@ -226,6 +228,27 @@
...
@@ -226,6 +228,27 @@
// this.$refs.paging.complete(false);
// this.$refs.paging.complete(false);
// })
// })
},
},
// 点赞
praise
(
item
)
{
var
type
=
''
if
(
item
.
isLike
==
'0'
)
{
//取消点赞
type
=
'cancel'
item
.
likeCount
-=
1
}
else
{
//点赞
type
=
'praise'
item
.
likeCount
+=
1
}
const
params
=
{
id
:
item
.
businessId
,
praiseType
:
type
}
like
(
params
).
then
(
res
=>
{
let
idx
=
this
.
dataList
.
findIndex
(
obj
=>
obj
.
businessId
==
item
.
businessId
)
this
.
dataList
.
splice
(
idx
,
1
,
item
)
})
},
}
}
}
}
</
script
>
</
script
>
...
...
pages/tab/article.vue
View file @
cadb56f7
...
@@ -107,7 +107,7 @@
...
@@ -107,7 +107,7 @@
goMessage
()
{
goMessage
()
{
},
},
//
//
登录弹窗
getToLogin
(
e
)
{
getToLogin
(
e
)
{
if
(
e
==
0
)
{
if
(
e
==
0
)
{
//取消登录
//取消登录
...
...
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