Merge branch 'main' of http://192.168.1.42/developOne/harmonyPool
Showing
6 changed files
with
86 additions
and
23 deletions
| @@ -843,6 +843,13 @@ export class HttpUrlUtils { | @@ -843,6 +843,13 @@ export class HttpUrlUtils { | ||
| 843 | let url = HttpUrlUtils._hostUrl + "/api/rmrb-interact/interact/zh/c/like/executeLike"; | 843 | let url = HttpUrlUtils._hostUrl + "/api/rmrb-interact/interact/zh/c/like/executeLike"; |
| 844 | return url; | 844 | return url; |
| 845 | } | 845 | } |
| 846 | + | ||
| 847 | + //获取点赞状态 | ||
| 848 | + static getLikeStatus() { | ||
| 849 | + let url = HttpUrlUtils._hostUrl + "/api/rmrb-interact/interact/zh/c/batchLikeAndCollect/status"; | ||
| 850 | + return url; | ||
| 851 | + } | ||
| 852 | + | ||
| 846 | //搜索推荐 | 853 | //搜索推荐 |
| 847 | static getSearchSuggestDataUrl() { | 854 | static getSearchSuggestDataUrl() { |
| 848 | let url = HttpUrlUtils._hostUrl + HttpUrlUtils.SEARCH_SUGGEST_DATA_PATH | 855 | let url = HttpUrlUtils._hostUrl + HttpUrlUtils.SEARCH_SUGGEST_DATA_PATH |
| @@ -14,6 +14,8 @@ export { PageComponent } from "./src/main/ets/components/page/PageComponent" | @@ -14,6 +14,8 @@ export { PageComponent } from "./src/main/ets/components/page/PageComponent" | ||
| 14 | 14 | ||
| 15 | export { BottomNavigationComponent } from "./src/main/ets/components/page/BottomNavigationComponent" | 15 | export { BottomNavigationComponent } from "./src/main/ets/components/page/BottomNavigationComponent" |
| 16 | 16 | ||
| 17 | +export { LikeComponent } from "./src/main/ets/components/view/LikeComponent" | ||
| 18 | + | ||
| 17 | export { TopNavigationComponent } from "./src/main/ets/components/page/TopNavigationComponent" | 19 | export { TopNavigationComponent } from "./src/main/ets/components/page/TopNavigationComponent" |
| 18 | 20 | ||
| 19 | export { LabelComponent } from "./src/main/ets/components/view/LabelComponent" | 21 | export { LabelComponent } from "./src/main/ets/components/view/LabelComponent" |
| 1 | import { Logger } from 'wdKit/Index' | 1 | import { Logger } from 'wdKit/Index' |
| 2 | import { LikeViewModel } from '../../viewmodel/LikeViewModel' | 2 | import { LikeViewModel } from '../../viewmodel/LikeViewModel' |
| 3 | 3 | ||
| 4 | +const TAG = 'LikeComponent'; | ||
| 5 | + | ||
| 4 | @Component | 6 | @Component |
| 5 | export struct LikeComponent { | 7 | export struct LikeComponent { |
| 6 | @State likeStatus: boolean = false | 8 | @State likeStatus: boolean = false |
| @@ -15,17 +17,12 @@ export struct LikeComponent { | @@ -15,17 +17,12 @@ export struct LikeComponent { | ||
| 15 | // this.data['title'] = '开创两校交流先河!克罗地亚教育代表团访问同济大学' | 17 | // this.data['title'] = '开创两校交流先河!克罗地亚教育代表团访问同济大学' |
| 16 | // this.data['userHeaderUrl'] = "" | 18 | // this.data['userHeaderUrl'] = "" |
| 17 | // this.data['channelId'] = "2059" //必须 | 19 | // this.data['channelId'] = "2059" //必须 |
| 18 | - // this.data['status'] = "1" //必须 | 20 | + // this.data['status'] = "1" |
| 19 | 21 | ||
| 20 | aboutToAppear(): void { | 22 | aboutToAppear(): void { |
| 21 | if (this.data) { | 23 | if (this.data) { |
| 22 | - Logger.debug("ddd: " + this.data['status']) | ||
| 23 | - if (this.data['status'] == '1') { | ||
| 24 | - this.likeStatus = true | ||
| 25 | - } else { | ||
| 26 | - this.likeStatus = false | ||
| 27 | - } | ||
| 28 | - | 24 | + //获取点赞状态 |
| 25 | + this.getLikeStatus() | ||
| 29 | } | 26 | } |
| 30 | 27 | ||
| 31 | } | 28 | } |
| @@ -41,10 +38,10 @@ export struct LikeComponent { | @@ -41,10 +38,10 @@ export struct LikeComponent { | ||
| 41 | } | 38 | } |
| 42 | if (this.likeStatus) { | 39 | if (this.likeStatus) { |
| 43 | //1 | 40 | //1 |
| 44 | - this.executeLike('1') | 41 | + this.executeLike('0') |
| 45 | } else { | 42 | } else { |
| 46 | //0 | 43 | //0 |
| 47 | - this.executeLike('0') | 44 | + this.executeLike('1') |
| 48 | } | 45 | } |
| 49 | }) | 46 | }) |
| 50 | }.width(24).height(24) | 47 | }.width(24).height(24) |
| @@ -59,4 +56,18 @@ export struct LikeComponent { | @@ -59,4 +56,18 @@ export struct LikeComponent { | ||
| 59 | this.enableBtn = true | 56 | this.enableBtn = true |
| 60 | }) | 57 | }) |
| 61 | } | 58 | } |
| 59 | + | ||
| 60 | + getLikeStatus() { | ||
| 61 | + this.viewModel.getLikeStatus(this.data).then((data) => { | ||
| 62 | + if (data && data['data'].length && data['data'][0]['likeStatus']) { | ||
| 63 | + this.likeStatus = data['data'][0]['likeStatus'] | ||
| 64 | + }else { | ||
| 65 | + this.likeStatus = false | ||
| 66 | + } | ||
| 67 | + }).catch(() => { | ||
| 68 | + this.likeStatus = false | ||
| 69 | + }) | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + | ||
| 62 | } | 73 | } |
| 1 | import { HashMap } from '@kit.ArkTS'; | 1 | import { HashMap } from '@kit.ArkTS'; |
| 2 | import { Logger } from 'wdKit/Index'; | 2 | import { Logger } from 'wdKit/Index'; |
| 3 | -import { HttpUrlUtils, ResponseDTO } from 'wdNetwork/Index'; | 3 | +import { HttpBizUtil, HttpUrlUtils, ResponseDTO } from 'wdNetwork/Index'; |
| 4 | import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest'; | 4 | import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest'; |
| 5 | 5 | ||
| 6 | export class LikeModel { | 6 | export class LikeModel { |
| @@ -8,7 +8,7 @@ export class LikeModel { | @@ -8,7 +8,7 @@ export class LikeModel { | ||
| 8 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 8 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 9 | 9 | ||
| 10 | return new Promise<object>((success, fail) => { | 10 | return new Promise<object>((success, fail) => { |
| 11 | - HttpRequest.post<ResponseDTO<object>>(HttpUrlUtils.executeLike(), data, headers).then((data: ResponseDTO<object>) => { | 11 | + HttpBizUtil.post<ResponseDTO<object>>(HttpUrlUtils.executeLike(), data, headers).then((data: ResponseDTO<object>) => { |
| 12 | if (data.code != 0) { | 12 | if (data.code != 0) { |
| 13 | fail(data.message) | 13 | fail(data.message) |
| 14 | return | 14 | return |
| @@ -20,4 +20,28 @@ export class LikeModel { | @@ -20,4 +20,28 @@ export class LikeModel { | ||
| 20 | }) | 20 | }) |
| 21 | }) | 21 | }) |
| 22 | } | 22 | } |
| 23 | + | ||
| 24 | + | ||
| 25 | + getLikeStatus(data: Record<string, string>) { | ||
| 26 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 27 | + let model : Record<string,Record<string,string>[]> = {} | ||
| 28 | + model['contentList'] = [data] | ||
| 29 | + | ||
| 30 | + return new Promise<object>((success, fail) => { | ||
| 31 | + HttpBizUtil.post<ResponseDTO<object>>(HttpUrlUtils.getLikeStatus(), model, headers).then((data: ResponseDTO<object>) => { | ||
| 32 | + if (data.code != 0) { | ||
| 33 | + fail(data.message) | ||
| 34 | + return | ||
| 35 | + } | ||
| 36 | + success(data) | ||
| 37 | + }, (error: Error) => { | ||
| 38 | + fail(error.message) | ||
| 39 | + Logger.debug("LoginViewModel:error ", error.toString()) | ||
| 40 | + }) | ||
| 41 | + }) | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + | ||
| 45 | + | ||
| 46 | + | ||
| 23 | } | 47 | } |
| @@ -21,6 +21,7 @@ export class LikeViewModel { | @@ -21,6 +21,7 @@ export class LikeViewModel { | ||
| 21 | this.likeModel.executeLike(bean) | 21 | this.likeModel.executeLike(bean) |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | + //点赞 | ||
| 24 | executeLike2(bean: Record<string, string>) { | 25 | executeLike2(bean: Record<string, string>) { |
| 25 | 26 | ||
| 26 | return new Promise<object>((success, fail) => { | 27 | return new Promise<object>((success, fail) => { |
| @@ -32,4 +33,20 @@ export class LikeViewModel { | @@ -32,4 +33,20 @@ export class LikeViewModel { | ||
| 32 | }) | 33 | }) |
| 33 | 34 | ||
| 34 | } | 35 | } |
| 36 | + | ||
| 37 | + //点赞状态 | ||
| 38 | + getLikeStatus(bean: Record<string, string>) { | ||
| 39 | + | ||
| 40 | + return new Promise<object>((success, fail) => { | ||
| 41 | + this.likeModel.getLikeStatus(bean).then((data) => { | ||
| 42 | + success(data) | ||
| 43 | + }).catch((error: string) => { | ||
| 44 | + fail(error) | ||
| 45 | + }) | ||
| 46 | + }) | ||
| 47 | + | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + | ||
| 51 | + | ||
| 35 | } | 52 | } |
| @@ -60,7 +60,7 @@ struct LaunchAdvertisingPage { | @@ -60,7 +60,7 @@ struct LaunchAdvertisingPage { | ||
| 60 | 60 | ||
| 61 | Stack({alignContent:Alignment.Bottom}){ | 61 | Stack({alignContent:Alignment.Bottom}){ |
| 62 | Column(){ | 62 | Column(){ |
| 63 | - if(!(this.model.launchAdInfo[0].matInfo.matType == '1')){ | 63 | + if(this.model.launchAdInfo.length && !(this.model.launchAdInfo[0].matInfo.matType == '1')){ |
| 64 | //显示图片 | 64 | //显示图片 |
| 65 | Image(this.model.launchAdInfo[0].matInfo.matImageUrl[0]) | 65 | Image(this.model.launchAdInfo[0].matInfo.matImageUrl[0]) |
| 66 | .width('100%') | 66 | .width('100%') |
| @@ -100,7 +100,7 @@ struct LaunchAdvertisingPage { | @@ -100,7 +100,7 @@ struct LaunchAdvertisingPage { | ||
| 100 | } | 100 | } |
| 101 | .width('100%') | 101 | .width('100%') |
| 102 | .height('100%') | 102 | .height('100%') |
| 103 | - if(!(this.model.launchAdInfo[0].matInfo.startStyle == 1)){ | 103 | + if(this.model.launchAdInfo.length && !(this.model.launchAdInfo[0].matInfo.startStyle == 1)){ |
| 104 | //底部logo样式 按钮加载在背景展示图上 | 104 | //底部logo样式 按钮加载在背景展示图上 |
| 105 | Button(){ | 105 | Button(){ |
| 106 | Row(){ | 106 | Row(){ |
| @@ -133,7 +133,7 @@ struct LaunchAdvertisingPage { | @@ -133,7 +133,7 @@ struct LaunchAdvertisingPage { | ||
| 133 | .height('84%') | 133 | .height('84%') |
| 134 | .margin({top:'0'}) | 134 | .margin({top:'0'}) |
| 135 | 135 | ||
| 136 | - if(this.model.launchAdInfo[0].matInfo.startStyle == 1){ | 136 | + if(this.model.launchAdInfo.length && this.model.launchAdInfo[0].matInfo.startStyle == 1){ |
| 137 | //全屏样式,底部无logo 按钮放在原底部logo位置 | 137 | //全屏样式,底部无logo 按钮放在原底部logo位置 |
| 138 | Button(){ | 138 | Button(){ |
| 139 | Row(){ | 139 | Row(){ |
| @@ -176,17 +176,19 @@ struct LaunchAdvertisingPage { | @@ -176,17 +176,19 @@ struct LaunchAdvertisingPage { | ||
| 176 | action(){ | 176 | action(){ |
| 177 | //跳转 url linkUrl https://news.bjd.com.cn/2024/03/19/10724331.shtml | 177 | //跳转 url linkUrl https://news.bjd.com.cn/2024/03/19/10724331.shtml |
| 178 | // openType 端外 端内 打开 | 178 | // openType 端外 端内 打开 |
| 179 | - if (this.model.launchAdInfo[0].matInfo.openType == '2') { | ||
| 180 | - //端外打开 | 179 | + if(this.model.launchAdInfo.length){ |
| 180 | + if (this.model.launchAdInfo[0].matInfo.openType == '2') { | ||
| 181 | + //端外打开 | ||
| 181 | 182 | ||
| 182 | - ProcessUtils.jumpExternalWebPage(this.model.launchAdInfo[0].matInfo.linkUrl) | ||
| 183 | - clearInterval(this.timer) | 183 | + ProcessUtils.jumpExternalWebPage(this.model.launchAdInfo[0].matInfo.linkUrl) |
| 184 | + clearInterval(this.timer) | ||
| 184 | 185 | ||
| 185 | - }else { | ||
| 186 | - //端内打开 | ||
| 187 | - ProcessUtils.gotoDefaultWebPage(this.model.launchAdInfo[0].matInfo.linkUrl) | ||
| 188 | - clearInterval(this.timer) | 186 | + }else { |
| 187 | + //端内打开 | ||
| 188 | + ProcessUtils.gotoDefaultWebPage(this.model.launchAdInfo[0].matInfo.linkUrl) | ||
| 189 | + clearInterval(this.timer) | ||
| 189 | 190 | ||
| 191 | + } | ||
| 190 | } | 192 | } |
| 191 | } | 193 | } |
| 192 | 194 |
-
Please register or login to post a comment