Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
yuanfeiyang02
2024-04-25 16:16:34 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
775f4f5d46fb639ca40a82652a56f34333ce89e7
775f4f5d
1 parent
35378b3a
feat:稿件点赞组件增加点赞状态查询
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
73 additions
and
12 deletions
sight_harmony/commons/wdNetwork/src/main/ets/http/HttpUrlUtils.ets
sight_harmony/features/wdComponent/Index.ets
sight_harmony/features/wdComponent/src/main/ets/components/view/LikeComponent.ets
sight_harmony/features/wdComponent/src/main/ets/model/LikeModel.ets
sight_harmony/features/wdComponent/src/main/ets/viewmodel/LikeViewModel.ets
sight_harmony/commons/wdNetwork/src/main/ets/http/HttpUrlUtils.ets
View file @
775f4f5
...
...
@@ -843,6 +843,13 @@ export class HttpUrlUtils {
let url = HttpUrlUtils._hostUrl + "/api/rmrb-interact/interact/zh/c/like/executeLike";
return url;
}
//获取点赞状态
static getLikeStatus() {
let url = HttpUrlUtils._hostUrl + "/api/rmrb-interact/interact/zh/c/batchLikeAndCollect/status";
return url;
}
//搜索推荐
static getSearchSuggestDataUrl() {
let url = HttpUrlUtils._hostUrl + HttpUrlUtils.SEARCH_SUGGEST_DATA_PATH
...
...
sight_harmony/features/wdComponent/Index.ets
View file @
775f4f5
...
...
@@ -14,6 +14,8 @@ export { PageComponent } from "./src/main/ets/components/page/PageComponent"
export { BottomNavigationComponent } from "./src/main/ets/components/page/BottomNavigationComponent"
export { LikeComponent } from "./src/main/ets/components/view/LikeComponent"
export { TopNavigationComponent } from "./src/main/ets/components/page/TopNavigationComponent"
export { LabelComponent } from "./src/main/ets/components/view/LabelComponent"
...
...
sight_harmony/features/wdComponent/src/main/ets/components/view/LikeComponent.ets
View file @
775f4f5
import { Logger } from 'wdKit/Index'
import { LikeViewModel } from '../../viewmodel/LikeViewModel'
const TAG = 'LikeComponent';
@Component
export struct LikeComponent {
@State likeStatus: boolean = false
...
...
@@ -15,17 +17,12 @@ export struct LikeComponent {
// this.data['title'] = '开创两校交流先河!克罗地亚教育代表团访问同济大学'
// this.data['userHeaderUrl'] = ""
// this.data['channelId'] = "2059" //必须
// this.data['status'] = "1"
//必须
// this.data['status'] = "1"
aboutToAppear(): void {
if (this.data) {
Logger.debug("ddd: " + this.data['status'])
if (this.data['status'] == '1') {
this.likeStatus = true
} else {
this.likeStatus = false
}
//获取点赞状态
this.getLikeStatus()
}
}
...
...
@@ -41,10 +38,10 @@ export struct LikeComponent {
}
if (this.likeStatus) {
//1
this.executeLike('
1
')
this.executeLike('
0
')
} else {
//0
this.executeLike('
0
')
this.executeLike('
1
')
}
})
}.width(24).height(24)
...
...
@@ -59,4 +56,18 @@ export struct LikeComponent {
this.enableBtn = true
})
}
getLikeStatus() {
this.viewModel.getLikeStatus(this.data).then((data) => {
if (data && data['data'].length && data['data'][0]['likeStatus']) {
this.likeStatus = data['data'][0]['likeStatus']
}else {
this.likeStatus = false
}
}).catch(() => {
this.likeStatus = false
})
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/model/LikeModel.ets
View file @
775f4f5
import { HashMap } from '@kit.ArkTS';
import { Logger } from 'wdKit/Index';
import { HttpUrlUtils, ResponseDTO } from 'wdNetwork/Index';
import { Http
BizUtil, Http
UrlUtils, ResponseDTO } from 'wdNetwork/Index';
import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
export class LikeModel {
...
...
@@ -8,7 +8,7 @@ export class LikeModel {
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return new Promise<object>((success, fail) => {
Http
Request
.post<ResponseDTO<object>>(HttpUrlUtils.executeLike(), data, headers).then((data: ResponseDTO<object>) => {
Http
BizUtil
.post<ResponseDTO<object>>(HttpUrlUtils.executeLike(), data, headers).then((data: ResponseDTO<object>) => {
if (data.code != 0) {
fail(data.message)
return
...
...
@@ -20,4 +20,28 @@ export class LikeModel {
})
})
}
getLikeStatus(data: Record<string, string>) {
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
let model : Record<string,Record<string,string>[]> = {}
model['contentList'] = [data]
return new Promise<object>((success, fail) => {
HttpBizUtil.post<ResponseDTO<object>>(HttpUrlUtils.getLikeStatus(), model, headers).then((data: ResponseDTO<object>) => {
if (data.code != 0) {
fail(data.message)
return
}
success(data)
}, (error: Error) => {
fail(error.message)
Logger.debug("LoginViewModel:error ", error.toString())
})
})
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/viewmodel/LikeViewModel.ets
View file @
775f4f5
...
...
@@ -21,6 +21,7 @@ export class LikeViewModel {
this.likeModel.executeLike(bean)
}
//点赞
executeLike2(bean: Record<string, string>) {
return new Promise<object>((success, fail) => {
...
...
@@ -32,4 +33,20 @@ export class LikeViewModel {
})
}
//点赞状态
getLikeStatus(bean: Record<string, string>) {
return new Promise<object>((success, fail) => {
this.likeModel.getLikeStatus(bean).then((data) => {
success(data)
}).catch((error: string) => {
fail(error)
})
})
}
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment