yangchenggong1_wd

Merge branch 'feature_ycg'

... ... @@ -136,6 +136,14 @@ export class HttpUrlUtils {
static readonly APPOINTMENT_OPERATION_STATUS_PATH: string = "/api/live-center-message/zh/c/live/subscribe";
/**
* 预约操作
*/
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";
/**
* 早晚报列表
* 根据页面id获取页面楼层列表
* https://pdapis.pdnews.cn/api/rmrb-bff-display-zh/display/zh/c/pageInfo?pageId=28927
... ... @@ -318,7 +326,7 @@ export class HttpUrlUtils {
return HttpUrlUtils.userId;
}
private static getUserType() {
public static getUserType() {
let userType = SPHelper.default.getSync(SpConstants.USER_Type,"")
if(StringUtils.isNotEmpty(userType)) {
return userType as string;
... ... @@ -443,6 +451,16 @@ 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 getYcgCommonHeaders(): HashMap<string, string> {
let headers: HashMap<string, string> = new HashMap<string, string>()
... ...
import { Params } from 'wdBean';
import { LazyDataSource, StringUtils } from 'wdKit';
import { HttpUrlUtils } from 'wdNetwork';
import { WDRouterPage, WDRouterRule } from 'wdRouter';
import MinePageDatasModel from '../../../model/MinePageDatasModel';
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 { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI';
... ... @@ -74,7 +76,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()
... ... @@ -114,7 +116,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)=>{
... ... @@ -127,7 +129,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()
... ... @@ -197,7 +199,8 @@ struct ChildComponent {
.height('46lpx')
.margin({left:'4lpx',top:'23lpx'})
.onClick(()=>{
this.data.status = "0"
this.followOperation()
// this.data.status = "0"
})
}else{
Row(){
... ... @@ -218,7 +221,8 @@ struct ChildComponent {
.height('46lpx')
.margin({left:'4lpx',top:'23lpx'})
.onClick(()=>{
this.data.status = "1"
this.followOperation()
// this.data.status = "1"
})
}
}.alignItems(VerticalAlign.Top)
... ... @@ -240,4 +244,15 @@ struct ChildComponent {
// WDRouterRule.jumpWithPage(WDRouterPage.otherNormalUserHomePagePage,params)
})
}
followOperation(){
let item = new FollowOperationRequestItem(this.data.cnUserType,this.data.cnUserId,this.data.creatorId,HttpUrlUtils.getUserType(),HttpUrlUtils.getUserId(),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 { Params } from 'wdBean';
import { LazyDataSource, StringUtils } from 'wdKit';
import { HttpUrlUtils } from 'wdNetwork';
import { WDRouterPage, WDRouterRule } from 'wdRouter';
import MinePageDatasModel from '../../../model/MinePageDatasModel';
import { CommentListItem } from '../../../viewmodel/CommentListItem';
import { FollowListDetailItem } from '../../../viewmodel/FollowListDetailItem';
import { FollowListDetailRequestItem } from '../../../viewmodel/FollowListDetailRequestItem';
import { FollowOperationRequestItem } from '../../../viewmodel/FollowOperationRequestItem';
import { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI';
const TAG = "HomePageBottomComponent"
... ... @@ -155,7 +157,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()
... ... @@ -180,7 +182,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()
... ... @@ -249,7 +251,8 @@ struct ChildFollowComponent {
.height('46lpx')
.margin({left:'4lpx',top:'23lpx'})
.onClick(()=>{
this.data.status = "0"
// this.data.status = "0"
this.followOperation()
})
}else{
Row(){
... ... @@ -270,7 +273,8 @@ struct ChildFollowComponent {
.height('46lpx')
.margin({left:'4lpx',top:'23lpx'})
.onClick(()=>{
this.data.status = "1"
// this.data.status = "1"
this.followOperation()
})
}
}.alignItems(VerticalAlign.Top)
... ... @@ -285,6 +289,18 @@ struct ChildFollowComponent {
}.height('146lpx')
.justifyContent(FlexAlign.Center)
}
followOperation(){
let item = new FollowOperationRequestItem(this.data.cnUserType,this.data.cnUserId,this.data.creatorId,HttpUrlUtils.getUserType(),HttpUrlUtils.getUserId(),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
... ...
... ... @@ -5,6 +5,7 @@ import { OtherUserCommentListRequestItem } from '../../../viewmodel/OtherUserCom
import { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI';
import { MineCommentListDetailItem } from '../../../viewmodel/MineCommentListDetailItem';
import { OtherUserCommentLikeStatusRequestItem } from '../../../viewmodel/OtherUserCommentLikeStatusRequestItem';
import { CommentLikeOperationRequestItem } from '../../../viewmodel/CommentLikeOperationRequestItem';
const TAG = "HomePageBottomComponent"
@Component
... ... @@ -102,7 +103,7 @@ export struct OtherHomePageBottomCommentComponent{
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()
... ... @@ -190,8 +191,9 @@ struct ChildCommentComponent {
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.Medium)
.borderRadius(50)
}
}.onClick(()=>{
this.commentLikeOperation()
})
}
.margin({bottom:'10lpx'})
.width('100%')
... ... @@ -238,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
... ...
... ... @@ -116,7 +116,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()
... ...
... ... @@ -21,6 +21,8 @@ import { OtherUserCommentLikeStatusRequestItem } from '../viewmodel/OtherUserCom
import { QueryCommentListIsLikedItem } from '../viewmodel/QueryCommentListIsLikedItem';
import { UserFollowListRequestItem } from '../viewmodel/UserFollowListRequestItem';
import { AppointmentOperationRequestItem } from '../viewmodel/AppointmentOperationRequestItem';
import { CommentLikeOperationRequestItem } from '../viewmodel/CommentLikeOperationRequestItem';
import { FollowOperationRequestItem } from '../viewmodel/FollowOperationRequestItem';
const TAG = "MinePageDatasModel"
... ... @@ -664,6 +666,86 @@ class MinePageDatasModel{
}
/**
* 评论点赞操作
* @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>(context,'comment_like_operation_data.json');
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>(context,'follow_operation_data.json');
if (!compRes ) {
Logger.info(TAG, `getMineFollowListDataLocal compRes is empty`);
return compRes
}
Logger.info(TAG, `getMineFollowListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes
}
}
... ...
// {
// "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.targetId = targetId
this.userName = userName
this.userHeaderUrl = userHeaderUrl
this.status = status
}
}
... ...
... ... @@ -10,8 +10,11 @@ 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 +23,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
}
}
... ...
{
"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
... ...