yangchenggong1_wd

desc:同步4.0

{
"code": "0",
"data": null,
"message": "Success",
"meta": null,
"requestId": "",
"success": true,
"timestamp": 1711609914928
}
\ No newline at end of file
... ...
{
"code": "0",
"data": null,
"message": "Success",
"meta": null,
"requestId": "",
"success": true,
"timestamp": 1711609966231
}
\ No newline at end of file
... ...
import { LazyDataSource, StringUtils } from 'wdKit';
import MinePageDatasModel from '../../../../model/MinePageDatasModel';
import { HttpUrlUtils } from '../../../../network/HttpUrlUtils';
import { Params } from '../../../../repository/bean/Params';
import RouteManager from '../../../../utils/RouteManager';
import { FollowListDetailItem } from '../../../../viewmodel/FollowListDetailItem'
import { FollowListDetailRequestItem } from '../../../../viewmodel/FollowListDetailRequestItem';
import { FollowListStatusRequestItem } from '../../../../viewmodel/FollowListStatusRequestItem';
import { FollowOperationRequestItem } from '../../../../viewmodel/FollowOperationRequestItem';
import { MineFollowListDetailItem } from '../../../../viewmodel/MineFollowListDetailItem';
import { QueryListIsFollowedItem } from '../../../../viewmodel/QueryListIsFollowedItem';
import { RouterObject } from '../../../../viewmodel/RouterObject';
... ... @@ -75,7 +77,7 @@ export struct FollowListDetailUI{
this.hasMore = false
}else{
value.list.forEach((value)=>{
this.data.push(new FollowListDetailItem(value.attentionHeadPhotoUrl,value.attentionUserName,value.fansNum,value.introduction,value.attentionCreatorId,"1",value.attentionUserId))
this.data.push(new FollowListDetailItem(value.attentionHeadPhotoUrl,value.attentionUserName,value.fansNum,value.introduction,value.attentionCreatorId,"1",value.attentionUserId,value.attentionUserType,value.attentionUserId))
})
this.data.notifyDataReload()
this.count = this.data.totalCount()
... ... @@ -115,7 +117,7 @@ export struct FollowListDetailUI{
let data : FollowListDetailItem[] = []
value.list.forEach((item)=>{
status.creatorIds.push(new QueryListIsFollowedItem(item.creatorId))
data.push(new FollowListDetailItem(item.headPhotoUrl,item.cnUserName,item.cnFansNum,item.introduction,item.creatorId,"0",item.attentionUserId))
data.push(new FollowListDetailItem(item.headPhotoUrl,item.cnUserName,item.cnFansNum,item.introduction,item.creatorId,"0",item.attentionUserId,item.cnUserType,item.cnUserId))
})
MinePageDatasModel.getFollowListStatusData(status,getContext(this)).then((newValue)=>{
... ... @@ -128,7 +130,7 @@ export struct FollowListDetailUI{
})
data.forEach((item)=>{
this.data.push(new FollowListDetailItem(item.headPhotoUrl,item.cnUserName,item.cnFansNum,item.introduction,item.creatorId,item.status,item.attentionUserId))
this.data.push(new FollowListDetailItem(item.headPhotoUrl,item.cnUserName,item.cnFansNum,item.introduction,item.creatorId,item.status,item.attentionUserId,item.cnUserType,item.cnUserId))
})
this.data.notifyDataReload()
... ... @@ -198,7 +200,8 @@ struct ChildComponent {
.height('46lpx')
.margin({left:'4lpx',top:'23lpx'})
.onClick(()=>{
this.data.status = "0"
this.followOperation()
// this.data.status = "0"
})
}else{
Row(){
... ... @@ -219,7 +222,8 @@ struct ChildComponent {
.height('46lpx')
.margin({left:'4lpx',top:'23lpx'})
.onClick(()=>{
this.data.status = "1"
this.followOperation()
// this.data.status = "1"
})
}
}.alignItems(VerticalAlign.Top)
... ... @@ -238,4 +242,14 @@ struct ChildComponent {
// RouteManager.jumpNewPage("pages/OtherNormalUserHomePage",new RouterObject(this.data.attentionUserId,0))
})
}
followOperation(){
let item = new FollowOperationRequestItem(this.data.cnUserType,this.data.cnUserId,this.data.creatorId,HttpUrlUtils.getYcgUserType(),HttpUrlUtils.getYcgUserId(),this.data.status==="0" ? 1:0)
MinePageDatasModel.getFollowOperation(item,getContext(this)).then((value)=>{
if(value!=null){
if (value.code === 0 || value.code.toString() === "0") {
this.data.status = this.data.status ==="0"?"1":"0"
}
}
})
}
}
\ No newline at end of file
... ...
import { LazyDataSource, StringUtils } from 'wdKit';
import MinePageDatasModel from '../../../../model/MinePageDatasModel';
import { HttpUrlUtils } from '../../../../network/HttpUrlUtils';
import RouteManager from '../../../../utils/RouteManager';
import { CommentListItem } from '../../../../viewmodel/CommentListItem';
import { FollowListDetailItem } from '../../../../viewmodel/FollowListDetailItem';
import { FollowListDetailRequestItem } from '../../../../viewmodel/FollowListDetailRequestItem';
import { FollowOperationRequestItem } from '../../../../viewmodel/FollowOperationRequestItem';
import { RouterObject } from '../../../../viewmodel/RouterObject';
import { ListHasNoMoreDataUI } from '../../../reusable/ListHasNoMoreDataUI';
... ... @@ -150,7 +152,7 @@ export struct HomePageBottomComponent{
this.hasMore = false
}else{
value.list.forEach((value)=>{
this.data_follow.push(new FollowListDetailItem(value.attentionHeadPhotoUrl,value.attentionUserName,value.fansNum,value.introduction,value.attentionCreatorId,"1",value.attentionUserId))
this.data_follow.push(new FollowListDetailItem(value.attentionHeadPhotoUrl,value.attentionUserName,value.fansNum,value.introduction,value.attentionCreatorId,"1",value.attentionUserId,value.attentionUserType,value.attentionUserId))
})
this.data_follow.notifyDataReload()
this.count = this.data_follow.totalCount()
... ... @@ -175,7 +177,7 @@ export struct HomePageBottomComponent{
this.hasMore = false
}else{
value.list.forEach((value)=>{
this.data_comment.push(new CommentListItem(value.fromUserHeader,value.fromUserName,value.targetTitle,value.createTime,value.commentContent,value.likeNum,0,value.id))
this.data_comment.push(new CommentListItem(value.fromUserHeader,value.fromUserName,value.targetTitle,value.createTime,value.commentContent,value.likeNum,0,value.id,value.targetId,value.targetType))
})
this.data_comment.notifyDataReload()
this.count = this.data_comment.totalCount()
... ... @@ -244,7 +246,8 @@ struct ChildFollowComponent {
.height('46lpx')
.margin({left:'4lpx',top:'23lpx'})
.onClick(()=>{
this.data.status = "0"
// this.data.status = "0"
this.followOperation()
})
}else{
Row(){
... ... @@ -265,7 +268,8 @@ struct ChildFollowComponent {
.height('46lpx')
.margin({left:'4lpx',top:'23lpx'})
.onClick(()=>{
this.data.status = "1"
// this.data.status = "1"
this.followOperation()
})
}
}.alignItems(VerticalAlign.Top)
... ... @@ -280,6 +284,17 @@ struct ChildFollowComponent {
}.height('146lpx')
.justifyContent(FlexAlign.Center)
}
followOperation(){
let item = new FollowOperationRequestItem(this.data.cnUserType,this.data.cnUserId,this.data.creatorId,HttpUrlUtils.getYcgUserType(),HttpUrlUtils.getYcgUserId(),this.data.status==="0" ? 1:0)
MinePageDatasModel.getFollowOperation(item,getContext(this)).then((value)=>{
if(value!=null){
if (value.code === 0 || value.code.toString() === "0") {
this.data.status = this.data.status ==="0"?"1":"0"
}
}
})
}
}
@Component
... ... @@ -296,14 +311,13 @@ struct ChildCommentComponent {
.objectFit(ImageFit.Auto)
.width('69lpx')
.height('69lpx')
.margin({right:'15lpx'})
.borderRadius(50)
Image(this.levelHead)
.width('89lpx')
.height('89lpx')
.objectFit(ImageFit.Cover)
.borderRadius(50)
}
}.margin({right:'15lpx'})
Column(){
Text(this.data.fromUserName)
... ... @@ -367,4 +381,7 @@ struct ChildCommentComponent {
}
.justifyContent(FlexAlign.Center)
}
}
\ No newline at end of file
... ...
... ... @@ -5,6 +5,7 @@ import { OtherUserCommentListRequestItem } from '../../../../viewmodel/OtherUser
import MinePageDatasModel from '../../../../model/MinePageDatasModel';
import { MineCommentListDetailItem } from '../../../../viewmodel/MineCommentListDetailItem';
import { OtherUserCommentLikeStatusRequestItem } from '../../../../viewmodel/OtherUserCommentLikeStatusRequestItem';
import { CommentLikeOperationRequestItem } from '../../../../viewmodel/CommentLikeOperationRequestItem';
const TAG = "HomePageBottomComponent"
@Component
... ... @@ -87,7 +88,7 @@ export struct OtherHomePageBottomCommentComponent{
if (!this.data_comment || value.list.length == 0){
this.hasMore = false
}else{
this.getFollowListStatus(value)
this.getCommentListStatus(value)
}
}).catch((err:Error)=>{
console.log(TAG,"请求失败")
... ... @@ -96,13 +97,13 @@ export struct OtherHomePageBottomCommentComponent{
}
}
getFollowListStatus(value:MineCommentListDetailItem){
getCommentListStatus(value:MineCommentListDetailItem){
let status = new OtherUserCommentLikeStatusRequestItem()
let data : CommentListItem[] = []
value.list.forEach((item)=>{
status.commentIdList.push(item.id)
data.push(new CommentListItem(item.fromUserHeader,item.fromUserName,item.targetTitle,item.createTime,item.commentContent,item.likeNum,0,item.id))
data.push(new CommentListItem(item.fromUserHeader,item.fromUserName,item.targetTitle,item.createTime,item.commentContent,item.likeNum,0,item.id,item.targetId,item.targetType))
})
MinePageDatasModel.getOtherUserCommentLikeStatusData(status,getContext(this)).then((newValue)=>{
... ... @@ -115,7 +116,7 @@ export struct OtherHomePageBottomCommentComponent{
})
data.forEach((item)=>{
this.data_comment.push(new CommentListItem(item.fromUserHeader,item.fromUserName,item.targetTitle,item.createTime,item.commentContent,item.likeNum,item.like_status,item.id))
this.data_comment.push(new CommentListItem(item.fromUserHeader,item.fromUserName,item.targetTitle,item.createTime,item.commentContent,item.likeNum,item.like_status,item.id,item.targetId,item.targetType))
})
this.data_comment.notifyDataReload()
... ... @@ -150,14 +151,14 @@ struct ChildCommentComponent {
.objectFit(ImageFit.Auto)
.width('69lpx')
.height('69lpx')
.margin({right:'15lpx'})
.borderRadius(50)
Image(this.levelHead)
.width('89lpx')
.height('89lpx')
.objectFit(ImageFit.Cover)
.borderRadius(50)
}
}.margin({right:'15lpx'})
Column(){
Text(this.data.fromUserName)
... ... @@ -189,7 +190,9 @@ struct ChildCommentComponent {
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.Medium)
.borderRadius(50)
}
}.onClick(()=>{
this.commentLikeOperation()
})
}
.margin({bottom:'10lpx'})
... ... @@ -237,4 +240,16 @@ struct ChildCommentComponent {
}
.justifyContent(FlexAlign.Center)
}
commentLikeOperation(){
let item = new CommentLikeOperationRequestItem(this.data.targetId,this.data.id+"",this.data.targetType+"",this.data.fromUserName,this.data.fromUserHeader,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
}
}
})
}
}
\ No newline at end of file
... ...
... ... @@ -113,7 +113,7 @@ export struct OtherHomePageBottomFollowComponent{
this.hasMore = false
}else{
value.list.forEach((value)=>{
this.data_follow.push(new FollowListDetailItem(value.attentionHeadPhotoUrl,value.attentionUserName,value.fansNum,value.introduction,value.attentionCreatorId,"1",value.attentionUserId))
this.data_follow.push(new FollowListDetailItem(value.attentionHeadPhotoUrl,value.attentionUserName,value.fansNum,value.introduction,value.attentionCreatorId,"1",value.attentionUserId,value.cnUserType,value.cnUserId))
})
this.data_follow.notifyDataReload()
this.count = this.data_follow.totalCount()
... ...
... ... @@ -139,24 +139,25 @@ export struct OtherUserHomeComponent {
.padding({ left: '35lpx' })
//用户简介区域
Column() {
Row() {
Text(this.desc)
.fontSize('27lpx')
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.lineHeight('40lpx')
.fontWeight('400lpx')
.fontColor($r('app.color.color_222222'))
.textAlign(TextAlign.Start)
if(StringUtils.isNotEmpty(this.desc)){
Column() {
Row() {
Text(this.desc)
.fontSize('27lpx')
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.lineHeight('40lpx')
.fontWeight('400lpx')
.fontColor($r('app.color.color_222222'))
.textAlign(TextAlign.Start)
}
}.padding({ left: '31lpx',right:'31lpx',top:'19lpx',bottom:'31lpx'})
.alignItems(HorizontalAlign.Start)
.justifyContent(FlexAlign.Center)
.width('100%')
.backgroundColor($r('app.color.white'))
.visibility(StringUtils.isEmpty(this.desc)?Visibility.Hidden:Visibility.Visible)
}
}.padding({ left: '31lpx',right:'31lpx',top:'19lpx',bottom:'31lpx'})
.alignItems(HorizontalAlign.Start)
.justifyContent(FlexAlign.Center)
.width('100%')
.backgroundColor($r('app.color.white'))
}
//间隔符
Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx')
... ...
... ... @@ -22,6 +22,8 @@ import { QueryCommentListIsLikedItem } from '../viewmodel/QueryCommentListIsLike
import { UserFollowListRequestItem } from '../viewmodel/UserFollowListRequestItem';
import { OtherUserDetailRequestItem } from '../viewmodel/OtherUserDetailRequestItem';
import { AppointmentOperationRequestItem } from '../viewmodel/AppointmentOperationRequestItem';
import { FollowOperationRequestItem } from '../viewmodel/FollowOperationRequestItem';
import { CommentLikeOperationRequestItem } from '../viewmodel/CommentLikeOperationRequestItem';
const TAG = "MinePageDatasModel"
/**
... ... @@ -676,6 +678,86 @@ class MinePageDatasModel{
return compRes
}
/**
* 评论点赞操作
* @param params
* @param context
* @returns
*/
getCommentLikeOperation(params:CommentLikeOperationRequestItem,context: Context): Promise<ResponseDTO> {
return new Promise((success, error) => {
Logger.info(TAG, `getAppointmentList start`);
this.fetchCommentLikeOperation(params).then((navResDTO: ResponseDTO) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getCommentLikeOperationLocal(context))
return
}
Logger.info(TAG, "getAppointmentList then,AppointmentResDTO.timeStamp:" + navResDTO.timestamp);
success(navResDTO);
}).catch((err: Error) => {
Logger.error(TAG, `fetchAppointmentListDataApi catch, error.name : ${err.name}, error.message:${err.message}`);
success(this.getCommentLikeOperationLocal(context))
})
})
}
fetchCommentLikeOperation(object:CommentLikeOperationRequestItem) {
let url = HttpUrlUtils.getCommentLikeOperationUrl()
let headers: HashMap<string, string> = HttpUrlUtils.getYcgCommonHeaders();
return WDHttp.post<ResponseDTO>(url,object, headers)
};
async getCommentLikeOperationLocal(context: Context): Promise<ResponseDTO> {
Logger.info(TAG, `getMineFollowListDataLocal start`);
let compRes: ResponseDTO | null = await ResourcesUtils.getResourcesJson<ResponseDTO>('comment_like_operation_data.json',context);
if (!compRes ) {
Logger.info(TAG, `getMineFollowListDataLocal compRes is empty`);
return compRes
}
Logger.info(TAG, `getMineFollowListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes
}
/**
* 关注 取消关注 操作
* @param params
* @param context
* @returns
*/
getFollowOperation(params:FollowOperationRequestItem,context: Context): Promise<ResponseDTO> {
return new Promise((success, error) => {
Logger.info(TAG, `getAppointmentList start`);
this.fetchFollowOperation(params).then((navResDTO: ResponseDTO) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getFollowOperationLocal(context))
return
}
Logger.info(TAG, "getAppointmentList then,AppointmentResDTO.timeStamp:" + navResDTO.timestamp);
success(navResDTO);
}).catch((err: Error) => {
Logger.error(TAG, `fetchAppointmentListDataApi catch, error.name : ${err.name}, error.message:${err.message}`);
success(this.getFollowOperationLocal(context))
})
})
}
fetchFollowOperation(object:FollowOperationRequestItem) {
let url = HttpUrlUtils.getFollowOperationUrl()
let headers: HashMap<string, string> = HttpUrlUtils.getYcgCommonHeaders();
return WDHttp.post<ResponseDTO>(url,object, headers)
};
async getFollowOperationLocal(context: Context): Promise<ResponseDTO> {
Logger.info(TAG, `getMineFollowListDataLocal start`);
let compRes: ResponseDTO | null = await ResourcesUtils.getResourcesJson<ResponseDTO>('follow_operation_data.json',context);
if (!compRes ) {
Logger.info(TAG, `getMineFollowListDataLocal compRes is empty`);
return compRes
}
Logger.info(TAG, `getMineFollowListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes
}
}
const minePageDatasModel = MinePageDatasModel.getInstance()
... ...
... ... @@ -248,6 +248,26 @@ export class HttpUrlUtils {
return url
}
static getCommentLikeOperationUrl() {
let url = HttpUrlUtils.HOST_SIT + HttpUrlUtils.COMMENT_LIKE_OPERATION_PATH
return url
}
static getFollowOperationUrl() {
let url = HttpUrlUtils.HOST_SIT + HttpUrlUtils.FOLLOW_OPERATION_PATH
return url
}
/**
* 预约操作
*/
static readonly COMMENT_LIKE_OPERATION_PATH: string = "/api/rmrb-comment/comment/zh/c/commentLike";
/**
* 关注操作
*/
static readonly FOLLOW_OPERATION_PATH: string = "https://pd-apis-sit.pdnews.cn/api/rmrb-interact/interact/zh/c/attention/operation";
static getYcgCommonHeaders(): HashMap<string, string> {
let headers: HashMap<string, string> = new HashMap<string, string>()
... ... @@ -402,4 +422,12 @@ export class HttpUrlUtils {
private static getUserType() {
return '2';
}
public static getYcgUserType() {
return '1';
}
public static getYcgUserId() {
return '459776297474949';
}
}
\ No newline at end of file
... ...
// {
// "targetId":"30000627490",
// "commentId":"303318",
// "targetType":"13",
// "userName":"人民日报网友aPrtq5",
// "userHeaderUrl":"https://sitcontentjdcdn.aikan.pdnews.cn//img/user/2024031215/48d5bd53227d436b9faa937b3ac14600.png",
// "status":1
// }
export class CommentLikeOperationRequestItem{
targetId:string = ""
commentId:string = ""
targetType:string = ""
userName:string = ""
userHeaderUrl:string = ""
status:number = 1
constructor(targetId: string, commentId: string, targetType: string , userName: string,
userHeaderUrl: string , status:number) {
this.targetId = targetId
this.commentId = commentId
this.targetType = targetType
this.userName = userName
this.userHeaderUrl = userHeaderUrl
this.status = status
}
}
... ...
... ... @@ -10,8 +10,10 @@ export class CommentListItem{
likeNum:number = 0
like_status:number = 0
id:number = 0
targetId:string = ""
targetType:number = 0
constructor(fromUserHeader:string,fromUserName:string,targetTitle:string,createTime:string,commentContent:string,likeNum:number,like_status:number,id:number) {
constructor(fromUserHeader:string,fromUserName:string,targetTitle:string,createTime:string,commentContent:string,likeNum:number,like_status:number,id:number,targetId:string,targetType:number) {
this.fromUserHeader = fromUserHeader
this.fromUserName = fromUserName
this.commentContent = commentContent
... ... @@ -20,5 +22,7 @@ export class CommentListItem{
this.likeNum = likeNum
this.like_status = like_status
this.id = id
this.targetId = targetId
this.targetType = targetType
}
}
... ...
... ... @@ -69,13 +69,18 @@ export class FollowListDetailItem{
creatorId:string = ""
attentionUserId:string = ""
cnUserType:string = ""
cnUserId:string = ""
attentionCreatorId:string = ""
attentionUserType:string = ""
attentionHeadPhotoUrl:string = ""
attentionUserName:string = ""
fansNum :number = 0
constructor(headPhotoUrl:string,cnUserName:string,cnFansNum:number,introduction:string,creatorId:string,status:string,attentionUserId:string) {
constructor(headPhotoUrl:string,cnUserName:string,cnFansNum:number,introduction:string,creatorId:string,status:string,attentionUserId:string,cnUserType:string,cnUserId:string) {
this.headPhotoUrl = headPhotoUrl
this.cnUserName = cnUserName
this.cnFansNum = cnFansNum
... ... @@ -83,5 +88,7 @@ export class FollowListDetailItem{
this.creatorId = creatorId
this.status = status
this.attentionUserId = attentionUserId
this.cnUserType = cnUserType
this.cnUserId = cnUserId
}
}
... ...
// {
// "attentionUserType":"2",
// "attentionUserId":"444911718724933",
// "attentionCreatorId":"3004861",
// "userType":1,
// "userId":"567387477063621",
// "status":1
// }
export class FollowOperationRequestItem{
attentionUserType:string = ""
attentionUserId:string = ""
attentionCreatorId:string = ""
userType:string = ""
userId:string = ""
status:number = 1
constructor(attentionUserType:string, attentionUserId:string, attentionCreatorId:string, userType:string, userId:string, status:number) {
this.attentionUserType = attentionUserType
this.attentionUserId = attentionUserId
this.attentionCreatorId = attentionCreatorId
this.userType = userType
this.userId = userId
this.status = status
}
}
... ...
... ... @@ -18,7 +18,7 @@ export class CommentLikeOperationRequestItem{
userHeaderUrl: string , status:number) {
this.targetId = targetId
this.commentId = commentId
this.targetId = targetId
this.targetType = targetType
this.userName = userName
this.userHeaderUrl = userHeaderUrl
this.status = status
... ...