yangchenggong1_wd

fix:bug[18515] 未登录状态进入我的--评论下鸿蒙版未能显示游客评论内容

... ... @@ -236,6 +236,10 @@ export class HttpUrlUtils {
* 预约状态
*/
static readonly LIVE_APPOINTMENT_BATCH_PATH: string = "/api/live-center-message/zh/c/live/subscribe/user/batch";
/**
* 游客 评论列表
*/
static readonly VISITOR_COMMENT_LIST_DATA_PATH: string = "/api/rmrb-comment/comment/zh/c/visitorCommentList";
/**
* 查询是否被禁言
... ... @@ -868,4 +872,9 @@ export class HttpUrlUtils {
let url = HttpUrlUtils.getHost() + "/api/rmrb-contact/contact/zh/c/push/device"
return url
}
static getVisitorCommentListDataUrl() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.VISITOR_COMMENT_LIST_DATA_PATH
return url
}
}
... ...
... ... @@ -91,6 +91,8 @@ export class WDRouterPage {
static loginProtocolPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginProtocolWebview");
//我的主页
static mineHomePage = new WDRouterPage("wdComponent", "ets/pages/MineHomePage");
//游客评论列表
static visitorCommentPage = new WDRouterPage("wdComponent", "ets/pages/VisitorCommentPage");
// 隐私设置页
static privacySettingPage = new WDRouterPage("wdComponent", "ets/components/page/PrivacySettingPage");
// 关于页
... ...
... ... @@ -23,7 +23,7 @@ export default struct MinePagePersonFunctionUI {
switch (item.msg){
case "评论":{
if(!this.isLogin){
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
WDRouterRule.jumpWithPage(WDRouterPage.visitorCommentPage)
return
}else {
let params: Record<string, string> = {'comment': "1"};
... ...
import { ContentDTO } from 'wdBean/Index'
import { StringUtils, UserDataLocal } from 'wdKit/Index'
import MinePageDatasModel from '../../../model/MinePageDatasModel'
import { CommentLikeOperationRequestItem } from '../../../viewmodel/CommentLikeOperationRequestItem'
import { CommentListItem } from '../../../viewmodel/CommentListItem'
import measure from '@ohos.measure'
@Component
export struct VisitorCommentComponent {
@ObjectLink data: CommentListItem
isLastItem: boolean = false
@State isExpand: boolean = false;
@State isExpandParent: boolean = false;
@State isOverLines: boolean = false
@State isOverLinesParent: boolean = false
build() {
Column() {
Row() {
if (this.isExpand) {
Text() {
Span(this.data.commentContent)
}
.textStyle()
} else {
Text() {
Span(this.clipText(this.data.commentContent, 31, 5, 630, 0))
if (this.isOverLines) {
Span('...展开')
.fontColor($r('app.color.color_999999'))
.onClick(() => {
this.isExpand = true
})
}
}.maxLines(5)
.wordBreak(WordBreak.BREAK_ALL)
.textStyle()
}
}.padding({ left: '31lpx', right: '31lpx' })
.width('100%')
Column() {
if (StringUtils.isNotEmpty(this.data.parentCommentContent)) {
//父评论
Row() {
if (this.isExpandParent) {
Text() {
Span(`@${this.data.parentCommentUserName}:`)
.fontColor($r('app.color.color_000000'))
.fontWeight('500lpx')
.fontSize('27lpx')
.lineHeight('40lpx')
Span(this.data.parentCommentContent)
.fontColor($r('app.color.color_000000'))
.fontWeight('400lpx')
.fontSize('27lpx')
.lineHeight('40lpx')
}
.width('100%')
.textAlign(TextAlign.Start)
} else {
Text() {
Span(`@${this.data.parentCommentUserName}:`)
.fontColor($r('app.color.color_000000'))
.fontWeight('500lpx')
.fontSize('27lpx')
.lineHeight('40lpx')
Span(this.clipText(this.data.parentCommentContent, 31, 5, 630, 1))
.fontColor($r('app.color.color_000000'))
.fontWeight('400lpx')
.fontSize('27lpx')
.lineHeight('40lpx')
if (this.isOverLinesParent) {
Span('...展开')
.fontColor($r('app.color.color_999999'))
.onClick(() => {
this.isExpandParent = true
})
}
}.maxLines(5)
.wordBreak(WordBreak.BREAK_ALL)
.textAlign(TextAlign.Start)
.width('100%')
}
}
.width('100%')
.padding({ top: '23lpx', bottom: '15lpx', right: '23lpx' })
Divider()
.width('100%')
.height('1lpx')
.strokeWidth('1lpx')
.backgroundColor($r('app.color.color_EDEDED'))
.margin({ top: '4lpx', bottom: '4lpx' })
}
Column() {
Row() {
Row() {
Image($r('app.media.comment_link_icon'))
.objectFit(ImageFit.Auto)
.width('31lpx')
.height('31lpx')
.margin({ right: '10lpx' })
Column() {
Row() {
Text(`${this.data.targetTitle}`)
.fontWeight('400lpx')
.fontColor($r('app.color.color_666666'))
.lineHeight('38lpx')
.fontSize('27lpx')
.layoutWeight(1)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
}.width('100%')
}
.layoutWeight(1)
.alignItems(HorizontalAlign.Start)
}.layoutWeight(1)
Image($r('app.media.arrow_icon_right'))
.margin({ right: '4lpx' })
.width('23lpx')
.height('23lpx')
.margin({right:'23lpx'})
}
.width('100%')
.height('69lpx')
.justifyContent(FlexAlign.SpaceBetween)
}.height('69lpx')
.justifyContent(FlexAlign.Center)
}
.margin({ top: '19lpx', bottom: '31lpx', left: '31lpx', right: '31lpx' })
.padding({ left: '23lpx' })
.width('662lpx')
.backgroundColor($r('app.color.color_F5F5F5'))
if (!this.isLastItem) {
Divider().width('100%')
.height('12lpx')
.strokeWidth('12lpx')
.color($r('app.color.color_F5F5F5'))
}
}
.justifyContent(FlexAlign.Center)
}
commentLikeOperation() {
let item = new CommentLikeOperationRequestItem(this.data.targetId, this.data.id + "", this.data.targetType + "", UserDataLocal.getUserName(), UserDataLocal.getUserHeaderUrl(), this.data.like_status === 0 ? 1 : 0)
MinePageDatasModel.getCommentLikeOperation(item, getContext(this)).then((value) => {
if (value != null) {
if (value.code === 0 || value.code.toString() === "0") {
this.data.like_status = this.data.like_status === 0 ? 1 : 0
this.data.likeNum = this.data.like_status === 0 ? this.data.likeNum - 1 : this.data.likeNum + 1
}
}
})
}
/**
* 截断文本
* @author liuzhendong(猩猩G)
* @param {string} str 要截断的文本 '啊啊啊啊啊'
* @param {number} fontSize 字体大小(px)
* @param {number} maxLines 最大行数 3
* @param {number} textWidth 文本宽度(px) vp 需要转换vp2px()
* @returns {string} clipStr 截断后的文本 '啊啊'
* @param {type} 0 我的评论 1 父评论
*/
clipText(str: string, fontSize: number, maxLines: number, textWidth: number, type: number): string {
let strArr: string[] = str.split("")
let truncateContent: string = '啊啊啊啊啊' // ...比正常文字宽度更小,这里使用啊啊啊(任意三个文字)代替计算
let measureTruncateWidth: number = measure.measureText({
textContent: truncateContent,
fontSize: px2fp(fontSize),
wordBreak:WordBreak.BREAK_ALL
})
if(type === 1){
measureTruncateWidth = measureTruncateWidth + measure.measureText({
textContent: `@${this.data.parentCommentUserName}:`,
fontSize: px2fp(fontSize),
wordBreak:WordBreak.BREAK_ALL
})
}
let clipStr: string = ''
for (let i = 0; i < strArr.length; i++) {
if (measure.measureText({
textContent: clipStr,
fontSize: px2fp(fontSize),
wordBreak:WordBreak.BREAK_ALL
}) >= textWidth * maxLines - measureTruncateWidth) {
if (type === 0) {
this.isOverLines = true
} else {
this.isOverLinesParent = true
}
break;
}
clipStr += strArr[i]
}
return clipStr
}
}
@Extend(Text)
function textStyle() {
.width('630lpx')
.fontSize('31lpx')
.fontWeight('400lpx')
.fontColor($r('app.color.color_222222'))
.lineHeight('46lpx')
}
function getParams(item: CommentListItem) : ContentDTO{
let contentDTO = new ContentDTO();
// contentDTO.objectType = item.targetType + ""
// contentDTO.objectId = item.targetId + ""
// contentDTO.newsTitle = item.targetTitle
// contentDTO.channelId =
// contentDTO.rmhPlatform =
contentDTO.objectId = item.targetId;
contentDTO.relType = item.targetRelType + "";
contentDTO.relId = item.targetRelId;
contentDTO.objectType = item.targetType + "";
contentDTO.newsTitle = item.targetTitle
return contentDTO
}
... ...
... ... @@ -29,10 +29,10 @@ export struct CustomTitleUI {
Text(this.titleName)
.maxLines(1)
.id("title")
.fontSize(`${this.calcHeight(30)}lpx`)
.fontSize(`${this.calcHeight(35)}lpx`)
.fontWeight(400)
.fontColor($r('app.color.color_222222'))
.lineHeight(`${this.calcHeight(43)}lpx`)
.lineHeight(`${this.calcHeight(50)}lpx`)
.alignRules({
center: {anchor: "__container__", align: VerticalAlign.Center},
middle: {anchor: "__container__", align: HorizontalAlign.Center}
... ...
... ... @@ -4,7 +4,7 @@ import MinePageCreatorFunctionsItem from '../viewmodel/MinePageCreatorFunctionsI
import MinePageMoreFunctionModel from '../viewmodel/MinePageMoreFunctionModel';
import { HttpBizUtil, HttpUrlUtils, HttpUtils, ResponseDTO, WDHttp } from 'wdNetwork';
import { MineAppointmentListItem } from '../viewmodel/MineAppointmentListItem';
import { Logger, StringUtils, EmitterUtils, EmitterEventId, SPHelper } from 'wdKit';
import { Logger, StringUtils, EmitterUtils, EmitterEventId, SPHelper, DeviceUtil, DateTimeUtils } from 'wdKit';
import { MineFollowListDetailItem } from '../viewmodel/MineFollowListDetailItem';
import { FollowListDetailRequestItem } from '../viewmodel/FollowListDetailRequestItem';
import { FollowListItem } from '../viewmodel/FollowListItem';
... ... @@ -918,6 +918,37 @@ class MinePageDatasModel{
return rmhInfo
}
/**
* 游客评论列表
* @param pageSize
* @param pageNum
* @returns
*/
fetchVisitorCommentListData(pageNum:string,visitorFirstTime:string) {
let time = encodeURI(DateTimeUtils.getCurDate(DateTimeUtils.PATTERN_DATE_TIME_HYPHEN))
let deviceId = DeviceUtil.clientId()
let url = HttpUrlUtils.getVisitorCommentListDataUrl()+ `?pageSize=${20}&pageNum=${pageNum}&visitorFirstTime=${visitorFirstTime}&time=${time}&deviceId=${deviceId}`
return WDHttp.get<ResponseDTO<MineCommentListDetailItem>>(url)
};
visitorCommentListData(pageNum:string,visitorFirstTime:string): Promise<MineCommentListDetailItem> {
return new Promise<MineCommentListDetailItem>((success, error) => {
Logger.info(TAG, `visitorCommentListData start`);
this.fetchVisitorCommentListData(pageNum,visitorFirstTime).then((navResDTO: ResponseDTO<MineCommentListDetailItem>) => {
if (!navResDTO || navResDTO.code != 0) {
error(null)
return
}
Logger.info(TAG, "visitorCommentListData then,visitorCommentListData.timeStamp:" + navResDTO.timestamp);
let navigationBean = navResDTO.data as MineCommentListDetailItem
success(navigationBean);
}).catch((err: Error) => {
Logger.error(TAG, `visitorCommentListData catch, error.name : ${err.name}, error.message:${err.message}`);
error(null)
})
})
}
}
const minePageDatasModel = MinePageDatasModel.getInstance()
... ...
import { TAG } from '@ohos/hypium/src/main/Constant';
import { ContentDTO } from 'wdBean/Index';
import { SpConstants } from 'wdConstant/Index'
import { DateTimeUtils, LazyDataSource, NetworkUtil, SPHelper, StringUtils} from 'wdKit/Index'
import { ProcessUtils } from 'wdRouter/Index';
import { VisitorCommentComponent } from '../components/mine/home/VisitorCommentComponent';
import { CustomPullToRefresh } from '../components/reusable/CustomPullToRefresh';
import { CustomTitleUI } from '../components/reusable/CustomTitleUI';
import { ListHasNoMoreDataUI } from '../components/reusable/ListHasNoMoreDataUI';
import { EmptyComponent } from '../components/view/EmptyComponent';
import MinePageDatasModel from '../model/MinePageDatasModel';
import { CommentListItem } from '../viewmodel/CommentListItem';
@Entry
@Component
struct VisitorCommentPage {
@State data: LazyDataSource<CommentListItem> = new LazyDataSource();
@State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
@State count: number = 0;
@State isLoading: boolean = false
@State hasMore: boolean = true
curPageNum: number = 1;
@State isGetRequest: boolean = false
private scroller: Scroller = new Scroller();
@State isConnectNetwork : boolean = NetworkUtil.isNetConnected()
@State commentTime:string = ""
aboutToAppear(): void {
this.commentTime = SPHelper.default.getSync(SpConstants.FIRSTCOMMENTTIME, "") as string
if (StringUtils.isNotEmpty(this.commentTime)) {
this.getNewPageData(this.commentTime)
}else{
this.isGetRequest = true
}
}
build() {
Column() {
//标题栏目
CustomTitleUI({ titleName: "评论列表" })
if (this.count == 0) {
if (this.isGetRequest == true) {
if(this.isConnectNetwork){
EmptyComponent({ emptyType: 10 })
.height('100%')
.width('100%')
}else{
EmptyComponent({ emptyType: 1,emptyHeight:"100%" ,retry: () => {
this.isConnectNetwork = NetworkUtil.isNetConnected()
if(this.isConnectNetwork){
this.curPageNum = 1;
this.hasMore = true
this.isGetRequest = false
this.data.clear()
if (!this.isLoading) {
this.getNewPageData(this.commentTime)
}
}
}})
.layoutWeight(1)
.width('100%')
}
}
} else {
Stack(){
Row()
.width("100%")
.height("100%")
.backgroundColor($r('app.color.white'))
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM])
CustomPullToRefresh({
alldata:this.data,
scroller:this.scroller,
customList:()=>{
this.ListLayout()
},
onRefresh:(resolve)=>{
this.curPageNum = 1;
this.hasMore = true
this.isGetRequest = false
this.data.clear()
if (!this.isLoading){
this.getNewPageData(this.commentTime)
if(resolve) resolve('刷新成功')
}
},
onLoadMore:(resolve)=> {
if (!this.isLoading) {
this.isLoading = true
this.getNewPageData(this.commentTime)
}
}
})
}
}
}
.backgroundColor($r('app.color.color_transparent'))
.height('100%')
.width('100%')
}
@Builder ListLayout(){
List({ space:6,scroller: this.scroller }) {
LazyForEach(this.data, (item: CommentListItem, index: number) => {
ListItem() {
VisitorCommentComponent({
data: item,
isLastItem: index === this.data.totalCount() - 1
})
}
.onClick(() => {
let content = getParams(item)
ProcessUtils.processPage(content)
})
}, (item: CommentListItem, index: number) => index.toString())
//没有更多数据 显示提示
if (!this.hasMore) {
ListItem() {
ListHasNoMoreDataUI()
}.padding({bottom:px2vp(this.bottomSafeHeight) + 20})
}
}
.cachedCount(4)
.scrollBar(BarState.Off)
.edgeEffect(EdgeEffect.None)
.margin({ top: '23lpx'})
.layoutWeight(1)
}
getNewPageData(commentTime:string) {
this.isLoading = true
if (this.hasMore) {
MinePageDatasModel.visitorCommentListData( `${this.curPageNum}`, encodeURI(commentTime)).then((value) => {
if (!this.data || value.list.length == 0) {
this.hasMore = false
} else {
value.list.forEach((item) => {
let commentContent = item.commentContent
if (item.sensitiveShow === 0 && item.sensitiveExist === 1) {
commentContent = item.commentContentSensitive
}
let parentCommentContent = ""
if (item.parentCommentVo != null) {
parentCommentContent = item.parentCommentVo.commentContent
}
let parentCommentUserName = ""
if (item.parentCommentVo != null) {
parentCommentUserName = item.parentCommentVo.fromUserName
}
let publishTime =
DateTimeUtils.getCommentTime(DateTimeUtils.parseDate(item.createTime, DateTimeUtils.PATTERN_DATE_TIME_HYPHEN))
this.data.push(new CommentListItem(item.fromUserHeader, item.fromUserName, item.targetTitle, publishTime,
commentContent, item.likeNum, 0, item.id, item.targetId, item.targetType, item.targetRelId,
item.targetRelObjectId, item.targetRelType, item.targetStatus, item.checkStatus, parentCommentContent,
parentCommentUserName))
})
this.data.notifyDataReload()
this.count = this.data.totalCount()
if (this.data.totalCount() < value.totalCount) {
this.curPageNum++
} else {
this.hasMore = false
}
}
this.isGetRequest = true
this.isLoading = false
}).catch((err: Error) => {
console.log(TAG, JSON.stringify(err))
this.isGetRequest = true
this.isLoading = false
})
}
}
}
function getParams(item: CommentListItem) : ContentDTO{
let contentDTO = new ContentDTO();
// contentDTO.objectType = item.targetType + ""
// contentDTO.objectId = item.targetId + ""
// contentDTO.newsTitle = item.targetTitle
// contentDTO.channelId =
// contentDTO.rmhPlatform =
contentDTO.objectId = item.targetId;
contentDTO.relType = item.targetRelType + "";
contentDTO.relId = item.targetRelId;
contentDTO.objectType = item.targetType + "";
contentDTO.newsTitle = item.targetTitle
return contentDTO
}
\ No newline at end of file
... ...
... ... @@ -26,6 +26,7 @@
"pages/MineMessagePage",
"components/page/InteractMessagePage",
"pages/ShowHomePageHeaderPage",
"pages/SubscribeMessagePage"
"pages/SubscribeMessagePage",
"pages/VisitorCommentPage"
]
}
\ No newline at end of file
... ...