liyubing

Merge remote-tracking branch 'origin/main'

# Conflicts:
#	sight_harmony/features/wdBean/src/main/ets/bean/component/CompDTO.ets
#	sight_harmony/features/wdComponent/src/main/ets/components/CompParser.ets
#	sight_harmony/features/wdComponent/src/main/ets/viewmodel/PageHelper.ets
Showing 82 changed files with 1462 additions and 975 deletions

Too many changes to show.

To preserve performance only 82 of 82+ files are displayed.

... ... @@ -34,6 +34,7 @@ export class SpConstants{
//定位相关
static LOCATION_CITY_NAME = "location_city_name" //定位
static LOCATION_CITY_CODE = "location_city_code" //定位
static LOCATION_PERMISSION_REFUSE = "location_permission_refuse" //定位
//启动页数据存储key
static APP_LAUNCH_PAGE_DATA_MODEL = 'app_launch_page_data_model'
... ...
import { Action } from './Action';
interface dataObject {
// dataSource:
// 1、图文详情数据
... ... @@ -17,7 +18,11 @@ interface dataObject {
webViewHeight?: string
dataJson?: string
appInnerLink?: string
method?: string
url?: string
parameters?: object
}
/**
* 消息Message
*/
... ...
... ... @@ -10,5 +10,7 @@ export enum EmitterEventId {
NETWORK_DISCONNECTED = 3,
// 跳转首页指定频道,事件id
JUMP_HOME_CHANNEL = 4,
LOCATION = 5
}
... ...
export { ResponseDTO } from "./src/main/ets/bean/ResponseDTO"
export { ResposeError } from "./src/main/ets/bean/ResposeError"
export { HttpRequest as WDHttp } from "./src/main/ets/http/HttpRequest"
export { HttpUrlUtils } from "./src/main/ets/http/HttpUrlUtils"
... ...
/**
* 接口返回错误数据封装
*/
export class ResposeError {
code: number = -1;
message: string = '';
static buildError(message: string, code?: number): ResposeError {
let error = new ResposeError()
error.message = message
if (code) {
error.code = code
}
return error;
}
}
\ No newline at end of file
... ...
... ... @@ -6,6 +6,7 @@ import axios, {
InternalAxiosRequestConfig
} from '@ohos/axios';
import { Logger } from 'wdKit/Index';
import { ResposeError } from '../bean/ResposeError';
// import type ResponseDTO from '../models/ResponseDTO';
... ... @@ -99,17 +100,16 @@ instance.interceptors.response.use(// 响应拦截器response类型就是Axios.r
},
(error: AxiosError) => {
// 异常响应
// console.log('全局响应失败拦截')
// console.log(error.request)
// console.log(error.response)
// 429-流量超标;403-临时token;406-token过期,强制下线
// 这里用来处理http常见错误,进行全局提示
let errorBean = new ResposeError()
if (error != null && error.response != null) {
let message = buildErrorMsg(error.response.status);
// 错误消息可以使用全局弹框展示出来
console.log(`httpStatus:${error.response?.status}-${message},请检查网络或联系管理员!`)
errorBean = buildError(error.response.status)
}
return Promise.reject(error);
return Promise.reject(errorBean);
}
);
... ... @@ -161,3 +161,9 @@ function buildErrorMsg(httpStatus: number): string {
}
return message;
}
function buildError(httpStatus: number): ResposeError {
let message = buildErrorMsg(httpStatus);
let error: ResposeError = ResposeError.buildError(message, httpStatus)
return error;
}
... ...
... ... @@ -4,6 +4,7 @@ import HashMap from '@ohos.util.HashMap';
import { ResponseDTO } from '../bean/ResponseDTO';
import { HttpUrlUtils, WDHttp } from '../../../../Index';
import { RefreshTokenRes } from '../bean/RefreshTokenRes';
import { ResposeError } from '../bean/ResposeError';
const TAG: string = 'HttpBizUtil'
... ... @@ -20,37 +21,31 @@ export class HttpBizUtil {
* @returns 返回值
*/
static get<T = ResponseDTO<string>>(url: string, headers?: HashMap<string, string>): Promise<T> {
return new Promise<T>((success, debug) => {
return new Promise<T>((success, error) => {
WDHttp.get<T>(url, headers).then((originalRes: T) => {
try {
let resDTO = originalRes as ResponseDTO
Logger.debug(TAG, 'get: ' + resDTO.code)
Logger.debug(TAG, 'get: ' + resDTO.message)
// 403:临时token;406:强制下线、封禁、清空登录信息还要跳转登录页面
if (resDTO.code == 403 || resDTO.code == 406) {
HttpBizUtil.refreshToken().then((token: string) => {
if (headers) {
headers.replace('RMRB-X-TOKEN', token)
headers.replace('cookie', 'RMRB-X-TOKEN=' + token)
}
Logger.debug(TAG, 'get again send: ' + token)
// refreshToken为空场景不处理,直接请求接口。
WDHttp.get<T>(url, headers).then((againResDTO: T) => {
Logger.debug(TAG, 'get again: ' + againResDTO)
success(againResDTO)
}).catch((res: object) => {
debug(res)
})
});
} else {
success(originalRes)
}
} catch (e) {
debug(originalRes)
success(originalRes)
}).catch((res: ResposeError) => {
// 403:临时token;406:强制下线、封禁、清空登录信息还要跳转登录页面
if (res.code == 403 || res.code == 406) {
HttpBizUtil.refreshToken().then((token: string) => {
if (headers) {
headers.replace('RMRB-X-TOKEN', token)
headers.replace('cookie', 'RMRB-X-TOKEN=' + token)
}
Logger.debug(TAG, 'get again send: ' + token)
// refreshToken为空场景不处理,直接请求接口。
WDHttp.get<T>(url, headers).then((againResDTO: T) => {
Logger.debug(TAG, 'get again: ' + againResDTO)
success(againResDTO)
}).catch((res: object) => {
error(ResposeError.buildError(JSON.stringify(res)))
})
});
} else {
// 非403、406,直接抛出去
Logger.debug(TAG, 'get else: ' + JSON.stringify(res))
error(res)
}
}).catch((res: object) => {
debug(res)
})
})
}
... ... @@ -63,34 +58,31 @@ export class HttpBizUtil {
* @returns 返回值
*/
static post<T = ResponseDTO<string>>(url: string, data?: object, headers?: HashMap<string, string>): Promise<T> {
return new Promise<T>((success, debug) => {
return new Promise<T>((success, error) => {
WDHttp.post<T>(url, data, headers).then((originalRes: T) => {
try {
let resDTO = originalRes as ResponseDTO
Logger.debug(TAG, 'post: ' + resDTO.code)
Logger.debug(TAG, 'post: ' + resDTO.message)
// 403:临时token;406:强制下线、封禁、清空登录信息还要跳转登录页面
if (resDTO.code == 403 || resDTO.code == 406) {
HttpBizUtil.refreshToken().then((token: string) => {
if (headers) {
headers.replace('RMRB-X-TOKEN', token)
headers.replace('cookie', 'RMRB-X-TOKEN=' + token)
}
// refreshToken为空场景不处理,直接请求接口。
WDHttp.post<T>(url, headers).then((againResDTO: T) => {
success(againResDTO)
}).catch((res: object) => {
debug(res)
})
});
} else {
success(originalRes)
}
} catch (e) {
success(originalRes)
success(originalRes)
}).catch((res: ResposeError) => {
// 403:临时token;406:强制下线、封禁、清空登录信息还要跳转登录页面
Logger.debug(TAG, 'post catch error: ' + JSON.stringify(res))
if (res.code == 403 || res.code == 406) {
HttpBizUtil.refreshToken().then((token: string) => {
if (headers) {
headers.replace('RMRB-X-TOKEN', token)
headers.replace('cookie', 'RMRB-X-TOKEN=' + token)
}
Logger.debug(TAG, 'post again send: ' + token)
// refreshToken为空场景不处理,直接请求接口。
WDHttp.post<T>(url, data, headers).then((againResDTO: T) => {
Logger.debug(TAG, 'post again success: ' + JSON.stringify(againResDTO))
success(againResDTO)
}).catch((res: object) => {
error(ResposeError.buildError(JSON.stringify(res)))
})
});
} else {
// 非403、406,直接抛出去
error(res)
}
}).catch((res: object) => {
debug(res)
})
})
}
... ... @@ -104,9 +96,9 @@ export class HttpBizUtil {
params.set('refreshToken', HttpUrlUtils.getRefreshToken())
params.set('deviceId', HttpUrlUtils.getDeviceId())
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
Logger.debug(TAG, 'refreshToken getRefreshToken: ' + HttpUrlUtils.getRefreshToken())
// // 请求刷新token接口
return new Promise<string>((success, debug) => {
// Logger.debug(TAG, 'refreshToken getRefreshToken: ' + HttpUrlUtils.getRefreshToken())
// 请求刷新token接口
return new Promise<string>((success, error) => {
WDHttp.post<ResponseDTO<RefreshTokenRes>>(url, params, headers).then((resDTO: ResponseDTO<RefreshTokenRes>) => {
let newToken = ''
if (resDTO) {
... ... @@ -126,6 +118,7 @@ export class HttpBizUtil {
Logger.debug(TAG, 'refreshToken refreshToken: ' + resDTO.data.refreshToken)
}
}
Logger.debug(TAG, 'refreshToken last jwtToken: ' + newToken)
success(newToken)
});
})
... ...
... ... @@ -47,6 +47,10 @@ export class HttpUrlUtils {
*/
static readonly INTERACT_DATA_PATH: string = "/api/rmrb-contact/contact/zh/c/content/interactData";
/**
* 查询各类型内容动态数据接口V2:其他场景的均调用V2---api缓存1-2s
*/
static readonly INTERACT_V2_DATA_PATH: string = "/api/rmrb-contact/contact/zh/c/v2/content/interactData";
/**
* 查询视频频道推荐楼层
*/
static readonly DISPLAY_REC_COMPINFO: string = "/api/rmrb-bff-display-zh/display/zh/c/rec/compInfo";
... ... @@ -742,7 +746,7 @@ export class HttpUrlUtils {
}
static getSearchHotsDataUrl() {
let url = HttpUrlUtils.HOST_SIT + HttpUrlUtils.SEARCH_HOTS_DATA_PATH
let url = HttpUrlUtils._hostUrl + HttpUrlUtils.SEARCH_HOTS_DATA_PATH
return url
}
... ... @@ -843,6 +847,13 @@ export class HttpUrlUtils {
let url = HttpUrlUtils._hostUrl + "/api/rmrb-interact/interact/zh/c/like/executeLike";
return url;
}
//获取点赞状态
static getLikeStatus() {
let url = HttpUrlUtils._hostUrl + "/api/rmrb-interact/interact/zh/c/batchLikeAndCollect/status";
return url;
}
//搜索推荐
static getSearchSuggestDataUrl() {
let url = HttpUrlUtils._hostUrl + HttpUrlUtils.SEARCH_SUGGEST_DATA_PATH
... ...
... ... @@ -171,6 +171,17 @@ export class ProcessUtils {
Logger.debug(TAG, `gotoMultiPictureListPage`);
}
public static _gotoSpecialTopic(linkUrl: string) {
let taskAction: Action = {
type: 'JUMP_INNER_NEW_PAGE',
params: {
url: linkUrl,
pageID: 'SPACIAL_TOPIC_PAGE',
} as Params,
};
WDRouterRule.jumpWithAction(taskAction)
}
public static gotoSpecialTopic(content: ContentDTO) {
let taskAction: Action = {
type: 'JUMP_INNER_NEW_PAGE',
... ... @@ -182,6 +193,16 @@ export class ProcessUtils {
WDRouterRule.jumpWithAction(taskAction)
}
public static _gotoDefaultWeb(linkUrl: string) {
let taskAction: Action = {
type: 'JUMP_H5_BY_WEB_VIEW',
params: {
url: linkUrl,
} as Params,
};
WDRouterRule.jumpWithAction(taskAction)
}
public static gotoDefaultWeb(content: ContentDTO) {
let taskAction: Action = {
type: 'JUMP_H5_BY_WEB_VIEW',
... ...
... ... @@ -11,6 +11,7 @@
"wdKit": "file:../wdKit",
"wdJsBridge": "file:../wdJsBridge",
"wdBean": "file:../../features/wdBean",
"wdRouter": "file:../wdRouter"
"wdRouter": "file:../wdRouter",
"wdNetwork": "file:../wdNetwork"
}
}
... ...
... ... @@ -10,6 +10,9 @@ export class H5CallNativeType {
static jsCall_callAppService = 'jsCall_callAppService'
static jsCall_appInnerLinkMethod = 'jsCall_appInnerLinkMethod'
static jsCall_receiveH5Data = 'jsCall_receiveH5Data'
static jsCall_getAppLoginAuthInfo = 'jsCall_getAppLoginAuthInfo'
static jsCall_appNotifyEvent = 'jsCall_appNotifyEvent'
// TODO 业务自行新增类型、自行在JsBridgeBiz#performJSCallNative里添加接收分支处理。
static {
... ... @@ -19,6 +22,8 @@ export class H5CallNativeType {
H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_callAppService)
H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_appInnerLinkMethod)
H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_receiveH5Data)
H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_getAppLoginAuthInfo)
H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_appNotifyEvent)
}
}
... ...
import HashMap from '@ohos.util.HashMap';
import { Callback } from 'wdJsBridge';
import { Message } from 'wdJsBridge/src/main/ets/bean/Message';
import { Logger } from 'wdKit';
... ... @@ -8,6 +9,7 @@ import { ProcessUtils } from 'wdRouter';
import router from '@ohos.router';
import Url from '@ohos.url'
import { ContentDTO } from 'wdBean/Index';
import { ResponseDTO, WDHttp, HttpUrlUtils } from 'wdNetwork';
const TAG = 'JsBridgeBiz'
... ... @@ -37,7 +39,9 @@ export function performJSCallNative(data: Message, call: Callback) {
case H5CallNativeType.jsCall_getArticleDetailBussinessData:
break;
case H5CallNativeType.jsCall_callAppService:
handleJsCallCallAppService(data)
handleJsCallCallAppService(data, (res: string) => {
call(res)
})
break;
case H5CallNativeType.jsCall_receiveH5Data:
handleJsCallReceiveH5Data(data)
... ... @@ -60,6 +64,21 @@ function handleJsCallCurrentPageOperate(data: Message) {
}
}
function handleJsCallCallAppService(data: Message, callback: (res: string) => void) {
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
let url: string = HttpUrlUtils.getHost() + data?.data?.url
if (data?.data?.method === 'get') {
WDHttp.get<ResponseDTO<string>>(url, headers).then((res: ResponseDTO<string>) => {
callback(JSON.stringify(res))
})
}
if (data?.data?.method === 'post') {
WDHttp.post<ResponseDTO<string>>(url, data?.data?.parameters, headers).then(res => {
callback(JSON.stringify(res))
})
}
}
/**
* 获取App公共信息
*/
... ... @@ -87,19 +106,14 @@ function handleJsCallReceiveH5Data(data: Message) {
}
}
function handleJsCallCallAppService(data: Message) {
}
function handleJsCallAppInnerLinkMethod(data: Message) {
let urlObject = Url.URL.parseURL(data?.data?.appInnerLink);
let urlParams = new Url.URLParams(urlObject.search);
console.log('urlObject:', `${JSON.stringify(urlParams)}`)
let content: ContentDTO = {
objectId: urlParams.get('contentId') || '',
relId: urlParams.get('relId') || '',
relType: urlParams.get('relType') || '',
pageId:urlParams.get('pageId') || '',
pageId: urlParams.get('pageId') || '',
objectType: ''
} as ContentDTO
if (urlParams.get('skipType') === '1') {
... ... @@ -130,14 +144,14 @@ function handleJsCallAppInnerLinkMethod(data: Message) {
ProcessUtils.processPage(content)
break;
case 'topic':
if(urlParams.get('subType') === 'h5'){
if (urlParams.get('subType') === 'h5') {
content.objectType = ContentConstants.TYPE_SPECIAL_TOPIC
ProcessUtils.processPage(content)
}
if(urlParams.get('subType') === 'moring_evening_news'){
if (urlParams.get('subType') === 'moring_evening_news') {
ProcessUtils.gotoMorningEveningPaper()
}
if(urlParams.get('subType') === 'electronic_newspapers'){
if (urlParams.get('subType') === 'electronic_newspapers') {
ProcessUtils.gotoENewsPaper()
}
break;
... ... @@ -148,7 +162,7 @@ function handleJsCallAppInnerLinkMethod(data: Message) {
case 'owner_page':
let creatorId = urlParams.get('creatorId') || ''
ProcessUtils.gotoPeopleShipHomePage(creatorId)
break;
break;
default:
break;
}
... ...
... ... @@ -32,6 +32,7 @@ export interface CompDTO {
subType: string;
imageScale: number; // 封面图比例 1-4:3, 2-16:9, 3-3:2
audioDataList: AudioDTO[];
titleShowPolicy: string | number;
/**
* 组件内容源类型 (LIVE_HORIZONTAL_CARD\LIVE_RESERVATION\LIVE_LARGE_CARD\LIVE_END\LIVE_MONTHLY_RANKING )
... ... @@ -42,4 +43,7 @@ export interface CompDTO {
* 信息流广告素材
*/
matInfo: CompAdvMatInfoBean
pageId?: string;
objectType?: string;
}
\ No newline at end of file
... ...
import { RmhInfoDTO } from '../detail/RmhInfoDTO'
export interface LiveDetailsBean {
/**
* {
... ... @@ -164,14 +166,16 @@ export interface LiveDetailsBean {
//迁移id
oldNewsId: string
reLInfo: ReLInfo
rmhInfo: RmhInfo
rmhInfo: RmhInfoDTO
}
export interface LiveInfo {
//直播新闻-直播状态 wait 待开播 running 直播中 end 已结束cancel已取消paused暂停
liveState: string
//2024-04-12 15:00:00 直播开始时间
planStartTime: string
//直播样式 0-正常模式 , 1-隐藏直播间,2-隐藏大家聊 【人民号发布是竖屏的,为空】
liveStyle: number;
vlive: Array<Vlive>
mlive: MLive
... ... @@ -197,11 +201,3 @@ export interface Vlive {
export interface ReLInfo {
relId: string
}
export interface RmhInfo {
rmhName: string;
rmhHeadUrl: string;
rmhId: string;
userId: string;
userType: string;
}
\ No newline at end of file
... ...
... ... @@ -9,6 +9,7 @@ export interface PageInfoDTO {
name: string; // 名称
hasPopUp: number;
baselineShow: number;
baselineCopywriting: string;
groups: GroupInfoDTO[];
channelInfo: ChannelInfoDTO;
... ... @@ -20,11 +21,11 @@ export interface PageInfoDTO {
/**
* 挂角广告数据
*/
cornersAdv:AdvRuleBean
cornersAdv: AdvRuleBean
/**
* 广告中心-挂角广告信息
*/
cornersAdv2:CompAdvBean[]
cornersAdv2: CompAdvBean[]
}
... ...
... ... @@ -14,6 +14,8 @@ export { PageComponent } from "./src/main/ets/components/page/PageComponent"
export { BottomNavigationComponent } from "./src/main/ets/components/page/BottomNavigationComponent"
export { LikeComponent } from "./src/main/ets/components/view/LikeComponent"
export { TopNavigationComponent } from "./src/main/ets/components/page/TopNavigationComponent"
export { LabelComponent } from "./src/main/ets/components/view/LabelComponent"
... ... @@ -77,7 +79,11 @@ export { LiveCommentComponent } from "./src/main/ets/components/comment/view/Liv
export { WDViewDefaultType } from "./src/main/ets/components/view/EmptyComponent"
export { PermissionDesComponent } from "./src/main/ets/components/view/PermissionDesComponent"
export { AudioRowComponent } from "./src/main/ets/components/live/AudioRowComponent"
export { WDLiveViewDefaultType } from "./src/main/ets/components/view/LiveEmptyComponent"
export { LiveFollowComponent } from "./src/main/ets/components/cardCommon/LiveFollowComponent"
... ...
... ... @@ -20,8 +20,8 @@ import { ZhCarouselLayout01 } from './compview/ZhCarouselLayout01';
import { CardParser } from './CardParser';
import { LiveHorizontalReservationComponent } from './view/LiveHorizontalReservationComponent';
import { ZhGridLayout02 } from './compview/ZhGridLayout02';
import { Card5Component } from './cardview/Card5Component';
import { Card2Component } from './cardview/Card2Component';
import { Card5Component } from './cardview/Card5Component';
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import { CardAdvComponent } from './cardViewAdv/CardAdvComponent';
import { AdvCardParser } from './cardViewAdv/AdvCardParser';
... ...
import { AccountManagerUtils, Logger, DateTimeUtils } from 'wdKit';
import { AccountManagerUtils, Logger, DateTimeUtils, SPHelper, NumberFormatterUtils } from 'wdKit';
import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel';
import { ContentDetailDTO,batchLikeAndCollectResult,batchLikeAndCollectParams,postBatchAttentionStatusParams,
import { ContentDetailDTO,postBatchAttentionStatusParams,
PhotoListBean,
ContentDTO,
RmhInfoDTO, } from 'wdBean';
batchLikeAndCollectResult,
RmhInfoDTO,
InteractDataDTO, } from 'wdBean';
import media from '@ohos.multimedia.media';
import { OperRowListView } from './view/OperRowListView';
import { WDPlayerController } from 'wdPlayer/Index';
import {
batchLikeAndCollectParams,
ContentDetailRequest,
contentListParams,
postExecuteCollectRecordParams,
postExecuteLikeParams,
postInteractAccentionOperateParams
} from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest';
import { ContentConstants } from '../constants/ContentConstants';
import { ProcessUtils } from 'wdRouter';
import { ProcessUtils, WDRouterPage, WDRouterRule } from 'wdRouter';
import { StringUtils } from 'wdKit/src/main/ets/utils/StringUtils';
import display from '@ohos.display';
import { BusinessError } from '@ohos.base';
import { CommonConstants } from 'wdConstant/Index';
import { CommonConstants, SpConstants } from 'wdConstant/Index';
import { CardMediaInfo } from '../components/cardCommon/CardMediaInfo'
import router from '@ohos.router';
const TAG = 'DynamicDetailComponent'
... ... @@ -23,32 +33,23 @@ export struct DynamicDetailComponent {
private relId: string = ''
private contentId: string = ''
private relType: string = ''
//出参 fixme 模拟数据用json转换
@State contentDetailData: ContentDetailDTO = {
publishTime: "2023年03月14日 08:16",
rmhInfo:{rmhHeadUrl:"",rmhName:"人民号名称",rmhDesc:"人民号描述单行展示"},
newsContent:"优先展示这个内容",
newsSummary:"其次展示这个内容",
newsTitle:"上面两个都没有再展示这个内容",
newsType:15
} as ContentDetailDTO
//变量
//出参
@State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
//UI
scroller: Scroller = new Scroller();
//点赞 收藏 评论 数量
@State interactDataDTO: InteractDataDTO = {likeNum:0} as InteractDataDTO
/**
* 默认未关注 点击去关注
* 关注状态:默认未关注 点击去关注
*/
private followStatus: String = '0';
@State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态
@State followStatus: String = '0';
@State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined// 点赞、收藏状态
//跳转
private mJumpInfo: ContentDTO = {} as ContentDTO;
// 获取当前所有的display对象
promise: Promise<Array<display.Display>> = display.getAllDisplays()
// 屏幕宽度(单位px)
@State screenWidth: number = 0;
async aboutToAppear() {
await this.getContentDetailData()
}
... ... @@ -130,7 +131,7 @@ export struct DynamicDetailComponent {
.backgroundColor($r('app.color.color_ED2800'))
.fontColor($r('app.color.color_fff'))
.onClick(() => {
// this.handleAccention(this.item, 1)
this.handleAccention()
})
} else {
Text('已关注')
... ... @@ -143,7 +144,7 @@ export struct DynamicDetailComponent {
.borderColor($r('app.color.color_CCCCCC'))
.fontColor($r('app.color.color_CCCCCC'))
.onClick(() => {
// this.handleAccention(this.item, 0)
this.handleAccention()
})
}
}
... ... @@ -224,6 +225,9 @@ export struct DynamicDetailComponent {
item.height = callback?.height || 0;
})
}
.onClick((event: ClickEvent) => {
ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList)
})
}
} else if (this.contentDetailData.photoList.length === 4) {
GridCol({
... ... @@ -233,6 +237,9 @@ export struct DynamicDetailComponent {
.aspectRatio(1)
.borderRadius(this.caclImageRadius(index))
}
.onClick((event: ClickEvent) => {
ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList)
})
} else {
GridCol({
span: { sm: 4, lg: 3 }
... ... @@ -241,6 +248,9 @@ export struct DynamicDetailComponent {
.aspectRatio(1)
.borderRadius(this.caclImageRadius(index))
}
.onClick((event: ClickEvent) => {
ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList)
})
}
})
}
... ... @@ -316,17 +326,32 @@ export struct DynamicDetailComponent {
.margin({ top: $r('app.float.margin_24')})
//点赞
Row(){
Image($r('app.media.icon_like_selected_redheart'))
Blank().layoutWeight(1)
Image(this.newsStatusOfUser?.likeStatus == '1'?
$r('app.media.icon_like_selected_redheart')
:$r('app.media.icon_like_unselect_grey_redheart'))
.width($r('app.float.margin_24'))
.height($r('app.float.margin_24'))
.objectFit(ImageFit.Cover)
Text("2.6万")
.fontColor($r('app.color.color_999999'))
.fontSize($r('app.float.font_size_16'))
.lineHeight($r('app.float.margin_20'))
.margin({ left: $r('app.float.margin_2')})
if(this.interactDataDTO?.likeNum != 0){
Text(NumberFormatterUtils.formatNumberWithWan(this.interactDataDTO?.likeNum))
.fontColor($r('app.color.color_999999'))
.fontSize($r('app.float.font_size_16'))
.lineHeight($r('app.float.margin_20'))
.margin({ left: $r('app.float.margin_2')})
}
Blank().layoutWeight(1)
}
.width($r('app.float.margin_154'))
.height($r('app.float.margin_40'))
.margin({top:$r('app.float.margin_16')})
.borderWidth($r('app.float.margin_1'))
.borderColor($r('app.color.color_EDEDED'))
.borderRadius($r('app.float.margin_20'))
.onClick((event: ClickEvent) => {
//点赞操作
this.toggleLikeStatus()
})
Blank().layoutWeight(1)
//fixme 评论组件
}
... ... @@ -394,20 +419,23 @@ export struct DynamicDetailComponent {
this.getBatchAttentionStatus()
this.getInteractDataStatus()
this.makeJumpInfo()
this.interactDataV2()
}
// 查询当前登录用户点赞状态
private async interactDataV2() {
this.interactDataDTO = await MultiPictureDetailViewModel.interactDataV2(
this.contentDetailData?.newsId+'',this.contentDetailData?.newsType+'',this.contentDetailData.reLInfo == null ?'':this.contentDetailData.reLInfo?.relId,this.contentDetailData.rmhPlatform)
}
// 已登录->查询用户对作品点赞、收藏状态
private async getInteractDataStatus() {
//未登录
if(!AccountManagerUtils.isLoginSync() || this.contentDetailData?.openLikes != 1){
return
}
try {
const params: batchLikeAndCollectParams = {
contentList: [
{
contentId: this.contentDetailData?.newsId + '',
contentType: this.contentDetailData?.newsType + '',
contentId: this.contentDetailData[0]?.newsId + '',
contentType: this.contentDetailData[0]?.newsType + '',
}
]
}
... ... @@ -486,6 +514,64 @@ export struct DynamicDetailComponent {
return 3; //普通图
}
}
/**
* 关注号主
*/
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.contentDetailData?.rmhInfo?.userType || '', //被关注用户类型(1 普通用户 2 视频号 3 矩阵号)
attentionUserId: this.contentDetailData?.rmhInfo?.userId || '', // 被关注用户号主id
attentionCreatorId: this.contentDetailData?.rmhInfo?.rmhId || '', // 被关注用户号主id
status: this.followStatus == '0'? 1:0,
}
ContentDetailRequest.postInteractAccentionOperate(params2).then(res => {
console.log('关注号主==', JSON.stringify(res.data))
if (this.followStatus == '1') {
this.followStatus = '0'
} else {
this.followStatus = '1'
}
})
}
/**
* 点赞、取消点赞
*/
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.contentDetailData?.newsId + '',
contentType: this.contentDetailData?.newsType + '',
}
ContentDetailRequest.postExecuteLike(params).then(res => {
if (this.newsStatusOfUser) {
this.newsStatusOfUser.likeStatus = this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1'
if (this.newsStatusOfUser.likeStatus === '1') {
this.interactDataDTO.likeNum = Number(this.interactDataDTO.likeNum) + 1
} else {
this.interactDataDTO.likeNum = Number(this.interactDataDTO.likeNum) - 1
}
console.log('点赞、取消点赞==', this.newsStatusOfUser?.likeStatus, this.interactDataDTO?.likeNum)
// this.queryContentInteractCount()
}
})
}
}
interface radiusType {
... ...
... ... @@ -12,7 +12,7 @@ import {
} from 'wdBean';
import DetailViewModel from '../viewmodel/DetailViewModel';
import { ImageAndTextWebComponent } from './ImageAndTextWebComponent';
import router from '@ohos.router';
import { OperRowListView } from './view/OperRowListView';
import { RecommendList } from '../components/view/RecommendList'
import { CommonConstants } from 'wdConstant';
import { HttpUrlUtils } from 'wdNetwork/Index';
... ... @@ -74,6 +74,45 @@ export struct ImageAndTextPageComponent {
isPageEnd: $isPageEnd
})
Column() {
// 点赞
if (this.contentDetailData[0]?.openLikes) {
// 点赞
Row() {
Row() {
if (this.newsStatusOfUser?.likeStatus === '1') {
Image(this.contentDetailData[0]?.likesStyle === 1 ? $r('app.media.ic_like_check') : (this.contentDetailData[0]?.likesStyle === 2 ? $r('app.media.icon_prayer_active') : $r('app.media.icon_candle_active')))
.width(24)
.height(24)
.margin({ right: 5 })
} else {
Image(this.contentDetailData[0]?.likesStyle === 1 ? $r('app.media.icon_like') : (this.contentDetailData[0]?.likesStyle === 2 ? $r('app.media.icon_prayer') : $r('app.media.icon_candle')))
.width(24)
.height(24)
.margin({ right: 5 })
}
Text(`${this.interactData?.likeNum || 0}`)
.fontSize(16)
.fontColor(this.newsStatusOfUser?.likeStatus === '1' ? '#ED2800' : '#999999')
.fontWeight(500)
}
.width(140)
.height(36)
.justifyContent(FlexAlign.Center)
.alignItems(VerticalAlign.Center)
.borderRadius(20)
.border({
width: 1,
color: '#EDEDED',
})
.onClick(() => {
this.toggleLikeStatus()
})
}.width(CommonConstants.FULL_WIDTH).height(80)
.justifyContent(FlexAlign.Center)
Divider().strokeWidth(6).color('#f5f5f5')
}
if (this.recommendList.length > 0) {
RecommendList({ recommendList: this.recommendList })
}
... ... @@ -91,42 +130,7 @@ export struct ImageAndTextPageComponent {
}
//底部交互区
Row() {
Image($r('app.media.icon_arrow_left'))
.width(24)
.height(24)
.onClick((event: ClickEvent) => {
router.back()
})
Row() {
Image($r('app.media.icon_comment'))
.width(24)
.height(24)
.margin({ right: 24 })
.id('comment')
Image($r('app.media.icon_star'))
.width(24)
.height(24)
.margin({ right: 24 })
Image($r('app.media.icon_listen'))
.width(24)
.height(24)
.margin({ right: 24 })
Image($r('app.media.icon_forward'))
.width(24)
.height(24)
}
}
.width(CommonConstants.FULL_WIDTH)
.height(56)
.padding({ left: 15, right: 15, bottom: 50, top: 20 })
.justifyContent(FlexAlign.SpaceBetween)
.backgroundColor(Color.White)
OperRowListView({ contentDetailData: this.contentDetailData[0] })
}
}
... ...
... ... @@ -6,7 +6,8 @@ import {
H5ReceiveDetailBean,
ResponseBean
} from 'wdBean';
import { Logger } from 'wdKit';
import { Logger, SPHelper, NetworkUtil } from 'wdKit';
import { SpConstants } from 'wdConstant';
import { WdWebLocalComponent } from 'wdWebComponent';
import { NativeCallH5Type } from 'wdWebComponent/src/main/ets/pages/NativeCallH5Type';
import { BridgeWebViewControl } from 'wdJsBridge/Index';
... ... @@ -22,7 +23,7 @@ export struct ImageAndTextWebComponent {
private webPrepared = false;
private dataPrepared = false;
onDetailDataUpdated() {
async onDetailDataUpdated() {
if (this.action) {
let contentId: string = ''
let contentType: string = ''
... ... @@ -30,6 +31,8 @@ export struct ImageAndTextWebComponent {
let channelId: string = ''
let compId: string = ''
let sourcePage: string = '5'
let creatorId = await SPHelper.default.get(SpConstants.USER_CREATOR_ID, '') || ''
let isLogin = await SPHelper.default.get(SpConstants.USER_STATUS, '') || '0'
if (this.action.params) {
if (this.action.params.contentID) {
contentId = this.action.params?.contentID
... ... @@ -56,9 +59,9 @@ export struct ImageAndTextWebComponent {
// TODO 对接user信息、登录情况
let h5ReceiveDataExtraBean: H5ReceiveDataExtraBean = {
creatorId: '',
isLogin: '0',
networkStatus: 1,
creatorId: creatorId,
isLogin: isLogin,
networkStatus: Number(NetworkUtil.isNetConnected()),
loadImageOnlyWifiSwitch: '2',
} as H5ReceiveDataExtraBean
... ...
/**
* 直播详情 关注相关信息
*/
import {
ContentDetailRequest,
postInteractAccentionOperateParams
} from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest';
import { postBatchAttentionStatusParams, RmhInfoDTO } from 'wdBean/Index';
import { SpConstants } from 'wdConstant/Index';
import { Logger, SPHelper } from 'wdKit/Index';
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import { MultiPictureDetailViewModel } from '../../viewmodel/MultiPictureDetailViewModel';
const TAG = 'LiveFollowComponent'
@Component
export struct LiveFollowComponent {
@Prop rmhInfo: RmhInfoDTO
aboutToAppear(): void {
this.getBatchAttentionStatus()
}
/**
* 默认未关注 点击去关注
*/
@State followStatus: String = '0';
build() {
Stack() {
Stack()
.height(22)
.width(130)
.backgroundColor('#000000')
.opacity(0.3)
.borderRadius({
topLeft: 90,
bottomLeft: 90
})
Row() {
Image(this.rmhInfo.rmhHeadUrl)
.width(24)
.height(24)
.borderRadius(90)
Text(this.rmhInfo.rmhName)
.fontColor(Color.White)
.maxLines(1)
.fontWeight(500)
.fontSize('12fp')
.layoutWeight(1)
.margin({
left: 4,
right: 6
})
Blank()
Text(this.followStatus === '0' ? '关注' : '已关注')
.fontColor(Color.White)
.fontWeight(500)
.fontSize('10fp')
.padding({
left: 8,
right: 8,
top: 3,
bottom: 3
})
.borderRadius(2)
.margin({ right: 2 })
.backgroundColor(this.followStatus === '0' ? $r('app.color.color_ED2800') : $r('app.color.color_CCCCCC'))
.onClick(() => {
this.handleAccention()
})
}
.height(22)
.width(130)
}
}
/**
* 查询当前登录用户是否关注作品号主
* */
private async getBatchAttentionStatus() {
try {
const params: postBatchAttentionStatusParams = {
creatorIds: [{ creatorId: this.rmhInfo?.rmhId ?? '' }]
}
let data = await MultiPictureDetailViewModel.getBatchAttentionStatus(params)
this.followStatus = data[0]?.status;
Logger.info(TAG, `followStatus:${JSON.stringify(this.followStatus)}`)
} catch (exception) {
}
}
/**
* 关注号主
*/
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('关注号主==', JSON.stringify(res.data))
if (this.followStatus == '1') {
this.followStatus = '0'
} else {
this.followStatus = '1'
}
})
}
}
\ No newline at end of file
... ...
... ... @@ -20,6 +20,7 @@ export struct Card5Component {
// newsTitle: '今天是周日,天气阴天,明天是周一。',
// objectType: '6'
} as ContentDTO;
@State titleShowPolicy: number | string = 1
build() {
Stack() {
... ... @@ -27,7 +28,7 @@ export struct Card5Component {
.width(CommonConstants.FULL_WIDTH)
.autoResize(true)
.borderRadius($r('app.float.image_border_radius'))
if (this.contentDTO.titleShow === 1 && this.contentDTO.newsTitle) {
if ((this.titleShowPolicy === 1 || this.contentDTO.titleShow === 1) && this.contentDTO.newsTitle) {
Row()
.width(CommonConstants.FULL_WIDTH)
.height(59)
... ...
... ... @@ -87,6 +87,10 @@ export class commentItemModel {
maxLine: number = 3
/*是否有展示更多*/
hasMore: boolean = false
/*展开子评论的状态下是否有展开更多*/
childsHasMore: boolean = false
/*子评论pageNum*/
pageNum:number = 1
/*当有展示更多的时候,当前的状态是展开还是收起*/
expanded: boolean = false
/*是否正在加载子评论*/
... ...
@Observed
export class publishCommentModel {
/*被评论的内容id*/
//页面必传
/*被评论的内容id 页面必传*/
targetId: string = ""
/*被评论的内容关系id*/
/*被评论的内容关系id 页面必传*/
targetRelId: string = ""
/*1.文字 2.文字+表情 3.定制表情(客户端写死) 4.图片*/
commentType: string = '1'
/*根评论id,如果是一级评论,传-1;否则,传当前评论所属的根评论id*/
rootCommentId: string = "-1"
/*【迭代二新增】内容的标题,取bff内容详情接口中newsTitle字段*/
/*【迭代二新增】内容的标题,取bff内容详情接口中newsTitle字段 页面必传*/
targetTitle: string = ""
/*被评论的内容关系类型,1.频道关系;2.专题关系;【人民号内容为空】默认0*/
/*被评论的内容关系类型,1.频道关系;2.专题关系;【人民号内容为空】默认0 页面必传*/
targetRelType: string = ''
/*【迭代二新增】关联的频道id/专题id;*/
/*【迭代二新增】关联的频道id/专题id; 页面必传*/
targetRelObjectId: string = ""
/*【迭代二新增】是否是重点稿件 1是 0否 页面必传*/
keyArticle: string = ''
/*内容类别, 1:点播,2:直播,3:活动,4:广告,5:专题,6:链接,7:榜单,8:图文,9:组图,10:H5新闻,11:频道,12:组件,13:音频,14:动态(13和14为中文版新增) 页面必传*/
targetType: string = ''
/*评论总数*/
totalCommentNumer: string = ''
//评论传参
/*评论图片url,多个逗号隔开*/
commentPics: string = ""
/*评论内容*/
commentContent: string = ""
/*【迭代二新增】是否是重点稿件 1是 0否*/
keyArticle: string = ''
/*内容类别, 1:点播,2:直播,3:活动,4:广告,5:专题,6:链接,7:榜单,8:图文,9:组图,10:H5新闻,11:频道,12:组件,13:音频,14:动态(13和14为中文版新增)*/
targetType: string = ''
/*1.文字 2.文字+表情 3.定制表情(客户端写死) 4.图片*/
commentType: string = '1'
/*根评论id,如果是一级评论,传-1;否则,传当前评论所属的根评论id*/
rootCommentId: string = "-1"
/*父评论id,如果是其它评论的回复,该字段必填*/
parentId: string = "-1"
//可选
placeHolderText: string = "优质评论会获得最佳评论人的称号"
}
... ...
... ... @@ -12,45 +12,23 @@ import { ifaa } from '@kit.OnlineAuthenticationKit';
const TAG = 'CommentComponent';
const testString = '因为读书的人\n是低着头向上看的人\n身处一隅,却能放眼世界\n2,因为读书的人\n总是比不读书的人\n活得有趣一点\n3,因为读书的人\n即使平凡,绝不平庸'
// @Entry
@Preview
@Component
export struct CommentComponent {
@State contentId: string = '30004266013'
/*内容类别, 1:点播,2:直播,3:活动,4:广告,5:专题,6:链接,7:榜单,8:图文,9:组图,10:H5新闻,11:频道,12:组件,13:音频,14:动态(13和14为中文版新增)*/
@State contentType: string = '8'
/*内容的标题,取bff内容详情接口中newsTitle字段*/
@State targetTitle: string = '北约同意向乌克兰提供防空系统在内的更多军事支持'
/*被评论的内容关系id*/
@State targetRelId: string = "500002849023"
/*关联的频道id/专题id*/
@State targetRelObjectId: string = "2002"
/*是否是重点稿件 1是 0否*/
@State keyArticle: string = "0"
/*被评论的内容关系类型,1.频道关系;2.专题关系;【人民号内容为空】默认0*/
@State targetRelType: string = "1"
// @State private browSingModel: commentListModel = new commentListModel()
/*必传*/
@ObjectLink publishCommentModel: publishCommentModel
isloading: boolean = false
@State allDatas: LazyDataSource<commentItemModel> = new LazyDataSource();
@State publishCommentModel: publishCommentModel = new publishCommentModel()
@State dialogController: CustomDialogController | null = new CustomDialogController({
builder: CommentCustomDialog({
confirm: (value: Record<string, string>) => {
this.publishComment(value)
},
commentText: this.publishCommentModel.commentContent,
placeHolderText: this.publishCommentModel.placeHolderText,
}),
autoCancel: true,
alignment: DialogAlignment.Bottom,
customStyle: true,
offset: {
dx: 0,
dy: -20
},
})
@State dialogController: CustomDialogController | null = null;
// 在自定义组件即将析构销毁时将dialogControlle置空
aboutToDisappear() {
... ... @@ -58,13 +36,22 @@ export struct CommentComponent {
}
aboutToAppear() {
this.publishCommentModel.targetTitle = this.targetTitle
this.publishCommentModel.targetId = this.contentId
this.publishCommentModel.targetType = this.contentType
this.publishCommentModel.targetRelId = this.targetRelId
this.publishCommentModel.targetRelType = this.targetRelType
this.publishCommentModel.targetRelObjectId = this.targetRelObjectId
this.publishCommentModel.keyArticle = this.keyArticle
this.dialogController = new CustomDialogController({
builder: CommentCustomDialog({
confirm: (value: Record<string, string>) => {
},
publishCommentModel:this.publishCommentModel
}),
autoCancel: true,
alignment: DialogAlignment.Bottom,
customStyle: true,
offset: {
dx: 0,
dy: -20
},
})
this.getData();
... ... @@ -105,7 +92,7 @@ export struct CommentComponent {
/*查看更多和收起*/
@Builder
GroupFooterView(item: commentItemModel, index: number) {
footerExpandedView({ item: item, contentId: this.contentId, contentType: this.contentType })
footerExpandedView({ item: item, contentId: this.publishCommentModel.targetId, contentType: this.publishCommentModel.targetType })
}
build() {
... ... @@ -152,13 +139,13 @@ export struct CommentComponent {
//获取数据
async getData() {
commentViewModel.fetchContentCommentList('1', this.contentId, this.contentType).then(commentListModel => {
commentViewModel.fetchContentCommentList('1', this.publishCommentModel.targetId, this.publishCommentModel.targetType).then(commentListModel => {
if (commentListModel && commentListModel.list && commentListModel.list.length > 0) {
commentListModel.list.forEach(element => {
element.hasMore = Number.parseInt(element.childCommentNum) ? true : false
let newModel = commentViewModel.deepCopyCommentItemModel(element)
newModel.targetId = this.contentId
newModel.targetType = this.contentType
// newModel.targetId = this.publishCommentModel.targetId
// newModel.targetType = this.publishCommentModel.targetType
this.allDatas.push(newModel)
});
... ... @@ -167,20 +154,6 @@ export struct CommentComponent {
})
}
/*回复评论*/
publishComment(value: Record<string, string>) {
this.publishCommentModel.commentContent = value['commentContent']
this.publishCommentModel.commentType = value['commentType']
commentViewModel.publishComment(this.publishCommentModel).then(() => {
this.publishCommentModel.commentContent = ''
}).catch(() => {
})
}
}
... ... @@ -230,7 +203,7 @@ struct ChildCommentItem {
.fontSize(14)
.fontColor($r('app.color.color_222222'))
.fontWeight(FontWeight.Medium)
.margin({ left: 0 , right:0})
.margin({ left: 0, right: 0 })
/// 暂时不显示 “我” 的标签了
... ... @@ -257,10 +230,12 @@ struct ChildCommentItem {
.margin({ left: 5 });
}
}.margin({ left: 0, right: 16 })
// .backgroundColor(Color.Red)
CommentText({
longMessage: this.item.commentContent,
// longMessage:testString,
maxline: 3,
fontSize: 14,
fontWeight: FontWeight.Regular,
... ... @@ -297,12 +272,27 @@ struct footerExpandedView {
build() {
Row() {
if (this.item.expanded) {
if (this.item.childsHasMore) {
Row() {
Text().backgroundColor($r('app.color.color_EDEDED')).width(24).height(1)
Text('查看更多回复').fontColor($r('app.color.color_222222')).fontSize(14).margin({ left: 6 })
Image($r('app.media.comment_unfold')).width(12).height(12)
}.margin({ left: 53 })
.onClick(() => {
if (this.item.isLoading) {
return
}
this.item.isLoading = true
fetchChildContentCommentList(this.contentId, this.contentType, this.item)
})
}
Row() {
Text('收起').fontColor($r('app.color.color_222222')).fontSize(14)
Image($r('app.media.comment_pickUp')).width(12).height(12)
}.margin({ left: 213 })
}.margin({ left: this.item.childsHasMore ? 32 : 213 })
.onClick(() => {
this.item.expanded = !this.item.expanded
this.item.pageNum = 1
this.item.expanded = false
this.item.childComments = []
this.item.childCommentsLazyDataSource.clear()
})
... ... @@ -317,28 +307,35 @@ struct footerExpandedView {
return
}
this.item.isLoading = true
//load child
commentViewModel.fetchChildContentCommentList('1', this.contentId, this.contentType, this.item.id)
.then((commentListModel) => {
this.item.isLoading = false
this.item.expanded = !this.item.expanded
commentListModel.list.forEach(element => {
this.item.childComments.push(element)
let newModel = commentViewModel.deepCopyCommentItemModel(element)
newModel.targetId = this.contentId
newModel.targetType = this.contentType
this.item.childCommentsLazyDataSource.push(newModel)
})
}).catch(() => {
this.item.isLoading = false
})
fetchChildContentCommentList(this.contentId, this.contentType, this.item)
})
}
}.height(30)
}
}
function fetchChildContentCommentList(contentId: string, contentType: string, item: commentItemModel) {
commentViewModel.fetchChildContentCommentList(item.pageNum + '', contentId, contentType, item.id)
.then((commentListModel) => {
item.pageNum = item.pageNum + 1
item.childsHasMore = commentListModel.hasNext > 0 ? true : false
item.isLoading = false
item.expanded = true
commentListModel.list.forEach(element => {
item.childComments.push(element)
let newModel = commentViewModel.deepCopyCommentItemModel(element)
newModel.targetId = contentId
newModel.targetType = contentType
item.childCommentsLazyDataSource.push(newModel)
})
}).catch(() => {
item.isLoading = false
})
}
@Component
struct commentHeaderView {
@Link publishCommentModel: publishCommentModel
... ... @@ -411,7 +408,14 @@ struct commentHeaderView {
marginWidth: (59 + 16)
})
.margin({ left: 59, right: 16, top: -5 })
.onClick(() => {
this.publishCommentModel.rootCommentId = this.item.rootCommentId
this.publishCommentModel.parentId = this.item.id
this.publishCommentModel.placeHolderText = '回复' + this.item.fromUserName + ':'
if (this.dialogController != null) {
this.dialogController.open()
}
})
commentFooterView({
item: this.item,
... ... @@ -456,7 +460,12 @@ struct commentFooterView {
.fontColor($r('app.color.color_222222'))
.fontSize(12)
.onClick(() => {
//TODO: 回复
this.publishCommentModel.rootCommentId = this.item.rootCommentId
this.publishCommentModel.parentId = this.item.id
this.publishCommentModel.placeHolderText = '回复' + this.item.fromUserName + ':'
if (this.dialogController != null) {
this.dialogController.open()
}
})
}
... ...
... ... @@ -5,27 +5,51 @@ import commentViewModel from '../viewmodel/CommentViewModel'
@Preview
@CustomDialog
export struct CommentCustomDialog {
commentText: string = ''
placeHolderText: string = '优质评论会获得最佳评论人的称号'
@ObjectLink publishCommentModel: publishCommentModel
controller?: CustomDialogController
confirm: (value: Record<string, string>) => void = () => {
}
@State private emojiSwitch: boolean = false
textInputController: TextAreaController = new TextAreaController()
aboutToAppear(): void {
}
publishCommentRequest() {
let bean: Record<string, string> = {};
// this.publishCommentModel.commentContent = this.commentText
//TODO 判断类型
this.publishCommentModel.commentType = '1'
commentViewModel.publishComment(this.publishCommentModel).then(() => {
this.publishCommentModel.commentContent = ''
// this.commentText = ''
if (this.controller != null) {
this.controller.close()
}
this.confirm(bean)
}).catch(() => {
if (this.controller != null) {
this.controller.close()
}
})
}
build() {
Column() {
Row() {
TextArea({
placeholder: this.placeHolderText,
placeholder: this.publishCommentModel.placeHolderText,
controller: this.textInputController,
text: this.commentText
text: this.publishCommentModel.commentContent
})
.height('100%')
.width('100%')
.backgroundColor($r('app.color.color_transparent'))
.onChange(value => {
this.commentText = value;
this.publishCommentModel.commentContent = value;
})
}
.backgroundColor('#F9F9F9')
... ... @@ -68,18 +92,11 @@ export struct CommentCustomDialog {
.textAlign(TextAlign.Center)
.borderRadius(4)
.onClick(() => {
if (this.commentText.length > 0) {
if (this.publishCommentModel.commentContent.length > 0) {
//请求评论接口
//commentType
//commentContent
let bean: Record<string, string> = {};
bean['commentContent'] = this.commentText
//TODO 判断类型
bean['commentType'] = '1'
this.confirm(bean)
if (this.controller != null) {
this.controller.close()
}
this.publishCommentRequest()
}
})
}
... ...
import { publishCommentModel } from '../model/PublishCommentModel'
@Preview
@Component
export struct CommentTabComponent {
@ObjectLink publishCommentModel: publishCommentModel
build() {
}
}
\ No newline at end of file
... ...
... ... @@ -44,7 +44,8 @@ export struct CommentText {
textContent: this.longMessage,
fontSize: this.fontSize,
fontWeight: this.fontWeight,
constraintWidth: (this.screenWidth - padding)
constraintWidth: (this.screenWidth - padding),
wordBreak:WordBreak.BREAK_ALL
})
console.log(`文本宽度为:${this.textWidth}`)
... ... @@ -71,7 +72,8 @@ export struct CommentText {
textContent: string,
fontSize: this.fontSize,
fontWeight: this.fontWeight,
constraintWidth: (this.screenWidth - padding)
constraintWidth: (this.screenWidth - padding),
wordBreak:WordBreak.BREAK_ALL
})
//计算有误差20
... ... @@ -130,6 +132,7 @@ export struct CommentText {
.fontWeight(this.fontWeight)
.fontColor(this.fontColor)
.maxLines(this.lines)
.wordBreak(WordBreak.BREAK_ALL)
// .backgroundColor(Color.Red)
... ...
... ... @@ -8,6 +8,10 @@ import { MyCommentDataSource } from '../model/MyCommentDataSource'
import { HttpUtils } from 'wdNetwork/src/main/ets/utils/HttpUtils'
import { HttpUrlUtils } from 'wdNetwork/Index'
import PageModel from '../../../viewmodel/PageModel'
import { ErrorComponent } from '../../view/ErrorComponent'
import { EmptyComponent , WDViewDefaultType} from '../../view/EmptyComponent'
import { CustomPullToRefresh } from '../../reusable/CustomPullToRefresh'
import NoMoreLayout from '../../page/NoMoreLayout'
const TAG = 'QualityCommentsComponent';
... ... @@ -16,8 +20,13 @@ const TAG = 'QualityCommentsComponent';
@Component
export struct QualityCommentsComponent {
@State private browSingModel: PageModel = new PageModel()
isloading : boolean = false
//刷新
@State viewType:number = ViewType.LOADING;
@State hasMore: boolean = true;
@State currentPage: number = 1;
private scroller: Scroller = new Scroller();
@State tileOpacity: number = 0;
firstPositionY: number = 0;
... ... @@ -25,7 +34,7 @@ export struct QualityCommentsComponent {
topSafeHeight: number = AppStorage.get<number>('topSafeHeight') as number;
lastWindowColor: string = '#ffffff'
currentWindowColor: string = '#FF4202'
@State allDatas: MyCommentDataSource = new MyCommentDataSource();
@State allDatas: LazyDataSource<commentItemModel> = new LazyDataSource();
aboutToDisappear(): void {
... ... @@ -40,14 +49,31 @@ export struct QualityCommentsComponent {
aboutToAppear(): void {
this.fullScreen();
this.getData();
}
getData(resolve?: (value: string | PromiseLike<string>) => void){
commentViewModel.fetchQualityCommentList(this.currentPage + '').then((commentListModel) => {
if(resolve) resolve('刷新成功')
commentViewModel.fetchQualityCommentList('1').then((commentListModel) => {
if (commentListModel && commentListModel.list && commentListModel.list.length > 0) {
if (this.currentPage === 1) {
this.allDatas.clear()
}
commentListModel.list.forEach(element => {
this.allDatas.pushData(commentViewModel.deepCopyCommentItemModel(element))
this.allDatas.push(commentViewModel.deepCopyCommentItemModel(element))
});
} else {
if (commentListModel.hasNext === 0) {
this.hasMore = false;
} else {
this.hasMore = true;
}
} else {
if (this.currentPage === 1) {
this.viewType = ViewType.EMPTY;
}
}
})
}
... ... @@ -151,36 +177,46 @@ export struct QualityCommentsComponent {
build() {
Column() {
Stack({ alignContent: Alignment.Top }) {
Scroll() {
Column() {
Stack() {
this.titleHeader()
this.listLayout()
// if(this.viewType == ViewType.ERROR){
// ErrorComponent()
// }else if(this.viewType == ViewType.EMPTY){
// EmptyComponent({emptyType:WDViewDefaultType.WDViewDefaultType_NoComment})
// }else {
// CustomPullToRefresh({
// alldata:[],
// scroller:this.scroller,
// customList:()=>{
// // this.listLayout()
// this.testLayout()
// },
// onRefresh:(resolve)=>{
// this.currentPage = 1
// this.getData(resolve)
// },
// onLoadMore:(resolve)=> {
// if (this.hasMore === false) {
// if(resolve) resolve('')
// return
// }
// this.currentPage++
// this.getData(resolve)
// }
// })
// }
List({ space: 12 }) {
// ListItemGroup({ header: this.titleHeader() })
LazyForEach(this.allDatas, (item: commentItemModel, index: number) => {
ListItem() {
QualityCommentItem({ item: item, index: index }).margin({ left: 12, right: 12 })
}
})
ListItem() {
}.height(this.bottomSafeHeight)
}
.margin({ top: 196 })
.height("100%")
.width("100%")
.edgeEffect(EdgeEffect.Spring)
.nestedScroll({
scrollForward: NestedScrollMode.PARENT_FIRST,
scrollBackward: NestedScrollMode.SELF_FIRST
})
// .margin({ bottom: this.bottomSafeHeight })
// .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM])
}.alignContent(Alignment.Top)
}.backgroundColor(this.currentWindowColor).width('100%')
}
... ... @@ -193,15 +229,57 @@ export struct QualityCommentsComponent {
this.TabbarTransparent()
this.TabbarNormal()
}
}
}
@Builder
listLayout(){
List({ space: 12, scroller:this.scroller }) {
// ListItemGroup({ header: this.titleHeader() })
LazyForEach(this.allDatas, (item: commentItemModel, index: number) => {
ListItem() {
QualityCommentItem({ item: item, index: index }).margin({ left: 12, right: 12 })
}
})
// 加载更多
ListItem() {
if (this.hasMore === false) NoMoreLayout()
}
ListItem() {
}.height(this.bottomSafeHeight)
}
.margin({ top: 196 })
.height("100%")
.width("100%")
.edgeEffect(EdgeEffect.None) // 必须设置列表为滑动到边缘无效果
// .edgeEffect(EdgeEffect.Spring)
.nestedScroll({
scrollForward: NestedScrollMode.PARENT_FIRST,
scrollBackward: NestedScrollMode.SELF_FIRST
})
}
@Builder
testLayout(){
List({ space: 12, scroller:this.scroller }){
LazyForEach(this.allDatas, (item: commentItemModel, index: number) => {
ListItem() {
// QualityCommentItem({ item: item, index: index }).margin({ left: 12, right: 12 })
}
})
}
}
}
@Component
struct QualityCommentItem {
@ObjectLink item: commentItemModel
... ... @@ -316,10 +394,10 @@ struct QualityCommentItem {
.margin({ left: 3 })
}
}.onClick(() => {
commentViewModel.commnetLikeChange(this.item)
commentLikeChange(this.item)
commentViewModel.commentLike(this.item).then(() => {
}).catch(() => {
commentViewModel.commnetLikeChange(this.item)
commentLikeChange(this.item)
})
})
}
... ... @@ -331,5 +409,24 @@ struct QualityCommentItem {
}
}
function commentLikeChange(item: commentItemModel) {
item.api_status = !item.api_status
//点赞
if (item.api_status) {
if (item.likeNum.length > 0) {
item.likeNum = (Number.parseInt(item.likeNum) + 1) + ''
} else {
item.likeNum = '1'
}
}
//取消点赞
if (!item.api_status) {
item.likeNum = (Number.parseInt(item.likeNum) - 1) + ''
if (Number.parseInt(item.likeNum) <= 0) {
item.likeNum = ''
}
}
}
... ...
... ... @@ -239,52 +239,53 @@ class CommentViewModel {
let promiseArray: Promise<commentStatusListModel | void>[] = [];
//TODO 未登录不用批查
if (commentIDs.length > 0) {
let promise1 = new Promise<void>((success) => {
// HttpRequest HttpBizUtil
let url = HttpUrlUtils.getBatchCommentStatusUrl();
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
let bean: Record<string, string[]> = {};
bean['commentIdList'] = commentIDs;
HttpRequest.post<ResponseDTO<commentStatusModel[]>>(url, bean, headers).then((data: ResponseDTO<commentStatusModel[]>) => {
if (!data || !data.data) {
success()
return
}
if (data.code != 0) {
success()
return
}
if (data.data.length == 0) {
success()
return
}
let listData = data.data as commentStatusModel[]
//点赞
for (const element of listData) {
for (const commentModel of model.list) {
if (element.commentId == commentModel.id) {
commentModel.api_status = element.status
}
if (commentModel.childComments) {
for (const childCommentModel of commentModel.childComments) {
if (element.commentId == childCommentModel.id) {
childCommentModel.api_status = element.status
//未登录不用批查
if (HttpUrlUtils.getUserId()){
if (commentIDs.length > 0) {
let promise1 = new Promise<void>((success) => {
// HttpRequest HttpBizUtil
let url = HttpUrlUtils.getBatchCommentStatusUrl();
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
let bean: Record<string, string[]> = {};
bean['commentIdList'] = commentIDs;
HttpRequest.post<ResponseDTO<commentStatusModel[]>>(url, bean, headers).then((data: ResponseDTO<commentStatusModel[]>) => {
if (!data || !data.data) {
success()
return
}
if (data.code != 0) {
success()
return
}
if (data.data.length == 0) {
success()
return
}
let listData = data.data as commentStatusModel[]
//点赞
for (const element of listData) {
for (const commentModel of model.list) {
if (element.commentId == commentModel.id) {
commentModel.api_status = element.status
}
if (commentModel.childComments) {
for (const childCommentModel of commentModel.childComments) {
if (element.commentId == childCommentModel.id) {
childCommentModel.api_status = element.status
}
}
}
}
}
}
success()
}, (error: Error) => {
success()
Logger.debug(TAG, error.toString())
success()
}, (error: Error) => {
success()
Logger.debug(TAG, error.toString())
})
})
})
promiseArray.push(promise1);
}
promiseArray.push(promise1);
}
}
if (fromUserIDs.length > 0) {
let promise2 = new Promise<void>((success) => {
let url = HttpUrlUtils.getBatchUserUrl();
... ... @@ -385,21 +386,7 @@ class CommentViewModel {
}
commnetLikeChange(model: commentItemModel) {
model.api_status = !model.api_status
//点赞
if (model.api_status) {
model.likeNum = (Number.parseInt(model.likeNum) + 1) + ''
}
//取消点赞
if (!model.api_status) {
model.likeNum = (Number.parseInt(model.likeNum) - 1) + ''
if (Number.parseInt(model.likeNum) < 0) {
model.likeNum = '0'
}
}
// return model
}
deepCopyCommentItemModel(model: commentItemModel) {
let newModel = new commentItemModel()
... ...
... ... @@ -88,11 +88,11 @@ export struct ZhCarouselLayout01 {
.curve(Curve.Linear)
.autoPlay(this.isAutoPlay())
.onAnimationStart((index: number, targetIndex: number) => {
Logger.info(TAG, `Swiper onAnimationStart index : ${index}, targetIndex: ${targetIndex}`);
// Logger.info(TAG, `Swiper onAnimationStart index : ${index}, targetIndex: ${targetIndex}`);
this.swiperIndex = targetIndex
})
.onChange((index: number) => {
Logger.info(TAG, `Swiper onChange index : ${index}`);
// Logger.info(TAG, `Swiper onChange index : ${index}`);
})
.onAnimationEnd((index: number, extraInfo: SwiperAnimationEvent) => {
... ... @@ -100,7 +100,7 @@ export struct ZhCarouselLayout01 {
setTimeout(() => {
this.SecondWd = 12
}, 2000)
console.info("onAnimationEnd, index: " + index)
// console.info("onAnimationEnd, index: " + index)
})
if (this.compDTO?.operDataList.length > 1) {
... ...
... ... @@ -65,7 +65,11 @@ export struct ZhGridLayout03 {
}
.width('100%')
.onClick((event: ClickEvent) => {
ProcessUtils.processPage(item)
if (item.objectType === '11') {
ProcessUtils.jumpChannelTab(item.objectId, item.pageId)
} else {
ProcessUtils.processPage(item)
}
})
}
}
... ...
... ... @@ -15,8 +15,14 @@ const TAG = 'Zh_Single_Column-09'
@Component
export struct ZhSingleColumn09 {
@State compDTO: CompDTO = {} as CompDTO
@State list: Array<string> = ['社会', '三个字', '是四个字', '时事', '社会', '三个字', '是四个字', '时事']
@State activeIndexs: Array<number> = []
@State operDataList: ContentDTO[] = this.compDTO?.operDataList || []
@State selfClosed: Boolean = false;
aboutToAppear(): void {
this.operDataList = this.shuffleArray(this.compDTO?.operDataList)
}
getItemWidth(index: number) {
if (index % 4 === 0 || index % 4 === 3) {
... ... @@ -26,12 +32,56 @@ export struct ZhSingleColumn09 {
}
}
shuffleArray(array: ContentDTO[]) {
for(let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
const tempArray = array[i];
array[i] = array[j];
array[j] = tempArray
}
return array
}
build() {
Column() {
//顶部
this.CompHeader(this.compDTO)
Row() {
Column() {
Text('以下是否有您感兴趣?')
.fontSize(18)
.fontColor(0x000000)
.fontWeight(600)
.width('70%')
.margin({bottom: 4})
Text('选中标签,为您推荐更多您感兴趣的内容')
.fontSize(12)
.fontColor(0xB0B0B0)
.margin({bottom: 10})
.width('70%')
}
Button('选好了', { type: ButtonType.Normal, stateEffect: false })
.fontColor(this.activeIndexs.length > 0 ? 0xed2800 : 0xB0B0B0)
.fontSize(14)
.width(62)
.height(26)
.backgroundColor(this.activeIndexs.length > 0 ? 0xfdf0ed : 0xf5f5f5)
// .lineHeight(26)
.borderRadius(4)
.margin({top: -10})
.padding({top: 0, bottom: 0, left: 0, right: 0})
.onClick(() => {
if (this.activeIndexs.length > 0) {
this.selfClosed = true;
}
})
}
.justifyContent(FlexAlign.SpaceBetween)
.width('100%')
Grid() {
ForEach(this.compDTO.operDataList, (item: ContentDTO, index: number) => {
ForEach(this.operDataList, (item: ContentDTO, index: number) => {
GridItem() {
Stack({alignContent: Alignment.TopEnd}) {
Image(item.coverUrl)
... ... @@ -73,17 +123,24 @@ export struct ZhSingleColumn09 {
Row() {
Text('换一换')
.fontSize(14)
.fontColor(0xed2800)
.fontColor(this.compDTO?.operDataList.length > 8 ? 0xed2800 : 0xB0B0B0)
.margin({right: 4})
Image($r('app.media.icon_refresh'))
Image(this.compDTO?.operDataList.length > 8 ? $r('app.media.icon_refresh') : $r('app.media.ic_refresh'))
.width(14)
.height(14)
}
.onClick(() => {
if (this.compDTO?.operDataList.length > 8) {
this.operDataList = this.shuffleArray(this.operDataList)
this.activeIndexs = [];
}
})
Image($r("app.media.close_button"))
.width(14)
.height(14)
.onClick(() => {
this.selfClosed = true;
})
}
.height(40)
... ... @@ -98,42 +155,7 @@ export struct ZhSingleColumn09 {
bottom: $r('app.float.card_comp_pagePadding_tb')
})
.backgroundColor($r('app.color.white'))
.margin({ bottom: 8 })
}
@Builder
CompHeader(item: CompDTO) {
Row() {
Column() {
Text('以下是否有您感兴趣?')
.fontSize(18)
.fontColor(0x000000)
.fontWeight(600)
.width('70%')
.margin({bottom: 4})
Text('选中标签,为您推荐更多您感兴趣的内容')
.fontSize(12)
.fontColor(0xB0B0B0)
.margin({bottom: 10})
.width('70%')
}
Text('选好了')
.fontColor(0xed2800)
.fontSize(14)
.width(62)
.height(26)
.backgroundColor(0xfdf0ed)
.textAlign(TextAlign.Center)
// .lineHeight(26)
.borderRadius(4)
.margin({top: -10})
}
.justifyContent(FlexAlign.SpaceBetween)
.width('100%')
.visibility(this.selfClosed ? Visibility.None : Visibility.Visible)
}
}
... ...
... ... @@ -70,9 +70,7 @@ export struct ZhSingleRow02 {
.height(14)
.onClick(() => {
// TODO 跳转的页面,定义的入参可能不合理。推荐id: 41
let params: Params = {
pageID: "1"
}
let params = {'index': "1"} as Record<string, string>
WDRouterRule.jumpWithPage(WDRouterPage.followListPage, params)
})
}
... ... @@ -80,10 +78,13 @@ export struct ZhSingleRow02 {
right: $r('app.float.card_comp_pagePadding_lf'),
})
.onClick(() => {
let params: Params = {
pageID: "1"
if (this.compDTO?.objectType === '11') {
ProcessUtils.jumpChannelTab(this.compDTO.objectId, this.compDTO.pageId as string)
} else if (this.compDTO?.objectType === '5') {
ProcessUtils._gotoSpecialTopic(this.compDTO.linkUrl)
} else if (this.compDTO?.objectType === '6') {
ProcessUtils._gotoDefaultWeb(this.compDTO.linkUrl)
}
WDRouterRule.jumpWithPage(WDRouterPage.followListPage, params)
})
}
.justifyContent(FlexAlign.SpaceBetween)
... ...
... ... @@ -36,6 +36,15 @@ export struct ZhSingleRow04 {
.width(14)
.height(14)
}
.onClick(() => {
if (this.compDTO?.objectType === '11') {
ProcessUtils.jumpChannelTab(this.compDTO.objectId, this.compDTO.pageId as string)
} else if (this.compDTO?.objectType === '5') {
ProcessUtils._gotoSpecialTopic(this.compDTO.linkUrl)
} else if (this.compDTO?.objectType === '6') {
ProcessUtils._gotoDefaultWeb(this.compDTO.linkUrl)
}
})
}
.justifyContent(FlexAlign.SpaceBetween)
.margin({ top: 8, bottom: 8 })
... ...
... ... @@ -83,9 +83,7 @@ export struct ZhSingleRow05 {
.height(14)
.onClick(() => {
// TODO 跳转的页面,定义的入参可能不合理。推荐id: 41
let params: Params = {
pageID: "1"
}
let params = {'index': "1"} as Record<string, string>;
WDRouterRule.jumpWithPage(WDRouterPage.followListPage, params)
})
}
... ...
import { Logger, StringUtils, UserDataLocal } from 'wdKit'
import { StringUtils, UserDataLocal } from 'wdKit'
import { WDRouterPage, WDRouterRule } from 'wdRouter'
import MinePageDatasModel from '../../model/MinePageDatasModel'
const TAG = "MinePageUserSimpleInfoUI"
... ...
... ... @@ -4,6 +4,8 @@ import { ListHasNoMoreDataUI } from '../../reusable/ListHasNoMoreDataUI';
import { MineAppointmentItem } from '../../../viewmodel/MineAppointmentItem';
import { LazyDataSource, StringUtils } from 'wdKit';
import MinePageDatasModel from '../../../model/MinePageDatasModel';
import { EmptyComponent } from '../../view/EmptyComponent';
const TAG = "AppointmentListUI"
@Component
... ... @@ -23,7 +25,9 @@ export struct AppointmentListUI{
//标题栏目
CustomTitleUI({titleName:"预约列表"})
if(this.count == 0){
ListHasNoMoreDataUI({style:2})
EmptyComponent({emptyType:10})
.height('100%')
.width('100%')
}else{
//刷新控件 TODO
//List
... ... @@ -84,6 +88,8 @@ export struct AppointmentListUI{
this.hasMore = false
}
}
}).catch((err:Error)=>{
console.log(TAG,JSON.stringify(err))
})
}
this.isLoading = false
... ...
... ... @@ -15,6 +15,7 @@ export struct ChildCommentComponent {
@State isExpandParent: boolean = false;
@State isOverLines: boolean = false
@State isOverLinesParent: boolean = false
testText:string = "1,因为读书的人\n是低着头向上看的人\n身处一隅,却能放眼世界\n2,因为读书的人\n总是比不读书的人\n活得有趣一点\n3,因为读书的人\n即使平凡,绝不平庸"
build() {
Column() {
... ... @@ -71,7 +72,7 @@ export struct ChildCommentComponent {
})
}
}
.margin({ bottom: '10lpx' })
.margin({ bottom: '5lpx' })
.width('100%')
.height('108lpx')
.padding({ left: '31lpx', right: '31lpx' })
... ... @@ -93,6 +94,7 @@ export struct ChildCommentComponent {
})
}
}.maxLines(5)
.wordBreak(WordBreak.BREAK_ALL)
.textStyle()
}
}.padding({ left: '31lpx', right: '31lpx' })
... ... @@ -138,6 +140,7 @@ export struct ChildCommentComponent {
})
}
}.maxLines(5)
.wordBreak(WordBreak.BREAK_ALL)
.textAlign(TextAlign.Start)
.width('100%')
}
... ... @@ -243,11 +246,13 @@ export struct ChildCommentComponent {
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 = ''
... ... @@ -255,6 +260,7 @@ export struct ChildCommentComponent {
if (measure.measureText({
textContent: clipStr,
fontSize: px2fp(fontSize),
wordBreak:WordBreak.BREAK_ALL
}) >= textWidth * maxLines - measureTruncateWidth) {
if (type === 0) {
this.isOverLines = true
... ...
... ... @@ -89,9 +89,7 @@ export struct HomePageBottomComponent{
.backgroundColor($r('app.color.color_F5F5F5'))
.margin({top:'31lpx',bottom:'4lpx'})
.onClick(()=>{
let params: Params = {
pageID: "1"
}
let params = {'index': "1"} as Record<string, string>
WDRouterRule.jumpWithPage(WDRouterPage.followListPage,params)
})
... ... @@ -128,9 +126,7 @@ export struct HomePageBottomComponent{
.backgroundColor($r('app.color.color_F5F5F5'))
.margin({top:'31lpx',bottom:'4lpx'})
}.onClick(()=>{
let params: Params = {
pageID: "1"
}
let params = {'index': "1"} as Record<string, string>
WDRouterRule.jumpWithPage(WDRouterPage.followListPage,params)
})
... ...
... ... @@ -51,9 +51,7 @@ export struct OtherHomePageBottomFollowComponent{
.backgroundColor($r('app.color.color_F5F5F5'))
.margin({top:'31lpx',bottom:'4lpx'})
.onClick(()=>{
let params: Params = {
pageID: "1"
}
let params = {'index': "1"} as Record<string, string>
WDRouterRule.jumpWithPage(WDRouterPage.followListPage,params)
})
... ... @@ -85,9 +83,7 @@ export struct OtherHomePageBottomFollowComponent{
.backgroundColor($r('app.color.color_F5F5F5'))
.margin({top:'31lpx',bottom:'4lpx'})
}.onClick(()=>{
let params: Params = {
pageID: "1"
}
let params = {'index': "1"} as Record<string, string>;
WDRouterRule.jumpWithPage(WDRouterPage.followListPage,params)
})
... ...
import { BottomNavi, CommonConstants } from 'wdConstant';
import { BottomNavDTO } from 'wdBean';
import { EmitterEventId, EmitterUtils, Logger } from 'wdKit';
import { DateTimeUtils, EmitterEventId, EmitterUtils, Logger } from 'wdKit';
import { TopNavigationComponent } from './TopNavigationComponent';
import { MinePageComponent } from './MinePageComponent';
import { CompUtils } from '../../utils/CompUtils';
... ... @@ -40,11 +40,10 @@ export struct BottomNavigationComponent {
* Component opacity value: 0.6.
*/
readonly SIXTY_OPACITY: number = 0.6;
// 接收指定频道跳转的参数
@State assignChannel: AssignChannelParam = new AssignChannelParam()
// 用于传参到顶导组件,【不用channelParam,主要是时序问题,需要先底导处理完,再延时触发顶导处理】
@State assignChannel1: AssignChannelParam = new AssignChannelParam()
@State assignChannel: AssignChannelParam = new AssignChannelParam()
// 自动刷新触发(双击tab自动刷新)
@State autoRefresh: number = 0
async aboutToAppear() {
Logger.info(TAG, `aboutToAppear currentNavIndex: ${this.currentNavIndex}`);
let bottomNav = await PageViewModel.getBottomNavData(getContext(this))
... ... @@ -60,8 +59,8 @@ export struct BottomNavigationComponent {
Logger.debug(TAG, 'receiveEvent JUMP_HOME_CHANNEL: ' + str)
if (str) {
// 跳转指定频道场景,传参底导id、频道id
this.assignChannel = JSON.parse(str) as AssignChannelParam
this.changeBottomNav()
let assignChannel = JSON.parse(str) as AssignChannelParam
this.changeBottomNav(assignChannel)
}
})
}
... ... @@ -83,9 +82,11 @@ export struct BottomNavigationComponent {
groupId: navItem.id,
topNavList: navItem.topNavChannelList.filter(item => item.channelId != 2073),
_currentNavIndex: $currentNavIndex,
navIndex: index,
currentBottomNavName: navItem.name,
barBackgroundColor: $barBackgroundColor,
assignChannel: this.assignChannel1
assignChannel: this.assignChannel,
autoRefresh: this.autoRefresh
})
}
... ... @@ -100,11 +101,6 @@ export struct BottomNavigationComponent {
.barMode(BarMode.Fixed)
// TODO:更详细的判断是视频频道
.barBackgroundColor(this.barBackgroundColor)
.onChange((index: number) => {
Logger.info(TAG, `onChange, index: ${index}`);
this.currentNavIndex = index;
// this.onBottomNavigationIndexChange()
})
.backgroundColor(this.barBackgroundColor)
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM])
... ... @@ -141,6 +137,19 @@ export struct BottomNavigationComponent {
}
.height($r('app.float.bottom_navigation_barHeight'))
.hoverEffect(HoverEffect.Highlight)
.onClick(() => {
if (this.currentNavIndex === index) {
// 当前tab,双击事件
this.doubleClick(() => {
Logger.info(TAG, 'tab double click ')
this.autoRefresh++
})
} else {
// 切换tab
this.currentNavIndex = index;
Logger.info(TAG, `onChange, index: ${index}`);
}
})
// .justifyContent(FlexAlign.Center)
// .onClick(() => {
... ... @@ -164,11 +173,11 @@ export struct BottomNavigationComponent {
/**
* 底导id变化,即指定频道跳转场景
*/
changeBottomNav() {
changeBottomNav(assignChannel: AssignChannelParam) {
let index = -1
for (let i = 0; i < this.bottomNavList.length; i++) {
let bottomNavDTO: BottomNavDTO = this.bottomNavList[i]
if (bottomNavDTO.id.toString() === this.assignChannel.bottomNavId) {
if (bottomNavDTO.id.toString() === assignChannel.bottomNavId) {
index = i
break
}
... ... @@ -180,10 +189,27 @@ export struct BottomNavigationComponent {
setTimeout(() => {
// 底导切换后,触发顶导切换
this.assignChannel1 = new AssignChannelParam()
this.assignChannel1.pageId = this.assignChannel.pageId
this.assignChannel1.channelId = this.assignChannel.channelId
this.assignChannel1.bottomNavId = this.assignChannel.bottomNavId
this.assignChannel = new AssignChannelParam()
this.assignChannel.pageId = assignChannel.pageId
this.assignChannel.channelId = assignChannel.channelId
this.assignChannel.bottomNavId = assignChannel.bottomNavId
}, 20)
}
/**
* 双击实现
*/
doubleClickTime: number = 0
/**
* 双击实现
*/
private doubleClick(fun: () => void) {
let now = DateTimeUtils.getTimeStamp()
if (now - this.doubleClickTime < 200) {
fun()
} else {
this.doubleClickTime = now
}
}
}
\ No newline at end of file
... ...
... ... @@ -2,8 +2,7 @@ import { Action, ContentDTO, Params } from 'wdBean';
import { CommonConstants, ConfigConstants, ScreenType } from 'wdConstant';
import { Logger } from 'wdKit';
import { CompUtils } from '../../utils/CompUtils';
import { WDRouterRule } from 'wdRouter';
import { ProcessUtils } from 'wdRouter';
import { ProcessUtils, WDRouterRule } from 'wdRouter';
const TAG: string = 'CardView';
... ... @@ -24,8 +23,7 @@ export struct CarouselLayout01CardView {
Image(this.item.coverUrl)
.width(CommonConstants.FULL_PARENT)
.height(CommonConstants.FULL_PARENT)
.objectFit(ImageFit.Cover)
// .borderRadius($r("app.float.border_radius_6"))
.objectFit(ImageFit.Cover)// .borderRadius($r("app.float.border_radius_6"))
.alignRules({
top: { anchor: '__container__', align: VerticalAlign.Top },
left: { anchor: '__container__', align: HorizontalAlign.Start }
... ... @@ -435,11 +433,10 @@ export struct PaperSingleColumn999CardView {
.fontSize(12)
.fontColor(Color.Gray)
.margin({ left: 22 })
Image($r('app.media.icon_share'))
Image($r('app.media.icon_forward'))
.width(16)
.height(16)
.margin({ left: 10, right: 22, top: 10, bottom: 10 })
.backgroundColor(Color.Brown)
}.width(CommonConstants.FULL_PARENT)
.justifyContent(FlexAlign.SpaceBetween)
}
... ... @@ -447,7 +444,7 @@ export struct PaperSingleColumn999CardView {
.backgroundColor(Color.White)
.margin({ bottom: 5, left: 12, right: 12 })
.borderRadius(4)
.onClick(()=>{
.onClick(() => {
ProcessUtils.processPage(this.item)
})
}
... ...
... ... @@ -137,7 +137,7 @@ struct EditUserInfoPage {
TextPickerDialog.show({
range:['男','女'],
canLoop:false,
selected:0,
selected:this.currentUserInfo.userExtend.sex === 0?1:0,
onAccept:(value:TextPickerResult) => {
this.currentUserInfo.userExtend.sex = value.index == 0?1:0;
this.currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_sex
... ...
... ... @@ -52,22 +52,34 @@ struct EditUserIntroductionPage {
.margin(30)
.onClick(()=>{
this.updateEditModel()
let params: editModelParams = {
introduction: this.introduction
}
router.back({
url:'',
params:params
})
})
}
}
updateEditModel(){
if (this.params.editContent === this.introduction) {
this.goBack()
return
}
let currentUserInfo:editModel = new editModel()
currentUserInfo.userExtend.introduction = this.introduction
currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_intro
EditInfoViewModel.updateUserInfo(currentUserInfo)
EditInfoViewModel.updateUserInfo(currentUserInfo).then(()=>{
this.goBack()
}).catch(()=>{
this.goBack()
})
}
goBack(){
let params: editModelParams = {
introduction: this.introduction
}
router.back({
url:'',
params:params
})
}
}
\ No newline at end of file
... ...
... ... @@ -60,17 +60,28 @@ struct EditUserNikeNamePage {
}
async updateEditModel(){
if (this.params.editContent === this.nikeName) {
this.goBack()
return
}
let currentUserInfo:editModel = new editModel()
currentUserInfo.userName = await encryptMessage(this.nikeName);
currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_nickname
EditInfoViewModel.updateUserInfo(currentUserInfo).then(()=>{
let params: editModelParams = {
userName: this.nikeName
}
router.back({
url:'',
params:params
})
this.goBack()
}).catch(()=>{
this.goBack()
})
}
goBack(){
let params: editModelParams = {
userName: this.nikeName
}
router.back({
url:'',
params:params
})
}
}
\ No newline at end of file
... ...
... ... @@ -5,11 +5,11 @@ import router from '@ohos.router';
@Entry
@Component
struct FollowListPage {
@State params:Params = router.getParams() as Params;
@State params:Record<string, string> = router.getParams() as Record<string, string>;
@State curIndex: string = '0';
onPageShow() {
this.curIndex = this.params?.pageID;
this.curIndex = this.params?.['index'];
}
build() {
... ...
... ... @@ -50,7 +50,7 @@ export struct MinePageComponent {
//个人功能数据
this.personalData = MinePageDatasModel.getPersonalFunctionsData()
//创作者功能数据
this.creatorData = MinePageDatasModel.getCreatorFunctionsData()
// this.creatorData = MinePageDatasModel.getCreatorFunctionsData()
//更多功能数据
this.moreData = MinePageDatasModel.getMoreFunctionsData()
}
... ...
/**
* 已到底UI,数据bean封装【page接口返回配置信息:文字、文字颜色】
*/
@Observed
export class NoMoreBean {
text: string = '';
textColor: string = '';
constructor(text: string) {
this.text = text;
}
}
\ No newline at end of file
... ...
import { CommonConstants, ViewType } from 'wdConstant';
import { Logger } from 'wdKit';
import PageViewModel from '../../viewmodel/PageViewModel';
import { EmptyComponent } from '../view/EmptyComponent';
import { ErrorComponent } from '../view/ErrorComponent';
import PageModel from '../../viewmodel/PageModel';
import { listTouchEvent } from '../../utils/PullDownRefresh';
import { autoRefresh, listTouchEvent } from '../../utils/PullDownRefresh';
import RefreshLayout from './RefreshLayout';
import { RefreshLayoutBean } from './RefreshLayoutBean';
import NoMoreLayout from './NoMoreLayout';
import LoadMoreLayout from './LoadMoreLayout';
import CustomRefreshLoadLayout from './CustomRefreshLoadLayout';
import { CompParser } from '../CompParser';
import { CompDTO } from 'wdBean';
import PageHelper from '../../viewmodel/PageHelper';
import { channelSkeleton } from '../skeleton/channelSkeleton'
import { ProcessUtils } from 'wdRouter/Index';
import PageAdModel from '../../viewmodel/PageAdvModel';
import PageNoMoreLayout from './PageNoMoreLayout';
import { NoMoreBean } from './NoMoreBean';
const TAG = 'PageComponent';
... ... @@ -27,18 +25,24 @@ export struct PageComponent {
pageId: string = "";
channelId: string = "";
@Link @Watch('onChange') currentTopNavSelectedIndex: number
// 自动刷新通知
@Prop @Watch('onAutoRefresh') autoRefresh: number = 0
build() {
Column() {
if (this.pageModel.viewType == ViewType.LOADING) {
// LoadingComponent()
this.LoadingLayout()
} else if (this.pageModel.viewType == ViewType.ERROR) {
ErrorComponent()
} else if (this.pageModel.viewType == ViewType.EMPTY) {
EmptyComponent()
} else {
} else if (this.pageModel.viewType == ViewType.LOADED) {
this.ListLayout()
} else if (this.pageModel.viewType == ViewType.EMPTY) {
//缺省页
EmptyComponent({
emptyType: this.pageModel.emptyType,
emptyButton: true,
retry: () => {
this.getData()
}
})
}
}
.width(CommonConstants.FULL_PARENT)
... ... @@ -65,6 +69,7 @@ export struct PageComponent {
this.pageModel.pullDownRefreshText, this.pageModel.pullDownRefreshHeight)
})
}
LazyForEach(this.pageModel.compList, (compDTO: CompDTO, compIndex: number) => {
ListItem() {
Column() {
... ... @@ -83,7 +88,7 @@ export struct PageComponent {
this.pageModel.pullUpLoadText, this.pageModel.pullUpLoadHeight)
})
} else if (!this.pageModel.contentNeedScroll) {
NoMoreLayout()
PageNoMoreLayout({ noMoreBean: new NoMoreBean(this.pageModel.pageInfo.baselineCopywriting) })
}
}
}
... ... @@ -224,6 +229,15 @@ export struct PageComponent {
}
}
onAutoRefresh() {
if (this.navIndex != this.currentTopNavSelectedIndex) {
return
}
// 当前页面,自动刷新数据
Logger.debug(TAG, 'page onAutoRefresh ' + this.autoRefresh)
autoRefresh(this.pageModel, this.pageAdvModel)
}
async getData() {
Logger.info(TAG, `getData id: ${this.pageId} , ${this.channelId} , navIndex: ${this.currentTopNavSelectedIndex}`);
this.pageModel.pageId = this.pageId;
... ... @@ -231,14 +245,6 @@ export struct PageComponent {
this.pageModel.channelId = this.channelId;
this.pageModel.currentPage = 1;
PageHelper.getInitData(this.pageModel, this.pageAdvModel)
// let pageInfo = await PageViewModel.getPageInfo(this.pageModel.pageId);
// if (pageInfo == null) {
// this.pageModel.viewType = ViewType.EMPTY;
// return;
// }
// this.pageModel.pageInfo = pageInfo;
// this.pageModel.loadStrategy = 1
// PageHelper.parseGroup(this.pageModel)
}
}
... ...
import { RefreshConstants } from '../../utils/RefreshConstants'
import { NoMoreBean } from './NoMoreBean';
/**
* The No more data layout component.
*/
@Component
export default struct PageNoMoreLayout {
@ObjectLink noMoreBean: NoMoreBean;
text: string | Resource = $r('app.string.footer_text')
aboutToAppear(): void {
if (this.noMoreBean && this.noMoreBean.text.length > 0) {
this.text = this.noMoreBean.text
}
}
build() {
Row() {
Text(this.text)
.margin({ left: RefreshConstants.NoMoreLayoutConstant_NORMAL_PADDING })
.fontSize(RefreshConstants.NoMoreLayoutConstant_TITLE_FONT)
.textAlign(TextAlign.Center)
}
.width(RefreshConstants.FULL_WIDTH)
.justifyContent(FlexAlign.Center)
.height(RefreshConstants.CUSTOM_LAYOUT_HEIGHT)
}
}
\ No newline at end of file
... ...
import { Action, CompDTO, Params, TopNavDTO } from 'wdBean';
import { LazyDataSource, Logger, StringUtils } from 'wdKit';
import { CompDTO, TopNavDTO } from 'wdBean';
import { LazyDataSource, Logger } from 'wdKit';
import { ProcessUtils } from 'wdRouter';
import { PageComponent } from './PageComponent';
import { ChannelSubscriptionLayout } from './ChannelSubscriptionLayout';
import { FirstTabTopSearchComponent } from '../search/FirstTabTopSearchComponent';
import window from '@ohos.window';
import { WindowModel } from 'wdKit';
import { VideoChannelDetail } from 'wdDetailPlayShortVideo/Index';
import { AssignChannelParam } from 'wdRouter/src/main/ets/utils/HomeChannelUtils';
... ... @@ -51,6 +49,12 @@ export struct TopNavigationComponent {
@State localChannelList: TopNavDTO[] = []
readonly MAX_LINE: number = 1;
@ObjectLink @Watch('onAssignChannelChange') assignChannel: AssignChannelParam
// 底导传递过来的自动刷新通知
@Prop @Watch('onAutoRefresh') autoRefresh: number = 0
// 传递给page的自动刷新通知
@State autoRefresh2Page: number = 0
// 当前底导index
@State navIndex: number = 0
//处理新闻tab顶导频道数据
topNavListHandle() {
... ... @@ -201,6 +205,7 @@ export struct TopNavigationComponent {
navIndex: index,
pageId: navItem.pageId + '',
channelId: navItem.channelId + '',
autoRefresh: this.autoRefresh2Page
})
}
}
... ... @@ -258,10 +263,10 @@ export struct TopNavigationComponent {
if (this.currentTopNavSelectedIndex == 0) {
return item.name === '视频' ? Color.White : '#e5e0e0'
} else {
return this.currentTopNavSelectedIndex === index ? Color.Black : Color.Gray
return this.currentTopNavSelectedIndex === index ? Color.Black : "#999999"
}
} else {
return this.currentTopNavSelectedIndex === index ? Color.Black : Color.Gray
return this.currentTopNavSelectedIndex === index ? Color.Black : "#999999"
}
}
... ... @@ -269,30 +274,28 @@ export struct TopNavigationComponent {
tabBarBuilder(item: TopNavDTO, index: number) {
Column() {
Text(item.name)
.fontSize(this.currentTopNavSelectedIndex === index ? $r('app.float.selected_text_size') : $r('app.float.normal_text_size'))
.fontSize($r('app.float.selected_text_size'))
.fontWeight(this.currentTopNavSelectedIndex === index ? FontWeight.Bold : FontWeight.Normal)
.fontColor(this.getFontColor(item, index))
.padding({ top: $r('app.float.top_tab_item_padding_top') })
.padding({ top: $r('app.float.top_tab_item_padding_top') , bottom: $r('app.float.top_tab_item_padding_bottom')})
.maxLines(this.MAX_LINE)
if (this.currentTopNavSelectedIndex === index) {
Row()
.width(20)
.height(3)
.backgroundImage($r('app.media.icon_channel_active'), ImageRepeat.NoRepeat)
.backgroundImageSize(ImageSize.Contain)
}
}
.hoverEffect(HoverEffect.Highlight)
.constraintSize({
minWidth: $r('app.float.top_tab_item_min_width'),
maxWidth: $r('app.float.top_tab_item_max_width')
})
// .margin({ right: 36 })
.backgroundColor(Color.Transparent)
.padding({
left: $r('app.float.top_tab_item_padding_horizontal'),
right: $r('app.float.top_tab_item_padding_horizontal'),
bottom: $r('app.float.top_tab_item_padding_bottom')
})
.id(`col_tabBar${index}`)
.margin({ right: this.myChannelList.length === index + 1 ? 36 : 0 })
... ... @@ -311,6 +314,14 @@ export struct TopNavigationComponent {
Logger.info(TAG, `onTopNavigationDataUpdated currentTopNavIndex: ${this.currentTopNavSelectedIndex},topNavList.length:${this.topNavList.length}`);
}
onAutoRefresh() {
if (this.navIndex != this._currentNavIndex) {
return
}
// 通知page刷新
this.autoRefresh2Page++
}
/**
* 频道id变化,即指定频道跳转场景
*/
... ...
... ... @@ -23,6 +23,9 @@ export struct SearchHotsComponent{
}
}).catch((err:Error)=>{
console.log(TAG,JSON.stringify(err))
if(this.searchHotsData.length === 0){
this.searchHotsData.push(new SearchHotContentItem("二十大",0,1))
}
})
}
... ...
... ... @@ -29,6 +29,17 @@ export struct HorizontalStrokeCardThreeTwoRadioForMoreComponent {
.width(14)
.height(14)
}
.visibility(this.compDTO?.objectType === '0' ? Visibility.None : Visibility.Visible)
.onClick(() => {
if (this.compDTO?.objectType === '11') {
ProcessUtils.jumpChannelTab(this.compDTO.objectId, this.compDTO.pageId as string)
} else if (this.compDTO?.objectType === '5') {
ProcessUtils._gotoSpecialTopic(this.compDTO.linkUrl)
} else if (this.compDTO?.objectType === '6') {
ProcessUtils._gotoDefaultWeb(this.compDTO.linkUrl)
}
})
}.justifyContent(FlexAlign.SpaceBetween)
.padding({ left: 16, right: 16 })
.margin({ top: 8, bottom: 8 })
... ...
import { Logger } from 'wdKit/Index'
import { LikeViewModel } from '../../viewmodel/LikeViewModel'
const TAG = 'LikeComponent';
@Component
export struct LikeComponent {
@State likeStatus: boolean = false
... ... @@ -15,17 +17,12 @@ export struct LikeComponent {
// this.data['title'] = '开创两校交流先河!克罗地亚教育代表团访问同济大学'
// this.data['userHeaderUrl'] = ""
// this.data['channelId'] = "2059" //必须
// this.data['status'] = "1" //必须
// this.data['status'] = "1"
aboutToAppear(): void {
if (this.data) {
Logger.debug("ddd: " + this.data['status'])
if (this.data['status'] == '1') {
this.likeStatus = true
} else {
this.likeStatus = false
}
//获取点赞状态
this.getLikeStatus()
}
}
... ... @@ -41,10 +38,10 @@ export struct LikeComponent {
}
if (this.likeStatus) {
//1
this.executeLike('1')
this.executeLike('0')
} else {
//0
this.executeLike('0')
this.executeLike('1')
}
})
}.width(24).height(24)
... ... @@ -59,4 +56,18 @@ export struct LikeComponent {
this.enableBtn = true
})
}
getLikeStatus() {
this.viewModel.getLikeStatus(this.data).then((data) => {
if (data && data['data'].length && data['data'][0]['likeStatus']) {
this.likeStatus = data['data'][0]['likeStatus']
}else {
this.likeStatus = false
}
}).catch(() => {
this.likeStatus = false
})
}
}
\ No newline at end of file
... ...
... ... @@ -12,6 +12,7 @@ import {
import router from '@ohos.router';
import inputMethod from '@ohos.inputMethod';
import { MultiPictureDetailViewModel } from '../../viewmodel/MultiPictureDetailViewModel';
import { LikeComponent } from './LikeComponent';
import { HttpUrlUtils } from 'wdNetwork/Index';
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import { PageRepository } from '../../repository/PageRepository';
... ... @@ -29,9 +30,11 @@ const TAG = 'OperRowListView';
@Preview
@Component
export struct OperRowListView {
private contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
// private contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
@Prop contentDetailData: ContentDetailDTO
@State interactData: InteractDataDTO = {} as InteractDataDTO
@State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态
@State likeBean: Record<string, string> = {}
@State operationList: OperationItem[] = [
{
... ... @@ -60,6 +63,20 @@ export struct OperRowListView {
this.getInteractDataStatus()
}
this.queryContentInteractCount()
// 点赞需要数据
// this.data['userName'] = '人民日报网友2kD2xW'
// this.data['contentType'] = '8' //必须
// this.data['title'] = '开创两校交流先河!克罗地亚教育代表团访问同济大学'
// this.data['userHeaderUrl'] = ""
// this.data['channelId'] = "2059" //必须
// this.data['status'] = "1" //必须
this.likeBean['contentId'] = this.contentDetailData.newsId + ''
this.likeBean['userName'] = this.contentDetailData.editorName + ''
this.likeBean['contentType'] = this.contentDetailData.newsType + ''
this.likeBean['title'] = this.contentDetailData.newsTitle + ''
this.likeBean['userHeaderUrl'] = ''
this.likeBean['channelId'] = this.contentDetailData.reLInfo?.channelId + ''
this.likeBean['status'] = ''
}
build() {
... ... @@ -83,7 +100,7 @@ export struct OperRowListView {
.onClick(() => {
router.back();
})
TextInput({placeholder:'说两句...'})
TextInput({placeholder:'说两句11...'})
.placeholderColor('#999999')
.placeholderFont(
{
... ... @@ -112,10 +129,9 @@ export struct OperRowListView {
.width('54.5%')
}
.width('100%')
.height(56)
.height(126)
.backgroundColor(Color.Black)
}
/**
* 组件项
*
... ... @@ -125,7 +141,11 @@ export struct OperRowListView {
buildOperationItem(item: OperationItem, index: number) {
Column() {
if (item.text === '点赞') {
RelativeContainer() {
LikeComponent({
data: this.likeBean
})
/* RelativeContainer() {
Row() {
Image(this.newsStatusOfUser?.likeStatus == '1' ? item.icon_check : item.icon)
.width(24)
... ... @@ -134,6 +154,7 @@ export struct OperRowListView {
.interpolation(ImageInterpolation.High)
.onClick(() => {
this.toggleLikeStatus()
console.log('点赞_111', JSON.stringify(this.contentDetailData))
})
}
.alignRules({
... ... @@ -168,7 +189,7 @@ export struct OperRowListView {
.id(`e_row3_${index}`)
}
}
.id(`e_icon_${index}`)
.id(`e_icon_${index}`)*/
} else if (item.text === '收藏') {
RelativeContainer() {
Row() {
... ...
@Component
export struct PermissionDesComponent {
@State translateY: number = 0
aboutToAppear(): void {
this.startDismiss()
}
build() {
Column() {
Row() {
Image($r('app.media.tips')).width(20).height(20)
Text("权限使用说明").fontColor('#FF222222').fontSize(14)
.fontWeight(FontWeight.Bold)
.margin({left:4})
}.height(26)
Text("用于为你推荐你可能感兴趣的资讯内容及附近的相关信息,以提升浏览体验。不授权该权限不影响App正常使用。")
.fontSize(14)
.fontColor('#666666')
}
.translate({ y: this.translateY })
.animation({
duration: 400,
curve: Curve.Linear,
})
.alignItems(HorizontalAlign.Start)
.width('90%')
// .height(60)
.backgroundColor('#FFFFFF')
.border({ radius: 5 })
.margin({ top: 12 })
.padding(12)
}
startDismiss() {
setTimeout(() => {
this.translateY = -250
}, 4000)
}
}
\ No newline at end of file
... ...
import { HashMap } from '@kit.ArkTS';
import { Logger } from 'wdKit/Index';
import { HttpUrlUtils, ResponseDTO } from 'wdNetwork/Index';
import { HttpBizUtil, HttpUrlUtils, ResponseDTO } from 'wdNetwork/Index';
import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
export class LikeModel {
... ... @@ -8,7 +8,7 @@ export class LikeModel {
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return new Promise<object>((success, fail) => {
HttpRequest.post<ResponseDTO<object>>(HttpUrlUtils.executeLike(), data, headers).then((data: ResponseDTO<object>) => {
HttpBizUtil.post<ResponseDTO<object>>(HttpUrlUtils.executeLike(), data, headers).then((data: ResponseDTO<object>) => {
if (data.code != 0) {
fail(data.message)
return
... ... @@ -20,4 +20,28 @@ export class LikeModel {
})
})
}
getLikeStatus(data: Record<string, string>) {
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
let model : Record<string,Record<string,string>[]> = {}
model['contentList'] = [data]
return new Promise<object>((success, fail) => {
HttpBizUtil.post<ResponseDTO<object>>(HttpUrlUtils.getLikeStatus(), model, headers).then((data: ResponseDTO<object>) => {
if (data.code != 0) {
fail(data.message)
return
}
success(data)
}, (error: Error) => {
fail(error.message)
Logger.debug("LoginViewModel:error ", error.toString())
})
})
}
}
\ No newline at end of file
... ...
... ... @@ -118,7 +118,7 @@ class MinePageDatasModel{
Logger.info(TAG, `getAppointmentList start`);
this.fetchAppointmentListData(pageSize,pageNum).then((navResDTO: ResponseDTO<MineAppointmentListItem>) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getAppointmentListDataLocal(context))
error(null)
return
}
Logger.info(TAG, "getAppointmentList then,AppointmentResDTO.timeStamp:" + navResDTO.timestamp);
... ... @@ -126,22 +126,11 @@ class MinePageDatasModel{
success(navigationBean);
}).catch((err: Error) => {
Logger.error(TAG, `fetchAppointmentListDataApi catch, error.name : ${err.name}, error.message:${err.message}`);
success(this.getAppointmentListDataLocal(context))
error(null)
})
})
}
async getAppointmentListDataLocal(context: Context): Promise<MineAppointmentListItem> {
Logger.info(TAG, `getBottomNavDataMock start`);
let compRes: ResponseDTO<MineAppointmentListItem> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<MineAppointmentListItem>>(context,'appointment_list_data.json' );
if (!compRes || !compRes.data) {
Logger.info(TAG, `getAppointmentListDataLocal compRes is empty`);
return new MineAppointmentListItem()
}
Logger.info(TAG, `getAppointmentListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
/**
* 关注频道详情
* @param pageSize
... ... @@ -154,7 +143,7 @@ class MinePageDatasModel{
Logger.info(TAG, `getAppointmentList start`);
this.fetchFollowListDetailData(params).then((navResDTO: ResponseDTO<MineFollowListDetailItem>) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getFollowListDetailDataLocal(context))
error(null)
return
}
Logger.info(TAG, "getAppointmentList then,AppointmentResDTO.timeStamp:" + navResDTO.timestamp);
... ... @@ -162,22 +151,11 @@ class MinePageDatasModel{
success(navigationBean);
}).catch((err: Error) => {
Logger.error(TAG, `fetchAppointmentListDataApi catch, error.name : ${err.name}, error.message:${err.message}`);
success(this.getFollowListDetailDataLocal(context))
error(null)
})
})
}
async getFollowListDetailDataLocal(context: Context): Promise<MineFollowListDetailItem> {
Logger.info(TAG, `getBottomNavDataMock start`);
let compRes: ResponseDTO<MineFollowListDetailItem> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<MineFollowListDetailItem>>(context,'follow_list_detail_data_id120.json' );
if (!compRes || !compRes.data) {
Logger.info(TAG, `getAppointmentListDataLocal compRes is empty`);
return new MineFollowListDetailItem()
}
Logger.info(TAG, `getAppointmentListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
fetchFollowListDetailData(object:FollowListDetailRequestItem) {
let url = HttpUrlUtils.getFollowListDetailDataUrl()
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
... ... @@ -199,7 +177,7 @@ class MinePageDatasModel{
Logger.info(TAG, `getAppointmentList start`);
this.fetchFollowListData().then((navResDTO: ResponseDTO<FollowListItem[]>) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getFollowListDataLocal(context))
error(null)
return
}
Logger.info(TAG, "getAppointmentList then,AppointmentResDTO.timeStamp:" + navResDTO.timestamp);
... ... @@ -207,21 +185,11 @@ class MinePageDatasModel{
success(navigationBean);
}).catch((err: Error) => {
Logger.error(TAG, `fetchAppointmentListDataApi catch, error.name : ${err.name}, error.message:${err.message}`);
success(this.getFollowListDataLocal(context))
error(null)
})
})
}
async getFollowListDataLocal(context: Context): Promise<FollowListItem[]> {
Logger.info(TAG, `getFollowListDataLocal start`);
let compRes: ResponseDTO<FollowListItem[]> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<FollowListItem[]>>(context,'follow_list_data.json' );
if (!compRes || !compRes.data) {
Logger.info(TAG, `getFollowListDataLocal compRes is empty`);
return []
}
Logger.info(TAG, `getFollowListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
/**
* 我的关注列表
... ... @@ -234,7 +202,7 @@ class MinePageDatasModel{
Logger.info(TAG, `getAppointmentList start`);
this.fetchMineDetailFollowListData(params).then((navResDTO: ResponseDTO<MineFollowListItem>) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getMineFollowListDataLocal(context))
error(null)
return
}
Logger.info(TAG, "getAppointmentList then,AppointmentResDTO.timeStamp:" + navResDTO.timestamp);
... ... @@ -242,7 +210,7 @@ class MinePageDatasModel{
success(navigationBean);
}).catch((err: Error) => {
Logger.error(TAG, `fetchAppointmentListDataApi catch, error.name : ${err.name}, error.message:${err.message}`);
success(this.getMineFollowListDataLocal(context))
error(null)
})
})
}
... ... @@ -253,17 +221,6 @@ class MinePageDatasModel{
return WDHttp.get<ResponseDTO<MineFollowListItem>>(url, headers)
};
async getMineFollowListDataLocal(context: Context): Promise<MineFollowListItem> {
Logger.info(TAG, `getMineFollowListDataLocal start`);
let compRes: ResponseDTO<MineFollowListItem> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<MineFollowListItem>>(context,'mine_follow_list_data.json' );
if (!compRes || !compRes.data) {
Logger.info(TAG, `getMineFollowListDataLocal compRes is empty`);
return new MineFollowListItem()
}
Logger.info(TAG, `getMineFollowListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
/**
* 查询是否被关注 列表
* @param params
... ... @@ -275,7 +232,7 @@ class MinePageDatasModel{
Logger.info(TAG, `getAppointmentList start`);
this.fetchFollowListStatusData(params).then((navResDTO: ResponseDTO<QueryListIsFollowedItem[]>) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getFollowListStatusDataLocal(context))
error(null)
return
}
Logger.info(TAG, "getAppointmentList then,AppointmentResDTO.timeStamp:" + navResDTO.timestamp);
... ... @@ -283,7 +240,7 @@ class MinePageDatasModel{
success(navigationBean);
}).catch((err: Error) => {
Logger.error(TAG, `fetchAppointmentListDataApi catch, error.name : ${err.name}, error.message:${err.message}`);
success(this.getFollowListStatusDataLocal(context))
error(null)
})
})
}
... ... @@ -294,18 +251,6 @@ class MinePageDatasModel{
return WDHttp.post<ResponseDTO<QueryListIsFollowedItem[]>>(url,object, headers)
};
async getFollowListStatusDataLocal(context: Context): Promise<QueryListIsFollowedItem[]> {
Logger.info(TAG, `getMineFollowListDataLocal start`);
let compRes: ResponseDTO<QueryListIsFollowedItem[]> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<QueryListIsFollowedItem[]>>(context,'follow_list_id120_isfocus_data.json' );
if (!compRes || !compRes.data) {
Logger.info(TAG, `getMineFollowListDataLocal compRes is empty`);
return []
}
Logger.info(TAG, `getMineFollowListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
/**
* 我的评论列表
* @param params
... ... @@ -317,16 +262,15 @@ class MinePageDatasModel{
Logger.info(TAG, `getAppointmentList start`);
this.fetchMineCommentListData(time,params).then((navResDTO: ResponseDTO<MineCommentListDetailItem>) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getMineCommentListDataLocal(context))
error(null)
return
}
Logger.info(TAG, "getAppointmentList then,AppointmentResDTO.timeStamp:" + navResDTO.timestamp);
let navigationBean = navResDTO.data as MineCommentListDetailItem
success(navigationBean);
// success(this.getMineCommentListDataLocal(context))
}).catch((err: Error) => {
Logger.error(TAG, `fetchAppointmentListDataApi catch, error.name : ${err.name}, error.message:${err.message}`);
success(this.getMineCommentListDataLocal(context))
error(null)
})
})
}
... ... @@ -337,16 +281,6 @@ class MinePageDatasModel{
return WDHttp.get<ResponseDTO<MineCommentListDetailItem>>(url, headers)
};
async getMineCommentListDataLocal(context: Context): Promise<MineCommentListDetailItem> {
Logger.info(TAG, `getMineFollowListDataLocal start`);
let compRes: ResponseDTO<MineCommentListDetailItem> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<MineCommentListDetailItem>>(context,'mine_comment_list_data2.json' );
if (!compRes || !compRes.data) {
Logger.info(TAG, `getMineFollowListDataLocal compRes is empty`);
return new MineCommentListDetailItem()
}
Logger.info(TAG, `getMineFollowListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
/**
* 个人中心 获取用户等级
... ... @@ -356,7 +290,7 @@ class MinePageDatasModel{
Logger.info(TAG, `getAppointmentList start`);
this.fetchMineUserLevelData().then((navResDTO: ResponseDTO<MineUserLevelItem>) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getMineUserLevelDataLocal(context))
error(null)
return
}
Logger.info(TAG, "getAppointmentList then,AppointmentResDTO.timeStamp:" + navResDTO.timestamp);
... ... @@ -364,7 +298,7 @@ class MinePageDatasModel{
success(navigationBean);
}).catch((err: Error) => {
Logger.error(TAG, `fetchMineUserLevelData catch, error.name : ${err.name}, error.message:${err.message}`);
success(this.getMineUserLevelDataLocal(context))
error(null)
})
})
}
... ... @@ -376,17 +310,6 @@ class MinePageDatasModel{
return HttpBizUtil.get<ResponseDTO<MineUserLevelItem>>(url, headers)
};
async getMineUserLevelDataLocal(context: Context): Promise<MineUserLevelItem> {
Logger.info(TAG, `getMineUserLevelDataLocal start`);
let compRes: ResponseDTO<MineUserLevelItem> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<MineUserLevelItem>>(context,'mine_user_level.json' );
if (!compRes || !compRes.data) {
Logger.info(TAG, `getMineUserLevelDataLocal compRes is empty`);
return new MineUserLevelItem()
}
Logger.info(TAG, `getMineUserLevelDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
/**
* 个人中心 获取用户详细信息
*/
... ... @@ -395,7 +318,7 @@ class MinePageDatasModel{
Logger.info(TAG, `getAppointmentList start`);
this.fetchMineUserDetailData().then((navResDTO: ResponseDTO<MineUserDetailItem>) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getMineUserDetailDataLocal(context))
error(null)
return
}
Logger.info(TAG, "getUserDetailData then,timeStamp:" + navResDTO.timestamp);
... ... @@ -403,7 +326,7 @@ class MinePageDatasModel{
success(navigationBean);
}).catch((err: Error) => {
Logger.error(TAG, `fetchMineUserDetailData catch, error.name : ${err.name}, error.message:${err.message}`);
success(this.getMineUserDetailDataLocal(context))
error(null)
})
})
}
... ... @@ -415,16 +338,7 @@ class MinePageDatasModel{
return HttpBizUtil.get<ResponseDTO<MineUserDetailItem>>(url, headers)
};
async getMineUserDetailDataLocal(context: Context): Promise<MineUserDetailItem> {
Logger.info(TAG, `getMineUserLevelDataLocal start`);
let compRes: ResponseDTO<MineUserDetailItem> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<MineUserDetailItem>>(context,'mine_user_detail.json' );
if (!compRes || !compRes.data) {
Logger.info(TAG, `getMineUserDetailDataLocal compRes is empty`);
return new MineUserDetailItem()
}
Logger.info(TAG, `getMineUserDetailDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
/**
* 个人中心 获取其他用户详细信息
*/
... ... @@ -433,7 +347,7 @@ class MinePageDatasModel{
Logger.info(TAG, `getAppointmentList start`);
this.fetchOtherUserDetailData(item).then((navResDTO: ResponseDTO<MineUserDetailItem>) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getOtherUserDetailDataLocal(context))
error(null)
return
}
Logger.info(TAG, "getUserDetailData then,timeStamp:" + navResDTO.timestamp);
... ... @@ -441,7 +355,7 @@ class MinePageDatasModel{
success(navigationBean);
}).catch((err: Error) => {
Logger.error(TAG, `fetchMineUserDetailData catch, error.name : ${err.name}, error.message:${err.message}`);
success(this.getOtherUserDetailDataLocal(context))
error(null)
})
})
}
... ... @@ -452,17 +366,6 @@ class MinePageDatasModel{
return WDHttp.post<ResponseDTO<MineUserDetailItem>>(url, item,headers)
};
async getOtherUserDetailDataLocal(context: Context): Promise<MineUserDetailItem> {
Logger.info(TAG, `getMineUserLevelDataLocal start`);
let compRes: ResponseDTO<MineUserDetailItem> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<MineUserDetailItem>>(context,'other_user512157124138245_detail.json' );
if (!compRes || !compRes.data) {
Logger.info(TAG, `getMineUserDetailDataLocal compRes is empty`);
return new MineUserDetailItem()
}
Logger.info(TAG, `getMineUserDetailDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
/**
* 个人中心 获取其他用户等级
*/
... ... @@ -471,7 +374,7 @@ class MinePageDatasModel{
Logger.info(TAG, `getAppointmentList start`);
this.fetchOtherUserLevelData(item).then((navResDTO: ResponseDTO<MineUserLevelItem[]>) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getOtherUserLevelDataLocal(context))
error(null)
return
}
Logger.info(TAG, "getAppointmentList then,AppointmentResDTO.timeStamp:" + navResDTO.timestamp);
... ... @@ -479,11 +382,11 @@ class MinePageDatasModel{
if(navigationBean.length>0 && StringUtils.isNotEmpty(navigationBean[0].levelHead)){
success(navigationBean);
}else{
success(this.getOtherUserLevelDataLocal(context))
error(null)
}
}).catch((err: Error) => {
Logger.error(TAG, `fetchMineUserLevelData catch, error.name : ${err.name}, error.message:${err.message}`);
success(this.getOtherUserLevelDataLocal(context))
error(null)
})
})
}
... ... @@ -494,17 +397,6 @@ class MinePageDatasModel{
return WDHttp.post<ResponseDTO<MineUserLevelItem[]>>(url,item, headers)
};
async getOtherUserLevelDataLocal(context: Context): Promise<MineUserLevelItem[]> {
Logger.info(TAG, `getMineUserLevelDataLocal start`);
let compRes: ResponseDTO<MineUserLevelItem[]> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<MineUserLevelItem[]>>(context,'other_user512157124138245_level.json' );
if (!compRes || !compRes.data) {
Logger.info(TAG, `getMineUserLevelDataLocal compRes is empty`);
return []
}
Logger.info(TAG, `getMineUserLevelDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
/**
* 其他用户的评论列表
* @param params
... ... @@ -516,7 +408,7 @@ class MinePageDatasModel{
Logger.info(TAG, `getAppointmentList start`);
this.fetchOtherCommentListData(params).then((navResDTO: ResponseDTO<MineCommentListDetailItem>) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getOtherCommentListDataLocal(context))
error(null)
return
}
Logger.info(TAG, "getAppointmentList then,AppointmentResDTO.timeStamp:" + navResDTO.timestamp);
... ... @@ -524,7 +416,7 @@ class MinePageDatasModel{
success(navigationBean);
}).catch((err: Error) => {
Logger.error(TAG, `fetchAppointmentListDataApi catch, error.name : ${err.name}, error.message:${err.message}`);
success(this.getOtherCommentListDataLocal(context))
error(null)
})
})
}
... ... @@ -535,16 +427,6 @@ class MinePageDatasModel{
return WDHttp.get<ResponseDTO<MineCommentListDetailItem>>(url, headers)
};
async getOtherCommentListDataLocal(context: Context): Promise<MineCommentListDetailItem> {
Logger.info(TAG, `getMineFollowListDataLocal start`);
let compRes: ResponseDTO<MineCommentListDetailItem> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<MineCommentListDetailItem>>(context,'other_user512157124138245_comment_list_data.json' );
if (!compRes || !compRes.data) {
Logger.info(TAG, `getMineFollowListDataLocal compRes is empty`);
return new MineCommentListDetailItem()
}
Logger.info(TAG, `getMineFollowListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
/**
* 查询是否点赞了这条评论
... ... @@ -557,7 +439,7 @@ class MinePageDatasModel{
Logger.info(TAG, `getAppointmentList start`);
this.fetchOtherUserCommentLikeStatusData(params).then((navResDTO: ResponseDTO<QueryCommentListIsLikedItem[]>) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getOtherUserCommentLikeStatusDataLocal(context))
error(null)
return
}
Logger.info(TAG, "getAppointmentList then,AppointmentResDTO.timeStamp:" + navResDTO.timestamp);
... ... @@ -565,7 +447,7 @@ class MinePageDatasModel{
success(navigationBean);
}).catch((err: Error) => {
Logger.error(TAG, `fetchAppointmentListDataApi catch, error.name : ${err.name}, error.message:${err.message}`);
success(this.getOtherUserCommentLikeStatusDataLocal(context))
error(null)
})
})
}
... ... @@ -576,17 +458,6 @@ class MinePageDatasModel{
return WDHttp.post<ResponseDTO<QueryCommentListIsLikedItem[]>>(url,object, headers)
};
async getOtherUserCommentLikeStatusDataLocal(context: Context): Promise<QueryCommentListIsLikedItem[]> {
Logger.info(TAG, `getMineFollowListDataLocal start`);
let compRes: ResponseDTO<QueryCommentListIsLikedItem[]> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<QueryCommentListIsLikedItem[]>>(context,'other_user512157124138245_comment_list_liked_data.json' );
if (!compRes || !compRes.data) {
Logger.info(TAG, `getMineFollowListDataLocal compRes is empty`);
return []
}
Logger.info(TAG, `getMineFollowListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
/**
* 其他用户的关注列表
* @param params
... ... @@ -598,7 +469,7 @@ class MinePageDatasModel{
Logger.info(TAG, `getAppointmentList start`);
this.fetchOtherUserFollowListData(params).then((navResDTO: ResponseDTO<MineFollowListItem>) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getOtherUserFollowListDataLocal(context))
error(null)
return
}
Logger.info(TAG, "getAppointmentList then,AppointmentResDTO.timeStamp:" + navResDTO.timestamp);
... ... @@ -606,7 +477,7 @@ class MinePageDatasModel{
success(navigationBean);
}).catch((err: Error) => {
Logger.error(TAG, `fetchAppointmentListDataApi catch, error.name : ${err.name}, error.message:${err.message}`);
success(this.getOtherUserFollowListDataLocal(context))
error(null)
})
})
}
... ... @@ -617,17 +488,6 @@ class MinePageDatasModel{
return WDHttp.get<ResponseDTO<MineFollowListItem>>(url, headers)
};
async getOtherUserFollowListDataLocal(context: Context): Promise<MineFollowListItem> {
Logger.info(TAG, `getMineFollowListDataLocal start`);
let compRes: ResponseDTO<MineFollowListItem> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<MineFollowListItem>>(context,'other_user_follow_list_data.json' );
if (!compRes || !compRes.data) {
Logger.info(TAG, `getMineFollowListDataLocal compRes is empty`);
return new MineFollowListItem()
}
Logger.info(TAG, `getMineFollowListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
/**
* 预约 和取消预约操作
* @param params
... ... @@ -639,14 +499,14 @@ class MinePageDatasModel{
Logger.info(TAG, `getAppointmentList start`);
this.fetchAppointmentOperation(params).then((navResDTO: ResponseDTO) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getAppointmentOperationLocal(context))
error(null)
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.getAppointmentOperationLocal(context))
error(null)
})
})
}
... ... @@ -657,18 +517,6 @@ class MinePageDatasModel{
return WDHttp.post<ResponseDTO>(url,object, headers)
};
async getAppointmentOperationLocal(context: Context): Promise<ResponseDTO> {
Logger.info(TAG, `getMineFollowListDataLocal start`);
let compRes: ResponseDTO | null = await ResourcesUtils.getResourcesJson<ResponseDTO>(context,'appointment_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
... ... @@ -680,14 +528,14 @@ class MinePageDatasModel{
Logger.info(TAG, `getAppointmentList start`);
this.fetchCommentLikeOperation(params).then((navResDTO: ResponseDTO) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getCommentLikeOperationLocal(context))
error(null)
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))
error(null)
})
})
}
... ... @@ -698,17 +546,6 @@ class MinePageDatasModel{
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
... ... @@ -720,14 +557,14 @@ class MinePageDatasModel{
Logger.info(TAG, `getAppointmentList start`);
this.fetchFollowOperation(params).then((navResDTO: ResponseDTO) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getFollowOperationLocal(context))
error(null)
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))
error(null)
})
})
}
... ... @@ -738,17 +575,6 @@ class MinePageDatasModel{
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
}
}
... ...
... ... @@ -100,7 +100,7 @@ class SearcherAboutDataModel{
Logger.info(TAG, `getSearchHintData start`);
this.fetchSearchHintData().then((navResDTO: ResponseDTO<string[]>) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getSearchHintDataLocal(context))
error(null)
return
}
Logger.info(TAG, "getSearchHintData then,SearchHintDataResDTO.timeStamp:" + navResDTO.timestamp);
... ... @@ -108,7 +108,7 @@ class SearcherAboutDataModel{
success(navigationBean);
}).catch((err: Error) => {
Logger.error(TAG, `fetchSearchHintData catch, error.name : ${err.name}, error.message:${err.message}`);
success(this.getSearchHintDataLocal(context))
error(null)
})
})
}
... ... @@ -119,17 +119,6 @@ class SearcherAboutDataModel{
return WDHttp.get<ResponseDTO<string[]>>(url, headers)
};
async getSearchHintDataLocal(context: Context): Promise<string[]> {
Logger.info(TAG, `getSearchHintDataLocal start`);
let compRes: ResponseDTO<string[]> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<string[]>>(context,'search_hint_data.json' );
if (!compRes || !compRes.data) {
Logger.info(TAG, `getSearchHintDataLocal compRes is empty`);
return []
}
Logger.info(TAG, `getSearchHintDataLocal compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
/**
* 搜索主页 热词
... ... @@ -139,7 +128,7 @@ class SearcherAboutDataModel{
Logger.info(TAG, `getSearchHintData start`);
this.fetchSearchHotsData().then((navResDTO: ResponseDTO<SearchHotContentItem[]>) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getSearchHotsDataLocal(context))
error(null)
return
}
Logger.info(TAG, "getSearchHotsData then,getSearchHotsData.timeStamp:" + navResDTO.timestamp);
... ... @@ -147,7 +136,7 @@ class SearcherAboutDataModel{
success(navigationBean);
}).catch((err: Error) => {
Logger.error(TAG, `getSearchHotsData catch, error.name : ${err.name}, error.message:${err.message}`);
success(this.getSearchHotsDataLocal(context))
error(null)
})
})
}
... ... @@ -158,18 +147,6 @@ class SearcherAboutDataModel{
return WDHttp.get<ResponseDTO<SearchHotContentItem[]>>(url, headers)
};
async getSearchHotsDataLocal(context: Context): Promise<SearchHotContentItem[]> {
Logger.info(TAG, `getSearchHotsDataLocal start`);
let compRes: ResponseDTO<SearchHotContentItem[]> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<SearchHotContentItem[]>>(context,'search_hots_data.json' ,);
if (!compRes || !compRes.data) {
Logger.info(TAG, `getSearchHotsDataLocal compRes is empty`);
return []
}
Logger.info(TAG, `getSearchHotsDataLocal compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
/**
* 搜索 联想词
*/
... ... @@ -178,7 +155,7 @@ class SearcherAboutDataModel{
Logger.info(TAG, `getSearchHintData start`);
this.fetchRelatedSearchContentData(keyword).then((navResDTO: ResponseDTO<string[]>) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getRelatedSearchContentDataLocal(context))
error(null)
return
}
Logger.info(TAG, "getSearchHintData then,SearchHintDataResDTO.timeStamp:" + navResDTO.timestamp);
... ... @@ -186,7 +163,7 @@ class SearcherAboutDataModel{
success(navigationBean);
}).catch((err: Error) => {
Logger.error(TAG, `fetchSearchHintData catch, error.name : ${err.name}, error.message:${err.message}`);
success(this.getRelatedSearchContentDataLocal(context))
error(null)
})
})
}
... ... @@ -197,17 +174,6 @@ class SearcherAboutDataModel{
return WDHttp.get<ResponseDTO<string[]>>(url, headers)
};
async getRelatedSearchContentDataLocal(context: Context): Promise<string[]> {
Logger.info(TAG, `getSearchHintDataLocal start`);
let compRes: ResponseDTO<string[]> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<string[]>>(context,'search_related_data_nimen.json' );
if (!compRes || !compRes.data) {
Logger.info(TAG, `getSearchHintDataLocal compRes is empty`);
return []
}
Logger.info(TAG, `getSearchHintDataLocal compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
/**
* 搜索结果 展示tab数量
*/
... ... @@ -216,7 +182,7 @@ class SearcherAboutDataModel{
Logger.info(TAG, `getSearchResultCountData start`);
this.fetchSearchResultCountData(keyword).then((navResDTO: ResponseDTO<SearchResultCountItem>) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getSearchResultCountDataLocal(context))
error(null)
return
}
Logger.info(TAG, "getSearchResultCountData then,SearchHintDataResDTO.timeStamp:" + navResDTO.timestamp);
... ... @@ -224,7 +190,7 @@ class SearcherAboutDataModel{
success(navigationBean);
}).catch((err: Error) => {
Logger.error(TAG, `getSearchResultCountData catch, error.name : ${err.name}, error.message:${err.message}`);
success(this.getSearchResultCountDataLocal(context))
error(null)
})
})
}
... ... @@ -235,17 +201,6 @@ class SearcherAboutDataModel{
return WDHttp.get<ResponseDTO<SearchResultCountItem>>(url, headers)
};
async getSearchResultCountDataLocal(context: Context): Promise<SearchResultCountItem> {
Logger.info(TAG, `getSearchResultCountDataLocal start`);
let compRes: ResponseDTO<SearchResultCountItem> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<SearchResultCountItem>>(context,'search_result_count_data.json' );
if (!compRes || !compRes.data) {
Logger.info(TAG, `getSearchResultCountDataLocal compRes is empty`);
return new SearchResultCountItem()
}
Logger.info(TAG, `getSearchResultCountDataLocal compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
/**
* 搜索结果 展示列表
*/
... ... @@ -254,7 +209,7 @@ class SearcherAboutDataModel{
Logger.info(TAG, `getSearchResultListData start`);
this.fetchSearchResultListData(pageSize,pageNum,searchType,keyword).then((navResDTO: ResponseDTO<SearchResultContentData>) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getSearchResultListDataLocal(context))
error(null)
return
}
Logger.info(TAG, "getSearchResultListData then,SearchResultListResDTO.timeStamp:" + navResDTO.timestamp);
... ... @@ -262,7 +217,7 @@ class SearcherAboutDataModel{
success(navigationBean);
}).catch((err: Error) => {
Logger.error(TAG, `getSearchResultListData catch, error.name : ${err.name}, error.message:${err.message}`);
success(this.getSearchResultListDataLocal(context))
error(null)
})
})
}
... ... @@ -273,17 +228,6 @@ class SearcherAboutDataModel{
return WDHttp.get<ResponseDTO<SearchResultContentData>>(url, headers)
};
async getSearchResultListDataLocal(context: Context): Promise<SearchResultContentData> {
Logger.info(TAG, `getSearchResultListDataLocal start`);
let compRes: ResponseDTO<SearchResultContentData> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<SearchResultContentData>>(context,'search_result_list_data.json' );
if (!compRes || !compRes.data) {
Logger.info(TAG, `getSearchResultListDataLocal compRes is empty`);
return new SearchResultContentData()
}
Logger.info(TAG, `getSearchResultListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
/**
* 搜索结果 展示列表(交互详情 评论收藏点赞分享数量)
*/
... ... @@ -292,7 +236,7 @@ class SearcherAboutDataModel{
Logger.info(TAG, `getInteractListData start`);
this.fetchInteractListData(data).then((navResDTO: ResponseDTO<InteractDataDTO[]>) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getInteractListDataLocal(context))
error(null)
return
}
Logger.info(TAG, "getInteractListData then,SearchResultListResDTO.timeStamp:" + navResDTO.timestamp);
... ... @@ -300,7 +244,7 @@ class SearcherAboutDataModel{
success(navigationBean);
}).catch((err: Error) => {
Logger.error(TAG, `getInteractListData catch, error.name : ${err.name}, error.message:${err.message}`);
success(this.getInteractListDataLocal(context))
error(null)
})
})
}
... ... @@ -311,18 +255,6 @@ class SearcherAboutDataModel{
return WDHttp.post<ResponseDTO<InteractDataDTO[]>>(url,data, headers)
};
async getInteractListDataLocal(context: Context): Promise<InteractDataDTO[]> {
Logger.info(TAG, `getInteractListDataLocal start`);
let compRes: ResponseDTO<InteractDataDTO[]> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<InteractDataDTO[]>>(context,'search_result_interact_list_data.json' );
if (!compRes || !compRes.data) {
Logger.info(TAG, `getInteractListDataLocal compRes is empty`);
return []
}
Logger.info(TAG, `getInteractListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
/**
* 获取关注详情 列表
*/
... ... @@ -331,7 +263,7 @@ class SearcherAboutDataModel{
Logger.info(TAG, `getCreatorDetailListData start`);
this.fetchCreatorDetailListData(object).then((navResDTO: ResponseDTO<CreatorDetailResponseItem[]>) => {
if (!navResDTO || navResDTO.code != 0) {
success([])
error(null)
return
}
Logger.info(TAG, "getCreatorDetailListData then,SearchResultListResDTO.timeStamp:" + navResDTO.timestamp);
... ... @@ -339,7 +271,7 @@ class SearcherAboutDataModel{
success(navigationBean);
}).catch((err: Error) => {
Logger.error(TAG, `getCreatorDetailListData catch, error.name : ${err.name}, error.message:${err.message}`);
success([])
error(null)
})
})
}
... ... @@ -357,9 +289,8 @@ class SearcherAboutDataModel{
return new Promise<ContentDTO[]>((success, error) => {
Logger.info(TAG, `getSearchSuggestData start`);
this.fetchSearchSuggestData(object).then((navResDTO: ResponseDTO<ContentDTO[]>) => {
if (!navResDTO || navResDTO.code != 0 /*|| navResDTO.data == null*/) {
// success(this.getSearchSuggestDataLocal(context))
success([])
if (!navResDTO || navResDTO.code != 0 ) {
error(null)
return
}
Logger.info(TAG, "getSearchSuggestData then,SearchResultListResDTO.timeStamp:" + navResDTO.timestamp);
... ... @@ -367,8 +298,7 @@ class SearcherAboutDataModel{
success(navigationBean);
}).catch((err: Error) => {
Logger.error(TAG, `getSearchSuggestData catch, error.name : ${err.name}, error.message:${err.message}`);
// success(this.getSearchSuggestDataLocal(context))
success([])
error(null)
})
})
}
... ... @@ -379,20 +309,6 @@ class SearcherAboutDataModel{
return WDHttp.post<ResponseDTO<ContentDTO[]>>(url,object, headers)
};
async getSearchSuggestDataLocal(context: Context): Promise<ContentDTO[]> {
Logger.info(TAG, `getInteractListDataLocal start`);
let compRes: ResponseDTO<ContentDTO[]> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<ContentDTO[]>>(context,'search_suggest_data.json' );
if (!compRes || !compRes.data) {
Logger.info(TAG, `getInteractListDataLocal compRes is empty`);
return []
}
Logger.info(TAG, `getInteractListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
}
const searcherAboutDataModel = SearcherAboutDataModel.getInstance()
... ...
... ... @@ -65,9 +65,8 @@ struct MineHomePage {
.height('130lpx')
.objectFit(ImageFit.Cover)
}.onClick(()=>{
let params: Params = {
pageID: "531267787833221"//sit 测试用 512157124138245
}
//TODO 显示头像
let params = {'userId': "531267787833221"} as Record<string, string>;
WDRouterRule.jumpWithPage(WDRouterPage.otherNormalUserHomePagePage,params)
}).width('135lpx')
.height('135lpx')
... ...
... ... @@ -11,11 +11,11 @@ const TAG = "OtherNormalUserHomePage"
@Entry
@Component
struct OtherNormalUserHomePage {
@State params:Params = router.getParams() as Params;
@State params:Record<string, string> = router.getParams() as Record<string, string>;
@Watch('change') @State curUserId: string = '-1';
onPageShow() {
this.curUserId = this.params?.pageID;
this.curUserId = this.params?.['userId'];
}
change(){
... ...
import HashMap from '@ohos.util.HashMap';
import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork';
import { DateTimeUtils, Logger } from 'wdKit';
import { DateTimeUtils, Logger, StringUtils } from 'wdKit';
import {
batchLikeAndCollectResult,
CompInfoBean,
... ... @@ -128,6 +128,19 @@ export class PageRepository {
return url;
}
static getInteractDataV2Url(contentId: string, contentType: string, contentRelId: string,rmhPlatform:number) {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_V2_DATA_PATH;
url = url + "?contentId=" + contentId
+ "&contentType=" + contentType
if(!StringUtils.isEmpty(contentRelId)){
url = url + "&contentRelId=" + contentRelId;
}
url = url + "&rmhPlatform=" + rmhPlatform;
url = url + "&detail=" + '1';
Logger.info(TAG, "getInteractDataV2Url url = " + url)
return url;
}
static getInteractDataUrl() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_PATH;
Logger.info(TAG, "getInteractDataUrl url = " + url)
... ... @@ -253,6 +266,12 @@ export class PageRepository {
return WDHttp.get<ResponseDTO<ContentDetailDTO[]>>(url, headers)
};
static fetchInteractDataV2(contentId: string, contentType: string, contentRelId: string,rmhPlatform:number) {
let url = PageRepository.getInteractDataV2Url(contentId, contentType, contentRelId,rmhPlatform)
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.get<ResponseDTO<InteractDataDTO>>(url, headers)
};
static fetchInteractData(param: object) {
let url = PageRepository.getInteractDataUrl()
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
... ...
import promptAction from '@ohos.promptAction';
import { RefreshConstants as Const, RefreshState } from './RefreshConstants';
import { touchMoveLoadMore, touchUpLoadMore } from './PullUpLoadMore';
import { PageDTO, CompDTO } from 'wdBean';
import PageModel from '../viewmodel/PageModel';
import PageViewModel from '../viewmodel/PageViewModel';
import { DateTimeUtils } from 'wdKit';
import PageHelper from '../viewmodel/PageHelper';
import PageAdModel from '../viewmodel/PageAdvModel';
export function listTouchEvent(pageModel: PageModel,pageAdvModel:PageAdModel, event: TouchEvent) {
export function listTouchEvent(pageModel: PageModel, pageAdvModel: PageAdModel, event: TouchEvent) {
switch (event.type) {
case TouchType.Down:
pageModel.downY = event.touches[0].y;
... ... @@ -36,7 +32,7 @@ export function listTouchEvent(pageModel: PageModel,pageAdvModel:PageAdModel, ev
}
if ((pageModel.isPullRefreshOperation === true)) {
// Lift your finger and pull down to refresh.
touchUpPullRefresh(pageModel,pageAdvModel);
touchUpPullRefresh(pageModel, pageAdvModel);
} else {
// Fingers up, handle loading more.
touchUpLoadMore(pageModel);
... ... @@ -66,7 +62,7 @@ export function touchMovePullRefresh(pageModel: PageModel, event: TouchEvent) {
}
}
export function touchUpPullRefresh(pageModel: PageModel,pageAdvModel:PageAdModel) {
export function touchUpPullRefresh(pageModel: PageModel, pageAdvModel: PageAdModel) {
if (pageModel.isCanRefresh === true) {
pageModel.offsetY = vp2px(pageModel.pullDownRefreshHeight);
pullRefreshState(pageModel, RefreshState.Refreshing);
... ... @@ -74,38 +70,26 @@ export function touchUpPullRefresh(pageModel: PageModel,pageAdvModel:PageAdModel
setTimeout(() => {
let self: PageModel = pageModel;
let advSelf: PageAdModel = pageAdvModel;
PageHelper.refreshUI(self,advSelf)
// PageViewModel.getPageData(self.bizCopy(2))
// .then((data: PageDTO) => {
// self.timestamp = DateTimeUtils.getTimeStamp().toString()
// if (data == null || data.compList == null || data.compList.length == 0) {
// self.hasMore = false;
// } else {
// if (data.compList.length == self.pageSize) {
// self.currentPage++;
// self.hasMore = true;
// } else {
// self.hasMore = false;
// }
// // 刷新,替换所有数据
// self.compList.replaceAll(...data.compList)
// PageViewModel.getInteractData(data.compList).then((data: CompDTO[]) => {
// // 刷新,替换所有数据
// self.compList.replaceAll(...data)
// self.timestamp = DateTimeUtils.getTimeStamp().toString()
// })
// }
// closeRefresh(self, true);
// }).catch((err: string | Resource) => {
// promptAction.showToast({ message: err });
// closeRefresh(self, false);
// });
PageHelper.refreshUI(self, advSelf)
}, Const.DELAY_TIME);
} else {
closeRefresh(pageModel, false);
}
}
/**
* 自动刷新接口,如首页底导,双击按钮自动刷新
* @param pageModel 页面数据
* @param pageAdvModel 广告数据
*/
export function autoRefresh(pageModel: PageModel, pageAdvModel: PageAdModel) {
pageModel.isVisiblePullDown = true;
pageModel.offsetY = vp2px(pageModel.pullDownRefreshHeight);
pullRefreshState(pageModel, RefreshState.Refreshing);
pageModel.currentPage = 1;
PageHelper.refreshUI(pageModel, pageAdvModel)
}
export function pullRefreshState(pageModel: PageModel, state: number) {
switch (state) {
case RefreshState.DropDown:
... ...
import promptAction from '@ohos.promptAction';
import PageModel from '../viewmodel/PageModel';
import { RefreshConstants as Const } from './RefreshConstants';
import PageViewModel from '../viewmodel/PageViewModel';
import { PageDTO, CompDTO } from 'wdBean';
import { DateTimeUtils } from 'wdKit';
import PageHelper from '../viewmodel/PageHelper';
export function touchMoveLoadMore(model: PageModel, event: TouchEvent) {
... ... @@ -30,29 +26,6 @@ export function touchUpLoadMore(model: PageModel) {
setTimeout(() => {
closeLoadMore(model);
PageHelper.loadMore(self)
// PageViewModel.getPageData(self.bizCopy())
// .then((data: PageDTO) => {
// self.timestamp = DateTimeUtils.getTimeStamp().toString()
// if (data == null || data.compList == null || data.compList.length == 0) {
// self.hasMore = false;
// } else {
// if (data.compList.length == self.pageSize) {
// self.currentPage++;
// self.hasMore = true;
// } else {
// self.hasMore = false;
// }
// let sizeBefore: number = self.compList.size();
// self.compList.push(...data.compList)
// PageViewModel.getInteractData(data.compList).then((data: CompDTO[]) => {
// // 刷新,替换所有数据
// self.compList.updateItems(sizeBefore, data)
// self.timestamp = DateTimeUtils.getTimeStamp().toString()
// })
// }
// }).catch((err: string | Resource) => {
// promptAction.showToast({ message: err });
// })
}, Const.DELAY_TIME);
} else {
closeLoadMore(self);
... ...
... ... @@ -21,6 +21,7 @@ export class LikeViewModel {
this.likeModel.executeLike(bean)
}
//点赞
executeLike2(bean: Record<string, string>) {
return new Promise<object>((success, fail) => {
... ... @@ -32,4 +33,20 @@ export class LikeViewModel {
})
}
//点赞状态
getLikeStatus(bean: Record<string, string>) {
return new Promise<object>((success, fail) => {
this.likeModel.getLikeStatus(bean).then((data) => {
success(data)
}).catch((error: string) => {
fail(error)
})
})
}
}
\ No newline at end of file
... ...
... ... @@ -5,7 +5,8 @@ import { ContentDetailDTO,
batchLikeAndCollectResult,
postBatchAttentionStatusParams,
postBatchAttentionStatusResult,
postInteractBrowsOperateParams
postInteractBrowsOperateParams,
InteractDataDTO
} from 'wdBean';
import { PageRepository } from '../repository/PageRepository';
... ... @@ -106,4 +107,28 @@ export class MultiPictureDetailViewModel {
})
}
//查询点赞数量
static async interactDataV2(contentId: string, contentType: string, contentRelId: string,rmhPlatform:number): Promise<InteractDataDTO> {
return new Promise<InteractDataDTO>((success, error) => {
Logger.info(TAG, `interactDataV2 start`);
PageRepository.fetchInteractDataV2(contentId, contentType, contentRelId,rmhPlatform).then((resDTO: ResponseDTO<InteractDataDTO>) => {
if (!resDTO || !resDTO.data) {
Logger.error(TAG, 'interactDataV2 is empty');
error('resDTO is empty');
return
}
if (resDTO.code != 0) {
Logger.error(TAG, `interactDataV2 then code:${resDTO.code}, message:${resDTO.message}`);
error('resDTO Response Code is failure');
return
}
Logger.info(TAG, "interactDataV2 then,navResDTO.timestamp:" + resDTO.timestamp);
success(resDTO.data);
}).catch((err: Error) => {
Logger.error(TAG, `interactDataV2 catch, error.name : ${err.name}, error.message:${err.message}`);
error(err);
})
})
}
}
... ...
import { PageDTO, CompDTO, PageInfoDTO, ContentDTO } from 'wdBean';
import { CompStyle, ViewType } from 'wdConstant/Index';
import { CollectionUtils, DateTimeUtils, Logger } from 'wdKit';
import { CollectionUtils, DateTimeUtils, Logger, NetworkUtil } from 'wdKit';
import { closeRefresh } from '../utils/PullDownRefresh';
import PageModel from './PageModel';
import PageViewModel from './PageViewModel';
... ... @@ -8,6 +8,7 @@ import { promptAction } from '@kit.ArkUI';
import { AdvRuleBean, CompAdvBean } from 'wdBean/src/main/ets/bean/adv/AdvsRuleBean';
import PageAdModel from './PageAdvModel';
import { ArrayList } from '@kit.ArkTS';
import { WDViewDefaultType } from '../components/view/EmptyComponent';
const TAG = 'PageHelper';
... ... @@ -37,22 +38,31 @@ export class PageHelper {
*/
async getInitData(pageModel: PageModel, pageAdvModel: PageAdModel) {
pageModel.loadStrategy = 1
this.getPageInfo(pageModel, pageAdvModel)
let netStatus = NetworkUtil.isNetConnected()
if (netStatus) {
this.getPageInfo(pageModel, pageAdvModel)
} else {
pageModel.viewType = ViewType.EMPTY;
pageModel.emptyType = WDViewDefaultType.WDViewDefaultType_NoNetwork;
}
}
async getPageInfo(pageModel: PageModel, pageAdvModel: PageAdModel) {
getPageInfo(pageModel: PageModel, pageAdvModel: PageAdModel) {
pageModel.currentPage = 1;
let pageInfo = await PageViewModel.getPageInfo(pageModel.pageId);
if (pageInfo == null) {
PageViewModel.getPageInfo(pageModel.pageId).then(pageInfo => {
if (pageInfo == null) {
pageModel.viewType = ViewType.EMPTY;
pageModel.emptyType = WDViewDefaultType.WDViewDefaultType_NoListContent;
return;
}
pageModel.pageInfo = pageInfo;
//解析广告资源
pageAdvModel.analysisAdvSource(pageInfo);
this.parseGroup(pageModel)
}).catch(() => {
pageModel.viewType = ViewType.EMPTY;
return;
}
pageModel.pageInfo = pageInfo;
//解析广告资源
pageAdvModel.analysisAdvSource(pageInfo)
this.parseGroup(pageModel)
pageModel.emptyType = WDViewDefaultType.WDViewDefaultType_ContentFailed;
})
}
... ... @@ -84,6 +94,8 @@ export class PageHelper {
// 没数据,展示空页面
Logger.debug(TAG, 'aboutToAppear, data response page ' + pageModel.pageId + ', comp list is empty.');
pageModel.viewType = ViewType.EMPTY;
pageModel.emptyType = WDViewDefaultType.WDViewDefaultType_NoListContent;
}
}
... ...
... ... @@ -5,6 +5,7 @@ import { RefreshConstants as Const } from '../utils/RefreshConstants';
import { PageUIReqBean } from '../components/page/bean/PageUIReqBean';
import { GroupInfoDTO, PageInfoDTO } from 'wdBean/src/main/ets/bean/navigation/PageInfoDTO';
import { AdvRuleBean, CompAdvBean } from 'wdBean/src/main/ets/bean/adv/AdvsRuleBean';
import { WDViewDefaultType } from '../components/view/EmptyComponent';
/**
* 页面下拉刷新、上拉加载数据bean。
... ... @@ -38,6 +39,7 @@ export default class PageModel {
isVisiblePullUpLoad: boolean = false;
offsetY: number = 0;
viewType: number = ViewType.LOADING;
emptyType: WDViewDefaultType = WDViewDefaultType.WDViewDefaultType_Default
hasMore: boolean = true;
startIndex = 0;
endIndex = 0;
... ...
... ... @@ -34,7 +34,7 @@
},
{
"name": "selected_text_size",
"value": "18fp"
"value": "17vp"
},
{
"name": "font_size_18",
... ... @@ -117,6 +117,10 @@
"value": "28vp"
},
{
"name": "margin_40",
"value": "40vp"
},
{
"name": "margin_48",
"value": "48vp"
},
... ... @@ -129,6 +133,10 @@
"value": "60vp"
},
{
"name": "margin_154",
"value": "154vp"
},
{
"name": "single_row_03_img_height",
"value": "88vp"
},
... ... @@ -170,11 +178,11 @@
},
{
"name": "top_tab_item_padding_bottom",
"value": "5vp"
"value": "2vp"
},
{
"name": "top_tab_item_padding_top",
"value": "2vp"
"value": "5vp"
},
{
"name": "top_bar_height",
... ... @@ -185,6 +193,10 @@
"value": "24vp"
},
{
"name": "margin_1",
"value": "1vp"
},
{
"name": "margin_6",
"value": "6vp"
},
... ...
... ... @@ -6,7 +6,7 @@
},
{
"name": "footer_text",
"value": "已经到底了"
"value": "已显示全部内容"
},
{
"name": "pull_up_load_text",
... ...
... ... @@ -98,7 +98,14 @@ export struct DetailPlayLivePage {
(data) => {
if (data.length > 0) {
if (data[0].liveInfo?.liveState == 'wait') {
this.tabs = ['简介', '直播间', '大家聊']
//直播样式 0-正常模式 , 1-隐藏直播间,2-隐藏大家聊 【人民号发布是竖屏的,为空】
if (data[0].liveInfo?.liveStyle == 1) {
this.tabs = ['简介', '大家聊']
} else if (data[0].liveInfo?.liveStyle == 2) {
this.tabs = ['简介', '直播间',]
} else {
this.tabs = ['简介', '直播间', '大家聊']
}
} else {
this.tabs = ['直播间', '大家聊']
}
... ...
... ... @@ -4,6 +4,7 @@ import { devicePLSensorManager } from 'wdDetailPlayApi/Index'
import { DateFormatUtil, WDPlayerController } from 'wdPlayer/Index'
import { LiveDetailsBean, LiveRoomDataBean } from 'wdBean/Index'
import { DisplayDirection } from 'wdConstant/Index'
import { LiveFollowComponent } from 'wdComponent/Index'
@Component
export struct PlayUIComponent {
... ... @@ -95,7 +96,17 @@ export struct PlayUIComponent {
bottom: 10
})
this.getLiveStatusView()
Row() {
if (this.liveDetailsBean?.rmhInfo) {
LiveFollowComponent({
rmhInfo: this.liveDetailsBean.rmhInfo
})
.margin({
right: 10
})
}
this.getLiveStatusView()
}
}.width('100%')
.padding({
top: 20,
... ...
... ... @@ -78,7 +78,7 @@ export struct PlayerCommentComponent {
LiveCommentComponent({ heartNum: this.liveRoomDataBean.likeNum })
.visibility(this.displayDirection == DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None)
.backgroundColor(Color.Transparent)
.backgroundColor(Color.Black)
}.alignItems(HorizontalAlign.Start)
}
... ...
import { LiveDetailsBean } from 'wdBean/Index';
import { WDPlayerController, WDPlayerRenderVLiveView, WDPlayerRenderView } from 'wdPlayer/Index';
const TAG = 'PlayerComponent'
@Component
export struct PlayerComponent {
private playerController?: WDPlayerController;
@Prop playerController: WDPlayerController;
@Consume @Watch('updateData') liveDetailsBean: LiveDetailsBean
@Consume @Watch('pageShowChange') pageShow: number
@Consume @Watch('pageHideChange') pageHide: number
... ... @@ -26,17 +26,15 @@ export struct PlayerComponent {
aboutToAppear(): void {
console.log(TAG, 'aboutToAppear')
if (this.playerController) {
this.playerController.onCanplay = () => {
console.log('可以播放了')
this.playerController?.play()
// this.playerController.selfSize
}
this.playerController.onCanplay = () => {
console.log('可以播放了')
this.playerController?.play()
}
}
aboutToDisappear(): void {
this.playerController.onCanplay = () => {
}
this.playerController?.pause()
this.playerController?.stop()
this.playerController?.release()
... ... @@ -74,15 +72,14 @@ export struct PlayerComponent {
.blur(100)
.renderFit(RenderFit.RESIZE_COVER)
// TODO:判断横竖屏,liveStreamType=1竖屏铺满屏幕,liveStreamType=0横屏正常展示
// TODO:判断横竖屏,liveStreamType=1竖屏铺满屏幕,裁剪不拉伸,liveStreamType=0横屏正常展示
if (this.liveStreamType == null) {
WDPlayerRenderVLiveView({
playerController: this.playerController,
onLoad: () => {
this.playerController?.firstPlay(this.playUrl);
}
}).height('100%')
.width('100%')
})
} else if (this.liveStreamType == 0) {
WDPlayerRenderView({
playerController: this.playerController,
... ...
import { LiveDetailsBean, LiveRoomDataBean } from 'wdBean/Index'
import { LiveFollowComponent } from 'wdComponent/Index'
import { NumberFormatterUtils } from 'wdKit/Index'
@Preview
... ... @@ -35,28 +36,12 @@ export struct PlayerTitleComponent {
@Builder
getLiveStatusView() {
if (this.liveDetailsBean.rmhInfo?.rmhName) {
Row() {
Image(this.liveDetailsBean.rmhInfo?.rmhHeadUrl || '')
.width(24)
.aspectRatio(1)
.borderRadius(12)
.fillColor(Color.Transparent)
LiveFollowComponent({
rmhInfo: this.liveDetailsBean.rmhInfo
}).margin({
right: 10
})
Text(this.liveDetailsBean.rmhInfo?.rmhName || '')
.fontSize(12)
.fontWeight(500)
.fontColor(Color.White)
.padding({
top: 2,
right: 8,
left: 4,
bottom: 2
})
}
.backgroundColor('#4D000000')
.borderRadius(2)
.borderRadius({ topLeft: 12, bottomLeft: 12 })
.margin({ right: 8 })
}
... ...
... ... @@ -23,12 +23,12 @@ export struct DetailPlayShortVideoPage {
@Prop index: number = 0
@Prop @Watch('currentIndexChange') currentIndex: number = 0
@State playerController: WDPlayerController = new WDPlayerController();
@Provide contentDetailData: ContentDetailDTO | undefined = undefined
@Provide interactData: InteractDataDTO | undefined = undefined
@Provide contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
@Provide interactData: InteractDataDTO = {} as InteractDataDTO
@Provide isFullScreen: boolean = false;
@Provide progressVal: number = 0;
@Provide videoLandScape?: number = 1; // 视频朝向, 横屏视频:1;竖屏视频:2
@Provide newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态
@Provide newsStatusOfUser: batchLikeAndCollectResult = {} as batchLikeAndCollectResult // 点赞、收藏状态
@Provide followStatus: string = '0' // 关注状态
@Provide isOpenDetail: boolean = false // 查看详情按钮点击
@Provide isDragging: boolean = false // 拖动时间进度条
... ...
... ... @@ -24,10 +24,8 @@ export struct DetailVideoListPage {
@Provide pageHide: number = -1
@Provide switchVideoStatus: boolean = false
@State data: ContentDetailDTO[] = []
@State testData: string[] = ['111', '222', '333']
@State currentIndex: number = 0
@State interactDataList: InteractDataDTO[] = []
@State isFullScreen: boolean = false
async aboutToAppear(): Promise<void> {
this.openFullScreen()
... ... @@ -41,10 +39,7 @@ export struct DetailVideoListPage {
}
await this.getContentDetail(this.contentId, this.relId, this.relType)
}
await this.queryVideoList()
this.getContentInteract()
console.log(TAG, 'aboutToAppear', JSON.stringify(action.params))
}
... ... @@ -93,9 +88,22 @@ export struct DetailVideoListPage {
contentId: contentId,
relId: relId,
relType: relType
}).then((resDTO: ResponseDTO<ContentDetailDTO[]>) => {
console.error('getContentDetail==', JSON.stringify(resDTO.data))
}).then(async (resDTO: ResponseDTO<ContentDetailDTO[]>) => {
console.log(TAG, 'getContentDetail:', JSON.stringify(resDTO.data))
if (resDTO.data) {
const params: contentListParams = {
contentList: [{
contentId: resDTO.data[0].newsId + '',
contentType: resDTO.data[0].newsType
}]
}
// 批量查询内容当前用户点赞、收藏状态
await ContentDetailRequest.getContentInteract(params).then(res => {
if (res.data) {
this.interactDataList = this.interactDataList.concat(res.data)
}
console.log('获取互动点赞等数据===', JSON.stringify(res))
})
this.data.push(resDTO.data[0])
}
})
... ... @@ -108,8 +116,9 @@ export struct DetailVideoListPage {
await ContentDetailRequest.postRecommendVideoList({
pageSize: 5,
refreshCnt: 1
}).then(res => {
}).then(async res => {
if (res.data) {
await this.getContentInteract(res.data)
this.data = this.data.concat(res.data)
console.log('视频列表===', JSON.stringify(res.data))
}
... ... @@ -119,21 +128,21 @@ export struct DetailVideoListPage {
/**
* 批量查询内容当前用户点赞、收藏状态
*/
getContentInteract() {
if (this.data.length > 0) {
async getContentInteract(data: ContentDetailDTO[]) {
if (data.length > 0) {
const params: contentListParams = {
contentList: []
}
this.data.map(item => {
data.map(item => {
params.contentList.push({
contentId: item.newsId + '',
contentType: item.newsType
})
})
// 批量查询内容当前用户点赞、收藏状态
ContentDetailRequest.getContentInteract(params).then(res => {
await ContentDetailRequest.getContentInteract(params).then(res => {
if (res.data) {
this.interactDataList = res.data || []
this.interactDataList = this.interactDataList.concat(res.data)
}
console.log('获取互动点赞等数据===', JSON.stringify(res))
})
... ...
... ... @@ -145,7 +145,7 @@ export struct VideoChannelDetail {
refreshTime: this.refreshTime,
}
await ContentDetailRequest.getRecCompInfo(params).then(res => {
await ContentDetailRequest.getRecCompInfo(params).then(async res => {
this.isRequestError = false
console.log('根据视频频道传参查询视频楼层信息totalCount', res.data?.totalCount + '')
... ... @@ -174,8 +174,8 @@ export struct VideoChannelDetail {
})
}
this.batchContentDetail(list1)
this.getContentInteract(list2)
await this.batchContentDetail(list1, list2)
setTimeout(() => {
this.isMouted = true
}, 500)
... ... @@ -189,11 +189,14 @@ export struct VideoChannelDetail {
/**
* 根据视频楼层信息批量查询视频列表
*/
async batchContentDetail(list: batchContentDetailParams) {
async batchContentDetail(list: batchContentDetailParams, list2: contentListParams) {
if (list.contents.length > 0) {
await ContentDetailRequest.batchContentDetail(list).then(res => {
await ContentDetailRequest.batchContentDetail(list).then(async res => {
if (res.data) {
await this.getContentInteract(list2)
this.data = this.data.concat(res.data)
}
console.log('根据视频楼层信息批量查询视频列表', res.data)
this.data = this.data.concat(res.data as [])
})
}
}
... ... @@ -204,7 +207,9 @@ export struct VideoChannelDetail {
async getContentInteract(list: contentListParams) {
if (list.contentList.length > 0) {
await ContentDetailRequest.getContentInteract(list).then(res => {
this.interactDataList = res.data || []
if (res.data) {
this.interactDataList = this.interactDataList.concat(res.data)
}
console.log('根据视频信息批量查询点赞、收藏状态', res.data)
})
}
... ...
... ... @@ -15,7 +15,9 @@ export struct PlayerProgressView {
if (this.playerController) {
this.playerController.onStatusChange = (status: number) => {
this.status = status
console.log('=============', this.status)
}
this.playerController.onSeekDone = (status: number) => {
this.playerController?.play()
}
}
}
... ...