yangsunyue_wd
... ... @@ -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
... ...
... ... @@ -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"
... ...
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
... ...
import { HashMap } from '@kit.ArkTS';
import { Logger } from 'wdKit/Index';
import { HttpUrlUtils, ResponseDTO } from 'wdNetwork/Index';
import { HttpBizUtil, HttpUrlUtils, 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) => {
HttpRequest.post<ResponseDTO<object>>(HttpUrlUtils.executeLike(), data, headers).then((data: ResponseDTO<object>) => {
HttpBizUtil.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
... ...
... ... @@ -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
... ...
... ... @@ -60,7 +60,7 @@ struct LaunchAdvertisingPage {
Stack({alignContent:Alignment.Bottom}){
Column(){
if(!(this.model.launchAdInfo[0].matInfo.matType == '1')){
if(this.model.launchAdInfo.length && !(this.model.launchAdInfo[0].matInfo.matType == '1')){
//显示图片
Image(this.model.launchAdInfo[0].matInfo.matImageUrl[0])
.width('100%')
... ... @@ -100,7 +100,7 @@ struct LaunchAdvertisingPage {
}
.width('100%')
.height('100%')
if(!(this.model.launchAdInfo[0].matInfo.startStyle == 1)){
if(this.model.launchAdInfo.length && !(this.model.launchAdInfo[0].matInfo.startStyle == 1)){
//底部logo样式 按钮加载在背景展示图上
Button(){
Row(){
... ... @@ -133,7 +133,7 @@ struct LaunchAdvertisingPage {
.height('84%')
.margin({top:'0'})
if(this.model.launchAdInfo[0].matInfo.startStyle == 1){
if(this.model.launchAdInfo.length && this.model.launchAdInfo[0].matInfo.startStyle == 1){
//全屏样式,底部无logo 按钮放在原底部logo位置
Button(){
Row(){
... ... @@ -176,17 +176,19 @@ struct LaunchAdvertisingPage {
action(){
//跳转 url linkUrl https://news.bjd.com.cn/2024/03/19/10724331.shtml
// openType 端外 端内 打开
if (this.model.launchAdInfo[0].matInfo.openType == '2') {
//端外打开
if(this.model.launchAdInfo.length){
if (this.model.launchAdInfo[0].matInfo.openType == '2') {
//端外打开
ProcessUtils.jumpExternalWebPage(this.model.launchAdInfo[0].matInfo.linkUrl)
clearInterval(this.timer)
ProcessUtils.jumpExternalWebPage(this.model.launchAdInfo[0].matInfo.linkUrl)
clearInterval(this.timer)
}else {
//端内打开
ProcessUtils.gotoDefaultWebPage(this.model.launchAdInfo[0].matInfo.linkUrl)
clearInterval(this.timer)
}else {
//端内打开
ProcessUtils.gotoDefaultWebPage(this.model.launchAdInfo[0].matInfo.linkUrl)
clearInterval(this.timer)
}
}
}
... ...