王士厅
@@ -19,9 +19,11 @@ export class HttpBizUtil { @@ -19,9 +19,11 @@ export class HttpBizUtil {
19 * @param headers 请求header参数 19 * @param headers 请求header参数
20 * @returns 返回值 20 * @returns 返回值
21 */ 21 */
22 - static get<T = string>(url: string, headers?: HashMap<string, string>): Promise<ResponseDTO<T>> {  
23 - return new Promise<ResponseDTO<T>>((success, debug) => {  
24 - WDHttp.get<ResponseDTO<T>>(url, headers).then((resDTO: ResponseDTO<T>) => { 22 + static get<T = ResponseDTO<string>>(url: string, headers?: HashMap<string, string>): Promise<T> {
  23 + return new Promise<T>((success, debug) => {
  24 + WDHttp.get<T>(url, headers).then((originalRes: T) => {
  25 + try {
  26 + let resDTO = originalRes as ResponseDTO
25 Logger.debug(TAG, 'get: ' + resDTO.code) 27 Logger.debug(TAG, 'get: ' + resDTO.code)
26 Logger.debug(TAG, 'get: ' + resDTO.message) 28 Logger.debug(TAG, 'get: ' + resDTO.message)
27 // 403:临时token;406:强制下线、封禁、清空登录信息还要跳转登录页面 29 // 403:临时token;406:强制下线、封禁、清空登录信息还要跳转登录页面
@@ -33,16 +35,20 @@ export class HttpBizUtil { @@ -33,16 +35,20 @@ export class HttpBizUtil {
33 } 35 }
34 Logger.debug(TAG, 'get again send: ' + token) 36 Logger.debug(TAG, 'get again send: ' + token)
35 // refreshToken为空场景不处理,直接请求接口。 37 // refreshToken为空场景不处理,直接请求接口。
36 - WDHttp.get<ResponseDTO<T>>(url, headers).then((resDTO: ResponseDTO<T>) => {  
37 - Logger.debug(TAG, 'get again: ' + resDTO.message)  
38 - success(resDTO) 38 + WDHttp.get<T>(url, headers).then((againResDTO: T) => {
  39 + Logger.debug(TAG, 'get again: ' + againResDTO)
  40 + success(againResDTO)
39 }).catch((res: object) => { 41 }).catch((res: object) => {
40 debug(res) 42 debug(res)
41 }) 43 })
42 }); 44 });
43 } else { 45 } else {
44 - success(resDTO) 46 + success(originalRes)
45 } 47 }
  48 + } catch (e) {
  49 + debug(originalRes)
  50 + }
  51 +
46 }).catch((res: object) => { 52 }).catch((res: object) => {
47 debug(res) 53 debug(res)
48 }) 54 })
@@ -56,9 +62,11 @@ export class HttpBizUtil { @@ -56,9 +62,11 @@ export class HttpBizUtil {
56 * @param headers 请求header参数 62 * @param headers 请求header参数
57 * @returns 返回值 63 * @returns 返回值
58 */ 64 */
59 - static post<T = string>(url: string, data?: object, headers?: HashMap<string, string>): Promise<ResponseDTO<T>> {  
60 - return new Promise<ResponseDTO<T>>((success, debug) => {  
61 - WDHttp.post<ResponseDTO<T>>(url, data, headers).then((resDTO: ResponseDTO<T>) => { 65 + static post<T = ResponseDTO<string>>(url: string, data?: object, headers?: HashMap<string, string>): Promise<T> {
  66 + return new Promise<T>((success, debug) => {
  67 + WDHttp.post<T>(url, data, headers).then((originalRes: T) => {
  68 + try {
  69 + let resDTO = originalRes as ResponseDTO
62 Logger.debug(TAG, 'post: ' + resDTO.code) 70 Logger.debug(TAG, 'post: ' + resDTO.code)
63 Logger.debug(TAG, 'post: ' + resDTO.message) 71 Logger.debug(TAG, 'post: ' + resDTO.message)
64 // 403:临时token;406:强制下线、封禁、清空登录信息还要跳转登录页面 72 // 403:临时token;406:强制下线、封禁、清空登录信息还要跳转登录页面
@@ -69,14 +77,17 @@ export class HttpBizUtil { @@ -69,14 +77,17 @@ export class HttpBizUtil {
69 headers.replace('cookie', 'RMRB-X-TOKEN=' + token) 77 headers.replace('cookie', 'RMRB-X-TOKEN=' + token)
70 } 78 }
71 // refreshToken为空场景不处理,直接请求接口。 79 // refreshToken为空场景不处理,直接请求接口。
72 - WDHttp.post<ResponseDTO<T>>(url, headers).then((resDTO: ResponseDTO<T>) => {  
73 - success(resDTO) 80 + WDHttp.post<T>(url, headers).then((againResDTO: T) => {
  81 + success(againResDTO)
74 }).catch((res: object) => { 82 }).catch((res: object) => {
75 debug(res) 83 debug(res)
76 }) 84 })
77 }); 85 });
78 } else { 86 } else {
79 - success(resDTO) 87 + success(originalRes)
  88 + }
  89 + } catch (e) {
  90 + success(originalRes)
80 } 91 }
81 }).catch((res: object) => { 92 }).catch((res: object) => {
82 debug(res) 93 debug(res)
1 import { CompDTO } from 'wdBean'; 1 import { CompDTO } from 'wdBean';
2 import { CommonConstants, CompStyle } from 'wdConstant'; 2 import { CommonConstants, CompStyle } from 'wdConstant';
3 -import { BannerComponent } from './view/BannerComponent';  
4 import { LabelComponent } from './view/LabelComponent'; 3 import { LabelComponent } from './view/LabelComponent';
5 import { LiveHorizontalCardComponent } from './view/LiveHorizontalCardComponent'; 4 import { LiveHorizontalCardComponent } from './view/LiveHorizontalCardComponent';
6 import { 5 import {
@@ -71,6 +71,7 @@ export struct AttentionListComponent { @@ -71,6 +71,7 @@ export struct AttentionListComponent {
71 }) 71 })
72 } 72 }
73 .listDirection(Axis.Horizontal) 73 .listDirection(Axis.Horizontal)
  74 + .scrollBar(BarState.Off)
74 .height(74) 75 .height(74)
75 } 76 }
76 .padding({ 77 .padding({
1 import { ContentDTO, FullColumnImgUrlDTO } from 'wdBean'; 1 import { ContentDTO, FullColumnImgUrlDTO } from 'wdBean';
2 import { RmhTitle } from '../cardCommon/RmhTitle' 2 import { RmhTitle } from '../cardCommon/RmhTitle'
3 import { ProcessUtils } from '../../utils/ProcessUtils'; 3 import { ProcessUtils } from '../../utils/ProcessUtils';
  4 +import { CommonConstants } from 'wdConstant/Index';
  5 +
4 const TAG = 'Card19Component'; 6 const TAG = 'Card19Component';
5 7
6 /** 8 /**
@@ -83,9 +85,16 @@ export struct Card19Component { @@ -83,9 +85,16 @@ export struct Card19Component {
83 .fontColor($r('app.color.color_222222')) 85 .fontColor($r('app.color.color_222222'))
84 .textOverflowStyle(2) 86 .textOverflowStyle(2)
85 .margin({ bottom: 8 }) 87 .margin({ bottom: 8 })
  88 + .width(CommonConstants.FULL_WIDTH)
  89 + .onClick((event: ClickEvent) => {
  90 + ProcessUtils.processPage(this.contentDTO)
  91 + })
86 } 92 }
87 // 图片-从无图到9图展示 93 // 图片-从无图到9图展示
88 createImg({ fullColumnImgUrls: this.contentDTO.fullColumnImgUrls }) 94 createImg({ fullColumnImgUrls: this.contentDTO.fullColumnImgUrls })
  95 + .onClick((event: ClickEvent) => {
  96 + ProcessUtils.processPage(this.contentDTO)
  97 + })
89 //TODO 底部的:分享、评论、点赞 功能;需要引用一个公共组件 98 //TODO 底部的:分享、评论、点赞 功能;需要引用一个公共组件
90 } 99 }
91 .padding({ 100 .padding({
@@ -94,9 +103,6 @@ export struct Card19Component { @@ -94,9 +103,6 @@ export struct Card19Component {
94 top: $r('app.float.card_comp_pagePadding_tb'), 103 top: $r('app.float.card_comp_pagePadding_tb'),
95 bottom: $r('app.float.card_comp_pagePadding_tb') 104 bottom: $r('app.float.card_comp_pagePadding_tb')
96 }) 105 })
97 - .onClick((event: ClickEvent) => {  
98 - ProcessUtils.processPage(this.contentDTO)  
99 - })  
100 } 106 }
101 } 107 }
102 108
@@ -12,12 +12,10 @@ import { ProcessUtils } from '../../utils/ProcessUtils'; @@ -12,12 +12,10 @@ import { ProcessUtils } from '../../utils/ProcessUtils';
12 export struct ZhSingleRow04 { 12 export struct ZhSingleRow04 {
13 @State compDTO: CompDTO = {} as CompDTO 13 @State compDTO: CompDTO = {} as CompDTO
14 14
15 - aboutToAppear() {}  
16 -  
17 build() { 15 build() {
18 - Column(){ 16 + Column() {
19 //顶部 17 //顶部
20 - Row(){ 18 + Row() {
21 Row() { 19 Row() {
22 Image($r("app.media.local_selection")) 20 Image($r("app.media.local_selection"))
23 .width(24) 21 .width(24)
@@ -28,6 +26,7 @@ export struct ZhSingleRow04 { @@ -28,6 +26,7 @@ export struct ZhSingleRow04 {
28 .fontColor($r("app.color.color_222222")) 26 .fontColor($r("app.color.color_222222"))
29 .fontWeight(600) 27 .fontWeight(600)
30 } 28 }
  29 +
31 Row() { 30 Row() {
32 Text("更多") 31 Text("更多")
33 .fontSize($r("app.float.font_size_14")) 32 .fontSize($r("app.float.font_size_14"))
@@ -41,64 +40,93 @@ export struct ZhSingleRow04 { @@ -41,64 +40,93 @@ export struct ZhSingleRow04 {
41 .justifyContent(FlexAlign.SpaceBetween) 40 .justifyContent(FlexAlign.SpaceBetween)
42 .margin({ top: 8, bottom: 8 }) 41 .margin({ top: 8, bottom: 8 })
43 .width('100%') 42 .width('100%')
  43 +
44 // 列表内容 44 // 列表内容
45 List({ space: 12 }) { 45 List({ space: 12 }) {
46 - ForEach(this.compDTO.operDataList, (item: ContentDTO) => { 46 + ForEach(this.compDTO.operDataList, (item: ContentDTO, index: number) => {
47 ListItem() { 47 ListItem() {
48 - Row(){  
49 - if(item.coverUrl) {  
50 - Image(item.coverUrl)  
51 - .width(84)  
52 - .height(56)  
53 - .borderRadius(3)  
54 - .objectFit(ImageFit.Cover)  
55 - .padding({right: 6})  
56 - }  
57 - Column(){  
58 - Text(item.newsTitle)  
59 - .fontSize($r("app.float.font_size_16"))  
60 - .fontColor($r("app.color.color_212228"))  
61 - .fontWeight(400)  
62 - .maxLines(2)  
63 - .textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。  
64 - .margin({ top: 8 })  
65 -  
66 - Row(){  
67 - Text(item.source)  
68 - .fontSize($r('app.float.font_size_12'))  
69 - .fontColor($r('app.color.color_B0B0B0'))  
70 - .textOverflow({overflow: TextOverflow.Ellipsis})  
71 - .maxLines(1)  
72 - .width(item.source.length > 10 ? '60%' : '')  
73 - Image($r("app.media.point"))  
74 - .width(16)  
75 - .height(16)  
76 - Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.compDTO.operDataList[0].publishTime)))  
77 - .fontSize($r("app.float.font_size_12"))  
78 - .fontColor($r("app.color.color_B0B0B0")) 48 + localCard(
  49 + {
  50 + operDataListItem: item
79 } 51 }
80 - .width('100%')  
81 - }  
82 - .width(200)  
83 - }  
84 - // .margin({right: 18})  
85 - .onClick(() =>{ 52 + )
  53 + .margin({right: index === this.compDTO.operDataList.length - 1 ? $r('app.float.card_comp_pagePadding_lf') : 0})
  54 + .onClick(() => {
86 ProcessUtils.processPage(item) 55 ProcessUtils.processPage(item)
87 }) 56 })
88 } 57 }
89 }) 58 })
90 } 59 }
91 .listDirection(Axis.Horizontal) 60 .listDirection(Axis.Horizontal)
92 - .width('100%') 61 + .scrollBar(BarState.Off)
  62 + .width(CommonConstants.FULL_PARENT)
93 } 63 }
94 .width(CommonConstants.FULL_WIDTH) 64 .width(CommonConstants.FULL_WIDTH)
95 .padding({ 65 .padding({
96 - top: 14,  
97 - left: 16,  
98 - right: 16,  
99 - bottom: 14 66 + left: $r('app.float.card_comp_pagePadding_lf'),
  67 + top: $r('app.float.card_comp_pagePadding_tb'),
  68 + bottom: $r('app.float.card_comp_pagePadding_tb')
100 }) 69 })
101 .backgroundColor($r("app.color.white")) 70 .backgroundColor($r("app.color.white"))
102 .margin({ bottom: 8 }) 71 .margin({ bottom: 8 })
103 } 72 }
104 } 73 }
  74 +
  75 +
  76 +@Component
  77 +struct localCard {
  78 + @Prop operDataListItem: ContentDTO
  79 +
  80 + build() {
  81 + Flex({ direction: FlexDirection.Column }) {
  82 + Text(this.operDataListItem.source)
  83 + .fontSize($r('app.float.font_size_12'))
  84 + .fontColor($r('app.color.color_B0B0B0'))
  85 + .width('100%')
  86 + .margin({ bottom: 6 })
  87 + .flexShrink(0)
  88 +
  89 + Text(this.operDataListItem.newsTitle)
  90 + .width(CommonConstants.FULL_PARENT)
  91 + .height(CommonConstants.FULL_PARENT)
  92 + .fontSize($r('app.float.font_size_16'))
  93 + .fontColor('#000000')
  94 + .align(Alignment.TopStart)
  95 + .maxLines(3)
  96 + .textOverflow({ overflow: TextOverflow.Ellipsis })
  97 + Row() {
  98 + Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.operDataListItem.publishTime)))
  99 + .fontSize($r("app.float.font_size_12"))
  100 + .fontColor($r("app.color.color_B0B0B0"))
  101 + .margin({ right: 5 })
  102 + // 这里需要外部查询评论接口后,写入字段
  103 + if(this.operDataListItem.interactData?.commentNum) {
  104 + Text(`${this.operDataListItem.interactData?.commentNum}评`)
  105 + .fontSize(12)
  106 + }
  107 + Blank()
  108 + Image($r('app.media.local_content_icon'))
  109 + .width(20)
  110 + .height(20)
  111 + .margin({
  112 + right: -4
  113 + })
  114 + }
  115 + .width('100%')
  116 + .padding({
  117 + top: 17
  118 + })
  119 + .flexShrink(0)
  120 + }
  121 + .width(182)
  122 + .height(146)
  123 + .padding(12)
  124 + .border({
  125 + radius: 2,
  126 + })
  127 + .shadow({ radius: 5, color: '#1A000000', offsetX: 0, offsetY: 2 })
  128 + .margin({
  129 + right: 10
  130 + })
  131 + }
  132 +}
@@ -44,6 +44,7 @@ export struct ZhSingleRow05 { @@ -44,6 +44,7 @@ export struct ZhSingleRow05 {
44 }) 44 })
45 } 45 }
46 .listDirection(Axis.Horizontal) 46 .listDirection(Axis.Horizontal)
  47 + .scrollBar(BarState.Off)
47 } 48 }
48 .width(CommonConstants.FULL_WIDTH) 49 .width(CommonConstants.FULL_WIDTH)
49 .height(170) 50 .height(170)
@@ -125,6 +126,7 @@ struct CreatorItem { @@ -125,6 +126,7 @@ struct CreatorItem {
125 .fontSize($r('app.float.font_size_12')) 126 .fontSize($r('app.float.font_size_12'))
126 .margin({ top: 8, bottom: 14 }) 127 .margin({ top: 8, bottom: 14 })
127 .textOverflowStyle(2) 128 .textOverflowStyle(2)
  129 + .height(34)
128 if (!this.rmhIsAttention) { 130 if (!this.rmhIsAttention) {
129 Text('关注') 131 Text('关注')
130 .width(60) 132 .width(60)
@@ -372,7 +372,7 @@ class MinePageDatasModel{ @@ -372,7 +372,7 @@ class MinePageDatasModel{
372 let url = HttpUrlUtils.getMineUserLevelDataUrl() 372 let url = HttpUrlUtils.getMineUserLevelDataUrl()
373 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); 373 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
374 // return WDHttp.get<ResponseDTO<MineUserLevelItem>>(url, headers) 374 // return WDHttp.get<ResponseDTO<MineUserLevelItem>>(url, headers)
375 - return HttpBizUtil.get<MineUserLevelItem>(url, headers) 375 + return HttpBizUtil.get<ResponseDTO<MineUserLevelItem>>(url, headers)
376 }; 376 };
377 377
378 async getMineUserLevelDataLocal(context: Context): Promise<MineUserLevelItem> { 378 async getMineUserLevelDataLocal(context: Context): Promise<MineUserLevelItem> {
@@ -411,7 +411,7 @@ class MinePageDatasModel{ @@ -411,7 +411,7 @@ class MinePageDatasModel{
411 let url = HttpUrlUtils.getMineUserDetailDataUrl() 411 let url = HttpUrlUtils.getMineUserDetailDataUrl()
412 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); 412 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
413 // return WDHttp.get<ResponseDTO<MineUserDetailItem>>(url, headers) 413 // return WDHttp.get<ResponseDTO<MineUserDetailItem>>(url, headers)
414 - return HttpBizUtil.get<MineUserDetailItem>(url, headers) 414 + return HttpBizUtil.get<ResponseDTO<MineUserDetailItem>>(url, headers)
415 }; 415 };
416 416
417 async getMineUserDetailDataLocal(context: Context): Promise<MineUserDetailItem> { 417 async getMineUserDetailDataLocal(context: Context): Promise<MineUserDetailItem> {
@@ -224,7 +224,7 @@ export class LoginModel { @@ -224,7 +224,7 @@ export class LoginModel {
224 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); 224 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
225 225
226 return new Promise<string>((success, fail) => { 226 return new Promise<string>((success, fail) => {
227 - HttpBizUtil.post<string>(HttpUrlUtils.getLogoutUrl(), bean, headers).then((data: ResponseDTO<string>)=>{ 227 + HttpBizUtil.post<ResponseDTO<string>>(HttpUrlUtils.getLogoutUrl(), bean, headers).then((data: ResponseDTO<string>)=>{
228 if (!data) { 228 if (!data) {
229 fail("数据为空") 229 fail("数据为空")
230 return 230 return