zhenghy

Merge remote-tracking branch 'origin/main'

... ... @@ -60,4 +60,6 @@ export { MpaasUtils } from './src/main/ets/mpaas/MpaasUtils'
export { MpaasUpgradeCheck, UpgradeTipContent } from './src/main/ets/mpaas/MpaasUpgradeCheck'
export { TingyunAPM } from './src/main/ets/tingyunAPM/TingyunAPM'
\ No newline at end of file
export { TingyunAPM } from './src/main/ets/tingyunAPM/TingyunAPM'
export { FastClickUtil } from './src/main/ets/utils/FastClickUtil';
\ No newline at end of file
... ...
import systemDateTime from '@ohos.systemDateTime';
/**
* 屏蔽快速点击事件,规定时间内只触发一次
*/
export class FastClickUtil {
static MIN_DELAY_TIME = 500
static minDelayBeforeTime = 0
static async isMinDelayTime(): Promise<boolean> {
let systime = await systemDateTime.getCurrentTime();
return new Promise<boolean>((success, error) => {
let rtnvalue = systime - FastClickUtil.minDelayBeforeTime <= FastClickUtil.MIN_DELAY_TIME;
this.minDelayBeforeTime = systime;
success(rtnvalue);
})
}
}
... ...
... ... @@ -108,7 +108,11 @@ export class ProcessUtils {
break;
case ContentConstants.TYPE_TELETEXT:
// 图文详情,跳转h5
ProcessUtils.gotoWeb(content);
if(content?.linkUrl){ //有 linkUrl 走专题页展示逻辑
ProcessUtils.gotoSpecialTopic(content)
}else{
ProcessUtils.gotoWeb(content);
}
break;
case ContentConstants.TYPE_LINK:
ProcessUtils.gotoDefaultWeb(content);
... ... @@ -455,4 +459,10 @@ export class ProcessUtils {
WDRouterRule.jumpWithAction(taskAction)
}
/**
* 跳转到登录页
*/
public static gotoLoginPage() {
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
}
}
... ...
... ... @@ -39,14 +39,14 @@ class AppLoginAuthInfo {
}
interface IDataJson {
jumpType:number
jumpUrl:string
newsId:string
newsObjectLevel:string
newsObjectType:number
newsRelId:string
newsTitle:string
pageId:string
jumpType: number
jumpUrl: string
newsId: string
newsObjectLevel: string
newsObjectType: number
newsRelId: string
newsTitle: string
pageId: string
}
/**
... ... @@ -159,59 +159,64 @@ function handleJsCallAppInnerLinkMethod(data: Message) {
content.objectType = '';
content.linkUrl = encodeURI(urlParams.get('url') || '');
switch (urlParams.get('type')) {
case 'video':
content.objectType = ContentConstants.TYPE_VOD
ProcessUtils.processPage(content)
break;
case 'live':
content.objectType = ContentConstants.TYPE_LIVE
ProcessUtils.processPage(content)
break;
case 'article':
content.objectType = ContentConstants.TYPE_TELETEXT
ProcessUtils.processPage(content)
break;
case 'picture':
content.objectType = ContentConstants.TYPE_NINE
ProcessUtils.processPage(content)
break;
case 'audio':
content.objectType = ContentConstants.TYPE_AUDIO
case 'video':
content.objectType = ContentConstants.TYPE_VOD
ProcessUtils.processPage(content)
break;
case 'live':
content.objectType = ContentConstants.TYPE_LIVE
ProcessUtils.processPage(content)
break;
case 'article':
content.objectType = ContentConstants.TYPE_TELETEXT
ProcessUtils.processPage(content)
break;
case 'picture':
content.objectType = ContentConstants.TYPE_NINE
ProcessUtils.processPage(content)
break;
case 'audio':
content.objectType = ContentConstants.TYPE_AUDIO
ProcessUtils.processPage(content)
break;
case 'h5':
if (urlParams.get('skipType') === '1') {
content.objectType = ContentConstants.TYPE_LINK
ProcessUtils.processPage(content)
break;
case 'h5':
if (urlParams.get('skipType') === '1') {
content.objectType = ContentConstants.TYPE_LINK
ProcessUtils.processPage(content)
}
if (urlParams.get('skipType') === '4') {
content.objectType = ContentConstants.TYPE_LINK
ProcessUtils.jumpExternalWebPage(content.linkUrl)
}
break;
case 'topic':
if (urlParams.get('subType') === 'h5') {
content.objectType = ContentConstants.TYPE_SPECIAL_TOPIC
ProcessUtils.processPage(content)
}
if (urlParams.get('subType') === 'moring_evening_news') {
ProcessUtils.gotoMorningEveningPaper()
}
if (urlParams.get('subType') === 'electronic_newspapers') {
ProcessUtils.gotoENewsPaper()
}
break;
case 'dynamic':
content.objectType = ContentConstants.TYPE_FOURTEEN
}
if (urlParams.get('skipType') === '4') {
content.objectType = ContentConstants.TYPE_LINK
ProcessUtils.jumpExternalWebPage(content.linkUrl)
}
break;
case 'topic':
if (urlParams.get('subType') === 'h5') {
content.objectType = ContentConstants.TYPE_SPECIAL_TOPIC
ProcessUtils.processPage(content)
break;
case 'owner_page':
let creatorId = urlParams.get('creatorId') || ''
ProcessUtils.gotoPeopleShipHomePage(creatorId)
break;
default:
break;
}
}
if (urlParams.get('subType') === 'moring_evening_news') {
ProcessUtils.gotoMorningEveningPaper()
}
if (urlParams.get('subType') === 'electronic_newspapers') {
ProcessUtils.gotoENewsPaper()
}
break;
case 'dynamic':
content.objectType = ContentConstants.TYPE_FOURTEEN
ProcessUtils.processPage(content)
break;
case 'owner_page':
let creatorId = urlParams.get('creatorId') || ''
ProcessUtils.gotoPeopleShipHomePage(creatorId)
break;
case 'app':
if (urlParams.get('subType') === 'login') {
ProcessUtils.gotoLoginPage()
}
break;
default:
break;
}
}
... ...
import { Message } from 'wdJsBridge/src/main/ets/bean/Message';
import { H5ReceiveDataJsonBean, postBatchAttentionStatusResult } from 'wdBean';
import { ResponseDTO, WDHttp, HttpUrlUtils } from 'wdNetwork';
import { WDHttp, HttpUrlUtils } from 'wdNetwork';
const TAG = 'JsCallAppService'
export function handleJsCallAppService(data: Message, callback: (res: string) => void) {
let url: string = HttpUrlUtils.getHost() + data?.data?.url
if (data?.data?.method === 'get') {
let queryString: string = ''
let parameters = data?.data?.parameters
if (parameters) {
queryString = Object.keys(parameters)
.map(key => `${encodeURIComponent(key)}=${encodeURIComponent(parameters?.[key])}`)
.join('&');
}
let responseMap: ResponseDTO<postBatchAttentionStatusResult> = {} as ResponseDTO<postBatchAttentionStatusResult>
let h5ReceiveDataJson: H5ReceiveDataJsonBean<ResponseDTO<postBatchAttentionStatusResult>> = {
netError: '0',
responseMap
} as H5ReceiveDataJsonBean<ResponseDTO<postBatchAttentionStatusResult>>
let url: string = HttpUrlUtils.getHost() + data?.data?.url
if (queryString) {
url = url + `?${queryString}`
}
console.log('yzl', queryString, url)
WDHttp.get(url).then((res) => {
callback(JSON.stringify({
netError: '0',
responseMap: res
}))
})
}
if (data?.data?.method === 'post') {
let url: string = HttpUrlUtils.getHost() + data?.data?.url
// if (data?.data?.method === 'get') {
// WDHttp.get<ResponseDTO<postBatchAttentionStatusResult>>(url, headers).then((res: ResponseDTO<postBatchAttentionStatusResult>) => {
// callback(JSON.stringify(res))
// })
// }
if (data?.data?.method === 'post' && data?.data?.url === '/api/rmrb-interact/interact/zh/c/batchAttention/status') {
WDHttp.post<ResponseDTO<postBatchAttentionStatusResult>>(url, data?.data?.parameters).then((res: ResponseDTO<postBatchAttentionStatusResult>) => {
h5ReceiveDataJson.responseMap = res
callback(JSON.stringify(h5ReceiveDataJson))
WDHttp.post(url, data?.data?.parameters).then((res) => {
callback(JSON.stringify({
netError: '0',
responseMap: res
}))
})
}
}
... ...
... ... @@ -9,4 +9,5 @@ export interface commentInfo {
relId: string;
relType: string;
userId: string;
newsType?: string
}
\ No newline at end of file
... ...
... ... @@ -5,7 +5,8 @@ import {
SPHelper,
NumberFormatterUtils,
DisplayUtils,
NetworkUtil
NetworkUtil,
FastClickUtil
} from 'wdKit';
import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel';
import {
... ... @@ -148,7 +149,11 @@ export struct DynamicDetailComponent {
.width($r('app.float.margin_48'))
.height($r('app.float.margin_48'))
.alignContent(Alignment.Center)
.onClick(() => {
.onClick(async () => {
let retvalue = await FastClickUtil.isMinDelayTime()
if(retvalue){
return
}
ProcessUtils.gotoPeopleShipHomePage(this.contentDetailData.rmhInfo == null ? "" :
this.contentDetailData.rmhInfo.rmhId)
})
... ... @@ -192,7 +197,11 @@ export struct DynamicDetailComponent {
.height($r('app.float.margin_24'))
.borderRadius($r('app.float.vp_3'))
.backgroundColor($r('app.color.color_ED2800'))
.onClick(() => {
.onClick(async () => {
let retvalue = await FastClickUtil.isMinDelayTime()
if(retvalue){
return
}
this.handleAccention()
})
} else {
... ... @@ -206,7 +215,11 @@ export struct DynamicDetailComponent {
.borderColor($r('app.color.color_CCCCCC_1A'))
.backgroundColor($r('app.color.color_CCCCCC_1A'))
.fontColor($r('app.color.color_CCCCCC'))
.onClick(() => {
.onClick(async () => {
let retvalue = await FastClickUtil.isMinDelayTime()
if(retvalue){
return
}
this.handleAccention()
})
}
... ... @@ -275,7 +288,11 @@ export struct DynamicDetailComponent {
}
}
.onClick((event: ClickEvent) => {
.onClick(async (event: ClickEvent) => {
let retvalue = await FastClickUtil.isMinDelayTime()
if(retvalue){
return
}
ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList, index)
})
} else {
... ... @@ -292,7 +309,11 @@ export struct DynamicDetailComponent {
item.height = callback?.height || 0;
})
}
.onClick((event: ClickEvent) => {
.onClick(async (event: ClickEvent) => {
let retvalue = await FastClickUtil.isMinDelayTime()
if(retvalue){
return
}
ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList, index)
})
}
... ... @@ -304,7 +325,11 @@ export struct DynamicDetailComponent {
.aspectRatio(1)
.borderRadius(this.caclImageRadius(index))
}
.onClick((event: ClickEvent) => {
.onClick(async (event: ClickEvent) => {
let retvalue = await FastClickUtil.isMinDelayTime()
if(retvalue){
return
}
ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList, index)
})
} else {
... ... @@ -315,7 +340,11 @@ export struct DynamicDetailComponent {
.aspectRatio(1)
.borderRadius(this.caclImageRadius(index))
}
.onClick((event: ClickEvent) => {
.onClick(async (event: ClickEvent) => {
let retvalue = await FastClickUtil.isMinDelayTime()
if(retvalue){
return
}
ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList, index)
})
}
... ... @@ -372,7 +401,11 @@ export struct DynamicDetailComponent {
left: this.contentDetailData.videoInfo[0].videoLandScape === 1 ? 0 : 25,
top: $r('app.float.margin_8')
})
.onClick((event: ClickEvent) => {
.onClick(async (event: ClickEvent) => {
let retvalue = await FastClickUtil.isMinDelayTime()
if(retvalue){
return
}
ProcessUtils.processPage(this.mJumpInfo)
})
}
... ... @@ -430,7 +463,11 @@ export struct DynamicDetailComponent {
.borderWidth($r('app.float.margin_1'))
.borderColor($r('app.color.color_EDEDED'))
.borderRadius($r('app.float.margin_20'))
.onClick((event: ClickEvent) => {
.onClick(async (event: ClickEvent) => {
let retvalue = await FastClickUtil.isMinDelayTime()
if(retvalue){
return
}
//点赞操作
this.toggleLikeStatus()
})
... ... @@ -481,6 +518,13 @@ export struct DynamicDetailComponent {
* */
private async getContentDetailData() {
this.isNetConnected = NetworkUtil.isNetConnected()
this.publishCommentModel.targetId = String(this.contentDetailData?.newsId || '')
this.publishCommentModel.targetRelId = String(this.contentDetailData?.reLInfo?.relId)
this.publishCommentModel.targetTitle = this.contentDetailData?.newsTitle
this.publishCommentModel.targetRelType = String(this.contentDetailData?.reLInfo?.relType)
this.publishCommentModel.targetRelObjectId = String(this.contentDetailData?.reLInfo?.relObjectId)
this.publishCommentModel.keyArticle = String(this.contentDetailData?.keyArticle)
this.publishCommentModel.targetType = String(this.contentDetailData?.newsType)
try {
let data = await MultiPictureDetailViewModel.getDetailData(this.relId, this.contentId, this.relType)
this.isPageEnd = true;
... ...
/**
* 这里是人民号动态中的顶部信息:人民号logo,名字,描述,关注等
*/
import {
ContentDetailRequest,
postInteractAccentionOperateParams
} from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest';
import { RmhInfoDTO } from 'wdBean'
import { CommonConstants } from 'wdConstant/Index';
import { DateTimeUtils, SPHelper } from 'wdKit';
import { DateTimeUtils, SPHelper, Logger, ToastUtils } from 'wdKit';
import { SpConstants } from 'wdConstant/Index'
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import router from '@ohos.router'
import { postBatchAttentionStatusParams } from 'wdBean/Index';
import { MultiPictureDetailViewModel } from '../../viewmodel/MultiPictureDetailViewModel'
@Component
export struct RmhTitle {
@Prop rmhInfo: RmhInfoDTO
@Prop publishTime: string | undefined
/**
* 是否需要隐藏发布时间超过2天的时间展示,默认不隐藏
*/
@Prop hideTime: boolean
/**
* 默认未关注 点击去关注
*/
@State followStatus: string = '0';
async appointReq() {
/**
* 关注号主
*/
async handleAccention() {
// 未登录,跳转登录
const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
if (!user_id) {
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
const params2: postInteractAccentionOperateParams = {
attentionUserType: this.rmhInfo?.userType || '', //被关注用户类型(1 普通用户 2 视频号 3 矩阵号)
attentionUserId: this.rmhInfo?.userId || '', // 被关注用户号主id
attentionCreatorId: this.rmhInfo?.rmhId || '', // 被关注用户号主id
status: this.followStatus == '0' ? 1 : 0,
}
ContentDetailRequest.postInteractAccentionOperate(params2).then(res => {
console.log('rmhTitle-data', JSON.stringify(res.data))
if (this.followStatus == '1') {
this.followStatus = '0'
} else {
this.followStatus = '1'
// 弹窗样式与何时调用待确认
ContentDetailRequest.postPointLevelOperate({ operateType: 6 }).then((res) => {
console.log('关注号主获取积分==', JSON.stringify(res.data))
if (res.data?.showToast) {
ToastUtils.showToast(res.data.ruleName + '+' + res.data.rulePoint + '积分', 1000);
}
})
}
})
}
/**
* 查询当前登录用户是否关注作品号主
* */
async getBatchAttentionStatus() {
try {
const params: postBatchAttentionStatusParams = {
creatorIds: [{ creatorId: this.rmhInfo?.rmhId ?? '' }]
}
let data = await MultiPictureDetailViewModel.getBatchAttentionStatus(params)
this.followStatus = data[0]?.status;
Logger.info(`rmhTitle-followStatus:${JSON.stringify(this.followStatus)}`)
} catch (exception) {
Logger.info(`rmhTitle-followStatus:${JSON.stringify(exception)}`)
}
}
aboutToAppear(): void {
this.getBatchAttentionStatus()
let page = router.getState();
if (page.path.includes('/page/PeopleShipHomePage') || page.path.includes('/pages/MainPage')) {
this.hideTime = true;
... ... @@ -88,17 +143,20 @@ export struct RmhTitle {
Blank()
if (this.rmhInfo.cnIsAttention) {
Row() {
Image($r('app.media.rmh_follow'))
.width(16)
.height(16)
Text('关注')
if (Number(this.followStatus) === 0) {
Image($r('app.media.rmh_follow'))
.width(16)
.height(16)
}
Text(Number(this.followStatus) === 0 ? '关注' : '已关注')
.fontSize($r('app.float.font_size_13'))
.fontColor($r('app.color.color_ED2800'))
}
.flexShrink(0)
.alignSelf(ItemAlign.Center)
.onClick(() => {
this.appointReq();
this.handleAccention();
})
}
}
... ...
import { commentInfo, CompDTO, ContentDTO, Params } from 'wdBean';
import { commentInfo, CompDTO, ContentDTO, Params, batchLikeAndCollectResult } from 'wdBean';
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import { DateTimeUtils, SPHelper } from 'wdKit/Index';
import { DateTimeUtils, SPHelper, Logger } from 'wdKit/Index';
import { ProcessUtils } from 'wdRouter';
import { SpConstants } from 'wdConstant/Index'
import {
batchLikeAndCollectParams,
ContentDetailRequest,
contentListParams,
postExecuteCollectRecordParams,
postExecuteLikeParams,
postInteractAccentionOperateParams
} from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest';
import { MultiPictureDetailViewModel } from '../../viewmodel/MultiPictureDetailViewModel';
/**
* 精选评论卡
* Zh_Single_Row-06
*/
const TAG = 'Zh_Single_Row-06'
// interface commentInfo {
// commentTitle: string,
// newsTitle: string,
// userName: string,
// userHeaderUrl: string,
// publishTime: number
// }
// interface operDataListItem {
// commentInfo: commentInfo
// }
// interface CommentData{
// operDataList: Array<operDataListItem>
// }
@Entry
@Component
export struct ZhSingleRow06 {
@State compDTO: CompDTO = {} as CompDTO
@State likeBl: boolean = false;
@State newsStatusOfUser: batchLikeAndCollectResult = {
likeStatus: '0'
} as batchLikeAndCollectResult // 点赞、收藏状态
aboutToAppear(): void {
this.getInteractDataStatus()
}
async likeAction() {
/**
* 点赞、取消点赞
*/
async toggleLikeStatus() {
// 未登录,跳转登录
const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
if (!user_id) {
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
const params: postExecuteLikeParams = {
status: this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1',
contentId: this.compDTO.operDataList[0]?.commentInfo?.newsId + '',
contentType: this.compDTO.operDataList[0]?.commentInfo?.newsType + '',
}
ContentDetailRequest.postExecuteLike(params).then(res => {
this.newsStatusOfUser.likeStatus = this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1'
})
}
if (this.likeBl) {
this.likeBl = false;
} else {
this.likeBl = true;
// 已登录->查询用户对作品点赞、收藏状态
async getInteractDataStatus() {
// 未登录,跳转登录
const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
if (!user_id) {
return
}
try {
const params: batchLikeAndCollectParams = {
contentList: [
{
contentId: this.compDTO.operDataList[0]?.commentInfo?.newsId + '',
contentType: this.compDTO.operDataList[0]?.commentInfo?.newsType + '',
}
]
}
let data = await MultiPictureDetailViewModel.getInteractDataStatus(params)
console.error(TAG, 'ZhSingleRow06-data', JSON.stringify(data))
this.newsStatusOfUser = data[0];
Logger.info(TAG, `ZhSingleRow06-newsStatusOfUser:${JSON.stringify(this.newsStatusOfUser)}`)
} catch (exception) {
console.error(TAG, JSON.stringify(exception))
}
}
... ... @@ -95,7 +126,7 @@ export struct ZhSingleRow06 {
.fontColor(0x999999)
Row(){
Image(this.likeBl ? $r('app.media.icon_like_select') : $r('app.media.icon_like'))
Image(this.newsStatusOfUser?.likeStatus == '1' ? $r('app.media.icon_like_select') : $r('app.media.icon_like'))
.width(16)
.height(16)
.margin({right: 3})
... ... @@ -103,9 +134,11 @@ export struct ZhSingleRow06 {
Text('点赞')
.fontSize(15)
.fontColor(0x999999)
.onClick(() => {
})
}
.onClick(() => {
this.likeAction()
this.toggleLikeStatus()
})
}
.justifyContent(FlexAlign.SpaceBetween)
... ...
... ... @@ -42,7 +42,8 @@ export default struct MinePagePersonFunctionUI {
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}else {
WDRouterRule.jumpWithPage(WDRouterPage.mineHomePage)
let params: Record<string, string> = {'comment': "1"};
WDRouterRule.jumpWithPage(WDRouterPage.mineHomePage,params)
}
break;
}
... ...
import { SpConstants } from 'wdConstant/Index'
import { DateTimeUtils, SPHelper, StringUtils, ToastUtils, UserDataLocal } from 'wdKit/Index'
import { SPHelper, StringUtils, ToastUtils, UserDataLocal } from 'wdKit/Index'
import { HttpUtils } from 'wdNetwork/Index'
import { WDRouterRule, WDRouterPage } from 'wdRouter/Index'
import MinePageDatasModel from '../../../model/MinePageDatasModel'
... ... @@ -116,9 +116,14 @@ export struct FollowChildComponent{
}.height('202lpx')
.justifyContent(FlexAlign.Start)
Text().backgroundColor($r('app.color.color_EDEDED'))
// Text().backgroundColor($r('app.color.color_EDEDED'))
// .width('100%')
// .height('2lpx')
Divider()
.width('100%')
.height('2lpx')
.color($r('app.color.color_F5F5F5'))
.strokeWidth('1lpx')
}.width('100%')
}else {
... ... @@ -230,9 +235,15 @@ export struct FollowChildComponent{
}.height('146lpx')
.justifyContent(FlexAlign.Center)
Text().backgroundColor($r('app.color.color_EDEDED'))
// Text().backgroundColor($r('app.color.color_EDEDED'))
// .width('100%')
// .height('2lpx')
Divider()
.width('100%')
.height('2lpx')
.color($r('app.color.color_F5F5F5'))
.strokeWidth('1lpx')
}.width('100%')
}
... ... @@ -255,12 +266,6 @@ export struct FollowChildComponent{
this.data.status = this.data.status ==="0"?"1":"0"
UserDataLocal.setUserFollowOperation(this.data.creatorId+","+this.data.status)
// if(this.data.status === "1"){
// UserDataLocal.setUserFollowOperation(DateTimeUtils.getTimeStamp()+"")
// }else{
// UserDataLocal.setUserFollowOperation(DateTimeUtils.getTimeStamp()+","+this.data.creatorId)
// }
}
}
})
... ...
import { ContentDTO,
import {
ContentDTO,
contentListParams,
FullColumnImgUrlDTO, InteractDataDTO,
FullColumnImgUrlDTO,
InteractDataDTO,
Params,
RmhInfoDTO, VideoInfoDTO } from 'wdBean/Index'
RmhInfoDTO,
VideoInfoDTO
} from 'wdBean/Index'
import { LiveInfoDTO } from 'wdBean/src/main/ets/bean/detail/LiveInfoDTO'
import { VoiceInfoDTO } from 'wdBean/src/main/ets/bean/detail/VoiceInfoDTO'
import { LazyDataSource, Logger, StringUtils, ToastUtils } from 'wdKit/Index'
import { LazyDataSource, Logger, StringUtils, ToastUtils, UserDataLocal } from 'wdKit/Index'
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'
import MinePageDatasModel from '../../model/MinePageDatasModel'
import SearcherAboutDataModel from '../../model/SearcherAboutDataModel'
import { CreatorDetailRequestItem } from '../../viewmodel/CreatorDetailRequestItem'
import { FollowListDetailItem } from '../../viewmodel/FollowListDetailItem'
import { FollowListStatusRequestItem } from '../../viewmodel/FollowListStatusRequestItem'
import { QueryListIsFollowedItem } from '../../viewmodel/QueryListIsFollowedItem'
import { SearchResultContentData } from '../../viewmodel/SearchResultContentData'
import { SearchResultContentItem, SearchRmhDescription } from '../../viewmodel/SearchResultContentItem'
import { CardParser } from '../CardParser'
import { FollowChildComponent } from '../mine/follow/FollowChildComponent'
import { ListHasNoMoreDataUI } from '../reusable/ListHasNoMoreDataUI'
import { ActivityItemComponent } from './ActivityItemComponent'
import { SearchCreatorComponent } from './SearchCreatorComponent'
... ... @@ -19,27 +28,28 @@ import { SearchCreatorComponent } from './SearchCreatorComponent'
const TAG = "SearchResultContentComponent"
@Component
export struct SearchResultContentComponent{
@State keywords:string = ""
@State searchType:string = ""
export struct SearchResultContentComponent {
@State keywords: string = ""
@State searchType: string = ""
@State data: LazyDataSource<ContentDTO> = new LazyDataSource();
@State data_rmh: SearchRmhDescription[] = []
@State count:number = -1;
@State isLoading:boolean = false
@State hasMore:boolean = true
curPageNum:number = 1;
@State count: number = -1;
@State isLoading: boolean = false
@State hasMore: boolean = true
curPageNum: number = 1;
@State bean: FollowListDetailItem = new FollowListDetailItem("", "", "", "", "", "", "", "", "", -1, -1, "")
scroller: Scroller = new Scroller()
aboutToAppear(): void {
if(this.searchType == "全部"){
if (this.searchType == "全部") {
this.searchType = "all"
}else if(this.searchType == "精选"){
} else if (this.searchType == "精选") {
this.searchType = "cms"
}else if(this.searchType == "人民号"){
} else if (this.searchType == "人民号") {
this.searchType = "rmh"
}else if(this.searchType == "视频"){
} else if (this.searchType == "视频") {
this.searchType = "video"
}else if(this.searchType == "活动"){
} else if (this.searchType == "活动") {
this.searchType = "activity"
}
... ... @@ -47,93 +57,135 @@ export struct SearchResultContentComponent{
this.getNewSearchResultData()
}
getNewSearchResultData(){
getNewSearchResultData() {
this.isLoading = true
if(this.hasMore){
SearcherAboutDataModel.getSearchResultListData("20",`${this.curPageNum}`,this.searchType,this.keywords,getContext(this)).then((value)=>{
if (!this.data || value.list.length == 0){
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
this.count = this.count===-1?0:this.count
}else{
if(value.list[0].dataList!=null){
this.count = this.count === -1 ? 0 : this.count
} else {
if (value.list[0].dataList != null) {
let data_temp: SearchRmhDescription[] = []
data_temp = value.list[0].dataList
//TODO 查询创作者详情接口
let request = new CreatorDetailRequestItem()
data_temp.forEach((data)=>{
data_temp.forEach((data) => {
request.creatorIdList.push(data.creatorId)
})
SearcherAboutDataModel.getCreatorDetailListData(request).then((value)=>{
if(value!=null && value.length>0){
data_temp.forEach((data)=>{
value.forEach((item)=>{
if(data.creatorId == item.creatorId){
SearcherAboutDataModel.getCreatorDetailListData(request).then((value) => {
if (value != null && value.length > 0) {
data_temp.forEach((data) => {
value.forEach((item) => {
if (data.creatorId == item.creatorId) {
data.headerPhotoUrl = item.headPhotoUrl.split("?")[0]
data.mainControl = item.mainControl+""
data.mainControl = item.mainControl + ""
if(data_temp.length === 1){
this.bean.headPhotoUrl = item.headPhotoUrl.split("?")[0]
this.bean.cnUserName = item.userName
this.bean.creatorId = item.creatorId
this.bean.authIcon = item.authIcon
if (value[0].fansNum > 10000) {
let temp = (value[0].fansNum / 10000) + ""
let index = temp.indexOf('.')
if (index != -1) {
temp = temp.substring(0, index + 2)
} else {
temp = temp
}
this.bean.cnFansNum = temp + "万"
} else {
this.bean.cnFansNum = item.fansNum + ""
}
this.bean.introduction = item.introduction
this.bean.mainControl = item.mainControl
this.bean.banControl = item.banControl
this.bean.cnUserType = item.userType
this.bean.cnUserId = item.userId
}
}
})
})
}
data_temp.forEach((data)=>{
data_temp.forEach((data) => {
this.data_rmh.push(data)
})
}).catch((err:Error)=>{
console.log(TAG,JSON.stringify(err))
//只有一条创作者,获取 创作者信息
if (this.data_rmh.length === 1) {
if(StringUtils.isNotEmpty(UserDataLocal.getUserId())){
//查询是否被关注
let status = new FollowListStatusRequestItem()
status.creatorIds.push(new QueryListIsFollowedItem(this.data_rmh[0].creatorId))
MinePageDatasModel.getFollowListStatusData(status, getContext(this)).then((newValue) => {
this.bean.status = newValue[0].status
}).catch((err: Error) => {
console.log(TAG, "请求失败")
})
}else{
this.bean.status = ""
}
}
}).catch((err: Error) => {
console.log(TAG, JSON.stringify(err))
})
}
this.getInteractData(value)
}
}).catch((err:Error)=>{
console.log(TAG,JSON.stringify(err))
}).catch((err: Error) => {
console.log(TAG, JSON.stringify(err))
this.isLoading = false
this.count = this.count===-1?0:this.count
this.count = this.count === -1 ? 0 : this.count
})
}
}
getInteractData(resultData:SearchResultContentData){
if(resultData.list[0].dataList!=null){
resultData.list.splice(0,1)
getInteractData(resultData: SearchResultContentData) {
if (resultData.list[0].dataList != null) {
resultData.list.splice(0, 1)
}
let data : contentListParams = {
let data: contentListParams = {
contentList: []
}
resultData.list.forEach((item)=>{
resultData.list.forEach((item) => {
data.contentList.push({
contentId: item.data.id + '',
contentType: Number.parseInt(item.data.type)
})
})
SearcherAboutDataModel.getInteractListData(data,getContext(this)).then((newValue)=>{
newValue.forEach((item)=>{
resultData.list.forEach((data)=>{
SearcherAboutDataModel.getInteractListData(data, getContext(this)).then((newValue) => {
newValue.forEach((item) => {
resultData.list.forEach((data) => {
if (item.contentId == data.data.id) {
data.data.collectNum = item.collectNum+""
data.data.commentNum = item.commentNum+""
data.data.likeNum = item.likeNum+""
data.data.readNum = item.readNum+""
data.data.shareNum = item.shareNum+""
data.data.collectNum = item.collectNum + ""
data.data.commentNum = item.commentNum + ""
data.data.likeNum = item.likeNum + ""
data.data.readNum = item.readNum + ""
data.data.shareNum = item.shareNum + ""
}
})
})
resultData.list.forEach((value)=>{
let photos:FullColumnImgUrlDTO[] = []
if(value.data.appStyle === 4){
value.data.appStyleImages.split("&&").forEach((value)=>{
photos.push({url:value} as FullColumnImgUrlDTO)
resultData.list.forEach((value) => {
let photos: FullColumnImgUrlDTO[] = []
if (value.data.appStyle === 4) {
value.data.appStyleImages.split("&&").forEach((value) => {
photos.push({ url: value } as FullColumnImgUrlDTO)
})
}
let contentDTO = this.dataTransform(value,photos);
if(contentDTO.appStyle != "13"){
let contentDTO = this.dataTransform(value, photos);
if (contentDTO.appStyle != "13") {
this.data.push(contentDTO)
}
... ... @@ -142,131 +194,189 @@ export struct SearchResultContentComponent{
this.count = this.data.totalCount()
if (this.data.totalCount() < resultData.totalCount) {
this.curPageNum++
}else {
} else {
this.hasMore = false
}
this.isLoading = false
if(this.count === 0 && resultData.list.length > 0){
if (this.count === 0 && resultData.list.length > 0) {
this.count = -1
if(!this.isLoading){
if (!this.isLoading) {
//加载分页数据
this.getNewSearchResultData()
}
}else if(this.count <= 20 && resultData.list.length > 0){
if(!this.isLoading){
} else if (this.count <= 10 && resultData.list.length > 0) {
if (!this.isLoading) {
//加载分页数据
this.getNewSearchResultData()
}
}
}).catch((err:Error)=>{
console.log(TAG,"请求失败")
}).catch((err: Error) => {
console.log(TAG, "请求失败")
this.isLoading = false
this.count = this.count===-1?0:this.count
this.count = this.count === -1 ? 0 : this.count
})
}
build() {
Column() {
if(this.count == 0){
ListHasNoMoreDataUI({style:2})
}else{
Column(){
if (this.data_rmh!=null && this.data_rmh.length > 0) {
//List
List({space:'8lpx'}) {
ForEach(this.data_rmh, (item: SearchRmhDescription, index: number) => {
ListItem() {
SearchCreatorComponent({item:item})
}.onClick(()=>{
//TODO 跳转
})
.width('150lpx')
.height('100%')
})
if (this.count == 0) {
ListHasNoMoreDataUI({ style: 2 })
} else {
List() {
if (this.data_rmh != null && this.data_rmh.length > 0){
if (this.data_rmh.length === 1){
ListItem(){
FollowChildComponent({ data: this.bean, type: 1 })
}.padding({left:"31lpx",right:"31lpx"})
}else{
ListItem(){
Column(){
Text("查看更多")
.width('19lpx')
.fontSize('19lpx')
.fontWeight('400lpx')
.lineHeight('27lpx')
.fontColor($r('app.color.color_9E9E9E'))
}.borderRadius({topLeft:'4lpx',bottomLeft:'4lpx'})
.height('180lpx')
.width('77lpx')
.backgroundColor($r('app.color.color_EDEDED'))
.justifyContent(FlexAlign.Center)
}.height('100%')
.margin({left:'23lpx'})
.onClick(()=>{
let params: Params = {
pageID: this.keywords
this.SearchListUI()
}
WDRouterRule.jumpWithPage(WDRouterPage.searchCreatorPage,params)
})
}
}
.cachedCount(6)
.edgeEffect(EdgeEffect.Spring)
.scrollBar(BarState.Off)
.listDirection(Axis.Horizontal)
.width('100%')
.height('219lpx')
Divider()
.width('100%')
.height('12lpx')
.color($r('app.color.color_F5F5F5'))
.strokeWidth('12lpx')
}
//List
List({ space: '6lpx' }) {
LazyForEach(this.data, (item: ContentDTO, index: number) => {
ListItem() {
Column(){
if(this.searchType == "activity"){
ActivityItemComponent({contentDTO:item})
}else{
CardParser({contentDTO:item})
}
if(index != this.data.totalCount()-1 ){
Divider()
.width('100%')
.height('1lpx')
.color($r('app.color.color_F5F5F5'))
.strokeWidth('1lpx')
}
LazyForEach(this.data, (item: ContentDTO, index: number) => {
ListItem() {
Column() {
if (this.searchType == "activity") {
ActivityItemComponent({ contentDTO: item })
} else {
CardParser({ contentDTO: item })
}
if (index != this.data.totalCount() - 1) {
Divider()
.width('100%')
.height('1lpx')
.color($r('app.color.color_F5F5F5'))
.strokeWidth('1lpx')
}
}
}, (item: ContentDTO, index: number) => index.toString())
//没有更多数据 显示提示
if(!this.hasMore && this.data.totalCount() > 0){
ListItem(){
ListHasNoMoreDataUI()
}
}
}.cachedCount(6)
.edgeEffect(EdgeEffect.None)
.scrollBar(BarState.Off)
.layoutWeight(1)
.onReachEnd(()=>{
console.log(TAG,"触底了");
if(!this.isLoading){
//加载分页数据
this.getNewSearchResultData()
}, (item: ContentDTO, index: number) => index.toString())
//没有更多数据 显示提示
if (!this.hasMore && this.data.totalCount() > 0) {
ListItem() {
ListHasNoMoreDataUI()
}
})
}.layoutWeight(1)
}
}.cachedCount(10)
.edgeEffect(EdgeEffect.None)
.scrollBar(BarState.Off)
.onReachEnd(() => {
console.log(TAG, "触底了");
if (!this.isLoading) {
//加载分页数据
this.getNewSearchResultData()
}
})
}
}
.backgroundColor($r('app.color.white'))
.layoutWeight(1)
.width('100%')
}
@Builder
multiCreatorUI() {
Column() {
List() {
ForEach(this.data_rmh, (item: SearchRmhDescription, index: number) => {
ListItem() {
SearchCreatorComponent({ item: item })
}
.width('150lpx')
.height('100%')
})
ListItem() {
Column() {
Text("查看更多")
.width('19lpx')
.fontSize('19lpx')
.fontWeight('400lpx')
.lineHeight('27lpx')
.fontColor($r('app.color.color_9E9E9E'))
}
.borderRadius({ topLeft: '4lpx', bottomLeft: '4lpx' })
.height('180lpx')
.width('77lpx')
.backgroundColor($r('app.color.color_EDEDED'))
.justifyContent(FlexAlign.Center)
}.height('100%')
.margin({ left: '23lpx' })
.onClick(() => {
let params: Params = {
pageID: this.keywords
}
WDRouterRule.jumpWithPage(WDRouterPage.searchCreatorPage, params)
})
}
.cachedCount(6)
.edgeEffect(EdgeEffect.None)
.scrollBar(BarState.Off)
.listDirection(Axis.Horizontal)
.width('100%')
.height('219lpx')
Divider()
.width('100%')
.height('12lpx')
.color($r('app.color.color_F5F5F5'))
.strokeWidth('12lpx')
}
}
@Builder
SearchListUI() {
List({space:'8lpx'}) {
ForEach(this.data_rmh, (item: SearchRmhDescription, index: number) => {
ListItem() {
SearchCreatorComponent({item:item})
}
.width('150lpx')
.height('100%')
})
ListItem(){
Column(){
Text("查看更多")
.width('19lpx')
.fontSize('19lpx')
.fontWeight('400lpx')
.lineHeight('27lpx')
.fontColor($r('app.color.color_9E9E9E'))
}.borderRadius({topLeft:'4lpx',bottomLeft:'4lpx'})
.height('180lpx')
.width('77lpx')
.backgroundColor($r('app.color.color_EDEDED'))
.justifyContent(FlexAlign.Center)
}.height('100%')
.margin({left:'23lpx'})
.onClick(()=>{
let params: Params = {
pageID: this.keywords
}
WDRouterRule.jumpWithPage(WDRouterPage.searchCreatorPage,params)
})
}
.cachedCount(6)
.edgeEffect(EdgeEffect.None)
.scrollBar(BarState.Off)
.listDirection(Axis.Horizontal)
.width('100%')
.height('219lpx')
Divider()
.width('100%')
.height('12lpx')
.color($r('app.color.color_F5F5F5'))
.strokeWidth('12lpx')
}
private dataTransform(value: SearchResultContentItem, photos: FullColumnImgUrlDTO[]): ContentDTO {
let contentDTO = new ContentDTO();
contentDTO.appStyle = value.data.appStyle + ""
... ...
... ... @@ -31,10 +31,19 @@ struct MineHomePage {
registTime:number = 0//账号注册时间
@State registerTimeForDay:number = 0
scroller: Scroller = new Scroller();
@State params:Record<string, string> = router.getParams() as Record<string, string>;
@State isCommentEnter:string = "";
onPageShow(): void {
this.getUserInfo()
let intervalID = setInterval(() => {
this.isCommentEnter = this.params?.['comment'];
if(StringUtils.isNotEmpty(this.isCommentEnter)){
this.scroller.scrollEdge(Edge.Bottom)
}
clearInterval(intervalID);
}, 200);
}
build() {
... ...