zhaojunkai

人民号-相关交互元素缺失修复,新增分享显示/隐藏逻辑

... ... @@ -10,6 +10,7 @@ import { BaseDTO } from '../component/BaseDTO';
@Observed
export class ContentDTO implements BaseDTO {
shareFlag?:string='0';
appStyle: string = '';
cityCode: string = '';
coverSize: string = '';
... ...
... ... @@ -34,6 +34,7 @@ export struct CarderInteraction {
build() {
Row() {
if(this.contentDTO.shareFlag === '1'){
Row() {
Image($r('app.media.CarderInteraction_share'))
.width(18)
... ... @@ -47,6 +48,8 @@ export struct CarderInteraction {
.onClick(() => {
WDShare.shareContent(this.contentDetailData)
})
}
Row() {
Image($r('app.media.CarderInteraction_comment'))
... ... @@ -66,11 +69,11 @@ export struct CarderInteraction {
}
.width('100%')
.margin({ top: 11 })
.padding({
left: 21,
right: 21
})
.justifyContent(FlexAlign.SpaceBetween)
// .padding({
// left: 21,
// right: 21
// })
.justifyContent(FlexAlign.SpaceAround)
.alignItems(VerticalAlign.Center)
}
... ...
... ... @@ -14,6 +14,7 @@ import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'
import MinePageDatasModel from '../../model/MinePageDatasModel'
import SearcherAboutDataModel from '../../model/SearcherAboutDataModel'
import { CreatorDetailRequestItem } from '../../viewmodel/CreatorDetailRequestItem'
import { CreatorDetailResponseItem } from '../../viewmodel/CreatorDetailResponseItem';
import { FollowListDetailItem } from '../../viewmodel/FollowListDetailItem'
import { FollowListStatusRequestItem } from '../../viewmodel/FollowListStatusRequestItem'
import { QueryListIsFollowedItem } from '../../viewmodel/QueryListIsFollowedItem'
... ... @@ -62,6 +63,7 @@ export struct SearchResultContentComponent {
if (this.hasMore) {
SearcherAboutDataModel.getSearchResultListData("15", `${this.curPageNum}`, this.searchType, this.keywords,
getContext(this)).then((value) => {
if (!this.data || value.list.length == 0) {
this.hasMore = false
this.isLoading = false
... ... @@ -69,7 +71,6 @@ export struct SearchResultContentComponent {
} else {
if (value.list[0].dataList != null) {
let data_temp: SearchRmhDescription[] = []
data_temp = value.list[0].dataList
//TODO 查询创作者详情接口
... ... @@ -118,7 +119,6 @@ export struct SearchResultContentComponent {
data_temp.forEach((data) => {
this.data_rmh.push(data)
})
//只有一条创作者,获取 创作者信息
if (this.data_rmh.length === 1) {
if(StringUtils.isNotEmpty(UserDataLocal.getUserId())){
... ... @@ -175,21 +175,34 @@ export struct SearchResultContentComponent {
}
})
})
// 批量号主信息
let creatorIdList: string[] = []
resultData.list.forEach((value:SearchResultContentItem) => {
creatorIdList.push(value.data.creatorId)
})
SearcherAboutDataModel.getCreatorDetailListData({creatorIdList:creatorIdList}).then((rem) => {
resultData.list.forEach((value) => {
let photos: FullColumnImgUrlDTO[] = []
if (value.data.appStyle === 4) {
// if (value.data.appStyle === 4) {
value.data.appStyleImages.split("&&").forEach((value) => {
photos.push({ url: value } as FullColumnImgUrlDTO)
const resizeParams = this.extractResizeParams(value)
photos.push({ fullUrl: value,weight:resizeParams.width,height:resizeParams.height, } as FullColumnImgUrlDTO)
})
}
let contentDTO = this.dataTransform(value, photos);
// }
let contentDTO = this.dataTransform(rem,value, photos);
if(value.data.type != "13"){
this.data.push(contentDTO)
}
})
}).catch((err: Error) => {
console.log(TAG, JSON.stringify(err))
})
this.data.notifyDataReload()
this.count = this.data.totalCount()
if (this.data.totalCount() < resultData.totalCount) {
... ... @@ -377,7 +390,10 @@ export struct SearchResultContentComponent {
.strokeWidth('12lpx')
}
private dataTransform(value: SearchResultContentItem, photos: FullColumnImgUrlDTO[]): ContentDTO {
private dataTransform(rem:CreatorDetailResponseItem[],value: SearchResultContentItem, photos: FullColumnImgUrlDTO[]): ContentDTO {
let rmhInfo = this.getRmhInfo(rem,value)
console.log('获取photos',JSON.stringify(photos))
console.log('获取value2',JSON.stringify(value))
let contentDTO = new ContentDTO();
contentDTO.appStyle = value.data.appStyle + ""
contentDTO.cityCode = value.data.cityCode
... ... @@ -453,8 +469,92 @@ export struct SearchResultContentComponent {
contentDTO.openType = '';
contentDTO.extra = '';
contentDTO.titleShow = value.data.type == "5" ? 1 : 0;
contentDTO.contentText = value.data.contentText;
contentDTO.rmhInfo = rmhInfo
contentDTO.shareFlag = value.data.shareFlag
return contentDTO;
}
// 搜索数据转化rmhInfo
private getRmhInfo(rem:CreatorDetailResponseItem[],value:SearchResultContentItem){
let obj = value.data
let rmhInfo:RmhInfoDTO = {
rmhHeadUrl:obj.headerPhotoUrl,
rmhName:obj.creatorName,
rmhId:obj.creatorId,
authIcon:obj.authIcon,
authTitle: obj.authTitle,
authTitle2: '',
banControl: 0,
cnIsAttention: 0,
cnAttention: 0,
cnlsComment: 0,
cnlsLike: 0,
cnMainControl: 0,
cnShareControl: 0,
cnIsComment: 0,
cnIsLike:0,
posterShareControl: 0,
rmhDesc: obj.introduction,
userId: obj.userId,
userType: obj.userType,
honoraryIcon:''
}
if(rem.length>0){
rem.forEach(item=>{
if(item.creatorId === obj.creatorId){
rmhInfo = {
rmhHeadUrl:item.headPhotoUrl,
rmhName:item.userName,
rmhId:item.creatorId,
authIcon:item.authIcon,
authTitle: item.authTitle,
authTitle2: '',
banControl: 0,
cnIsAttention:item.isAttention,
cnAttention: 0,
cnlsComment: 0,
cnlsLike: 0,
cnMainControl: 0,
cnShareControl: 0,
cnIsComment: 0,
cnIsLike:0,
posterShareControl: 0,
rmhDesc: item.introduction,
userId: item.userId,
userType: item.userType,
honoraryIcon:''
}
}
})
}
return rmhInfo
}
private extractResizeParams(url: string) {
const heightRegex = /h_(\d+)/; // 匹配高度参数,如h_450
const widthRegex = /w_(\d+)/; // 匹配宽度参数,如w_800
const heightMatch = url.match(heightRegex);
const widthMatch = url.match(widthRegex);
let height = heightMatch ? `h_${heightMatch[1]}` : undefined
let width = widthMatch ? `w_${widthMatch[1]}` : undefined
let h:number =0
let w:number =0
if(height){
h = Number(height.split('_')[1])
}
if(width){
w = Number(width.split('_')[1])
}
interface Obj{
width:number;
height:number
}
let obj:Obj = {
width:w,
height:h
}
return obj
}
}
\ No newline at end of file
... ...