Merge branch 'main' of http://192.168.1.42/developOne/harmonyPool into main
* 'main' of http://192.168.1.42/developOne/harmonyPool: (32 commits) desc:热门评论相关 50% 绑定手机号 h5专题跳转 H5详情 环境切换 新增样式卡-小视频卡人民号 desc:搜索结果 desc:搜索结果 comp 展现 样式卡作者信息展示优化 权限管理工具类 isFirstIn注释 webview高度自适应 删除冗余样式卡,样式卡集中在cardView和compView文件夹中 样式卡底部来源、评论、发布日期抽离组件 wdComponent Index.ets修改 音频dialog开发抽取工具类 视频频道入口修改 优化通信工具 播放器修改 人民号单图卡ui 直播与视频冲突,分开写 ...
Showing
61 changed files
with
2653 additions
and
1306 deletions
Too many changes to show.
To preserve performance only 61 of 61+ files are displayed.
| @@ -13,6 +13,11 @@ export class SpConstants{ | @@ -13,6 +13,11 @@ export class SpConstants{ | ||
| 13 | //协议相关 | 13 | //协议相关 |
| 14 | static USER_PROTOCOL = "user_protocol" //用户协议 | 14 | static USER_PROTOCOL = "user_protocol" //用户协议 |
| 15 | static PRIVATE_PROTOCOL = "private_protocol" //隐私协议 | 15 | static PRIVATE_PROTOCOL = "private_protocol" //隐私协议 |
| 16 | + static LOGOUT_PROTOCOL = "logout_protocol" //人民日报客户端app注销协议 | ||
| 17 | + static MESSAGE_BOARD_USER_PROTOCOL = "message_board_user_protocol" //"留言板-用户协议" | ||
| 18 | + static MESSAGE_BOARD_NOTICE_PROTOCOL = "message_board_notice_protocol" //留言板-留言须知 | ||
| 19 | + static MESSAGE_BOARD_QUESTION_PROTOCOL = "message_board_question_protocol" //"留言板-发布提问规定"" | ||
| 20 | + static MESSAGE_BOARD_PRIVATE_PROTOCOL = "message_board_private_protocol" //"留言板-隐私政策" | ||
| 16 | //设置页面 | 21 | //设置页面 |
| 17 | static SETTING_WIFI_IMAGE_SWITCH = "setting_wifi_switch" //wifi 图片开关 | 22 | static SETTING_WIFI_IMAGE_SWITCH = "setting_wifi_switch" //wifi 图片开关 |
| 18 | static SETTING_WIFI_VIDEO_SWITCH = "setting_wifi_switch" //wifi 视频开关 | 23 | static SETTING_WIFI_VIDEO_SWITCH = "setting_wifi_switch" //wifi 视频开关 |
| 1 | +/** | ||
| 2 | + * https://developer.huawei.com/consumer/cn/doc/harmonyos-references/js-apis-window-0000001820880785#ZH-CN_TOPIC_0000001811317218__systembarproperties | ||
| 3 | + * 状态栏、导航栏的属性。 | ||
| 4 | + */ | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * 状态栏背景颜色 statusBarColor | ||
| 8 | + * 导航栏背景颜色 navigationBarColor | ||
| 9 | + */ | ||
| 10 | +export const enum SysStatusBarColor { | ||
| 11 | + WHITE = '#ffffff', | ||
| 12 | + BLACK = '#000000', | ||
| 13 | + DEFAULT = '#0x66000000' | ||
| 14 | +} | ||
| 15 | + | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * 状态栏文字颜色 statusBarContentColor8 | ||
| 19 | + * 导航栏文字颜色 navigationBarContentColor8 | ||
| 20 | + */ | ||
| 21 | +export const enum SysBarContentColor { | ||
| 22 | + WHITE = '#ffffff', | ||
| 23 | + BLACK = '#000000', | ||
| 24 | + DEFAULT = '0xE5FFFFFF' | ||
| 25 | +} | ||
| 26 | + | ||
| 27 | + | ||
| 28 | + |
| 1 | import { Action } from './Action'; | 1 | import { Action } from './Action'; |
| 2 | - | 2 | +interface dataObject { |
| 3 | + webViewHeight?: string | ||
| 4 | + dataJson?: string | ||
| 5 | +} | ||
| 3 | /** | 6 | /** |
| 4 | * 消息Message | 7 | * 消息Message |
| 5 | */ | 8 | */ |
| @@ -7,7 +10,7 @@ export class Message { | @@ -7,7 +10,7 @@ export class Message { | ||
| 7 | callbackId: string = ""; //callbackId | 10 | callbackId: string = ""; //callbackId |
| 8 | responseId: string = ""; //responseId | 11 | responseId: string = ""; //responseId |
| 9 | responseData: string = ""; //responseData | 12 | responseData: string = ""; //responseData |
| 10 | - data?: object; //data of message | 13 | + data?: dataObject; //data of message |
| 11 | handlerName: string = ""; //name of handler | 14 | handlerName: string = ""; //name of handler |
| 12 | 15 | ||
| 13 | /** | 16 | /** |
| @@ -36,6 +36,10 @@ export { UserDataLocal } from './src/main/ets/utils/UserDataLocal' | @@ -36,6 +36,10 @@ export { UserDataLocal } from './src/main/ets/utils/UserDataLocal' | ||
| 36 | 36 | ||
| 37 | export { NumberFormatterUtils } from './src/main/ets/utils/NumberFormatterUtils' | 37 | export { NumberFormatterUtils } from './src/main/ets/utils/NumberFormatterUtils' |
| 38 | 38 | ||
| 39 | -// export { PermissionUtils } from './src/main/ets/utils/PermissionUtils' | 39 | +export { PermissionUtils } from './src/main/ets/utils/PermissionUtils' |
| 40 | 40 | ||
| 41 | -export { ErrorToastUtils } from './src/main/ets/utils/ErrorToastUtils' | ||
| 41 | +export { ErrorToastUtils } from './src/main/ets/utils/ErrorToastUtils' | ||
| 42 | + | ||
| 43 | +export { EmitterUtils } from './src/main/ets/utils/EmitterUtils' | ||
| 44 | + | ||
| 45 | +export { EmitterEventId } from './src/main/ets/utils/EmitterEventId' |
| 1 | +import emitter from '@ohos.events.emitter'; | ||
| 2 | + | ||
| 3 | +const TAG: string = 'EmitterUtils'; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * 线程间通信简单工具 | ||
| 7 | + */ | ||
| 8 | +export class EmitterUtils { | ||
| 9 | + /** | ||
| 10 | + * 发送空消息 | ||
| 11 | + * @param eventId 事件id | ||
| 12 | + */ | ||
| 13 | + static sendEmptyEvent(eventId: number) { | ||
| 14 | + let event: emitter.InnerEvent = { | ||
| 15 | + eventId: eventId, | ||
| 16 | + priority: emitter.EventPriority.LOW | ||
| 17 | + }; | ||
| 18 | + emitter.emit(event); | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * 发送消息 | ||
| 23 | + * @param eventId 事件id | ||
| 24 | + * @param str 字符串数据 | ||
| 25 | + */ | ||
| 26 | + static sendEvent(eventId: number, str?: string) { | ||
| 27 | + let event: emitter.InnerEvent = { | ||
| 28 | + eventId: eventId, | ||
| 29 | + priority: emitter.EventPriority.LOW | ||
| 30 | + }; | ||
| 31 | + let eventData: emitter.EventData = { | ||
| 32 | + data: { | ||
| 33 | + jsonStr: str | ||
| 34 | + } | ||
| 35 | + }; | ||
| 36 | + emitter.emit(event, eventData); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * 接收消息 | ||
| 41 | + * @param eventId 事件id | ||
| 42 | + * @param callback 回调函数 | ||
| 43 | + */ | ||
| 44 | + static receiveEvent(eventId: number, callback: (str?: string) => void) { | ||
| 45 | + let event: emitter.InnerEvent = { | ||
| 46 | + eventId: eventId | ||
| 47 | + }; | ||
| 48 | + | ||
| 49 | + // 收到eventId事件后执行该回调 | ||
| 50 | + let callback1 = (eventData?: emitter.EventData): void => { | ||
| 51 | + if (eventData && eventData.data) { | ||
| 52 | + try { | ||
| 53 | + let jsonObject: EmitterBean = JSON.parse(JSON.stringify(eventData.data)) | ||
| 54 | + callback(jsonObject.jsonStr) | ||
| 55 | + } catch (err) { | ||
| 56 | + callback() | ||
| 57 | + } | ||
| 58 | + } else { | ||
| 59 | + callback() | ||
| 60 | + } | ||
| 61 | + }; | ||
| 62 | + // 订阅eventId事件 | ||
| 63 | + emitter.on(event, callback1); | ||
| 64 | + } | ||
| 65 | +} | ||
| 66 | + | ||
| 67 | +interface EmitterBean { | ||
| 68 | + jsonStr: string | ||
| 69 | +} |
| 1 | -// import { abilityAccessCtrl, bundleManager, common, Permissions, Want } from '@kit.AbilityKit' | ||
| 2 | -// import { BusinessError } from '@kit.BasicServicesKit' | ||
| 3 | -// import { AppUtils } from './AppUtils' | ||
| 4 | -// import { Logger } from './Logger' | ||
| 5 | -// | ||
| 6 | -// /** | ||
| 7 | -// * 权限工具类 | ||
| 8 | -// * */ | ||
| 9 | -// export class PermissionUtils { | ||
| 10 | -// //相机权限 | ||
| 11 | -// static CAMERA: Permissions = 'ohos.permission.CAMERA' | ||
| 12 | -// //文件权限 | ||
| 13 | -// static READ_MEDIA: Permissions = 'ohos.permission.READ_MEDIA' | ||
| 14 | -// static WRITE_MEDIA: Permissions = 'ohos.permission.WRITE_MEDIA' | ||
| 15 | -// private static tokenId: number = 0 | ||
| 16 | -// | ||
| 17 | -// /**检查权限是否授权*/ | ||
| 18 | -// static async checkPermissions(permission: Permissions): Promise<boolean> { | ||
| 19 | -// let hasPermissions = false; | ||
| 20 | -// let grantStatus: abilityAccessCtrl.GrantStatus = await PermissionUtils.checkAccessToken(permission); | ||
| 21 | -// | ||
| 22 | -// if (grantStatus === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) { | ||
| 23 | -// // 已经授权,可以继续访问目标操作 | ||
| 24 | -// hasPermissions = true; | ||
| 25 | -// } else { | ||
| 26 | -// hasPermissions = false; | ||
| 27 | -// // 申请日历权限 | ||
| 28 | -// } | ||
| 29 | -// return hasPermissions; | ||
| 30 | -// } | ||
| 31 | -// | ||
| 32 | -// /**动态申请权限*/ | ||
| 33 | -// static reqPermissionsFromUser(permissions: Array<Permissions>, component: Object): Promise<boolean> { | ||
| 34 | -// | ||
| 35 | -// return new Promise((resolve, fail) => { | ||
| 36 | -// let context = getContext(component) as common.UIAbilityContext; | ||
| 37 | -// let atManager = abilityAccessCtrl.createAtManager(); | ||
| 38 | -// atManager.requestPermissionsFromUser(context, permissions).then((data) => { | ||
| 39 | -// let grantStatus: Array<number> = data.authResults; | ||
| 40 | -// let length: number = grantStatus.length; | ||
| 41 | -// | ||
| 42 | -// for (let i = 0; i < length; i++) { | ||
| 43 | -// if (grantStatus[i] === 0) { | ||
| 44 | -// // 用户授权,可以继续访问目标操作 | ||
| 45 | -// resolve(true); | ||
| 46 | -// } else { | ||
| 47 | -// resolve(false) | ||
| 48 | -// } | ||
| 49 | -// } | ||
| 50 | -// }).catch((err: Error) => { | ||
| 51 | -// fail(err) | ||
| 52 | -// }) | ||
| 53 | -// }); | ||
| 54 | -// } | ||
| 55 | -// | ||
| 56 | -// /**跳转设置页面*/ | ||
| 57 | -// static openPermissionsInSystemSettings(context: Object): void { | ||
| 58 | -// let uiContext = getContext(context) as common.UIAbilityContext; | ||
| 59 | -// let wantInfo: Want = { | ||
| 60 | -// bundleName: 'com.huawei.hmos.settings', | ||
| 61 | -// abilityName: 'com.huawei.hmos.settings.MainAbility', | ||
| 62 | -// uri: 'application_info_entry', | ||
| 63 | -// parameters: { | ||
| 64 | -// pushParams: AppUtils.getPackageName(uiContext) // 打开指定应用的设置页面 | ||
| 65 | -// } | ||
| 66 | -// } | ||
| 67 | -// uiContext.startAbility(wantInfo) | ||
| 68 | -// } | ||
| 69 | -// | ||
| 70 | -// private static async checkAccessToken(permission: Permissions): Promise<abilityAccessCtrl.GrantStatus> { | ||
| 71 | -// let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager(); | ||
| 72 | -// let grantStatus: abilityAccessCtrl.GrantStatus = abilityAccessCtrl.GrantStatus.PERMISSION_DENIED; | ||
| 73 | -// | ||
| 74 | -// // 获取应用程序的accessTokenID | ||
| 75 | -// if (PermissionUtils.tokenId == 0) { | ||
| 76 | -// try { | ||
| 77 | -// let bundleInfo: bundleManager.BundleInfo = await bundleManager.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION); | ||
| 78 | -// let appInfo: bundleManager.ApplicationInfo = bundleInfo.appInfo; | ||
| 79 | -// PermissionUtils.tokenId = appInfo.accessTokenId; | ||
| 80 | -// } catch (error) { | ||
| 81 | -// const err: BusinessError = error as BusinessError; | ||
| 82 | -// } | ||
| 83 | -// } | ||
| 84 | -// // 校验应用是否被授予权限 | ||
| 85 | -// try { | ||
| 86 | -// grantStatus = await atManager.checkAccessToken(PermissionUtils.tokenId, permission); | ||
| 87 | -// } catch (error) { | ||
| 88 | -// const err: BusinessError = error as BusinessError; | ||
| 89 | -// } | ||
| 90 | -// | ||
| 91 | -// return grantStatus; | ||
| 92 | -// } | ||
| 93 | -// | ||
| 94 | -// } | ||
| 1 | +import { abilityAccessCtrl, bundleManager, common, Permissions, Want } from '@kit.AbilityKit' | ||
| 2 | +import { BusinessError } from '@kit.BasicServicesKit' | ||
| 3 | +import { AppUtils } from './AppUtils' | ||
| 4 | +import { Logger } from './Logger' | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * 权限工具类 | ||
| 8 | + * */ | ||
| 9 | +export class PermissionUtils { | ||
| 10 | + //相机权限 | ||
| 11 | + static CAMERA: Permissions = 'ohos.permission.CAMERA' | ||
| 12 | + //文件权限 | ||
| 13 | + static READ_MEDIA: Permissions = 'ohos.permission.READ_MEDIA' | ||
| 14 | + static WRITE_MEDIA: Permissions = 'ohos.permission.WRITE_MEDIA' | ||
| 15 | + private static tokenId: number = 0 | ||
| 16 | + | ||
| 17 | + /**检查权限是否授权*/ | ||
| 18 | + static async checkPermissions(permission: Permissions): Promise<boolean> { | ||
| 19 | + let hasPermissions = false; | ||
| 20 | + let grantStatus: abilityAccessCtrl.GrantStatus = await PermissionUtils.checkAccessToken(permission); | ||
| 21 | + | ||
| 22 | + if (grantStatus === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) { | ||
| 23 | + // 已经授权,可以继续访问目标操作 | ||
| 24 | + hasPermissions = true; | ||
| 25 | + } else { | ||
| 26 | + hasPermissions = false; | ||
| 27 | + // 申请日历权限 | ||
| 28 | + } | ||
| 29 | + return hasPermissions; | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + /**动态申请权限*/ | ||
| 33 | + static reqPermissionsFromUser(permissions: Array<Permissions>, component: Object): Promise<boolean> { | ||
| 34 | + | ||
| 35 | + return new Promise((resolve, fail) => { | ||
| 36 | + let context = getContext(component) as common.UIAbilityContext; | ||
| 37 | + let atManager = abilityAccessCtrl.createAtManager(); | ||
| 38 | + atManager.requestPermissionsFromUser(context, permissions).then((data) => { | ||
| 39 | + let grantStatus: Array<number> = data.authResults; | ||
| 40 | + let length: number = grantStatus.length; | ||
| 41 | + | ||
| 42 | + for (let i = 0; i < length; i++) { | ||
| 43 | + if (grantStatus[i] === 0) { | ||
| 44 | + // 用户授权,可以继续访问目标操作 | ||
| 45 | + resolve(true); | ||
| 46 | + } else { | ||
| 47 | + resolve(false) | ||
| 48 | + } | ||
| 49 | + } | ||
| 50 | + }).catch((err: Error) => { | ||
| 51 | + fail(err) | ||
| 52 | + }) | ||
| 53 | + }); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + /**跳转设置页面*/ | ||
| 57 | + static openPermissionsInSystemSettings(context: Object): void { | ||
| 58 | + let uiContext = getContext(context) as common.UIAbilityContext; | ||
| 59 | + let wantInfo: Want = { | ||
| 60 | + bundleName: 'com.huawei.hmos.settings', | ||
| 61 | + abilityName: 'com.huawei.hmos.settings.MainAbility', | ||
| 62 | + uri: 'application_info_entry', | ||
| 63 | + parameters: { | ||
| 64 | + pushParams: AppUtils.getPackageName(uiContext) // 打开指定应用的设置页面 | ||
| 65 | + } | ||
| 66 | + } | ||
| 67 | + uiContext.startAbility(wantInfo) | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + private static async checkAccessToken(permission: Permissions): Promise<abilityAccessCtrl.GrantStatus> { | ||
| 71 | + let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager(); | ||
| 72 | + let grantStatus: abilityAccessCtrl.GrantStatus = abilityAccessCtrl.GrantStatus.PERMISSION_DENIED; | ||
| 73 | + | ||
| 74 | + // 获取应用程序的accessTokenID | ||
| 75 | + if (PermissionUtils.tokenId == 0) { | ||
| 76 | + try { | ||
| 77 | + let bundleInfo: bundleManager.BundleInfo = await bundleManager.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION); | ||
| 78 | + let appInfo: bundleManager.ApplicationInfo = bundleInfo.appInfo; | ||
| 79 | + PermissionUtils.tokenId = appInfo.accessTokenId; | ||
| 80 | + } catch (error) { | ||
| 81 | + const err: BusinessError = error as BusinessError; | ||
| 82 | + } | ||
| 83 | + } | ||
| 84 | + // 校验应用是否被授予权限 | ||
| 85 | + try { | ||
| 86 | + grantStatus = await atManager.checkAccessToken(PermissionUtils.tokenId, permission); | ||
| 87 | + } catch (error) { | ||
| 88 | + const err: BusinessError = error as BusinessError; | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + return grantStatus; | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | +} |
| @@ -4,3 +4,5 @@ export { HttpRequest as WDHttp } from "./src/main/ets/http/HttpRequest" | @@ -4,3 +4,5 @@ export { HttpRequest as WDHttp } from "./src/main/ets/http/HttpRequest" | ||
| 4 | 4 | ||
| 5 | export { HttpUrlUtils } from "./src/main/ets/http/HttpUrlUtils" | 5 | export { HttpUrlUtils } from "./src/main/ets/http/HttpUrlUtils" |
| 6 | 6 | ||
| 7 | +export { HttpBizUtil } from "./src/main/ets/http/HttpBizUtil" | ||
| 8 | + |
| 1 | +import { SpConstants } from 'wdConstant/Index'; | ||
| 2 | +import { EmitterEventId, EmitterUtils, Logger, SPHelper, ToastUtils } from 'wdKit/Index'; | ||
| 3 | +import HashMap from '@ohos.util.HashMap'; | ||
| 4 | +import { ResponseDTO } from '../bean/ResponseDTO'; | ||
| 5 | +import { HttpUrlUtils, WDHttp } from '../../../../Index'; | ||
| 6 | +import { RefreshTokenRes } from '../bean/RefreshTokenRes'; | ||
| 7 | + | ||
| 8 | +const TAG: string = 'HttpBizUtil' | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 网络请求工具,业务封装http,暂添加TokenInterceptor功能 | ||
| 12 | + * TODO 待优化,将HttpBizUtil接入 AxiosInstance.interceptors.response.use | ||
| 13 | + */ | ||
| 14 | +export class HttpBizUtil { | ||
| 15 | + /** | ||
| 16 | + * get请求,封装了刷新token逻辑,接口选用,不涉及业务接口可以用原来的接口(如page接口)。 | ||
| 17 | + * | ||
| 18 | + * @param url 请求地址 | ||
| 19 | + * @param headers 请求header参数 | ||
| 20 | + * @returns 返回值 | ||
| 21 | + */ | ||
| 22 | + static get<T = string>(url: string, headers?: HashMap<string, string>): Promise<ResponseDTO<T>> { | ||
| 23 | + return new Promise<ResponseDTO<T>>((success, debug) => { | ||
| 24 | + WDHttp.get<ResponseDTO<T>>(url, headers).then((resDTO: ResponseDTO<T>) => { | ||
| 25 | + Logger.debug(TAG, 'get: ' + resDTO.code) | ||
| 26 | + Logger.debug(TAG, 'get: ' + resDTO.message) | ||
| 27 | + // 403:临时token;406:强制下线、封禁、清空登录信息还要跳转登录页面 | ||
| 28 | + if (resDTO.code == 403 || resDTO.code == 406) { | ||
| 29 | + HttpBizUtil.refreshToken().then((token: string) => { | ||
| 30 | + if (headers) { | ||
| 31 | + headers.replace('RMRB-X-TOKEN', token) | ||
| 32 | + headers.replace('cookie', 'RMRB-X-TOKEN=' + token) | ||
| 33 | + } | ||
| 34 | + Logger.debug(TAG, 'get again send: ' + token) | ||
| 35 | + // refreshToken为空场景不处理,直接请求接口。 | ||
| 36 | + WDHttp.get<ResponseDTO<T>>(url, headers).then((resDTO: ResponseDTO<T>) => { | ||
| 37 | + Logger.debug(TAG, 'get again: ' + resDTO.message) | ||
| 38 | + success(resDTO) | ||
| 39 | + }).catch((res: object) => { | ||
| 40 | + debug(res) | ||
| 41 | + }) | ||
| 42 | + }); | ||
| 43 | + } else { | ||
| 44 | + success(resDTO) | ||
| 45 | + } | ||
| 46 | + }).catch((res: object) => { | ||
| 47 | + debug(res) | ||
| 48 | + }) | ||
| 49 | + }) | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * post请求,封装了刷新token逻辑,接口选用,不涉及业务接口可以用原来的接口(如page接口)。 | ||
| 54 | + * | ||
| 55 | + * @param url 请求地址 | ||
| 56 | + * @param headers 请求header参数 | ||
| 57 | + * @returns 返回值 | ||
| 58 | + */ | ||
| 59 | + static post<T = string>(url: string, data?: object, headers?: HashMap<string, string>): Promise<ResponseDTO<T>> { | ||
| 60 | + return new Promise<ResponseDTO<T>>((success, debug) => { | ||
| 61 | + WDHttp.post<ResponseDTO<T>>(url, data, headers).then((resDTO: ResponseDTO<T>) => { | ||
| 62 | + Logger.debug(TAG, 'post: ' + resDTO.code) | ||
| 63 | + Logger.debug(TAG, 'post: ' + resDTO.message) | ||
| 64 | + // 403:临时token;406:强制下线、封禁、清空登录信息还要跳转登录页面 | ||
| 65 | + if (resDTO.code == 0 || resDTO.code == 406) { | ||
| 66 | + HttpBizUtil.refreshToken().then((token: string) => { | ||
| 67 | + if (headers) { | ||
| 68 | + headers.replace('RMRB-X-TOKEN', token) | ||
| 69 | + headers.replace('cookie', 'RMRB-X-TOKEN=' + token) | ||
| 70 | + } | ||
| 71 | + // refreshToken为空场景不处理,直接请求接口。 | ||
| 72 | + WDHttp.post<ResponseDTO<T>>(url, headers).then((resDTO: ResponseDTO<T>) => { | ||
| 73 | + success(resDTO) | ||
| 74 | + }).catch((res: object) => { | ||
| 75 | + debug(res) | ||
| 76 | + }) | ||
| 77 | + }); | ||
| 78 | + } else { | ||
| 79 | + success(resDTO) | ||
| 80 | + } | ||
| 81 | + }).catch((res: object) => { | ||
| 82 | + debug(res) | ||
| 83 | + }) | ||
| 84 | + }) | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + /* | ||
| 88 | + * 获取刷新后的token,可能为空 | ||
| 89 | + */ | ||
| 90 | + static refreshToken(): Promise<string> { | ||
| 91 | + let url = HttpUrlUtils.getRefreshTokenUrl(); | ||
| 92 | + let params: HashMap<string, string> = new HashMap<string, string>() | ||
| 93 | + params.set('refreshToken', HttpUrlUtils.getRefreshToken()) | ||
| 94 | + params.set('deviceId', HttpUrlUtils.getDeviceId()) | ||
| 95 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 96 | + Logger.debug(TAG, 'refreshToken getRefreshToken: ' + HttpUrlUtils.getRefreshToken()) | ||
| 97 | + // // 请求刷新token接口 | ||
| 98 | + return new Promise<string>((success, debug) => { | ||
| 99 | + WDHttp.post<ResponseDTO<RefreshTokenRes>>(url, params, headers).then((resDTO: ResponseDTO<RefreshTokenRes>) => { | ||
| 100 | + let newToken = '' | ||
| 101 | + if (resDTO) { | ||
| 102 | + Logger.debug(TAG, 'refreshToken getRefreshToken: ' + resDTO.message) | ||
| 103 | + Logger.debug(TAG, 'refreshToken getRefreshToken: ' + resDTO.code) | ||
| 104 | + if (resDTO.code == 377) { | ||
| 105 | + // 377强制用户下线、重新登录、封禁等场景;refreshToken 失效 | ||
| 106 | + ToastUtils.showToast("已登出,请重新登入", 1000); | ||
| 107 | + EmitterUtils.sendEmptyEvent(EmitterEventId.FORCE_USER_LOGIN_OUT) | ||
| 108 | + // WDRouterRule.jumpWithPage(WDRouterPage.loginPage) | ||
| 109 | + } else if (resDTO.code == 0 && resDTO.data) { | ||
| 110 | + newToken = resDTO.data.jwtToken | ||
| 111 | + let refreshToken = resDTO.data.refreshToken | ||
| 112 | + SPHelper.default.save(SpConstants.USER_JWT_TOKEN, newToken) | ||
| 113 | + SPHelper.default.save(SpConstants.USER_REFRESH_TOKEN, refreshToken) | ||
| 114 | + Logger.debug(TAG, 'refreshToken jwtToken: ' + resDTO.data.jwtToken) | ||
| 115 | + Logger.debug(TAG, 'refreshToken refreshToken: ' + resDTO.data.refreshToken) | ||
| 116 | + } | ||
| 117 | + } | ||
| 118 | + success(newToken) | ||
| 119 | + }); | ||
| 120 | + }) | ||
| 121 | + } | ||
| 122 | +} |
| @@ -112,6 +112,10 @@ export class HttpUrlUtils { | @@ -112,6 +112,10 @@ export class HttpUrlUtils { | ||
| 112 | */ | 112 | */ |
| 113 | static readonly APPOINTMENT_userArea_PATH: string = "/api/rmrb-content-center/c/service/sys-area/treeselect"; | 113 | static readonly APPOINTMENT_userArea_PATH: string = "/api/rmrb-content-center/c/service/sys-area/treeselect"; |
| 114 | /** | 114 | /** |
| 115 | + * 用户token刷新接口(token过期,需要刷新) | ||
| 116 | + */ | ||
| 117 | + static readonly REFRESH_TOKEN_PATH: string = "/api/rmrb-user-center/auth/zh/c/refreshToken"; | ||
| 118 | + /** | ||
| 115 | /** | 119 | /** |
| 116 | * 个人中心 关注列表详情 | 120 | * 个人中心 关注列表详情 |
| 117 | */ | 121 | */ |
| @@ -188,7 +192,6 @@ export class HttpUrlUtils { | @@ -188,7 +192,6 @@ export class HttpUrlUtils { | ||
| 188 | * 搜索主页 热词 | 192 | * 搜索主页 热词 |
| 189 | */ | 193 | */ |
| 190 | static readonly SEARCH_HOTS_DATA_PATH: string = "/api/rmrb-search-api/zh/c/hots"; | 194 | static readonly SEARCH_HOTS_DATA_PATH: string = "/api/rmrb-search-api/zh/c/hots"; |
| 191 | - | ||
| 192 | /** | 195 | /** |
| 193 | * 搜索联想词 | 196 | * 搜索联想词 |
| 194 | */ | 197 | */ |
| @@ -198,7 +201,6 @@ export class HttpUrlUtils { | @@ -198,7 +201,6 @@ export class HttpUrlUtils { | ||
| 198 | * 直播详情 | 201 | * 直播详情 |
| 199 | */ | 202 | */ |
| 200 | static readonly LIVE_DETAILS_PATH: string = "/api/rmrb-bff-display-zh/content/zh/c/content/detail"; | 203 | static readonly LIVE_DETAILS_PATH: string = "/api/rmrb-bff-display-zh/content/zh/c/content/detail"; |
| 201 | - | ||
| 202 | /** | 204 | /** |
| 203 | * 直播详情-直播间列表 | 205 | * 直播详情-直播间列表 |
| 204 | */ | 206 | */ |
| @@ -215,6 +217,11 @@ export class HttpUrlUtils { | @@ -215,6 +217,11 @@ export class HttpUrlUtils { | ||
| 215 | static readonly SEARCH_RESULT_COUNT_DATA_PATH: string = "/api/rmrb-search-api/zh/c/count?keyword="; | 217 | static readonly SEARCH_RESULT_COUNT_DATA_PATH: string = "/api/rmrb-search-api/zh/c/count?keyword="; |
| 216 | 218 | ||
| 217 | /** | 219 | /** |
| 220 | + * 搜索结果 显示list 详情 | ||
| 221 | + */ | ||
| 222 | + static readonly SEARCH_RESULT_LIST_DATA_PATH: string = "/api/rmrb-search-api/zh/c/search"; | ||
| 223 | + | ||
| 224 | + /** | ||
| 218 | * 早晚报列表 | 225 | * 早晚报列表 |
| 219 | * 根据页面id获取页面楼层列表 | 226 | * 根据页面id获取页面楼层列表 |
| 220 | * https://pdapis.pdnews.cn/api/rmrb-bff-display-zh/display/zh/c/pageInfo?pageId=28927 | 227 | * https://pdapis.pdnews.cn/api/rmrb-bff-display-zh/display/zh/c/pageInfo?pageId=28927 |
| @@ -358,7 +365,7 @@ export class HttpUrlUtils { | @@ -358,7 +365,7 @@ export class HttpUrlUtils { | ||
| 358 | return ''; | 365 | return ''; |
| 359 | } | 366 | } |
| 360 | 367 | ||
| 361 | - private static getDeviceId() { | 368 | + public static getDeviceId() { |
| 362 | // TODO | 369 | // TODO |
| 363 | return '8a81226a-cabd-3e1b-b630-b51db4a720ed'; | 370 | return '8a81226a-cabd-3e1b-b630-b51db4a720ed'; |
| 364 | } | 371 | } |
| @@ -452,6 +459,10 @@ export class HttpUrlUtils { | @@ -452,6 +459,10 @@ export class HttpUrlUtils { | ||
| 452 | return url; | 459 | return url; |
| 453 | } | 460 | } |
| 454 | 461 | ||
| 462 | + static getRefreshTokenUrl() { | ||
| 463 | + let url = HttpUrlUtils._hostUrl + HttpUrlUtils.REFRESH_TOKEN_PATH; | ||
| 464 | + return url; | ||
| 465 | + } | ||
| 455 | 466 | ||
| 456 | static getResetPassworddUrl() { | 467 | static getResetPassworddUrl() { |
| 457 | let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-center/user/zh/c/resetPassword"; | 468 | let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-center/user/zh/c/resetPassword"; |
| @@ -488,6 +499,21 @@ export class HttpUrlUtils { | @@ -488,6 +499,21 @@ export class HttpUrlUtils { | ||
| 488 | return url; | 499 | return url; |
| 489 | } | 500 | } |
| 490 | 501 | ||
| 502 | + | ||
| 503 | + /*优质评论页*/ | ||
| 504 | + static getQualityCommentUrl() { | ||
| 505 | + let url = HttpUrlUtils._hostUrl + "/api/rmrb-comment/comment/zh/c/highQuality"; | ||
| 506 | + | ||
| 507 | + return url | ||
| 508 | + } | ||
| 509 | + | ||
| 510 | + /*获取详情页评论列表*/ | ||
| 511 | + static getContentCommentListDataUrl() { | ||
| 512 | + let url = HttpUrlUtils._hostUrl + "/api/rmrb-comment/comment/zh/c/contentCommentList" | ||
| 513 | + return url | ||
| 514 | + } | ||
| 515 | + | ||
| 516 | + | ||
| 491 | //账户注销 | 517 | //账户注销 |
| 492 | static accountLogoutUrl() { | 518 | static accountLogoutUrl() { |
| 493 | let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-center/user/zh/c/logoff"; | 519 | let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-center/user/zh/c/logoff"; |
| @@ -500,6 +526,12 @@ export class HttpUrlUtils { | @@ -500,6 +526,12 @@ export class HttpUrlUtils { | ||
| 500 | return url; | 526 | return url; |
| 501 | } | 527 | } |
| 502 | 528 | ||
| 529 | + //获取用户安全页信息 | ||
| 530 | + static querySecurity() { | ||
| 531 | + let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-center/user/zh/c/security/query"; | ||
| 532 | + return url; | ||
| 533 | + } | ||
| 534 | + | ||
| 503 | static getAppointmentListDataUrl() { | 535 | static getAppointmentListDataUrl() { |
| 504 | let url = HttpUrlUtils._hostUrl + HttpUrlUtils.APPOINTMENT_LIST_DATA_PATH | 536 | let url = HttpUrlUtils._hostUrl + HttpUrlUtils.APPOINTMENT_LIST_DATA_PATH |
| 505 | return url | 537 | return url |
| @@ -625,6 +657,11 @@ export class HttpUrlUtils { | @@ -625,6 +657,11 @@ export class HttpUrlUtils { | ||
| 625 | return url | 657 | return url |
| 626 | } | 658 | } |
| 627 | 659 | ||
| 660 | + static getSearchResultListDataUrl() { | ||
| 661 | + let url = HttpUrlUtils._hostUrl + HttpUrlUtils.SEARCH_RESULT_LIST_DATA_PATH | ||
| 662 | + return url | ||
| 663 | + } | ||
| 664 | + | ||
| 628 | // static getYcgCommonHeaders(): HashMap<string, string> { | 665 | // static getYcgCommonHeaders(): HashMap<string, string> { |
| 629 | // let headers: HashMap<string, string> = new HashMap<string, string>() | 666 | // let headers: HashMap<string, string> = new HashMap<string, string>() |
| 630 | // | 667 | // |
| @@ -53,6 +53,12 @@ export function registerRouter() { | @@ -53,6 +53,12 @@ export function registerRouter() { | ||
| 53 | return WDRouterPage.detailPlayLivePage | 53 | return WDRouterPage.detailPlayLivePage |
| 54 | } else if (action.params?.detailPageType == 7 || action.params?.detailPageType == 8) { | 54 | } else if (action.params?.detailPageType == 7 || action.params?.detailPageType == 8) { |
| 55 | return WDRouterPage.detailVideoListPage | 55 | return WDRouterPage.detailVideoListPage |
| 56 | + }else if(action.params?.detailPageType == 9){ | ||
| 57 | + //图集详情页 | ||
| 58 | + return WDRouterPage.multiPictureDetailPage | ||
| 59 | + }else if(action.params?.detailPageType == 14 || action.params?.detailPageType == 15){ | ||
| 60 | + //动态详情页 | ||
| 61 | + return WDRouterPage.dynamicDetailPage | ||
| 56 | } else if (action.params?.detailPageType == 17) { | 62 | } else if (action.params?.detailPageType == 17) { |
| 57 | return WDRouterPage.multiPictureDetailPage | 63 | return WDRouterPage.multiPictureDetailPage |
| 58 | } else if (action.params?.detailPageType == 13) { | 64 | } else if (action.params?.detailPageType == 13) { |
| @@ -74,6 +80,8 @@ export function registerRouter() { | @@ -74,6 +80,8 @@ export function registerRouter() { | ||
| 74 | return WDRouterPage.imageTextDetailPage | 80 | return WDRouterPage.imageTextDetailPage |
| 75 | } else if (action.params?.pageID == "BroadcastPage") { | 81 | } else if (action.params?.pageID == "BroadcastPage") { |
| 76 | return WDRouterPage.broadcastPage | 82 | return WDRouterPage.broadcastPage |
| 83 | + } else if (action.params?.pageID == "SPACIAL_TOPIC_PAGE") { | ||
| 84 | + return WDRouterPage.spacialTopicPage | ||
| 77 | } | 85 | } |
| 78 | return undefined | 86 | return undefined |
| 79 | }) | 87 | }) |
| @@ -32,6 +32,8 @@ export class WDRouterPage { | @@ -32,6 +32,8 @@ export class WDRouterPage { | ||
| 32 | static morningEveningPaperPage = new WDRouterPage("phone", "ets/pages/MorningEveningPaperPage") | 32 | static morningEveningPaperPage = new WDRouterPage("phone", "ets/pages/MorningEveningPaperPage") |
| 33 | // 图文详情页 | 33 | // 图文详情页 |
| 34 | static imageTextDetailPage = new WDRouterPage("phone", "ets/pages/ImageAndTextDetailPage"); | 34 | static imageTextDetailPage = new WDRouterPage("phone", "ets/pages/ImageAndTextDetailPage"); |
| 35 | + // 专题页 | ||
| 36 | + static spacialTopicPage = new WDRouterPage("phone", "ets/pages/SpacialTopicPage"); | ||
| 35 | // 短视频详情页 | 37 | // 短视频详情页 |
| 36 | static detailVideoListPage = new WDRouterPage("wdDetailPlayShortVideo", "ets/pages/DetailVideoListPage"); | 38 | static detailVideoListPage = new WDRouterPage("wdDetailPlayShortVideo", "ets/pages/DetailVideoListPage"); |
| 37 | static detailPlayShortVideoPage = new WDRouterPage("wdDetailPlayShortVideo", "ets/pages/DetailPlayShortVideoPage"); | 39 | static detailPlayShortVideoPage = new WDRouterPage("wdDetailPlayShortVideo", "ets/pages/DetailPlayShortVideoPage"); |
| @@ -45,6 +47,8 @@ export class WDRouterPage { | @@ -45,6 +47,8 @@ export class WDRouterPage { | ||
| 45 | static multiPictureDetailPage = new WDRouterPage("phone", "ets/pages/detail/MultiPictureDetailPage"); | 47 | static multiPictureDetailPage = new WDRouterPage("phone", "ets/pages/detail/MultiPictureDetailPage"); |
| 46 | // 音乐详情页 | 48 | // 音乐详情页 |
| 47 | static audioDetail = new WDRouterPage("phone", "ets/pages/detail/AudioDetail"); | 49 | static audioDetail = new WDRouterPage("phone", "ets/pages/detail/AudioDetail"); |
| 50 | + // 动态详情页 | ||
| 51 | + static dynamicDetailPage = new WDRouterPage("phone", "ets/pages/detail/DynamicDetailPage"); | ||
| 48 | static loginPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginPage"); | 52 | static loginPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginPage"); |
| 49 | static forgetPasswordPage = new WDRouterPage("wdLogin", "ets/pages/login/ForgetPasswordPage"); | 53 | static forgetPasswordPage = new WDRouterPage("wdLogin", "ets/pages/login/ForgetPasswordPage"); |
| 50 | //我的 预约 | 54 | //我的 预约 |
| @@ -8,13 +8,17 @@ export class H5CallNativeType { | @@ -8,13 +8,17 @@ export class H5CallNativeType { | ||
| 8 | static jsCall_getAppPublicInfo = 'jsCall_getAppPublicInfo' | 8 | static jsCall_getAppPublicInfo = 'jsCall_getAppPublicInfo' |
| 9 | static jsCall_getArticleDetailBussinessData = 'jsCall_getArticleDetailBussinessData' | 9 | static jsCall_getArticleDetailBussinessData = 'jsCall_getArticleDetailBussinessData' |
| 10 | static jsCall_callAppService = 'jsCall_callAppService' | 10 | static jsCall_callAppService = 'jsCall_callAppService' |
| 11 | + static jsCall_appInnerLinkMethod = 'jsCall_appInnerLinkMethod' | ||
| 12 | + static jsCall_receiveH5Data = 'jsCall_receiveH5Data' | ||
| 11 | // TODO 业务自行新增类型、自行在JsBridgeBiz#performJSCallNative里添加接收分支处理。 | 13 | // TODO 业务自行新增类型、自行在JsBridgeBiz#performJSCallNative里添加接收分支处理。 |
| 12 | 14 | ||
| 13 | - static init() { | 15 | + static { |
| 14 | H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_currentPageOperate) | 16 | H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_currentPageOperate) |
| 15 | H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_getAppPublicInfo) | 17 | H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_getAppPublicInfo) |
| 16 | H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_getArticleDetailBussinessData) | 18 | H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_getArticleDetailBussinessData) |
| 17 | H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_callAppService) | 19 | H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_callAppService) |
| 20 | + H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_appInnerLinkMethod) | ||
| 21 | + H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_receiveH5Data) | ||
| 18 | } | 22 | } |
| 19 | } | 23 | } |
| 20 | 24 |
| @@ -2,6 +2,9 @@ import { Callback, BridgeWebViewControl } from 'wdJsBridge'; | @@ -2,6 +2,9 @@ import { Callback, BridgeWebViewControl } from 'wdJsBridge'; | ||
| 2 | import { Message } from 'wdJsBridge/src/main/ets/bean/Message'; | 2 | import { Message } from 'wdJsBridge/src/main/ets/bean/Message'; |
| 3 | import { Logger, StringUtils, } from 'wdKit'; | 3 | import { Logger, StringUtils, } from 'wdKit'; |
| 4 | import { H5CallNativeType } from './H5CallNativeType'; | 4 | import { H5CallNativeType } from './H5CallNativeType'; |
| 5 | +import { ContentDTO } from 'wdBean'; | ||
| 6 | +//TODO 这里引用了 features模块,是否考虑将跳转抽到公共模块 | ||
| 7 | +import { ProcessUtils } from '../../../../../../features/wdComponent/src/main/ets/utils/ProcessUtils'; | ||
| 5 | 8 | ||
| 6 | const TAG = 'JsBridgeBiz' | 9 | const TAG = 'JsBridgeBiz' |
| 7 | 10 | ||
| @@ -11,7 +14,7 @@ const TAG = 'JsBridgeBiz' | @@ -11,7 +14,7 @@ const TAG = 'JsBridgeBiz' | ||
| 11 | * @param call | 14 | * @param call |
| 12 | */ | 15 | */ |
| 13 | export function performJSCallNative(data: Message, call: Callback) { | 16 | export function performJSCallNative(data: Message, call: Callback) { |
| 14 | - Logger.debug(TAG, 'performJSCallNative handlerName: ' + data.handlerName + ', data: ' + data.data) | 17 | + Logger.debug(TAG, 'performJSCallNative handlerName: ' + data.handlerName + ', data: ' + JSON.stringify(data.data)) |
| 15 | switch (data.handlerName) { | 18 | switch (data.handlerName) { |
| 16 | case H5CallNativeType.jsCall_currentPageOperate: | 19 | case H5CallNativeType.jsCall_currentPageOperate: |
| 17 | break; | 20 | break; |
| @@ -23,6 +26,9 @@ export function performJSCallNative(data: Message, call: Callback) { | @@ -23,6 +26,9 @@ export function performJSCallNative(data: Message, call: Callback) { | ||
| 23 | break; | 26 | break; |
| 24 | case H5CallNativeType.jsCall_callAppService: | 27 | case H5CallNativeType.jsCall_callAppService: |
| 25 | break; | 28 | break; |
| 29 | + case H5CallNativeType.jsCall_receiveH5Data: | ||
| 30 | + handleH5Data(JSON.parse(data?.data?.dataJson || '{}')) | ||
| 31 | + break; | ||
| 26 | case 'changeNativeMessage': | 32 | case 'changeNativeMessage': |
| 27 | call("this is change Web Message") | 33 | call("this is change Web Message") |
| 28 | break; | 34 | break; |
| @@ -50,4 +56,7 @@ function getAppPublicInfo(): string { | @@ -50,4 +56,7 @@ function getAppPublicInfo(): string { | ||
| 50 | return result; | 56 | return result; |
| 51 | } | 57 | } |
| 52 | 58 | ||
| 59 | +function handleH5Data(content:ContentDTO) { | ||
| 60 | + ProcessUtils.processPage(content) | ||
| 61 | +} | ||
| 53 | 62 |
| 1 | import router from '@ohos.router'; | 1 | import router from '@ohos.router'; |
| 2 | -import { Action } from 'wdBean'; | ||
| 3 | -import { ConfigConstants } from 'wdConstant'; | ||
| 4 | -import { Logger } from 'wdKit'; | ||
| 5 | -import { BridgeHandler, BridgeUtil, BridgeWebViewControl, Callback } from 'wdJsBridge'; | 2 | +import { BridgeUtil, BridgeWebViewControl, Callback } from 'wdJsBridge'; |
| 3 | +import { Logger } from 'wdKit/Index'; | ||
| 6 | import { performJSCallNative } from './JsBridgeBiz'; | 4 | import { performJSCallNative } from './JsBridgeBiz'; |
| 7 | -import { setDefaultNativeWebSettings } from './WebComponentUtil'; | 5 | +import { H5CallNativeType } from './H5CallNativeType'; |
| 8 | import { Message } from 'wdJsBridge/src/main/ets/bean/Message'; | 6 | import { Message } from 'wdJsBridge/src/main/ets/bean/Message'; |
| 9 | 7 | ||
| 10 | -const TAG = 'WdWebComponent'; | 8 | +const TAG = 'WdWebLocalComponent'; |
| 11 | 9 | ||
| 12 | @Component | 10 | @Component |
| 13 | export struct WdWebComponent { | 11 | export struct WdWebComponent { |
| 14 | - private webviewControl: BridgeWebViewControl = new BridgeWebViewControl() | ||
| 15 | - //TODO 默认网页 | ||
| 16 | - webUrl: string | Resource = ConfigConstants.DETAIL_URL | ||
| 17 | - /** | ||
| 18 | - * 对外暴露webview的回调,能力 | ||
| 19 | - */ | ||
| 20 | - onPageBegin: (url?: string) => void = () => { | ||
| 21 | - } | ||
| 22 | - onPageEnd: (url?: string) => void = () => { | ||
| 23 | - } | ||
| 24 | - onLoadIntercept: (url?: string) => boolean = () => { | ||
| 25 | - return false | ||
| 26 | - } | ||
| 27 | - onHttpErrorReceive: (url?: string) => boolean = () => { | ||
| 28 | - return false | ||
| 29 | - } | 12 | + webviewControl: BridgeWebViewControl = new BridgeWebViewControl() |
| 13 | + @Prop backVisibility: boolean = false | ||
| 14 | + @Prop webUrl: string = '' | ||
| 30 | @Prop @Watch('onReloadStateChanged') reload: number = 0 | 15 | @Prop @Watch('onReloadStateChanged') reload: number = 0 |
| 31 | - /** | ||
| 32 | - * 默认【CallNative】逻辑处理 | ||
| 33 | - */ | ||
| 34 | - private defaultPerformJSCallNative: (data: Message, f: Callback) => void = (data: Message, f: Callback) => { | ||
| 35 | - performJSCallNative(data, f) | ||
| 36 | - } | ||
| 37 | - /** | ||
| 38 | - * jsBridge的处理 | ||
| 39 | - */ | ||
| 40 | - handleInfo: [string, BridgeHandler][] = [] | ||
| 41 | - backVisibility: boolean = false | ||
| 42 | - | ||
| 43 | - defaultRegisterHandler(): void { | ||
| 44 | - this.webviewControl.registerHandler("CallNative", { | ||
| 45 | - handle: (data: Message, f: Callback) => { | ||
| 46 | - this.defaultPerformJSCallNative(data, f) | ||
| 47 | - } | ||
| 48 | - }); | ||
| 49 | - | ||
| 50 | - } | ||
| 51 | 16 | ||
| 52 | build() { | 17 | build() { |
| 53 | Column() { | 18 | Column() { |
| @@ -71,26 +36,13 @@ export struct WdWebComponent { | @@ -71,26 +36,13 @@ export struct WdWebComponent { | ||
| 71 | .zoomAccess(false) | 36 | .zoomAccess(false) |
| 72 | .horizontalScrollBarAccess(false) | 37 | .horizontalScrollBarAccess(false) |
| 73 | .verticalScrollBarAccess(false) | 38 | .verticalScrollBarAccess(false) |
| 74 | - .onHttpErrorReceive((event) => { | ||
| 75 | - //TODO 页面加载不成功的时候处理 | ||
| 76 | - Logger.info(TAG, 'onHttpErrorReceive event.request.getRequestUrl:' + event?.request.getRequestUrl()); | ||
| 77 | - Logger.info(TAG, 'onHttpErrorReceive event.response.getResponseCode:' + event?.response.getResponseCode()); | 39 | + .onPageBegin((event) => { |
| 40 | + console.log(this.webUrl,"yzl") | ||
| 41 | + this.onPageBegin(event?.url); | ||
| 78 | }) | 42 | }) |
| 79 | .onPageEnd((event) => { | 43 | .onPageEnd((event) => { |
| 80 | this.onPageEnd(event?.url) | 44 | this.onPageEnd(event?.url) |
| 81 | }) | 45 | }) |
| 82 | - .onPageBegin((event) => { | ||
| 83 | - // setDefaultNativeWebSettings(this.webviewControl, this.webUrl).then(()=>{ | ||
| 84 | - // this.handleInfo && this.handleInfo.length > 1 ? this.handleInfo.forEach(value => { | ||
| 85 | - // this.webviewControl.registerHandler(value[0], value[1]) | ||
| 86 | - // }) : this.defaultRegisterHandler() | ||
| 87 | - // setTimeout(()=>{ | ||
| 88 | - // BridgeUtil.webViewLoadLocalJs(getContext(this), this.webviewControl) | ||
| 89 | - // },500) | ||
| 90 | - // }) | ||
| 91 | - // this.onPageBegin(event?.url) | ||
| 92 | - // this.webviewControl?.setCustomUserAgent('Mozilla/5.0 (Linux; Android 12; HarmonyOS; OXF-AN00; HMSCore 6.13.0.302) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.88 HuaweiBrowser/14.0.6.300 Mobile Safari/537.36') | ||
| 93 | - }) | ||
| 94 | .onLoadIntercept((event) => { | 46 | .onLoadIntercept((event) => { |
| 95 | let url: string = event.data.getRequestUrl().toString() | 47 | let url: string = event.data.getRequestUrl().toString() |
| 96 | url = url.replace("%(?![0-9a-fA-F]{2})", "%25") | 48 | url = url.replace("%(?![0-9a-fA-F]{2})", "%25") |
| @@ -101,19 +53,51 @@ export struct WdWebComponent { | @@ -101,19 +53,51 @@ export struct WdWebComponent { | ||
| 101 | return true | 53 | return true |
| 102 | } | 54 | } |
| 103 | if (url.startsWith(BridgeUtil.YY_OVERRIDE_SCHEMA)) { | 55 | if (url.startsWith(BridgeUtil.YY_OVERRIDE_SCHEMA)) { |
| 56 | + Logger.debug(TAG, 'flushMessageQueue'); | ||
| 104 | this.webviewControl.flushMessageQueue() | 57 | this.webviewControl.flushMessageQueue() |
| 105 | return true | 58 | return true |
| 106 | } | 59 | } |
| 107 | - return this.onLoadIntercept(event.data.getRequestUrl().toString()) | 60 | + return this.onLoadIntercept(event.data.getRequestUrl().toString()); |
| 108 | }) | 61 | }) |
| 109 | } | 62 | } |
| 110 | } | 63 | } |
| 111 | 64 | ||
| 65 | + private registerHandlers(): void { | ||
| 66 | + // 注册h5调用js相关 | ||
| 67 | + for (let i = 0; i < H5CallNativeType.JsCallTypeList.length; i++) { | ||
| 68 | + let handleName = H5CallNativeType.JsCallTypeList[i]; | ||
| 69 | + console.log('handleName:', handleName) | ||
| 70 | + let handle = (data: Message, f: Callback) => { | ||
| 71 | + this.defaultPerformJSCallNative(data, f) | ||
| 72 | + }; | ||
| 73 | + this.webviewControl.registerHandler(handleName, { handle: handle }); | ||
| 74 | + } | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + /** | ||
| 78 | + * 默认【CallNative】逻辑处理 | ||
| 79 | + */ | ||
| 80 | + private defaultPerformJSCallNative: (data: Message, f: Callback) => void = (data: Message, f: Callback) => { | ||
| 81 | + performJSCallNative(data, f) | ||
| 82 | + } | ||
| 83 | + onPageBegin: (url?: string) => void = () => { | ||
| 84 | + Logger.debug(TAG, 'onPageBegin'); | ||
| 85 | + this.registerHandlers(); | ||
| 86 | + BridgeUtil.webViewLoadLocalJs(getContext(this), this.webviewControl) | ||
| 87 | + } | ||
| 88 | + onPageEnd: (url?: string) => void = () => { | ||
| 89 | + Logger.debug(TAG, 'onPageEnd'); | ||
| 90 | + } | ||
| 91 | + onLoadIntercept: (url?: string) => boolean = () => { | ||
| 92 | + Logger.debug(TAG, 'onLoadIntercept return false'); | ||
| 93 | + return false | ||
| 94 | + } | ||
| 112 | onReloadStateChanged() { | 95 | onReloadStateChanged() { |
| 113 | Logger.info(TAG, `onReloadStateChanged:::refresh, this.reload: ${this.reload}`); | 96 | Logger.info(TAG, `onReloadStateChanged:::refresh, this.reload: ${this.reload}`); |
| 114 | if (this.reload > 0) { | 97 | if (this.reload > 0) { |
| 115 | this.webviewControl.refresh() | 98 | this.webviewControl.refresh() |
| 116 | } | 99 | } |
| 117 | } | 100 | } |
| 101 | + | ||
| 118 | } | 102 | } |
| 119 | 103 |
| @@ -11,9 +11,10 @@ const TAG = 'WdWebLocalComponent'; | @@ -11,9 +11,10 @@ const TAG = 'WdWebLocalComponent'; | ||
| 11 | 11 | ||
| 12 | @Component | 12 | @Component |
| 13 | export struct WdWebLocalComponent { | 13 | export struct WdWebLocalComponent { |
| 14 | - private webviewControl: BridgeWebViewControl = new BridgeWebViewControl() | ||
| 15 | - backVisibility: boolean = false | ||
| 16 | - webResource: Resource = {} as Resource | 14 | + webviewControl: BridgeWebViewControl = new BridgeWebViewControl() |
| 15 | + @Prop backVisibility: boolean = false | ||
| 16 | + @Prop webResource: Resource = {} as Resource | ||
| 17 | + @State webHeight : string = '100%' | ||
| 17 | 18 | ||
| 18 | build() { | 19 | build() { |
| 19 | Column() { | 20 | Column() { |
| @@ -31,30 +32,16 @@ export struct WdWebLocalComponent { | @@ -31,30 +32,16 @@ export struct WdWebLocalComponent { | ||
| 31 | .visibility(this.backVisibility ? Visibility.Visible : Visibility.None) | 32 | .visibility(this.backVisibility ? Visibility.Visible : Visibility.None) |
| 32 | 33 | ||
| 33 | Web({ src: this.webResource, controller: this.webviewControl }) | 34 | Web({ src: this.webResource, controller: this.webviewControl }) |
| 34 | - .layoutMode(WebLayoutMode.FIT_CONTENT) | ||
| 35 | .domStorageAccess(true) | 35 | .domStorageAccess(true) |
| 36 | .databaseAccess(true) | 36 | .databaseAccess(true) |
| 37 | .javaScriptAccess(true) | 37 | .javaScriptAccess(true) |
| 38 | - // .imageAccess(true) | ||
| 39 | - // .onlineImageAccess(true) | ||
| 40 | - // .fileAccess(true) | 38 | + .imageAccess(true) |
| 39 | + .mixedMode(MixedMode.All) | ||
| 40 | + .onlineImageAccess(true) | ||
| 41 | + .enableNativeEmbedMode(true) | ||
| 42 | + .height(this.webHeight === '100%' ? '100%' : Number(this.webHeight)) | ||
| 41 | .onPageBegin((event) => { | 43 | .onPageBegin((event) => { |
| 42 | - | ||
| 43 | - // setDefaultNativeWebSettings(this.webviewControl, this.webResource).then(()=>{ | ||
| 44 | - // this.handleInfo && this.handleInfo.length > 1 ? this.handleInfo.forEach(value => { | ||
| 45 | - // this.webviewControl.registerHandler(value[0], value[1]) | ||
| 46 | - // }) : this.defaultRegisterHandler() | ||
| 47 | - // setTimeout(()=>{ | ||
| 48 | - // BridgeUtil.webViewLoadLocalJs(getContext(this), this.webviewControl) | ||
| 49 | - // },500) | ||
| 50 | - // }) | ||
| 51 | - // this.onPageBegin(event?.url) | ||
| 52 | - // BridgeUtil.webViewLoadLocalJs(getContext(this), this.webviewControl); | ||
| 53 | this.onPageBegin(event?.url); | 44 | this.onPageBegin(event?.url); |
| 54 | - this.registerHandlers(); | ||
| 55 | - setTimeout(() => { | ||
| 56 | - BridgeUtil.webViewLoadLocalJs(getContext(this), this.webviewControl) | ||
| 57 | - }, 200) | ||
| 58 | }) | 45 | }) |
| 59 | .onPageEnd((event) => { | 46 | .onPageEnd((event) => { |
| 60 | this.onPageEnd(event?.url) | 47 | this.onPageEnd(event?.url) |
| @@ -79,25 +66,24 @@ export struct WdWebLocalComponent { | @@ -79,25 +66,24 @@ export struct WdWebLocalComponent { | ||
| 79 | } | 66 | } |
| 80 | 67 | ||
| 81 | private registerHandlers(): void { | 68 | private registerHandlers(): void { |
| 82 | - // TODO 待优化 | ||
| 83 | - H5CallNativeType.init(); | ||
| 84 | // 注册h5调用js相关 | 69 | // 注册h5调用js相关 |
| 85 | for (let i = 0; i < H5CallNativeType.JsCallTypeList.length; i++) { | 70 | for (let i = 0; i < H5CallNativeType.JsCallTypeList.length; i++) { |
| 86 | let handleName = H5CallNativeType.JsCallTypeList[i]; | 71 | let handleName = H5CallNativeType.JsCallTypeList[i]; |
| 87 | let handle = (data: Message, f: Callback) => { | 72 | let handle = (data: Message, f: Callback) => { |
| 73 | + this.setCurrentPageOperate(data) | ||
| 88 | this.defaultPerformJSCallNative(data, f) | 74 | this.defaultPerformJSCallNative(data, f) |
| 89 | - } ; | 75 | + }; |
| 90 | this.webviewControl.registerHandler(handleName, { handle: handle }); | 76 | this.webviewControl.registerHandler(handleName, { handle: handle }); |
| 91 | } | 77 | } |
| 92 | - // // TODO test | ||
| 93 | - // this.webviewControl.registerHandler('changeNativeMessage', { | ||
| 94 | - // handle: (data: Message, f: Callback) => { | ||
| 95 | - // this.defaultPerformJSCallNative(data, f) | ||
| 96 | - // } | ||
| 97 | - // }); | ||
| 98 | - | ||
| 99 | } | 78 | } |
| 100 | 79 | ||
| 80 | + //webview 高度设置 | ||
| 81 | + private setCurrentPageOperate: (data: Message) => void = (data) => { | ||
| 82 | + console.log("setCurrentPageOperate",JSON.stringify(data)) | ||
| 83 | + if (data.handlerName === H5CallNativeType.jsCall_currentPageOperate) { | ||
| 84 | + this.webHeight = data?.data?.webViewHeight || '100%' | ||
| 85 | + } | ||
| 86 | + } | ||
| 101 | /** | 87 | /** |
| 102 | * 默认【CallNative】逻辑处理 | 88 | * 默认【CallNative】逻辑处理 |
| 103 | */ | 89 | */ |
| @@ -106,12 +92,16 @@ export struct WdWebLocalComponent { | @@ -106,12 +92,16 @@ export struct WdWebLocalComponent { | ||
| 106 | } | 92 | } |
| 107 | onPageBegin: (url?: string) => void = () => { | 93 | onPageBegin: (url?: string) => void = () => { |
| 108 | Logger.debug(TAG, 'onPageBegin'); | 94 | Logger.debug(TAG, 'onPageBegin'); |
| 95 | + this.registerHandlers(); | ||
| 96 | + // setTimeout(() => { | ||
| 97 | + BridgeUtil.webViewLoadLocalJs(getContext(this), this.webviewControl) | ||
| 98 | + // }, 100) | ||
| 109 | } | 99 | } |
| 110 | onPageEnd: (url?: string) => void = () => { | 100 | onPageEnd: (url?: string) => void = () => { |
| 111 | Logger.debug(TAG, 'onPageEnd'); | 101 | Logger.debug(TAG, 'onPageEnd'); |
| 112 | } | 102 | } |
| 113 | onLoadIntercept: (url?: string) => boolean = () => { | 103 | onLoadIntercept: (url?: string) => boolean = () => { |
| 114 | - Logger.debug(TAG, 'onPageBegin return false'); | 104 | + Logger.debug(TAG, 'onLoadIntercept return false'); |
| 115 | return false | 105 | return false |
| 116 | } | 106 | } |
| 117 | } | 107 | } |
| @@ -69,6 +69,8 @@ export interface ContentDTO { | @@ -69,6 +69,8 @@ export interface ContentDTO { | ||
| 69 | isSelect: boolean; | 69 | isSelect: boolean; |
| 70 | rmhInfo: RmhInfoDTO; // 人民号信息 | 70 | rmhInfo: RmhInfoDTO; // 人民号信息 |
| 71 | photoNum: number; | 71 | photoNum: number; |
| 72 | - | 72 | + corner: string; |
| 73 | + rmhPlatform: number; | ||
| 74 | + newTags: string | ||
| 73 | 75 | ||
| 74 | } | 76 | } |
| @@ -43,20 +43,14 @@ export { ImageAndTextWebComponent } from "./src/main/ets/components/ImageAndText | @@ -43,20 +43,14 @@ export { ImageAndTextWebComponent } from "./src/main/ets/components/ImageAndText | ||
| 43 | 43 | ||
| 44 | export { DetailViewModel } from "./src/main/ets/viewmodel/DetailViewModel" | 44 | export { DetailViewModel } from "./src/main/ets/viewmodel/DetailViewModel" |
| 45 | 45 | ||
| 46 | -export { SingleImageCardComponent } from "./src/main/ets/components/view/SingleImageCardComponent" | ||
| 47 | - | ||
| 48 | -export { TriPicCardComponent } from "./src/main/ets/components/view/TriPicCardComponent" | ||
| 49 | - | ||
| 50 | export { BigPicCardComponent } from "./src/main/ets/components/view/BigPicCardComponent" | 46 | export { BigPicCardComponent } from "./src/main/ets/components/view/BigPicCardComponent" |
| 51 | 47 | ||
| 52 | -export { HeadPictureCardComponent } from "./src/main/ets/components/view/HeadPictureCardComponent" | ||
| 53 | - | ||
| 54 | -export { ZhGridLayoutComponent } from "./src/main/ets/components/view/ZhGridLayoutComponent" | ||
| 55 | - | ||
| 56 | export { MultiPictureDetailPageComponent } from "./src/main/ets/components/MultiPictureDetailPageComponent" | 48 | export { MultiPictureDetailPageComponent } from "./src/main/ets/components/MultiPictureDetailPageComponent" |
| 57 | 49 | ||
| 58 | export { AudioDetailComponent } from "./src/main/ets/components/AudioDetailComponent" | 50 | export { AudioDetailComponent } from "./src/main/ets/components/AudioDetailComponent" |
| 59 | 51 | ||
| 52 | +export { AudioSuspensionModel } from "./src/main/ets/viewmodel/AudioSuspensionModel" | ||
| 53 | + | ||
| 60 | export { BroadcastPageComponent } from "./src/main/ets/components/broadcast/BroadcastPageComponent" | 54 | export { BroadcastPageComponent } from "./src/main/ets/components/broadcast/BroadcastPageComponent" |
| 61 | 55 | ||
| 62 | export { FirstTabTopSearchComponent } from "./src/main/ets/components/search/FirstTabTopSearchComponent" | 56 | export { FirstTabTopSearchComponent } from "./src/main/ets/components/search/FirstTabTopSearchComponent" |
| @@ -64,3 +58,8 @@ export { FirstTabTopSearchComponent } from "./src/main/ets/components/search/Fir | @@ -64,3 +58,8 @@ export { FirstTabTopSearchComponent } from "./src/main/ets/components/search/Fir | ||
| 64 | export { ListHasNoMoreDataUI } from "./src/main/ets/components/reusable/ListHasNoMoreDataUI" | 58 | export { ListHasNoMoreDataUI } from "./src/main/ets/components/reusable/ListHasNoMoreDataUI" |
| 65 | 59 | ||
| 66 | export { LottieView } from './src/main/ets/lottie/LottieView' | 60 | export { LottieView } from './src/main/ets/lottie/LottieView' |
| 61 | + | ||
| 62 | +export { SpacialTopicPageComponent } from './src/main/ets/components/SpacialTopicPageComponent' | ||
| 63 | + | ||
| 64 | +export { LogoutViewModel } from "./src/main/ets/viewmodel/LogoutViewModel" | ||
| 65 | + |
| @@ -12,6 +12,7 @@ import { Card17Component } from './cardview/Card17Component'; | @@ -12,6 +12,7 @@ import { Card17Component } from './cardview/Card17Component'; | ||
| 12 | import { Card15Component } from './cardview/Card15Component'; | 12 | import { Card15Component } from './cardview/Card15Component'; |
| 13 | import { Card19Component } from './cardview/Card19Component'; | 13 | import { Card19Component } from './cardview/Card19Component'; |
| 14 | import { Card20Component } from './cardview/Card20Component'; | 14 | import { Card20Component } from './cardview/Card20Component'; |
| 15 | +import { Card21Component } from './cardview/Card21Component'; | ||
| 15 | 16 | ||
| 16 | /** | 17 | /** |
| 17 | * card适配器,卡片样式汇总,依据ContentDTO#appStyle | 18 | * card适配器,卡片样式汇总,依据ContentDTO#appStyle |
| @@ -52,6 +53,8 @@ export struct CardParser { | @@ -52,6 +53,8 @@ export struct CardParser { | ||
| 52 | Card19Component({ contentDTO }) | 53 | Card19Component({ contentDTO }) |
| 53 | } else if (contentDTO.appStyle === CompStyle.Card_20) { | 54 | } else if (contentDTO.appStyle === CompStyle.Card_20) { |
| 54 | Card20Component({ contentDTO }) | 55 | Card20Component({ contentDTO }) |
| 56 | + } else if (contentDTO.appStyle === CompStyle.Card_21) { | ||
| 57 | + Card21Component({ contentDTO }) | ||
| 55 | } | 58 | } |
| 56 | else { | 59 | else { |
| 57 | // todo:组件未实现 / Component Not Implemented | 60 | // todo:组件未实现 / Component Not Implemented |
| 1 | +import { Logger } from 'wdKit'; | ||
| 2 | +import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel'; | ||
| 3 | +import { ContentDetailDTO } from 'wdBean'; | ||
| 4 | +import media from '@ohos.multimedia.media'; | ||
| 5 | +import { OperRowListView } from './view/OperRowListView'; | ||
| 6 | +import { WDPlayerController } from 'wdPlayer/Index'; | ||
| 7 | + | ||
| 8 | +const TAG = 'DynamicDetailComponent' | ||
| 9 | +@Preview | ||
| 10 | +@Component | ||
| 11 | +export struct DynamicDetailComponent { | ||
| 12 | + //入参 | ||
| 13 | + private relId: string = '' | ||
| 14 | + private contentId: string = '' | ||
| 15 | + private relType: string = '' | ||
| 16 | + //出参 | ||
| 17 | + @State contentDetailData: ContentDetailDTO[] = [] as ContentDetailDTO[] | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + async aboutToAppear() { | ||
| 21 | + await this.getContentDetailData() | ||
| 22 | + } | ||
| 23 | + onPageHide() { | ||
| 24 | + | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + build() { | ||
| 28 | + Row() { | ||
| 29 | + Column(){ | ||
| 30 | + Text("this is a test!") | ||
| 31 | + } | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + } | ||
| 35 | + private async getContentDetailData() { | ||
| 36 | + try { | ||
| 37 | + let data = await MultiPictureDetailViewModel.getDetailData(this.relId, this.contentId, this.relType) | ||
| 38 | + this.contentDetailData = data; | ||
| 39 | + console.log('动态详情',JSON.stringify(this.contentDetailData)) | ||
| 40 | + } catch (exception) { | ||
| 41 | + console.log('请求失败',JSON.stringify(exception)) | ||
| 42 | + } | ||
| 43 | + } | ||
| 44 | +} |
| @@ -22,13 +22,6 @@ import { PageRepository } from '../repository/PageRepository'; | @@ -22,13 +22,6 @@ import { PageRepository } from '../repository/PageRepository'; | ||
| 22 | 22 | ||
| 23 | const TAG = 'ImageAndTextPageComponent' | 23 | const TAG = 'ImageAndTextPageComponent' |
| 24 | 24 | ||
| 25 | -export interface OperationItem { | ||
| 26 | - icon: Resource; | ||
| 27 | - icon_check?: Resource; | ||
| 28 | - text: string | Resource; | ||
| 29 | - num?: number; // 个数 | ||
| 30 | -} | ||
| 31 | - | ||
| 32 | @Component | 25 | @Component |
| 33 | export struct ImageAndTextPageComponent { | 26 | export struct ImageAndTextPageComponent { |
| 34 | scroller: Scroller = new Scroller(); | 27 | scroller: Scroller = new Scroller(); |
| @@ -37,7 +30,6 @@ export struct ImageAndTextPageComponent { | @@ -37,7 +30,6 @@ export struct ImageAndTextPageComponent { | ||
| 37 | @State recommendList: ContentDTO[] = [] | 30 | @State recommendList: ContentDTO[] = [] |
| 38 | @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态 | 31 | @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态 |
| 39 | @State interactData: InteractDataDTO = {} as InteractDataDTO | 32 | @State interactData: InteractDataDTO = {} as InteractDataDTO |
| 40 | - | ||
| 41 | build() { | 33 | build() { |
| 42 | Column() { | 34 | Column() { |
| 43 | // 发布时间 | 35 | // 发布时间 |
| @@ -64,66 +56,28 @@ export struct ImageAndTextPageComponent { | @@ -64,66 +56,28 @@ export struct ImageAndTextPageComponent { | ||
| 64 | .objectFit(ImageFit.Cover) | 56 | .objectFit(ImageFit.Cover) |
| 65 | .margin({ top: 10 }) | 57 | .margin({ top: 10 }) |
| 66 | } | 58 | } |
| 67 | - .padding({ left: 15, right: 15, }) | 59 | + .padding({ left: 15, right: 15 }) |
| 68 | .backgroundColor(Color.White) | 60 | .backgroundColor(Color.White) |
| 69 | 61 | ||
| 70 | Stack({ alignContent: Alignment.Bottom }) { | 62 | Stack({ alignContent: Alignment.Bottom }) { |
| 71 | - List() { | ||
| 72 | - //详情展示区 | ||
| 73 | - ListItem() { | 63 | + Scroll(this.scroller) { |
| 64 | + Column() { | ||
| 65 | + ImageAndTextWebComponent({ | ||
| 66 | + contentDetailData: this.contentDetailData, | ||
| 67 | + action: this.action | ||
| 68 | + }) | ||
| 74 | Column() { | 69 | Column() { |
| 75 | - ImageAndTextWebComponent({ | ||
| 76 | - contentDetailData: this.contentDetailData, | ||
| 77 | - action: this.action, | ||
| 78 | - }) | ||
| 79 | - }.width(CommonConstants.FULL_WIDTH) | ||
| 80 | - .height(CommonConstants.FULL_HEIGHT) | ||
| 81 | - } | ||
| 82 | - | ||
| 83 | - if (this.contentDetailData[0]?.openLikes === 1) { | ||
| 84 | - ListItem() { | ||
| 85 | - // 点赞 | ||
| 86 | - Row() { | ||
| 87 | - Row() { | ||
| 88 | - if (this.newsStatusOfUser?.likeStatus === '1') { | ||
| 89 | - 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'))) | ||
| 90 | - .width(24) | ||
| 91 | - .height(24) | ||
| 92 | - .margin({ right: 5 }) | ||
| 93 | - } else { | ||
| 94 | - 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'))) | ||
| 95 | - .width(24) | ||
| 96 | - .height(24) | ||
| 97 | - .margin({ right: 5 }) | ||
| 98 | - } | ||
| 99 | - Text(`${this.interactData?.likeNum || 0}`) | ||
| 100 | - .fontSize(16) | ||
| 101 | - .fontColor(this.newsStatusOfUser?.likeStatus === '1' ? '#ED2800' : '#999999') | ||
| 102 | - .fontWeight(500) | ||
| 103 | - }.alignItems(VerticalAlign.Center) | ||
| 104 | - .onClick(() => { | ||
| 105 | - this.toggleLikeStatus() | ||
| 106 | - }) | ||
| 107 | - | ||
| 108 | - }.width(CommonConstants.FULL_WIDTH).height(80) | ||
| 109 | - .justifyContent(FlexAlign.Center) | 70 | + if (this.recommendList.length > 0) { |
| 71 | + RecommendList({ recommendList: this.recommendList }) | ||
| 72 | + } | ||
| 110 | } | 73 | } |
| 111 | - .border({ | ||
| 112 | - width: { bottom: 5 }, | ||
| 113 | - color: '#f5f5f5', | ||
| 114 | - }) | ||
| 115 | } | 74 | } |
| 116 | 75 | ||
| 117 | - // 相关推荐区 | ||
| 118 | - ListItem() { | ||
| 119 | - RecommendList({ recommendList: this.recommendList }) | ||
| 120 | - } | ||
| 121 | } | 76 | } |
| 122 | .width(CommonConstants.FULL_WIDTH) | 77 | .width(CommonConstants.FULL_WIDTH) |
| 123 | .height(CommonConstants.FULL_HEIGHT) | 78 | .height(CommonConstants.FULL_HEIGHT) |
| 124 | - .padding({ bottom: 56 }) | ||
| 125 | - .scrollBar(BarState.Off) | ||
| 126 | - .edgeEffect(EdgeEffect.None) | 79 | + .padding({ bottom: 76 }) |
| 80 | + // .scrollBar(BarState.Off) | ||
| 127 | 81 | ||
| 128 | //底部交互区 | 82 | //底部交互区 |
| 129 | Row() { | 83 | Row() { |
| @@ -163,11 +117,143 @@ export struct ImageAndTextPageComponent { | @@ -163,11 +117,143 @@ export struct ImageAndTextPageComponent { | ||
| 163 | .justifyContent(FlexAlign.SpaceBetween) | 117 | .justifyContent(FlexAlign.SpaceBetween) |
| 164 | .backgroundColor(Color.White) | 118 | .backgroundColor(Color.White) |
| 165 | } | 119 | } |
| 166 | - }.width(CommonConstants.FULL_WIDTH).height(CommonConstants.FULL_HEIGHT) | ||
| 167 | - .backgroundColor(Color.White) | ||
| 168 | - | 120 | + } |
| 121 | + .width(CommonConstants.FULL_WIDTH) | ||
| 122 | + .height(CommonConstants.FULL_HEIGHT) | ||
| 169 | } | 123 | } |
| 170 | 124 | ||
| 125 | + // build() { | ||
| 126 | + // Column() { | ||
| 127 | + // // 发布时间 | ||
| 128 | + // Row() { | ||
| 129 | + // Image($r('app.media.icon_ren_min_ri_bao')) | ||
| 130 | + // .width(70) | ||
| 131 | + // .height(28) | ||
| 132 | + // Text(this.contentDetailData[0]?.publishTime) | ||
| 133 | + // .fontColor($r('app.color.color_B0B0B0')) | ||
| 134 | + // .fontSize($r('app.float.font_size_13')) | ||
| 135 | + // .height('100%') | ||
| 136 | + // .align(Alignment.End) | ||
| 137 | + // } | ||
| 138 | + // .width(CommonConstants.FULL_WIDTH) | ||
| 139 | + // .height(32) | ||
| 140 | + // .padding({ left: 15, right: 15, }) | ||
| 141 | + // .justifyContent(FlexAlign.SpaceBetween) | ||
| 142 | + // .backgroundColor(Color.White) | ||
| 143 | + // | ||
| 144 | + // Row() { | ||
| 145 | + // Image($r('app.media.line')) | ||
| 146 | + // .width('100%') | ||
| 147 | + // .height(6) | ||
| 148 | + // .objectFit(ImageFit.Cover) | ||
| 149 | + // .margin({ top: 10 }) | ||
| 150 | + // } | ||
| 151 | + // .padding({ left: 15, right: 15, }) | ||
| 152 | + // .backgroundColor(Color.White) | ||
| 153 | + // | ||
| 154 | + // Stack({ alignContent: Alignment.Bottom }) { | ||
| 155 | + // | ||
| 156 | + // List() { | ||
| 157 | + // //详情展示区 | ||
| 158 | + // ListItem() { | ||
| 159 | + // Column() { | ||
| 160 | + // ImageAndTextWebComponent({ | ||
| 161 | + // contentDetailData: this.contentDetailData, | ||
| 162 | + // action: this.action, | ||
| 163 | + // }) | ||
| 164 | + // }.width(CommonConstants.FULL_WIDTH) | ||
| 165 | + // // .height(CommonConstants.FULL_HEIGHT) | ||
| 166 | + // } | ||
| 167 | + // | ||
| 168 | + // if (this.contentDetailData[0]?.openLikes === 1) { | ||
| 169 | + // ListItem() { | ||
| 170 | + // // 点赞 | ||
| 171 | + // Row() { | ||
| 172 | + // Row() { | ||
| 173 | + // if (this.newsStatusOfUser?.likeStatus === '1') { | ||
| 174 | + // 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'))) | ||
| 175 | + // .width(24) | ||
| 176 | + // .height(24) | ||
| 177 | + // .margin({ right: 5 }) | ||
| 178 | + // } else { | ||
| 179 | + // 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'))) | ||
| 180 | + // .width(24) | ||
| 181 | + // .height(24) | ||
| 182 | + // .margin({ right: 5 }) | ||
| 183 | + // } | ||
| 184 | + // Text(`${this.interactData?.likeNum || 0}`) | ||
| 185 | + // .fontSize(16) | ||
| 186 | + // .fontColor(this.newsStatusOfUser?.likeStatus === '1' ? '#ED2800' : '#999999') | ||
| 187 | + // .fontWeight(500) | ||
| 188 | + // }.alignItems(VerticalAlign.Center) | ||
| 189 | + // .onClick(() => { | ||
| 190 | + // this.toggleLikeStatus() | ||
| 191 | + // }) | ||
| 192 | + // | ||
| 193 | + // }.width(CommonConstants.FULL_WIDTH).height(80) | ||
| 194 | + // .justifyContent(FlexAlign.Center) | ||
| 195 | + // } | ||
| 196 | + // .border({ | ||
| 197 | + // width: { bottom: 5 }, | ||
| 198 | + // color: '#f5f5f5', | ||
| 199 | + // }) | ||
| 200 | + // } | ||
| 201 | + // | ||
| 202 | + // // 相关推荐区 | ||
| 203 | + // ListItem() { | ||
| 204 | + // RecommendList({ recommendList: this.recommendList }) | ||
| 205 | + // } | ||
| 206 | + // } | ||
| 207 | + // .width(CommonConstants.FULL_WIDTH) | ||
| 208 | + // .height(CommonConstants.FULL_HEIGHT) | ||
| 209 | + // .padding({ bottom: 56 }) | ||
| 210 | + // .scrollBar(BarState.Off) | ||
| 211 | + // .edgeEffect(EdgeEffect.None) | ||
| 212 | + // | ||
| 213 | + // //底部交互区 | ||
| 214 | + // Row() { | ||
| 215 | + // Image($r('app.media.icon_arrow_left')) | ||
| 216 | + // .width(24) | ||
| 217 | + // .height(24) | ||
| 218 | + // .onClick((event: ClickEvent) => { | ||
| 219 | + // router.back() | ||
| 220 | + // }) | ||
| 221 | + // | ||
| 222 | + // Row() { | ||
| 223 | + // Image($r('app.media.icon_comment')) | ||
| 224 | + // .width(24) | ||
| 225 | + // .height(24) | ||
| 226 | + // .margin({ right: 24 }) | ||
| 227 | + // .id('comment') | ||
| 228 | + // | ||
| 229 | + // Image($r('app.media.icon_star')) | ||
| 230 | + // .width(24) | ||
| 231 | + // .height(24) | ||
| 232 | + // .margin({ right: 24 }) | ||
| 233 | + // | ||
| 234 | + // Image($r('app.media.icon_listen')) | ||
| 235 | + // .width(24) | ||
| 236 | + // .height(24) | ||
| 237 | + // .margin({ right: 24 }) | ||
| 238 | + // | ||
| 239 | + // Image($r('app.media.icon_forward')) | ||
| 240 | + // .width(24) | ||
| 241 | + // .height(24) | ||
| 242 | + // | ||
| 243 | + // } | ||
| 244 | + // } | ||
| 245 | + // .width(CommonConstants.FULL_WIDTH) | ||
| 246 | + // .height(56) | ||
| 247 | + // .padding({ left: 15, right: 15, bottom: 50, top: 20 }) | ||
| 248 | + // .justifyContent(FlexAlign.SpaceBetween) | ||
| 249 | + // .backgroundColor(Color.White) | ||
| 250 | + // } | ||
| 251 | + // | ||
| 252 | + // }.width(CommonConstants.FULL_WIDTH).height(CommonConstants.FULL_HEIGHT) | ||
| 253 | + // .backgroundColor(Color.White) | ||
| 254 | + // | ||
| 255 | + // } | ||
| 256 | + | ||
| 171 | private async getDetail() { | 257 | private async getDetail() { |
| 172 | let contentId: string = '' | 258 | let contentId: string = '' |
| 173 | let relId: string = '' | 259 | let relId: string = '' |
| @@ -199,7 +285,6 @@ export struct ImageAndTextPageComponent { | @@ -199,7 +285,6 @@ export struct ImageAndTextPageComponent { | ||
| 199 | } | 285 | } |
| 200 | } | 286 | } |
| 201 | 287 | ||
| 202 | - | ||
| 203 | private async getRecommend() { | 288 | private async getRecommend() { |
| 204 | let params: postRecommendListParams = { | 289 | let params: postRecommendListParams = { |
| 205 | imei: "8272c108-4fa2-34ce-80b9-bc425a7c2a7e", | 290 | imei: "8272c108-4fa2-34ce-80b9-bc425a7c2a7e", |
| @@ -211,9 +296,7 @@ export struct ImageAndTextPageComponent { | @@ -211,9 +296,7 @@ export struct ImageAndTextPageComponent { | ||
| 211 | channelId: String(this.contentDetailData[0]?.reLInfo?.channelId) | 296 | channelId: String(this.contentDetailData[0]?.reLInfo?.channelId) |
| 212 | } | 297 | } |
| 213 | let recommendList = await DetailViewModel.postRecommendList(params) | 298 | let recommendList = await DetailViewModel.postRecommendList(params) |
| 214 | - if (recommendList && recommendList.length > 0) { | ||
| 215 | - this.recommendList = recommendList; | ||
| 216 | - } | 299 | + this.recommendList = recommendList; |
| 217 | } | 300 | } |
| 218 | 301 | ||
| 219 | // 已登录->查询用户对作品点赞、收藏状态 | 302 | // 已登录->查询用户对作品点赞、收藏状态 |
| @@ -7,7 +7,7 @@ import { | @@ -7,7 +7,7 @@ import { | ||
| 7 | ResponseBean | 7 | ResponseBean |
| 8 | } from 'wdBean'; | 8 | } from 'wdBean'; |
| 9 | import { Logger } from 'wdKit'; | 9 | import { Logger } from 'wdKit'; |
| 10 | -import { WdWebComponent, WdWebLocalComponent } from 'wdWebComponent'; | 10 | +import { WdWebLocalComponent } from 'wdWebComponent'; |
| 11 | import { NativeCallH5Type } from 'wdWebComponent/src/main/ets/pages/NativeCallH5Type'; | 11 | import { NativeCallH5Type } from 'wdWebComponent/src/main/ets/pages/NativeCallH5Type'; |
| 12 | import { BridgeWebViewControl } from 'wdJsBridge/Index'; | 12 | import { BridgeWebViewControl } from 'wdJsBridge/Index'; |
| 13 | 13 | ||
| @@ -85,11 +85,6 @@ export struct ImageAndTextWebComponent { | @@ -85,11 +85,6 @@ export struct ImageAndTextWebComponent { | ||
| 85 | webResource: $rawfile('apph5/index.html'), | 85 | webResource: $rawfile('apph5/index.html'), |
| 86 | backVisibility: false, | 86 | backVisibility: false, |
| 87 | }) | 87 | }) |
| 88 | - // WdWebLocalComponent({ | ||
| 89 | - // webviewControl: this.webviewControl, | ||
| 90 | - // webResource: "http://pd-people-uat.pdnews.cn/articletopic/35398-10000015965", | ||
| 91 | - // backVisibility: false, | ||
| 92 | - // }) | ||
| 93 | } | 88 | } |
| 94 | } | 89 | } |
| 95 | 90 | ||
| @@ -97,7 +92,7 @@ export struct ImageAndTextWebComponent { | @@ -97,7 +92,7 @@ export struct ImageAndTextWebComponent { | ||
| 97 | Logger.debug('ImageAndTextWebComponent', 'jsCall_receiveAppData'); | 92 | Logger.debug('ImageAndTextWebComponent', 'jsCall_receiveAppData'); |
| 98 | this.webviewControl.callHandle(NativeCallH5Type.jsCall_receiveAppData, | 93 | this.webviewControl.callHandle(NativeCallH5Type.jsCall_receiveAppData, |
| 99 | JSON.stringify(h5ReceiveAppData), (data: string) => { | 94 | JSON.stringify(h5ReceiveAppData), (data: string) => { |
| 100 | - // Logger.debug('ImageAndTextWebComponent', "from js data = " + data); | 95 | + Logger.debug('ImageAndTextWebComponent', "from js data = " + data); |
| 101 | }) | 96 | }) |
| 102 | } | 97 | } |
| 103 | } | 98 | } |
| 1 | +import { Action, ContentDetailDTO, } from 'wdBean'; | ||
| 2 | +import DetailViewModel from '../viewmodel/DetailViewModel'; | ||
| 3 | +import { WdWebComponent } from 'wdWebComponent'; | ||
| 4 | +import router from '@ohos.router'; | ||
| 5 | +import { CommonConstants } from 'wdConstant' | ||
| 6 | +import { BridgeWebViewControl } from 'wdJsBridge/Index'; | ||
| 7 | + | ||
| 8 | +const TAG = 'SpacialTopicPageComponent' | ||
| 9 | + | ||
| 10 | +@Component | ||
| 11 | +export struct SpacialTopicPageComponent { | ||
| 12 | + webviewControl: BridgeWebViewControl = new BridgeWebViewControl() | ||
| 13 | + scroller: Scroller = new Scroller(); | ||
| 14 | + action: Action = {} as Action | ||
| 15 | + @State webUrl: string = ''; | ||
| 16 | + build() { | ||
| 17 | + Column() { | ||
| 18 | + Stack({ alignContent: Alignment.Bottom }) { | ||
| 19 | + Column() { | ||
| 20 | + WdWebComponent({ | ||
| 21 | + webviewControl: this.webviewControl, | ||
| 22 | + webUrl: this.webUrl, | ||
| 23 | + backVisibility: false, | ||
| 24 | + }) | ||
| 25 | + } | ||
| 26 | + .padding({ bottom: 56 }) | ||
| 27 | + .width(CommonConstants.FULL_WIDTH) | ||
| 28 | + .height(CommonConstants.FULL_HEIGHT) | ||
| 29 | + | ||
| 30 | + //底部交互区 | ||
| 31 | + Row() { | ||
| 32 | + Image($r('app.media.icon_arrow_left')) | ||
| 33 | + .width(24) | ||
| 34 | + .height(24) | ||
| 35 | + .onClick((event: ClickEvent) => { | ||
| 36 | + router.back() | ||
| 37 | + }) | ||
| 38 | + | ||
| 39 | + Row() { | ||
| 40 | + Image($r('app.media.icon_comment')) | ||
| 41 | + .width(24) | ||
| 42 | + .height(24) | ||
| 43 | + .margin({ right: 24 }) | ||
| 44 | + .id('comment') | ||
| 45 | + | ||
| 46 | + Image($r('app.media.icon_star')) | ||
| 47 | + .width(24) | ||
| 48 | + .height(24) | ||
| 49 | + .margin({ right: 24 }) | ||
| 50 | + | ||
| 51 | + Image($r('app.media.icon_listen')) | ||
| 52 | + .width(24) | ||
| 53 | + .height(24) | ||
| 54 | + .margin({ right: 24 }) | ||
| 55 | + | ||
| 56 | + Image($r('app.media.icon_forward')) | ||
| 57 | + .width(24) | ||
| 58 | + .height(24) | ||
| 59 | + | ||
| 60 | + } | ||
| 61 | + } | ||
| 62 | + .width(CommonConstants.FULL_WIDTH) | ||
| 63 | + .height(56) | ||
| 64 | + .padding({ left: 15, right: 15, bottom: 20, top: 20 }) | ||
| 65 | + .justifyContent(FlexAlign.SpaceBetween) | ||
| 66 | + .backgroundColor(Color.White) | ||
| 67 | + } | ||
| 68 | + }.width(CommonConstants.FULL_WIDTH).height(CommonConstants.FULL_HEIGHT) | ||
| 69 | + .backgroundColor(Color.White) | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + aboutToAppear() { | ||
| 73 | + let action: Action = router.getParams() as Action | ||
| 74 | + if (action) { | ||
| 75 | + this.webUrl = action.params?.url || '' | ||
| 76 | + } | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + aboutToDisappear() { | ||
| 80 | + } | ||
| 81 | +} |
| 1 | +import { ContentDTO } from 'wdBean' | ||
| 2 | +import { CommonConstants } from 'wdConstant/Index'; | ||
| 3 | +import { DateTimeUtils } from 'wdKit/Index'; | ||
| 4 | + | ||
| 5 | +@Component | ||
| 6 | +export struct CardSourceInfo { | ||
| 7 | + @State contentDTO: ContentDTO = {} as ContentDTO; | ||
| 8 | + build() { | ||
| 9 | + Flex() { | ||
| 10 | + if(this.contentDTO.corner) { | ||
| 11 | + Text(this.contentDTO.corner) | ||
| 12 | + .fontSize($r("app.float.font_size_12")) | ||
| 13 | + .fontColor($r("app.color.color_ED2800")) | ||
| 14 | + .margin({right: 2}) | ||
| 15 | + } | ||
| 16 | + if(this.contentDTO.rmhPlatform === 1) { | ||
| 17 | + Text(this.contentDTO.rmhInfo.rmhName) | ||
| 18 | + .fontSize($r("app.float.font_size_12")) | ||
| 19 | + .fontColor($r("app.color.color_B0B0B0")) | ||
| 20 | + .maxLines(1) | ||
| 21 | + .textOverflow({overflow: TextOverflow.Ellipsis}) | ||
| 22 | + Image($r("app.media.point")) | ||
| 23 | + .width(16) | ||
| 24 | + .height(16) | ||
| 25 | + } else if(this.contentDTO.source) { | ||
| 26 | + Text(`${this.contentDTO.source}`) | ||
| 27 | + .fontSize($r("app.float.font_size_12")) | ||
| 28 | + .fontColor($r("app.color.color_B0B0B0")) | ||
| 29 | + .maxLines(1) | ||
| 30 | + .textOverflow({overflow: TextOverflow.Ellipsis}) | ||
| 31 | + Image($r("app.media.point")) | ||
| 32 | + .width(16) | ||
| 33 | + .height(16) | ||
| 34 | + } | ||
| 35 | + // TODO 这里还有个判断需要完善,依赖外部,新闻tab下的卡片,2天之前的不显示时间。但是如果是搜索情况下展示的卡片,显示时间 | ||
| 36 | + Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime))) | ||
| 37 | + .fontSize($r("app.float.font_size_12")) | ||
| 38 | + .fontColor($r("app.color.color_B0B0B0")) | ||
| 39 | + .margin({ right: 6 }) | ||
| 40 | + .flexShrink(0) | ||
| 41 | + if(this.contentDTO?.interactData?.commentNum) { | ||
| 42 | + Text(`${this.contentDTO.interactData.commentNum}评`) | ||
| 43 | + .fontSize($r("app.float.font_size_12")) | ||
| 44 | + .fontColor($r("app.color.color_B0B0B0")) | ||
| 45 | + .flexShrink(0) | ||
| 46 | + } | ||
| 47 | + } | ||
| 48 | + .width(CommonConstants.FULL_WIDTH) | ||
| 49 | + .margin({ top: 8 }) | ||
| 50 | + } | ||
| 51 | +} |
| @@ -2,7 +2,8 @@ import { ContentDTO, slideShows } from 'wdBean'; | @@ -2,7 +2,8 @@ import { ContentDTO, slideShows } from 'wdBean'; | ||
| 2 | import { CommonConstants } from 'wdConstant' | 2 | import { CommonConstants } from 'wdConstant' |
| 3 | import { DateTimeUtils } from 'wdKit'; | 3 | import { DateTimeUtils } from 'wdKit'; |
| 4 | import { ProcessUtils } from '../../utils/ProcessUtils'; | 4 | import { ProcessUtils } from '../../utils/ProcessUtils'; |
| 5 | - | 5 | +import { CardSourceInfo } from '../cardCommon/CardSourceInfo' |
| 6 | +import { CardMediaInfo } from '../cardCommon/CardMediaInfo' | ||
| 6 | 7 | ||
| 7 | /** | 8 | /** |
| 8 | * 大专题卡--CompStyle: 10 | 9 | * 大专题卡--CompStyle: 10 |
| @@ -76,10 +77,10 @@ export struct Card10Component { | @@ -76,10 +77,10 @@ export struct Card10Component { | ||
| 76 | } | 77 | } |
| 77 | .width(CommonConstants.FULL_WIDTH) | 78 | .width(CommonConstants.FULL_WIDTH) |
| 78 | .padding({ | 79 | .padding({ |
| 79 | - top: 14, | ||
| 80 | - left: 16, | ||
| 81 | - right: 16, | ||
| 82 | - bottom: 14 | 80 | + left: $r('app.float.card_comp_pagePadding_lf'), |
| 81 | + right: $r('app.float.card_comp_pagePadding_lf'), | ||
| 82 | + top: $r('app.float.card_comp_pagePadding_tb'), | ||
| 83 | + bottom: $r('app.float.card_comp_pagePadding_tb') | ||
| 83 | }) | 84 | }) |
| 84 | .backgroundColor($r("app.color.white")) | 85 | .backgroundColor($r("app.color.white")) |
| 85 | .margin({ bottom: 8 }) | 86 | .margin({ bottom: 8 }) |
| @@ -95,25 +96,14 @@ export struct Card10Component { | @@ -95,25 +96,14 @@ export struct Card10Component { | ||
| 95 | .fontColor($r('app.color.color_222222')) | 96 | .fontColor($r('app.color.color_222222')) |
| 96 | .maxLines(2) | 97 | .maxLines(2) |
| 97 | .textOverflow({ overflow: TextOverflow.Ellipsis }) | 98 | .textOverflow({ overflow: TextOverflow.Ellipsis }) |
| 98 | - Row() { | ||
| 99 | - // 展示发稿人 | ||
| 100 | - if (item.source) { | ||
| 101 | - Text(item.source) | ||
| 102 | - .fontSize($r('app.float.font_size_12')) | ||
| 103 | - .fontColor($r('app.color.color_B0B0B0')) | ||
| 104 | - .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 105 | - .maxLines(1) | ||
| 106 | - .width(item.source.length > 10 ? '60%' : '') | ||
| 107 | - | ||
| 108 | - Image($r('app.media.point')) | ||
| 109 | - .width(16) | ||
| 110 | - .height(16) | 99 | + CardSourceInfo( |
| 100 | + { | ||
| 101 | + contentDTO: { | ||
| 102 | + publishTime: item.publishTime || '', | ||
| 103 | + source: item.source || '' | ||
| 104 | + } as ContentDTO | ||
| 111 | } | 105 | } |
| 112 | - Text(DateTimeUtils.getCommentTime(Number.parseFloat(String(item.publishTime)))) | ||
| 113 | - .fontSize($r("app.float.font_size_12")) | ||
| 114 | - .fontColor($r("app.color.color_B0B0B0")) | ||
| 115 | - } | ||
| 116 | - .margin({ top: 12 }) | 106 | + ) |
| 117 | } | 107 | } |
| 118 | .layoutWeight(1) | 108 | .layoutWeight(1) |
| 119 | .alignItems(HorizontalAlign.Start) | 109 | .alignItems(HorizontalAlign.Start) |
| @@ -3,7 +3,7 @@ import { CommonConstants } from 'wdConstant' | @@ -3,7 +3,7 @@ import { CommonConstants } from 'wdConstant' | ||
| 3 | import { ContentDTO } from 'wdBean' | 3 | import { ContentDTO } from 'wdBean' |
| 4 | import { DateTimeUtils } from 'wdKit' | 4 | import { DateTimeUtils } from 'wdKit' |
| 5 | import { ProcessUtils } from '../../utils/ProcessUtils'; | 5 | import { ProcessUtils } from '../../utils/ProcessUtils'; |
| 6 | - | 6 | +import { CardSourceInfo } from '../cardCommon/CardSourceInfo' |
| 7 | const TAG = 'Card11Component'; | 7 | const TAG = 'Card11Component'; |
| 8 | 8 | ||
| 9 | /** | 9 | /** |
| @@ -21,29 +21,8 @@ export struct Card11Component { | @@ -21,29 +21,8 @@ export struct Card11Component { | ||
| 21 | .maxLines(3) | 21 | .maxLines(3) |
| 22 | .textOverflow({ overflow: TextOverflow.Ellipsis }) | 22 | .textOverflow({ overflow: TextOverflow.Ellipsis }) |
| 23 | .width(CommonConstants.FULL_WIDTH) | 23 | .width(CommonConstants.FULL_WIDTH) |
| 24 | - Row() { | ||
| 25 | - if (this.contentDTO.source) { | ||
| 26 | - Text(this.contentDTO.source) | ||
| 27 | - .fontSize($r("app.float.font_size_12")) | ||
| 28 | - .fontColor($r("app.color.color_B0B0B0")) | ||
| 29 | - .margin({ left: 6 }) | ||
| 30 | - Image($r("app.media.point")) | ||
| 31 | - .width(16) | ||
| 32 | - .height(16) | ||
| 33 | - } | ||
| 34 | - | ||
| 35 | - Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime))) | ||
| 36 | - .fontSize($r("app.float.font_size_12")) | ||
| 37 | - .fontColor($r("app.color.color_B0B0B0")) | ||
| 38 | - .margin({ right: 6 }) | ||
| 39 | - // TODO '评论取哪个字段' | ||
| 40 | - // Text(`1806评`) | ||
| 41 | - // .fontSize($r("app.float.font_size_12")) | ||
| 42 | - // .fontColor($r("app.color.color_B0B0B0")) | ||
| 43 | - }.width(CommonConstants.FULL_WIDTH) | ||
| 44 | - .justifyContent(FlexAlign.Start) | ||
| 45 | - .margin({ top: 8 }) | ||
| 46 | - | 24 | + // 评论等信息 |
| 25 | + CardSourceInfo({ contentDTO: this.contentDTO }) | ||
| 47 | }.width(CommonConstants.FULL_WIDTH) | 26 | }.width(CommonConstants.FULL_WIDTH) |
| 48 | .padding({ | 27 | .padding({ |
| 49 | left: $r('app.float.card_comp_pagePadding_lf'), | 28 | left: $r('app.float.card_comp_pagePadding_lf'), |
| 1 | +import { ContentDTO } from 'wdBean'; | ||
| 2 | +import { RmhTitle } from '../cardCommon/RmhTitle' | ||
| 3 | +import { CardMediaInfo } from '../cardCommon/CardMediaInfo' | ||
| 4 | +import { CommonConstants } from 'wdConstant/Index'; | ||
| 5 | + | ||
| 6 | +const TAG = 'Card12Component'; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * 人民号-动态---12:人民号无图卡; | ||
| 10 | + */ | ||
| 11 | +@Component | ||
| 12 | +export struct Card12Component { | ||
| 13 | + @State contentDTO: ContentDTO = { | ||
| 14 | + appStyle: '20', | ||
| 15 | + coverType: 1, | ||
| 16 | + coverUrl: 'https://rmrbcmsonline.peopleapp.com/upload/user_app/gov_dynamic/video/default_image/202105/rmrb_default_image_4GdWrgSw1622451312.jpg?x-oss-process=image/resize,m_fill,h_480,w_360/quality,q_90', | ||
| 17 | + fullColumnImgUrls: [ | ||
| 18 | + { | ||
| 19 | + landscape: 1, | ||
| 20 | + size: 1, | ||
| 21 | + url: 'https://rmrbcmsonline.peopleapp.com/upload/user_app/gov_dynamic/video/default_image/202105/rmrb_default_image_4GdWrgSw1622451312.jpg?x-oss-process=image/resize,m_fill,h_480,w_360/quality,q_90', | ||
| 22 | + weight: 1600 | ||
| 23 | + } | ||
| 24 | + ], | ||
| 25 | + newsTitle: '好玩!》10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人', | ||
| 26 | + rmhInfo: { | ||
| 27 | + authIcon: | ||
| 28 | + 'https://cdnjdphoto.aikan.pdnews.cn/creator-category/icon/auth/yellow.png', | ||
| 29 | + authTitle: '10后音乐人王烁然个人人民号', | ||
| 30 | + authTitle2: '10后音乐人王烁然个人人民号', | ||
| 31 | + banControl: 0, | ||
| 32 | + cnIsAttention: 1, | ||
| 33 | + rmhDesc: '10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人', | ||
| 34 | + rmhHeadUrl: 'https://cdnjdphoto.aikan.pdnews.cn/image/creator/rmh/20221031/3d3419e86a.jpeg?x-oss-process=image/resize,l_100/auto-orient,1/quality,q_90/format,jpg', | ||
| 35 | + rmhName: '王烁然', | ||
| 36 | + userId: '522435359667845', | ||
| 37 | + userType: '2' | ||
| 38 | + }, | ||
| 39 | + objectType: '1', | ||
| 40 | + videoInfo: { | ||
| 41 | + firstFrameImageUri: '', | ||
| 42 | + videoDuration: 37, | ||
| 43 | + videoUrl: 'https://rmrbcmsonline.peopleapp.com/upload/user_app/gov_dynamic/video/mp4/202105/rmrb_GSNARt6P1622451310.mp4' | ||
| 44 | + } | ||
| 45 | + } as ContentDTO; | ||
| 46 | + | ||
| 47 | + aboutToAppear(): void { | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + build() { | ||
| 51 | + Column() { | ||
| 52 | + // rmh信息 | ||
| 53 | + RmhTitle({ rmhInfo: this.contentDTO.rmhInfo }) | ||
| 54 | + // 标题 | ||
| 55 | + if (this.contentDTO.newsTitle) { | ||
| 56 | + Text(this.contentDTO.newsTitle) | ||
| 57 | + .fontSize($r('app.float.font_size_17')) | ||
| 58 | + .fontColor($r('app.color.color_222222')) | ||
| 59 | + .width(CommonConstants.FULL_WIDTH) | ||
| 60 | + .textOverflowStyle(3) | ||
| 61 | + .margin({ bottom: 8 }) | ||
| 62 | + .height(75) | ||
| 63 | + .lineHeight(25) | ||
| 64 | + .fontFamily('PingFang SC-Regular') | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + // if (this.contentDTO.fullColumnImgUrls?.[0]) { | ||
| 68 | + // createImg({ contentDTO: this.contentDTO }) | ||
| 69 | + // } | ||
| 70 | + //TODO 底部的:分享、评论、点赞 功能;需要引用一个公共组件 | ||
| 71 | + } | ||
| 72 | + .padding({ | ||
| 73 | + left: $r('app.float.card_comp_pagePadding_lf'), | ||
| 74 | + right: $r('app.float.card_comp_pagePadding_lf'), | ||
| 75 | + top: $r('app.float.card_comp_pagePadding_tb'), | ||
| 76 | + bottom: $r('app.float.card_comp_pagePadding_tb') | ||
| 77 | + }) | ||
| 78 | + } | ||
| 79 | +} | ||
| 80 | + | ||
| 81 | +interface radiusType { | ||
| 82 | + topLeft: number | Resource; | ||
| 83 | + topRight: number | Resource; | ||
| 84 | + bottomLeft: number | Resource; | ||
| 85 | + bottomRight: number | Resource; | ||
| 86 | +} | ||
| 87 | + | ||
| 88 | +@Component | ||
| 89 | +struct createImg { | ||
| 90 | + @Prop contentDTO: ContentDTO | ||
| 91 | + | ||
| 92 | + build() { | ||
| 93 | + GridRow() { | ||
| 94 | + if (this.contentDTO.fullColumnImgUrls[0].landscape === 1) { | ||
| 95 | + // 横屏 | ||
| 96 | + GridCol({ | ||
| 97 | + span: { xs: 12 } | ||
| 98 | + }) { | ||
| 99 | + Stack() { | ||
| 100 | + Image(this.contentDTO.coverUrl) | ||
| 101 | + .width(CommonConstants.FULL_WIDTH) | ||
| 102 | + .aspectRatio(16 / 9) | ||
| 103 | + .borderRadius($r('app.float.image_border_radius')) | ||
| 104 | + CardMediaInfo({ contentDTO: this.contentDTO }) | ||
| 105 | + } | ||
| 106 | + .align(Alignment.BottomEnd) | ||
| 107 | + } | ||
| 108 | + } else { | ||
| 109 | + // 竖图显示,宽度占50%,高度自适应 | ||
| 110 | + GridCol({ | ||
| 111 | + span: { xs: 6 } | ||
| 112 | + }) { | ||
| 113 | + Stack() { | ||
| 114 | + Image(this.contentDTO.coverUrl) | ||
| 115 | + .width(CommonConstants.FULL_WIDTH) | ||
| 116 | + .borderRadius($r('app.float.image_border_radius')) | ||
| 117 | + CardMediaInfo({ contentDTO: this.contentDTO }) | ||
| 118 | + } | ||
| 119 | + .align(Alignment.BottomEnd) | ||
| 120 | + } | ||
| 121 | + } | ||
| 122 | + } | ||
| 123 | + } | ||
| 124 | +} | ||
| 125 | + | ||
| 126 | + | ||
| 127 | +@Extend(Text) | ||
| 128 | +function textOverflowStyle(maxLine: number) { | ||
| 129 | + .maxLines(maxLine) | ||
| 130 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 131 | +} |
| 1 | +import { ContentDTO } from 'wdBean'; | ||
| 2 | +import { RmhTitle } from '../cardCommon/RmhTitle' | ||
| 3 | +import { CardMediaInfo } from '../cardCommon/CardMediaInfo' | ||
| 4 | +import { CommonConstants } from 'wdConstant/Index'; | ||
| 5 | + | ||
| 6 | +const TAG = 'Card12Component'; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * 人民号-动态---12:人民号无图卡; | ||
| 10 | + */ | ||
| 11 | +@Entry | ||
| 12 | +@Component | ||
| 13 | +export struct Card12Component { | ||
| 14 | + @State contentDTO: ContentDTO = { | ||
| 15 | + appStyle: '20', | ||
| 16 | + coverType: 1, | ||
| 17 | + coverUrl: 'https://rmrbcmsonline.peopleapp.com/upload/user_app/gov_dynamic/video/default_image/202105/rmrb_default_image_4GdWrgSw1622451312.jpg?x-oss-process=image/resize,m_fill,h_480,w_360/quality,q_90', | ||
| 18 | + fullColumnImgUrls: [ | ||
| 19 | + { | ||
| 20 | + landscape: 1, | ||
| 21 | + size: 1, | ||
| 22 | + url: 'https://rmrbcmsonline.peopleapp.com/upload/user_app/gov_dynamic/video/default_image/202105/rmrb_default_image_4GdWrgSw1622451312.jpg?x-oss-process=image/resize,m_fill,h_480,w_360/quality,q_90', | ||
| 23 | + weight: 1600 | ||
| 24 | + } | ||
| 25 | + ], | ||
| 26 | + newsTitle: '好玩!》10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人', | ||
| 27 | + rmhInfo: { | ||
| 28 | + authIcon: | ||
| 29 | + 'https://cdnjdphoto.aikan.pdnews.cn/creator-category/icon/auth/yellow.png', | ||
| 30 | + authTitle: '10后音乐人王烁然个人人民号', | ||
| 31 | + authTitle2: '10后音乐人王烁然个人人民号', | ||
| 32 | + banControl: 0, | ||
| 33 | + cnIsAttention: 1, | ||
| 34 | + rmhDesc: '10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人', | ||
| 35 | + rmhHeadUrl: 'https://cdnjdphoto.aikan.pdnews.cn/image/creator/rmh/20221031/3d3419e86a.jpeg?x-oss-process=image/resize,l_100/auto-orient,1/quality,q_90/format,jpg', | ||
| 36 | + rmhName: '王烁然', | ||
| 37 | + userId: '522435359667845', | ||
| 38 | + userType: '2' | ||
| 39 | + }, | ||
| 40 | + objectType: '1', | ||
| 41 | + videoInfo: { | ||
| 42 | + firstFrameImageUri: '', | ||
| 43 | + videoDuration: 37, | ||
| 44 | + videoUrl: 'https://rmrbcmsonline.peopleapp.com/upload/user_app/gov_dynamic/video/mp4/202105/rmrb_GSNARt6P1622451310.mp4' | ||
| 45 | + } | ||
| 46 | + } as ContentDTO; | ||
| 47 | + | ||
| 48 | + aboutToAppear(): void { | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + build() { | ||
| 52 | + Column() { | ||
| 53 | + // rmh信息 | ||
| 54 | + RmhTitle({ rmhInfo: this.contentDTO.rmhInfo }) | ||
| 55 | + // 左标题,右图 | ||
| 56 | + Flex({ direction: FlexDirection.Row }) { | ||
| 57 | + | ||
| 58 | + Text(this.contentDTO.newsTitle) | ||
| 59 | + .fontSize($r('app.float.font_size_17')) | ||
| 60 | + .fontColor($r('app.color.color_222222')) | ||
| 61 | + .textOverflowStyle(3) | ||
| 62 | + .lineHeight(25) | ||
| 63 | + .fontFamily('PingFang SC-Regular') | ||
| 64 | + .textAlign(TextAlign.Start) | ||
| 65 | + .flexBasis('auto') | ||
| 66 | + .margin({right: 12}) | ||
| 67 | + | ||
| 68 | + Image(this.contentDTO.coverUrl) | ||
| 69 | + .flexBasis(174) | ||
| 70 | + .height(75) | ||
| 71 | + .borderRadius($r('app.float.image_border_radius')) | ||
| 72 | + // .flexBasis(160) | ||
| 73 | + .backgroundImageSize(ImageSize.Auto) | ||
| 74 | + | ||
| 75 | + } | ||
| 76 | + .width(CommonConstants.FULL_WIDTH) | ||
| 77 | + .margin({ bottom: 8 }) | ||
| 78 | + .height(75) | ||
| 79 | + | ||
| 80 | + | ||
| 81 | + //TODO 底部的:分享、评论、点赞 功能;需要引用一个公共组件 | ||
| 82 | + } | ||
| 83 | + .padding({ | ||
| 84 | + left: $r('app.float.card_comp_pagePadding_lf'), | ||
| 85 | + right: $r('app.float.card_comp_pagePadding_lf'), | ||
| 86 | + top: $r('app.float.card_comp_pagePadding_tb'), | ||
| 87 | + bottom: $r('app.float.card_comp_pagePadding_tb') | ||
| 88 | + }) | ||
| 89 | + } | ||
| 90 | +} | ||
| 91 | + | ||
| 92 | +interface radiusType { | ||
| 93 | + topLeft: number | Resource; | ||
| 94 | + topRight: number | Resource; | ||
| 95 | + bottomLeft: number | Resource; | ||
| 96 | + bottomRight: number | Resource; | ||
| 97 | +} | ||
| 98 | + | ||
| 99 | +@Extend(Text) | ||
| 100 | +function textOverflowStyle(maxLine: number) { | ||
| 101 | + .maxLines(maxLine) | ||
| 102 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 103 | +} |
| @@ -4,7 +4,7 @@ import { CommonConstants } from 'wdConstant/Index'; | @@ -4,7 +4,7 @@ import { CommonConstants } from 'wdConstant/Index'; | ||
| 4 | import { DateTimeUtils } from 'wdKit'; | 4 | import { DateTimeUtils } from 'wdKit'; |
| 5 | import { WDRouterRule } from 'wdRouter'; | 5 | import { WDRouterRule } from 'wdRouter'; |
| 6 | import { CardMediaInfo } from '../cardCommon/CardMediaInfo' | 6 | import { CardMediaInfo } from '../cardCommon/CardMediaInfo' |
| 7 | - | 7 | +import { CardSourceInfo } from '../cardCommon/CardSourceInfo' |
| 8 | const TAG = 'Card17Component'; | 8 | const TAG = 'Card17Component'; |
| 9 | 9 | ||
| 10 | /** | 10 | /** |
| @@ -81,25 +81,8 @@ export struct Card17Component { | @@ -81,25 +81,8 @@ export struct Card17Component { | ||
| 81 | }; | 81 | }; |
| 82 | WDRouterRule.jumpWithAction(taskAction) | 82 | WDRouterRule.jumpWithAction(taskAction) |
| 83 | }) | 83 | }) |
| 84 | - | ||
| 85 | - Row() { | ||
| 86 | - if (this.contentDTO.source) { | ||
| 87 | - Text(this.contentDTO.source) | ||
| 88 | - .fontSize($r('app.float.font_size_13')) | ||
| 89 | - .fontColor($r('app.color.color_B0B0B0')) | ||
| 90 | - Image($r('app.media.point')) | ||
| 91 | - .width(16) | ||
| 92 | - .height(16) | ||
| 93 | - } | ||
| 94 | - if (this.contentDTO.publishTime && this.contentDTO.publishTime.length === 13) { | ||
| 95 | - Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime))) | ||
| 96 | - .fontSize($r('app.float.font_size_13')) | ||
| 97 | - .fontColor($r('app.color.color_B0B0B0')) | ||
| 98 | - } | ||
| 99 | - } | ||
| 100 | - .width(CommonConstants.FULL_WIDTH) | ||
| 101 | - .height(16) | ||
| 102 | - .id('label') | 84 | + // 评论等信息 |
| 85 | + CardSourceInfo({ contentDTO: this.contentDTO }) | ||
| 103 | } | 86 | } |
| 104 | .width(CommonConstants.FULL_WIDTH) | 87 | .width(CommonConstants.FULL_WIDTH) |
| 105 | .padding({ | 88 | .padding({ |
| 1 | +import { ContentDTO } from 'wdBean'; | ||
| 2 | +import { CommonConstants, CompStyle } from 'wdConstant'; | ||
| 3 | +import { ProcessUtils } from '../../utils/ProcessUtils'; | ||
| 4 | +import { RmhTitle } from '../cardCommon/RmhTitle' | ||
| 5 | +import { CardMediaInfo } from '../cardCommon/CardMediaInfo' | ||
| 6 | + | ||
| 7 | +const TAG: string = 'Card6Component-Card13Component'; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * 卡片样式:"appStyle":"21" 小视频卡人民号 | ||
| 11 | + */ | ||
| 12 | +@Component | ||
| 13 | +export struct Card21Component { | ||
| 14 | + @State contentDTO: ContentDTO = {} as ContentDTO; | ||
| 15 | + | ||
| 16 | + build() { | ||
| 17 | + Column() { | ||
| 18 | + // 顶部 rmh信息 | ||
| 19 | + RmhTitle({ rmhInfo: this.contentDTO.rmhInfo }) | ||
| 20 | + // 中间内容 | ||
| 21 | + Grid() { | ||
| 22 | + GridItem() { | ||
| 23 | + Text(`${this.contentDTO.newsTitle}`) | ||
| 24 | + .fontSize($r('app.float.selected_text_size')) | ||
| 25 | + .fontColor($r('app.color.color_222222')) | ||
| 26 | + .width(CommonConstants.FULL_WIDTH) | ||
| 27 | + .maxLines(4) | ||
| 28 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 29 | + .padding({ right: 12 }) | ||
| 30 | + .lineHeight(26) | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + GridItem() { | ||
| 34 | + Stack() { | ||
| 35 | + Image(this.contentDTO.coverUrl) | ||
| 36 | + .width(CommonConstants.FULL_WIDTH) | ||
| 37 | + .borderRadius($r('app.float.image_border_radius')) | ||
| 38 | + CardMediaInfo({ contentDTO: this.contentDTO }) | ||
| 39 | + } | ||
| 40 | + .alignContent(Alignment.BottomEnd) | ||
| 41 | + } | ||
| 42 | + } | ||
| 43 | + .columnsTemplate('2fr 1fr') | ||
| 44 | + .maxCount(1) | ||
| 45 | + | ||
| 46 | + //TODO 底部的:分享、评论、点赞 功能;需要引用一个公共组件 | ||
| 47 | + } | ||
| 48 | + .onClick((event: ClickEvent) => { | ||
| 49 | + ProcessUtils.processPage(this.contentDTO) | ||
| 50 | + }) | ||
| 51 | + .padding({ | ||
| 52 | + left: $r('app.float.card_comp_pagePadding_lf'), | ||
| 53 | + right: $r('app.float.card_comp_pagePadding_lf'), | ||
| 54 | + top: $r('app.float.card_comp_pagePadding_tb'), | ||
| 55 | + bottom: $r('app.float.card_comp_pagePadding_tb') | ||
| 56 | + }) | ||
| 57 | + .width(CommonConstants.FULL_WIDTH) | ||
| 58 | + } | ||
| 59 | +} |
| 1 | //全标题 "appStyle":"2", | 1 | //全标题 "appStyle":"2", |
| 2 | import { ContentDTO } from 'wdBean'; | 2 | import { ContentDTO } from 'wdBean'; |
| 3 | import { CommonConstants } from 'wdConstant/Index'; | 3 | import { CommonConstants } from 'wdConstant/Index'; |
| 4 | -import { DateTimeUtils } from 'wdKit/Index'; | ||
| 5 | import { ProcessUtils } from '../../utils/ProcessUtils'; | 4 | import { ProcessUtils } from '../../utils/ProcessUtils'; |
| 6 | import { CardMediaInfo } from '../cardCommon/CardMediaInfo' | 5 | import { CardMediaInfo } from '../cardCommon/CardMediaInfo' |
| 7 | - | 6 | +import { CardSourceInfo } from '../cardCommon/CardSourceInfo' |
| 8 | const TAG: string = 'Card2Component'; | 7 | const TAG: string = 'Card2Component'; |
| 9 | 8 | ||
| 10 | /** | 9 | /** |
| @@ -60,21 +59,8 @@ export struct Card2Component { | @@ -60,21 +59,8 @@ export struct Card2Component { | ||
| 60 | .alignItems(HorizontalAlign.Start) | 59 | .alignItems(HorizontalAlign.Start) |
| 61 | 60 | ||
| 62 | //bottom | 61 | //bottom |
| 63 | - Row() { | ||
| 64 | - Text(this.contentDTO.source) | ||
| 65 | - .bottomTextStyle() | ||
| 66 | - //间隔点 | ||
| 67 | - Image($r('app.media.point')) | ||
| 68 | - .width(12) | ||
| 69 | - .height(12) | ||
| 70 | - | ||
| 71 | - Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime))) | ||
| 72 | - .bottomTextStyle() | ||
| 73 | - } | ||
| 74 | - .width(CommonConstants.FULL_WIDTH) | ||
| 75 | - .height(18) | ||
| 76 | - .justifyContent(FlexAlign.Start) | ||
| 77 | - .margin({ top: 8 }) | 62 | + // 评论等信息 |
| 63 | + CardSourceInfo({ contentDTO: this.contentDTO }) | ||
| 78 | } | 64 | } |
| 79 | .width(CommonConstants.FULL_WIDTH) | 65 | .width(CommonConstants.FULL_WIDTH) |
| 80 | .padding({ | 66 | .padding({ |
| 1 | import { ContentDTO } from 'wdBean'; | 1 | import { ContentDTO } from 'wdBean'; |
| 2 | import { CommonConstants } from 'wdConstant' | 2 | import { CommonConstants } from 'wdConstant' |
| 3 | -import { DateTimeUtils } from 'wdKit/src/main/ets/utils/DateTimeUtils' | ||
| 4 | import { ProcessUtils } from '../../utils/ProcessUtils'; | 3 | import { ProcessUtils } from '../../utils/ProcessUtils'; |
| 4 | +import { CardSourceInfo } from '../cardCommon/CardSourceInfo' | ||
| 5 | 5 | ||
| 6 | /** | 6 | /** |
| 7 | * 卡片样式:"appStyle":"3" | 7 | * 卡片样式:"appStyle":"3" |
| @@ -27,30 +27,8 @@ export struct Card3Component { | @@ -27,30 +27,8 @@ export struct Card3Component { | ||
| 27 | .fontSize($r("app.float.font_size_16")) | 27 | .fontSize($r("app.float.font_size_16")) |
| 28 | .fontColor($r("app.color.color_222222")) | 28 | .fontColor($r("app.color.color_222222")) |
| 29 | .width(CommonConstants.FULL_WIDTH) | 29 | .width(CommonConstants.FULL_WIDTH) |
| 30 | - Row() { | ||
| 31 | - // TODO "锐评"取得哪个字段,什么时候显示。 | ||
| 32 | - // Text("锐评") | ||
| 33 | - // .fontSize($r("app.float.font_size_12")) | ||
| 34 | - // .fontColor($r("app.color.color_ED2800")) | ||
| 35 | - if(this.contentDTO.source) { | ||
| 36 | - Text(this.contentDTO.source) | ||
| 37 | - .fontSize($r("app.float.font_size_12")) | ||
| 38 | - .fontColor($r("app.color.color_B0B0B0")) | ||
| 39 | - Image($r("app.media.point")) | ||
| 40 | - .width(16) | ||
| 41 | - .height(16) | ||
| 42 | - } | ||
| 43 | - Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime))) | ||
| 44 | - .fontSize($r("app.float.font_size_12")) | ||
| 45 | - .fontColor($r("app.color.color_B0B0B0")) | ||
| 46 | - .margin({ right: 6 }) | ||
| 47 | - // TODO '评论取哪个字段' | ||
| 48 | - // Text(`1806评`) | ||
| 49 | - // .fontSize($r("app.float.font_size_12")) | ||
| 50 | - // .fontColor($r("app.color.color_B0B0B0")) | ||
| 51 | - }.width(CommonConstants.FULL_WIDTH) | ||
| 52 | - .justifyContent(FlexAlign.Start) | ||
| 53 | - .margin({ top: 8 }) | 30 | + // 评论等信息 |
| 31 | + CardSourceInfo({ contentDTO: this.contentDTO }) | ||
| 54 | } | 32 | } |
| 55 | .width(CommonConstants.FULL_WIDTH) | 33 | .width(CommonConstants.FULL_WIDTH) |
| 56 | .padding({ | 34 | .padding({ |
| 1 | import { ContentDTO, FullColumnImgUrlDTO } from 'wdBean'; | 1 | import { ContentDTO, FullColumnImgUrlDTO } from 'wdBean'; |
| 2 | import { CommonConstants } from 'wdConstant/Index'; | 2 | import { CommonConstants } from 'wdConstant/Index'; |
| 3 | import { ProcessUtils } from '../../utils/ProcessUtils'; | 3 | import { ProcessUtils } from '../../utils/ProcessUtils'; |
| 4 | -import { DateTimeUtils } from 'wdKit/Index'; | ||
| 5 | - | 4 | +import { CardSourceInfo } from '../cardCommon/CardSourceInfo' |
| 6 | const TAG: string = 'Card4Component'; | 5 | const TAG: string = 'Card4Component'; |
| 7 | 6 | ||
| 8 | /** | 7 | /** |
| @@ -110,25 +109,8 @@ export struct Card4Component { | @@ -110,25 +109,8 @@ export struct Card4Component { | ||
| 110 | .onClick((event: ClickEvent) => { | 109 | .onClick((event: ClickEvent) => { |
| 111 | ProcessUtils.processPage(this.contentDTO) | 110 | ProcessUtils.processPage(this.contentDTO) |
| 112 | }) | 111 | }) |
| 113 | - | ||
| 114 | - | ||
| 115 | - //bottom | ||
| 116 | - Row() { | ||
| 117 | - Text(this.contentDTO.source) | ||
| 118 | - .bottomTextStyle() | ||
| 119 | - //间隔点 | ||
| 120 | - Image($r('app.media.point')) | ||
| 121 | - .width(12) | ||
| 122 | - .height(12) | ||
| 123 | - Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime))) | ||
| 124 | - .bottomTextStyle() | ||
| 125 | - // TODO 评论字段取值 | ||
| 126 | - // Text('518条评论') | ||
| 127 | - // .bottomTextStyle() | ||
| 128 | - } | ||
| 129 | - .width('100%') | ||
| 130 | - .justifyContent(FlexAlign.Start) | ||
| 131 | - .margin({ top: 8 }) | 112 | + //bottom 评论等信息 |
| 113 | + CardSourceInfo({ contentDTO: this.contentDTO }) | ||
| 132 | } | 114 | } |
| 133 | .width(CommonConstants.FULL_WIDTH) | 115 | .width(CommonConstants.FULL_WIDTH) |
| 134 | .padding({ | 116 | .padding({ |
| 1 | import { ContentDTO } from 'wdBean'; | 1 | import { ContentDTO } from 'wdBean'; |
| 2 | import { CommonConstants, CompStyle } from 'wdConstant'; | 2 | import { CommonConstants, CompStyle } from 'wdConstant'; |
| 3 | -import { DateTimeUtils } from 'wdKit'; | ||
| 4 | import { ProcessUtils } from '../../utils/ProcessUtils'; | 3 | import { ProcessUtils } from '../../utils/ProcessUtils'; |
| 5 | - | 4 | +import { CardSourceInfo } from '../cardCommon/CardSourceInfo' |
| 5 | +import { CardMediaInfo } from '../cardCommon/CardMediaInfo' | ||
| 6 | const TAG: string = 'Card6Component-Card13Component'; | 6 | const TAG: string = 'Card6Component-Card13Component'; |
| 7 | -const FULL_PARENT: string = '100%'; | ||
| 8 | 7 | ||
| 9 | /** | 8 | /** |
| 10 | - * 卡片样式:"appStyle":"6"以及13 | 9 | + * 卡片样式:"appStyle":"6"以及13--- 小视频卡 |
| 11 | */ | 10 | */ |
| 12 | @Component | 11 | @Component |
| 13 | export struct Card6Component { | 12 | export struct Card6Component { |
| @@ -17,7 +16,17 @@ export struct Card6Component { | @@ -17,7 +16,17 @@ export struct Card6Component { | ||
| 17 | Row() { | 16 | Row() { |
| 18 | Column() { | 17 | Column() { |
| 19 | Column() { | 18 | Column() { |
| 20 | - Text(this.contentDTO.newsTitle) | 19 | + // TODO 这个tag涉及样式问题。待优化。 |
| 20 | + // if (this.contentDTO.newTags) { | ||
| 21 | + // Text(this.contentDTO.newTags) | ||
| 22 | + // .backgroundColor($r('app.color.color_ED2800')) | ||
| 23 | + // .borderRadius($r('app.float.button_border_radius')) | ||
| 24 | + // .fontColor($r('app.color.color_fff')) | ||
| 25 | + // .fontSize($r('app.float.font_size_12')) | ||
| 26 | + // .padding(2) | ||
| 27 | + // .margin({ right: 2 }) | ||
| 28 | + // } | ||
| 29 | + Text(`${this.contentDTO.newsTitle}`) | ||
| 21 | .fontSize(16) | 30 | .fontSize(16) |
| 22 | .fontWeight(FontWeight.Normal) | 31 | .fontWeight(FontWeight.Normal) |
| 23 | .maxLines(3)// | 32 | .maxLines(3)// |
| @@ -26,93 +35,35 @@ export struct Card6Component { | @@ -26,93 +35,35 @@ export struct Card6Component { | ||
| 26 | }.height("80%") | 35 | }.height("80%") |
| 27 | .justifyContent(FlexAlign.Start) | 36 | .justifyContent(FlexAlign.Start) |
| 28 | 37 | ||
| 29 | - Row() { | ||
| 30 | - if (this.contentDTO.source) { | ||
| 31 | - Text(this.contentDTO.source) | ||
| 32 | - .fontSize($r('app.float.font_size_12')) | ||
| 33 | - .fontColor(Color.Gray) | ||
| 34 | - .maxLines(1) | ||
| 35 | - .textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。 | ||
| 36 | - .width(this.contentDTO.source.length > 8 ? '50%' : '') | ||
| 37 | - Image($r('app.media.point')) | ||
| 38 | - .width(16) | ||
| 39 | - .height(16) | ||
| 40 | - } | ||
| 41 | - if (this.contentDTO.publishTime && this.contentDTO.publishTime.length === 13) { | ||
| 42 | - Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime))) | ||
| 43 | - .fontSize($r('app.float.font_size_12')) | ||
| 44 | - .fontColor(Color.Gray) | ||
| 45 | - } | ||
| 46 | - Text(this.contentDTO.visitorComment + '评') | ||
| 47 | - .fontSize($r('app.float.font_size_12')) | ||
| 48 | - .fontColor(Color.Gray) | ||
| 49 | - .padding({ | ||
| 50 | - left: 5 | ||
| 51 | - }) | ||
| 52 | - }.alignSelf(ItemAlign.Start) | ||
| 53 | - .height("20%") | ||
| 54 | - .justifyContent(FlexAlign.Start) | 38 | + |
| 39 | + //bottom 评论等信息 | ||
| 40 | + CardSourceInfo({ contentDTO: this.contentDTO }) | ||
| 55 | } | 41 | } |
| 56 | .alignItems(HorizontalAlign.Start) | 42 | .alignItems(HorizontalAlign.Start) |
| 57 | .justifyContent(FlexAlign.Start) | 43 | .justifyContent(FlexAlign.Start) |
| 58 | .width('58%') | 44 | .width('58%') |
| 59 | - | ||
| 60 | - Blank(16) | ||
| 61 | if (this.contentDTO.coverUrl) { | 45 | if (this.contentDTO.coverUrl) { |
| 62 | Stack() { | 46 | Stack() { |
| 63 | Image(this.contentDTO.coverUrl) | 47 | Image(this.contentDTO.coverUrl) |
| 64 | .borderRadius(5) | 48 | .borderRadius(5) |
| 65 | .aspectRatio(this.contentDTO.appStyle === CompStyle.Card_13 ? 3 / 2 : 3 / 4) | 49 | .aspectRatio(this.contentDTO.appStyle === CompStyle.Card_13 ? 3 / 2 : 3 / 4) |
| 66 | .height(this.contentDTO.appStyle === CompStyle.Card_13 ? 90 : 180) | 50 | .height(this.contentDTO.appStyle === CompStyle.Card_13 ? 90 : 180) |
| 67 | - if (this.contentDTO.videoInfo) { | ||
| 68 | - Row() { | ||
| 69 | - Image($r('app.media.iv_card_play_yellow_flag')) | ||
| 70 | - .width(22) | ||
| 71 | - .height(18) | ||
| 72 | - Text(DateTimeUtils.getFormattedDuration(this.contentDTO.videoInfo.videoDuration * 1000)) | ||
| 73 | - .fontSize($r('app.float.font_size_13')) | ||
| 74 | - .fontWeight(400) | ||
| 75 | - .fontColor($r('app.color.color_fff')) | ||
| 76 | - } | ||
| 77 | - .alignItems(VerticalAlign.Bottom) | ||
| 78 | - .height(18) | ||
| 79 | - .padding({ right: 4 }) | ||
| 80 | - .margin({ | ||
| 81 | - right: 4, | ||
| 82 | - bottom: 4 | ||
| 83 | - }) | ||
| 84 | - .backgroundColor($r('app.color.color_4d000000')) | ||
| 85 | - } else if (this.contentDTO.voiceInfo) { | ||
| 86 | - Row() { | ||
| 87 | - Image($r('app.media.icon_listen')) | ||
| 88 | - .width(22) | ||
| 89 | - .height(18) | ||
| 90 | - Text(DateTimeUtils.getFormattedDuration(this.contentDTO.voiceInfo | ||
| 91 | - .voiceDuration * 1000)) | ||
| 92 | - .fontSize($r('app.float.font_size_13')) | ||
| 93 | - .fontWeight(400) | ||
| 94 | - .fontColor($r('app.color.color_fff')) | ||
| 95 | - } | ||
| 96 | - .alignItems(VerticalAlign.Bottom) | ||
| 97 | - .height(18) | ||
| 98 | - .padding({ right: 4 }) | ||
| 99 | - .margin({ | ||
| 100 | - right: 4, | ||
| 101 | - bottom: 4 | ||
| 102 | - }) | ||
| 103 | - .backgroundColor($r('app.color.color_4d000000')) | ||
| 104 | - } | ||
| 105 | - }.alignContent(Alignment.BottomEnd) | 51 | + CardMediaInfo({ contentDTO: this.contentDTO }) |
| 52 | + } | ||
| 53 | + .alignContent(Alignment.BottomEnd) | ||
| 106 | } | 54 | } |
| 107 | } | 55 | } |
| 108 | .onClick((event: ClickEvent) => { | 56 | .onClick((event: ClickEvent) => { |
| 109 | ProcessUtils.processPage(this.contentDTO) | 57 | ProcessUtils.processPage(this.contentDTO) |
| 110 | }) | 58 | }) |
| 111 | - .padding( | ||
| 112 | - { top: 16, bottom: 16, left: 14, right: 14 }) | ||
| 113 | - .width(FULL_PARENT) | 59 | + .padding({ |
| 60 | + left: $r('app.float.card_comp_pagePadding_lf'), | ||
| 61 | + right: $r('app.float.card_comp_pagePadding_lf'), | ||
| 62 | + top: $r('app.float.card_comp_pagePadding_tb'), | ||
| 63 | + bottom: $r('app.float.card_comp_pagePadding_tb') | ||
| 64 | + }) | ||
| 65 | + .width(CommonConstants.FULL_WIDTH) | ||
| 114 | .height(this.contentDTO.appStyle === CompStyle.Card_13 ? 127 : 217) | 66 | .height(this.contentDTO.appStyle === CompStyle.Card_13 ? 127 : 217) |
| 115 | .justifyContent(FlexAlign.SpaceBetween) | 67 | .justifyContent(FlexAlign.SpaceBetween) |
| 116 | - | ||
| 117 | } | 68 | } |
| 118 | } | 69 | } |
sight_harmony/features/wdComponent/src/main/ets/components/comment/model/CommentModel.ets
0 → 100644
| 1 | +import PageModel from '../../../viewmodel/PageModel' | ||
| 2 | + | ||
| 3 | + | ||
| 4 | +/// 所有用户类型定义 | ||
| 5 | +/// 1--普通账户正常;--不能直播、点播 | ||
| 6 | +/// 2--视频号,可以直播、点播;显示查看修改都是自己的信息; | ||
| 7 | +/// 3--矩阵号,是有视频号升级来的;可以登陆app,我的里面是自己的信息;发评论、发视频、直播都是自己;矩阵号下面可以挂视频号、运营子账号; | ||
| 8 | +/// 4--运营子账号,登陆使用的是自己的userId手机,密码;显示是对应视频号的信息,我的里面是视频号的信息,无法更改基本信息,自己没有头像,昵称信息;发点播、发直播、发评论,都是对应视频号的身份发送的;还是需要记录子账号的userId;(评论表 userId,userType,creatorId) | ||
| 9 | +export enum WDPublicUserType { | ||
| 10 | + /// 未知类型 | ||
| 11 | + WDPublicUserType_Unkown = 0, | ||
| 12 | + | ||
| 13 | + /// 普通用户 | ||
| 14 | + WDPublicUserType_NormalUser = 1, | ||
| 15 | + | ||
| 16 | + /// 号主 | ||
| 17 | + WDPublicUserType_AccountOwner = 2, | ||
| 18 | + | ||
| 19 | + /// 矩阵号 | ||
| 20 | + WDPublicUserType_Matrix = 3, | ||
| 21 | + | ||
| 22 | + /// 运营子账号 | ||
| 23 | + WDPublicUserType_OperatingSubAccount = 4, | ||
| 24 | + | ||
| 25 | + /// 内容源账号 | ||
| 26 | + WDPublicUserType_ContentSourceAccount = 5, | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +@Observed | ||
| 30 | +export class commentListModel extends PageModel{ | ||
| 31 | + pageNum: number = 0 | ||
| 32 | + pageSize: number = 0 | ||
| 33 | + totalCount: number = 0 | ||
| 34 | + hasNext: number = 0 | ||
| 35 | + list: commentItemModel[] = [] | ||
| 36 | + | ||
| 37 | +} | ||
| 38 | + | ||
| 39 | +@Observed | ||
| 40 | +export class commentItemModel { | ||
| 41 | + authorLike: string = '' | ||
| 42 | + avatarFrame: string = '' | ||
| 43 | + checkStatus: string = '' | ||
| 44 | + childCommentNum: string = '' | ||
| 45 | + childComments: commentItemModel[] = [] | ||
| 46 | + commentContent: string = '' | ||
| 47 | + commentContentSensitive: string = '' | ||
| 48 | + commentLevel: number = 0 | ||
| 49 | + commentPics: string = '' | ||
| 50 | + commentSensitive: string = '' | ||
| 51 | + commentType: number = 0 | ||
| 52 | + contentAuthor: number = 0 | ||
| 53 | + createTime: string = '' | ||
| 54 | + creatorFlag: string = '' | ||
| 55 | + fromCreatorId: string = '' | ||
| 56 | + fromDeviceId: string = '' | ||
| 57 | + fromUserHeader: string = '' | ||
| 58 | + fromUserId: string = '' | ||
| 59 | + fromUserName: string = '' | ||
| 60 | + fromUserType: WDPublicUserType = 0 | ||
| 61 | + id: string = '' | ||
| 62 | + likeNum: string = '' | ||
| 63 | + /*是否点赞*/ | ||
| 64 | + isLike: boolean = false | ||
| 65 | + mySelf: string = '' | ||
| 66 | + parentId: string = '' | ||
| 67 | + region: string = '' | ||
| 68 | + replyNum: string = '' | ||
| 69 | + rootCommentId: string = '' | ||
| 70 | + sensitiveExist: string = '' | ||
| 71 | + sensitiveShow: string = '' | ||
| 72 | + toUserContentAuthor: string = '' | ||
| 73 | + toUserId: string = '' | ||
| 74 | + toUserName: string = '' | ||
| 75 | + toUserType: string = '' | ||
| 76 | + topFlag: string = '' | ||
| 77 | + uuid: string = '' | ||
| 78 | + /*本地使用,收起时默认3行 -1为不限制行数*/ | ||
| 79 | + maxLine: number = 3 | ||
| 80 | + | ||
| 81 | + /*是否有展示更多*/ | ||
| 82 | + hasMore:boolean = false | ||
| 83 | + /*当有展示更多的时候,当前的状态是展开还是收起*/ | ||
| 84 | + expanded:boolean = false | ||
| 85 | + | ||
| 86 | + highQualityExpireTime:string = ''; | ||
| 87 | + highQualityTime:string = ''; | ||
| 88 | + targetTitle:string = ''; | ||
| 89 | + targetStatus:string = ''; | ||
| 90 | + targetId:string = ''; | ||
| 91 | + targetRelId:string = ''; | ||
| 92 | + targetRelObjectId:string = ''; | ||
| 93 | + targetRelType:string = ''; | ||
| 94 | + targetType:string = ''; | ||
| 95 | + visitorComment:string = ''; | ||
| 96 | + shareInfo:commentItemShareInfoModel = new commentItemShareInfoModel; | ||
| 97 | + // targetId:string = ''; | ||
| 98 | + // targetId:string = ''; | ||
| 99 | + // targetId:string = ''; | ||
| 100 | + | ||
| 101 | +} | ||
| 102 | + | ||
| 103 | +export class commentItemShareInfoModel { | ||
| 104 | + shareCoverUrl: string = '' | ||
| 105 | + shareSummary: string = '' | ||
| 106 | + shareTitle: string = '' | ||
| 107 | + shareUrl: string = '' | ||
| 108 | +} |
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/BottomCommentComponent.ets
0 → 100644
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/CommentComponent.ets
0 → 100644
| 1 | +import ArrayList from '@ohos.util.ArrayList' | ||
| 2 | +import { ViewType } from 'wdConstant/Index'; | ||
| 3 | +import { DateTimeUtils, LazyDataSource } from 'wdKit/Index'; | ||
| 4 | +import PageModel from '../../../viewmodel/PageModel'; | ||
| 5 | +import { commentItemModel, commentListModel, WDPublicUserType } from '../model/CommentModel'; | ||
| 6 | +import commentViewModel from '../viewmodel/CommentViewModel' | ||
| 7 | +import { CommentText } from './CommentText'; | ||
| 8 | +import measure from '@ohos.measure' | ||
| 9 | + | ||
| 10 | +@Entry | ||
| 11 | +@Preview | ||
| 12 | +@Component | ||
| 13 | +export struct CommentComponent { | ||
| 14 | + @State private browSingModel: commentListModel = new commentListModel() | ||
| 15 | + isloading: boolean = false | ||
| 16 | + // @State allDatas :commentItemModel[] = []; | ||
| 17 | + | ||
| 18 | + @State allDatas: LazyDataSource<commentItemModel> = new LazyDataSource(); | ||
| 19 | + | ||
| 20 | + aboutToAppear() { | ||
| 21 | + this.getData(); | ||
| 22 | + this.getData(); | ||
| 23 | + this.getData(); | ||
| 24 | + this.getData(); | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + /*标题:全部评论*/ | ||
| 28 | + @Builder | ||
| 29 | + titleHeader() { | ||
| 30 | + Row() { | ||
| 31 | + Row() { | ||
| 32 | + Image($r('app.media.redLine')) | ||
| 33 | + .height(16) | ||
| 34 | + .width(3) | ||
| 35 | + Text('全部评论') | ||
| 36 | + .fontSize(18)// .fontColor('#222222') | ||
| 37 | + .fontColor($r('app.color.color_222222')) | ||
| 38 | + .fontWeight(FontWeight.Medium) | ||
| 39 | + .margin({ left: 5 }) | ||
| 40 | + | ||
| 41 | + } | ||
| 42 | + .margin({ left: 16 }) | ||
| 43 | + | ||
| 44 | + }.height(44) | ||
| 45 | + .width('100%') | ||
| 46 | + .justifyContent(FlexAlign.SpaceBetween); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + /*1级评论作为titleHeader*/ | ||
| 50 | + @Builder | ||
| 51 | + CommentHeaderItem(item: commentItemModel) { | ||
| 52 | + Column() { | ||
| 53 | + Row() { | ||
| 54 | + //头像 | ||
| 55 | + Stack() { | ||
| 56 | + Image(item.fromUserHeader) | ||
| 57 | + .alt($r('app.media.default_head')) | ||
| 58 | + .width('32') | ||
| 59 | + .height('32') | ||
| 60 | + .objectFit(ImageFit.Cover) | ||
| 61 | + .borderRadius(16) | ||
| 62 | + Image($r('app.media.icon_border_test')) | ||
| 63 | + .width('48') | ||
| 64 | + .height('48') | ||
| 65 | + .objectFit(ImageFit.Cover) | ||
| 66 | + .borderRadius(24) | ||
| 67 | + } | ||
| 68 | + .width(48) | ||
| 69 | + .height(48) | ||
| 70 | + .margin({ left: 8 }) | ||
| 71 | + .alignContent(Alignment.Center) | ||
| 72 | + .onClick(() => { | ||
| 73 | + // TODO 跳转个人详情 | ||
| 74 | + }) | ||
| 75 | + | ||
| 76 | + //昵称 | ||
| 77 | + Text(item.fromUserName) | ||
| 78 | + .fontSize(14) | ||
| 79 | + .fontColor($r('app.color.color_222222')) | ||
| 80 | + .fontWeight(FontWeight.Medium) | ||
| 81 | + .margin({ left: 5 }) | ||
| 82 | + | ||
| 83 | + | ||
| 84 | + /// 暂时不显示 “我” 的标签了 | ||
| 85 | + /// 人民号>置顶>作者 | ||
| 86 | + | ||
| 87 | + //人民号 | ||
| 88 | + // if (item.fromUserType === WDPublicUserType.WDPublicUserType_Matrix) { | ||
| 89 | + Image($r('app.media.comment_rmh_tag')).width(20).height(20).margin({ left: 5 }); | ||
| 90 | + // } | ||
| 91 | + //置顶 | ||
| 92 | + // if (item.topFlag) { | ||
| 93 | + Image($r('app.media.comment_icon_zhiding')).width(30).height(18).margin({ left: 5 }); | ||
| 94 | + // } | ||
| 95 | + //作者 | ||
| 96 | + // if (item.contentAuthor === 1) { | ||
| 97 | + Text('作者') | ||
| 98 | + .fontSize(11) | ||
| 99 | + .fontColor('#968562') | ||
| 100 | + .backgroundColor('#F1EFEB') | ||
| 101 | + .textAlign(TextAlign.Center) | ||
| 102 | + .borderRadius(2) | ||
| 103 | + .width(30) | ||
| 104 | + .height(18) | ||
| 105 | + .margin({ left: 5 }); | ||
| 106 | + // } | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + CommentText({ | ||
| 110 | + longMessage: item.commentContent, | ||
| 111 | + maxline: 3, | ||
| 112 | + fontSize: 16, | ||
| 113 | + fontWeight: FontWeight.Regular, | ||
| 114 | + marginWidth: (59 + 16) | ||
| 115 | + }) | ||
| 116 | + .margin({ left: 59, right: 16 }) | ||
| 117 | + | ||
| 118 | + | ||
| 119 | + this.CommentFooterView(item); | ||
| 120 | + }.alignItems(HorizontalAlign.Start) | ||
| 121 | + | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + /*查看更多和收起*/ | ||
| 125 | + @Builder | ||
| 126 | + GroupFooterView(item: commentItemModel) { | ||
| 127 | + Row() { | ||
| 128 | + if (item.expanded){ | ||
| 129 | + Row() { | ||
| 130 | + Text('收起').fontColor($r('app.color.color_222222')).fontSize(14) | ||
| 131 | + Image($r('app.media.comment_pickUp')).width(12).height(12) | ||
| 132 | + }.margin({ left: 213 }) | ||
| 133 | + }else { | ||
| 134 | + Row() { | ||
| 135 | + Text().backgroundColor($r('app.color.color_EDEDED')).width(24).height(1) | ||
| 136 | + Text('查看更多回复').fontColor($r('app.color.color_222222')).fontSize(14).margin({ left: 6 }) | ||
| 137 | + Image($r('app.media.comment_unfold')).width(12).height(12) | ||
| 138 | + }.margin({ left: 53 }) | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + | ||
| 142 | + | ||
| 143 | + | ||
| 144 | + }.height(30) | ||
| 145 | + } | ||
| 146 | + | ||
| 147 | + /*评论内容下面的IP地址时间点赞*/ | ||
| 148 | + @Builder | ||
| 149 | + CommentFooterView(item: commentItemModel) { | ||
| 150 | + Row() { | ||
| 151 | + | ||
| 152 | + Row({ space: 6 }) { | ||
| 153 | + Text(item.region ? (item.region + '网友') : '人民日报客户端网友') | ||
| 154 | + .fontColor($r('app.color.color_B0B0B0')) | ||
| 155 | + .fontSize(12); | ||
| 156 | + Image($r('app.media.comment_hyphen')) | ||
| 157 | + .size({ | ||
| 158 | + width: 4, | ||
| 159 | + height: 4 | ||
| 160 | + }) | ||
| 161 | + | ||
| 162 | + //TODO: 时间格式需要本地调整 | ||
| 163 | + // / 展现专用,用于获取多久之前 | ||
| 164 | + // ///小于1分钟:刚刚 | ||
| 165 | + // ///1~60分钟:x分钟前 | ||
| 166 | + // ///1小时~1天:x小时前 | ||
| 167 | + // ///1天~2天:1天前 | ||
| 168 | + // ///2天~:日期隐藏 | ||
| 169 | + | ||
| 170 | + | ||
| 171 | + Text(DateTimeUtils.getCommentTime(Number.parseFloat(item.createTime))) | ||
| 172 | + .fontColor($r('app.color.color_B0B0B0')) | ||
| 173 | + .fontSize(12) | ||
| 174 | + | ||
| 175 | + Image($r('app.media.comment_hyphen_block')) | ||
| 176 | + .size({ | ||
| 177 | + width: 4, | ||
| 178 | + height: 4 | ||
| 179 | + }) | ||
| 180 | + | ||
| 181 | + Text('回复') | ||
| 182 | + .fontColor($r('app.color.color_222222')) | ||
| 183 | + .fontSize(12) | ||
| 184 | + .onClick(() => { | ||
| 185 | + //TODO: 回复 | ||
| 186 | + }) | ||
| 187 | + } | ||
| 188 | + | ||
| 189 | + Row({ space: 6 }) { | ||
| 190 | + Text(item.likeNum) | ||
| 191 | + .fontColor($r('app.color.color_666666')) | ||
| 192 | + .fontSize(14) | ||
| 193 | + | ||
| 194 | + Image($r('app.media.comment_like_normal')) | ||
| 195 | + .size({ | ||
| 196 | + width: 16, | ||
| 197 | + height: 16 | ||
| 198 | + }) | ||
| 199 | + .onClick(() => { | ||
| 200 | + //TODO: 点赞 | ||
| 201 | + }) | ||
| 202 | + } | ||
| 203 | + | ||
| 204 | + } | ||
| 205 | + .justifyContent(FlexAlign.SpaceBetween) | ||
| 206 | + .height(30) | ||
| 207 | + .margin({ left: 59, right: 16 }) | ||
| 208 | + } | ||
| 209 | + | ||
| 210 | + build() { | ||
| 211 | + Column() { | ||
| 212 | + | ||
| 213 | + List() { | ||
| 214 | + ListItemGroup({ header: this.titleHeader() }) | ||
| 215 | + LazyForEach(this.allDatas, (item: commentItemModel, index: number) => { | ||
| 216 | + if (item.hasMore) { | ||
| 217 | + ListItemGroup({ header: this.CommentHeaderItem(item), footer: this.GroupFooterView(item) }) { | ||
| 218 | + ForEach(item.childComments, (childItem: commentItemModel, subIndex: number) => { | ||
| 219 | + ListItem() { | ||
| 220 | + ChildCommentItem(); | ||
| 221 | + } | ||
| 222 | + }) | ||
| 223 | + } | ||
| 224 | + }else { | ||
| 225 | + ListItemGroup({ header: this.CommentHeaderItem(item)}) { | ||
| 226 | + ForEach(item.childComments, (childItem: commentItemModel, subIndex: number) => { | ||
| 227 | + ListItem() { | ||
| 228 | + ChildCommentItem(); | ||
| 229 | + } | ||
| 230 | + }) | ||
| 231 | + } | ||
| 232 | + } | ||
| 233 | + }) | ||
| 234 | + }.layoutWeight(1) | ||
| 235 | + } | ||
| 236 | + } | ||
| 237 | + | ||
| 238 | + //获取数据 | ||
| 239 | + async getData() { | ||
| 240 | + this.browSingModel.currentPage = 1 | ||
| 241 | + commentViewModel.getCommentLocal(getContext()).then(commentListModel => { | ||
| 242 | + if (commentListModel && commentListModel.list && commentListModel.list.length > 0) { | ||
| 243 | + commentListModel.hasMore = true; | ||
| 244 | + this.browSingModel.viewType = ViewType.LOADED; | ||
| 245 | + this.allDatas.push(...commentListModel.list) | ||
| 246 | + if (commentListModel.list.length === this.browSingModel.pageSize) { | ||
| 247 | + this.browSingModel.currentPage++; | ||
| 248 | + this.browSingModel.hasMore = true; | ||
| 249 | + } else { | ||
| 250 | + this.browSingModel.hasMore = false; | ||
| 251 | + } | ||
| 252 | + } else { | ||
| 253 | + this.browSingModel.viewType = ViewType.EMPTY; | ||
| 254 | + } | ||
| 255 | + | ||
| 256 | + | ||
| 257 | + | ||
| 258 | + }) | ||
| 259 | + } | ||
| 260 | + | ||
| 261 | + /*回复评论*/ | ||
| 262 | + ReplyComment() { | ||
| 263 | + | ||
| 264 | + } | ||
| 265 | +} | ||
| 266 | + | ||
| 267 | + | ||
| 268 | +@Component | ||
| 269 | +struct ChildCommentItem { | ||
| 270 | + build() { | ||
| 271 | + Text('child') | ||
| 272 | + } | ||
| 273 | +} | ||
| 274 | + |
| 1 | +import measure from '@ohos.measure' | ||
| 2 | +import curves from '@ohos.curves'; | ||
| 3 | +import { BusinessError } from '@ohos.base'; | ||
| 4 | +import display from '@ohos.display'; | ||
| 5 | + | ||
| 6 | +const collapseString = '...展开全文' | ||
| 7 | +const uncollapseString = '...收起' | ||
| 8 | + | ||
| 9 | +@Component | ||
| 10 | +@Preview | ||
| 11 | +export struct CommentText { | ||
| 12 | + // 长文本 | ||
| 13 | + @State longMessage: string = '' | ||
| 14 | + // 最大显示行数 | ||
| 15 | + @State maxLineMesssage: string = ''; | ||
| 16 | + | ||
| 17 | + @State lines: number = 3; | ||
| 18 | + @State maxline: number = 3; | ||
| 19 | + @State marginWidth:number = 0; | ||
| 20 | + // 长文本状态(展开 or 收起) | ||
| 21 | + @State collapseText: string = collapseString | ||
| 22 | + // 屏幕宽度(单位px) | ||
| 23 | + screenWidth: number = 0; | ||
| 24 | + // 是否需要显示"展开"字样(注:当文本长度较短时就不需要“展开”) | ||
| 25 | + @State isExpanded: boolean = false | ||
| 26 | + /*当前展开状态*/ | ||
| 27 | + @State expandedStates: boolean = false; | ||
| 28 | + @State fontSize: number = 18; | ||
| 29 | + @State fontWeight: FontWeight = FontWeight.Regular | ||
| 30 | + fontColor: ResourceColor = $r('app.color.color_222222') | ||
| 31 | + // 测量文本宽度(单位px) | ||
| 32 | + @State textWidth: number = 0; | ||
| 33 | + | ||
| 34 | + // constructor(longMessage?:string,) { | ||
| 35 | + // super(); | ||
| 36 | + // this.longMessage = longMessage; | ||
| 37 | + // } | ||
| 38 | + // 获取当前所有的display对象 | ||
| 39 | + promise: Promise<Array<display.Display>> = display.getAllDisplays() | ||
| 40 | + | ||
| 41 | + | ||
| 42 | + | ||
| 43 | + aboutToAppear() { | ||
| 44 | + console.log(`文本宽度为:${this.textWidth}`) | ||
| 45 | + let padding = vp2px(5 + this.marginWidth) | ||
| 46 | + | ||
| 47 | + this.textWidth = measure.measureText({ | ||
| 48 | + textContent: this.longMessage, | ||
| 49 | + fontSize: this.fontSize, | ||
| 50 | + fontWeight: this.fontWeight, | ||
| 51 | + constraintWidth:(this.screenWidth - padding) | ||
| 52 | + }) | ||
| 53 | + | ||
| 54 | + console.log(`文本宽度为:${this.textWidth}`) | ||
| 55 | + | ||
| 56 | + this.promise.then((data: Array<display.Display>) => { | ||
| 57 | + console.log(`所有的屏幕信息:${JSON.stringify(data)}`) | ||
| 58 | + //单位为像素 | ||
| 59 | + this.screenWidth = data[0]["width"] | ||
| 60 | + // 屏幕宽度 * 最大行数 * 组件宽度比例 和 文字测量宽度 | ||
| 61 | + this.isExpanded = (this.screenWidth - padding) * this.lines <= this.textWidth | ||
| 62 | + // this.expandedStates = this.isExpanded; | ||
| 63 | + | ||
| 64 | + //需要展开的话计算3行需要显示的文字 | ||
| 65 | + if (this.isExpanded) { | ||
| 66 | + | ||
| 67 | + | ||
| 68 | + let padding = vp2px(5 + this.marginWidth) | ||
| 69 | + let maxLineTextWidth = (this.screenWidth - padding) * this.maxline; | ||
| 70 | + | ||
| 71 | + for (let index = 0; index < this.longMessage.length; index++) { | ||
| 72 | + const element = this.longMessage.substring(0, index) | ||
| 73 | + const string = element + this.collapseText; //截取 | ||
| 74 | + const thisTextWidth = measure.measureText({ | ||
| 75 | + textContent: string, | ||
| 76 | + fontSize: this.fontSize, | ||
| 77 | + fontWeight: this.fontWeight, | ||
| 78 | + constraintWidth:(this.screenWidth - padding) | ||
| 79 | + }) | ||
| 80 | + | ||
| 81 | + //计算有误差20 | ||
| 82 | + | ||
| 83 | + if (thisTextWidth >= maxLineTextWidth) { | ||
| 84 | + break | ||
| 85 | + } | ||
| 86 | + this.maxLineMesssage = element; | ||
| 87 | + | ||
| 88 | + } | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + | ||
| 92 | + }).catch((err: BusinessError) => { | ||
| 93 | + console.error(`Failed to obtain all the display objects. Code: ${JSON.stringify(err)}`) | ||
| 94 | + }) | ||
| 95 | + | ||
| 96 | + | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + build() { | ||
| 100 | + Row() { | ||
| 101 | + Column() { | ||
| 102 | + if (this.isExpanded) { | ||
| 103 | + // Stack({ alignContent: Alignment.BottomEnd }) { | ||
| 104 | + Text(this.longMessage) { | ||
| 105 | + Span(this.expandedStates ? this.longMessage : this.maxLineMesssage) | ||
| 106 | + Span(this.collapseText).onClick(() => { | ||
| 107 | + if (this.collapseText == collapseString) { | ||
| 108 | + this.collapseText = uncollapseString; | ||
| 109 | + this.expandedStates = true; | ||
| 110 | + this.lines = -1; // 使得设置的最大行属性无效 | ||
| 111 | + // 展开动画 | ||
| 112 | + // animateTo({ | ||
| 113 | + // duration: 150, | ||
| 114 | + // curve: curves.springMotion(), | ||
| 115 | + // }, () => { | ||
| 116 | + // this.lines = -1; // 使得设置的最大行属性无效 | ||
| 117 | + // }) | ||
| 118 | + } else { | ||
| 119 | + this.collapseText = collapseString; | ||
| 120 | + this.expandedStates = false; | ||
| 121 | + this.lines = this.maxline; // 只显示3行 | ||
| 122 | + // 收起动画 | ||
| 123 | + // animateTo({ | ||
| 124 | + // duration: 100, | ||
| 125 | + // curve: Curve.Friction, | ||
| 126 | + // }, () => { | ||
| 127 | + // this.lines = this.maxline; // 只显示3行 | ||
| 128 | + // }) | ||
| 129 | + } | ||
| 130 | + }) | ||
| 131 | + } | ||
| 132 | + .width('100%') | ||
| 133 | + .fontSize(this.fontSize) | ||
| 134 | + .fontWeight(this.fontWeight) | ||
| 135 | + .fontColor(this.fontColor) | ||
| 136 | + .maxLines(this.lines) | ||
| 137 | + // .backgroundColor(Color.Red) | ||
| 138 | + | ||
| 139 | + // } | ||
| 140 | + } | ||
| 141 | + else { | ||
| 142 | + Text('我没有展开收起') | ||
| 143 | + .width('100%') | ||
| 144 | + .fontSize(this.fontSize) | ||
| 145 | + .fontWeight(this.fontWeight) | ||
| 146 | + .fontColor(this.fontColor) | ||
| 147 | + } | ||
| 148 | + } | ||
| 149 | + // .backgroundColor(Color.Brown) | ||
| 150 | + .width('100%') | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + // .height('100%') | ||
| 154 | + } | ||
| 155 | +} | ||
| 156 | + | ||
| 157 | + | ||
| 158 | +// Index.ets | ||
| 159 | +@Entry | ||
| 160 | +@Component | ||
| 161 | +struct Index { | ||
| 162 | + build() { | ||
| 163 | + Column() { | ||
| 164 | + CommentText() | ||
| 165 | + } | ||
| 166 | + } | ||
| 167 | +} |
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/QualityCommentsComponent.ets
0 → 100644
| 1 | +import { ViewType } from 'wdConstant/Index' | ||
| 2 | +import { DateTimeUtils, LazyDataSource, WindowModel } from 'wdKit/Index' | ||
| 3 | +import { commentItemModel, commentListModel } from '../model/CommentModel' | ||
| 4 | +import commentViewModel from '../viewmodel/CommentViewModel' | ||
| 5 | +import { window } from '@kit.ArkUI' | ||
| 6 | + | ||
| 7 | +const TAG = 'QualityCommentsComponent'; | ||
| 8 | + | ||
| 9 | +@Entry | ||
| 10 | +@Preview | ||
| 11 | +@Component | ||
| 12 | +export struct QualityCommentsComponent { | ||
| 13 | + bottomSafeHeight: string = AppStorage.get<number>('bottomSafeHeight') + 'px'; | ||
| 14 | + @State private browSingModel: commentListModel = new commentListModel() | ||
| 15 | + isloading: boolean = false | ||
| 16 | + lastWindowColor:string = '#ffffff' | ||
| 17 | + currentWindowColor:string = '#FF4202' | ||
| 18 | + @State allDatas: LazyDataSource<commentItemModel> = new LazyDataSource(); | ||
| 19 | + | ||
| 20 | + aboutToDisappear(): void { | ||
| 21 | + | ||
| 22 | + const windowStage = WindowModel.shared.getWindowStage() as window.WindowStage | ||
| 23 | + const windowClass: window.Window = windowStage.getMainWindowSync(); // 获取应用主窗口 | ||
| 24 | + windowClass.setWindowBackgroundColor(this.lastWindowColor) | ||
| 25 | + windowClass.setWindowLayoutFullScreen(false) | ||
| 26 | + // windowClass.setWindowSystemBarProperties({ statusBarColor: '#000' }) | ||
| 27 | + | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + aboutToAppear(): void { | ||
| 31 | + | ||
| 32 | + this.fullScreen(); | ||
| 33 | + | ||
| 34 | + | ||
| 35 | + commentViewModel.fetchQualityCommentListLocal(getContext()).then(commentListModel => { | ||
| 36 | + this.allDatas.push(...commentListModel.list) | ||
| 37 | + }) | ||
| 38 | + | ||
| 39 | + // commentViewModel.fetchQualityCommentList('1').then((commentListModel) => { | ||
| 40 | + // if (commentListModel && commentListModel.list && commentListModel.list.length > 0) { | ||
| 41 | + // // commentListModel.hasMore = true; | ||
| 42 | + // // this.browSingModel.viewType = ViewType.LOADED; | ||
| 43 | + // this.allDatas.push(...commentListModel.list) | ||
| 44 | + // // if (commentListModel.list.length === this.browSingModel.pageSize) { | ||
| 45 | + // // this.browSingModel.currentPage++; | ||
| 46 | + // // this.browSingModel.hasMore = true; | ||
| 47 | + // // } else { | ||
| 48 | + // // this.browSingModel.hasMore = false; | ||
| 49 | + // // } | ||
| 50 | + // } else { | ||
| 51 | + // this.browSingModel.viewType = ViewType.EMPTY; | ||
| 52 | + // } | ||
| 53 | + // }) | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + fullScreen() { | ||
| 57 | + const windowStage = WindowModel.shared.getWindowStage() as window.WindowStage | ||
| 58 | + const windowClass: window.Window = windowStage.getMainWindowSync(); // 获取应用主窗口 | ||
| 59 | + // windowClass.setWindowBackgroundColor(this.currentWindowColor) | ||
| 60 | + windowClass.setWindowLayoutFullScreen(true) | ||
| 61 | + // windowClass.setWindowSystemBarProperties({ statusBarColor: '#fff' }) | ||
| 62 | + | ||
| 63 | + // windowClass.setWindowLayoutFullScreen(true).then(() => { | ||
| 64 | + // console.log(TAG + 'setWindowLayoutFullScreen'); | ||
| 65 | + // }) | ||
| 66 | + | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + @Builder | ||
| 70 | + titleHeader() { | ||
| 71 | + Row() { | ||
| 72 | + Image($r('app.media.comment_img_banner')).width('100%').aspectRatio(375 / 283); | ||
| 73 | + } | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + build() { | ||
| 77 | + Column() { | ||
| 78 | + // this.titleHeader() | ||
| 79 | + List({ space: 28 }) { | ||
| 80 | + ListItemGroup({ header: this.titleHeader() }) | ||
| 81 | + | ||
| 82 | + LazyForEach(this.allDatas, (item: commentItemModel, index: number) => { | ||
| 83 | + ListItem() { | ||
| 84 | + QualityCommentItem({ item: item }).margin({ left: 12, right: 12 }) | ||
| 85 | + } | ||
| 86 | + // .offset({ | ||
| 87 | + // y:-87 | ||
| 88 | + // }) | ||
| 89 | + }) | ||
| 90 | + } | ||
| 91 | + // .contentStartOffset(- 87) | ||
| 92 | + .edgeEffect(EdgeEffect.Spring) | ||
| 93 | + .margin({bottom:this.bottomSafeHeight}) | ||
| 94 | + // .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM]) | ||
| 95 | + }.backgroundColor(this.currentWindowColor).height('100%').width('100%') | ||
| 96 | + } | ||
| 97 | +} | ||
| 98 | + | ||
| 99 | + | ||
| 100 | +@Component | ||
| 101 | +struct QualityCommentItem { | ||
| 102 | + @ObjectLink item: commentItemModel | ||
| 103 | + | ||
| 104 | + build() { | ||
| 105 | + Column() { | ||
| 106 | + /*头像以及昵称*/ | ||
| 107 | + RelativeContainer() { | ||
| 108 | + Image(this.item.fromUserHeader) | ||
| 109 | + .width(50) | ||
| 110 | + .height(50) | ||
| 111 | + .borderRadius(25) | ||
| 112 | + .borderWidth(2) | ||
| 113 | + .borderColor(Color.White) | ||
| 114 | + .id('image1') | ||
| 115 | + .alignRules({ | ||
| 116 | + top: { anchor: "__container__", align: VerticalAlign.Top }, | ||
| 117 | + left: { anchor: "__container__", align: HorizontalAlign.Start } | ||
| 118 | + }) | ||
| 119 | + .offset( | ||
| 120 | + { | ||
| 121 | + y: -16 | ||
| 122 | + } | ||
| 123 | + ) | ||
| 124 | + Text(this.item.fromUserName) | ||
| 125 | + .fontSize(14) | ||
| 126 | + .fontColor('#222222') | ||
| 127 | + .fontWeight(FontWeight.Medium) | ||
| 128 | + .id('text1') | ||
| 129 | + .alignRules({ | ||
| 130 | + bottom: { anchor: "image1", align: VerticalAlign.Bottom }, | ||
| 131 | + left: { anchor: "image1", align: HorizontalAlign.End } | ||
| 132 | + }) | ||
| 133 | + .offset( | ||
| 134 | + { | ||
| 135 | + x: 6, | ||
| 136 | + y: -6 - 16 | ||
| 137 | + } | ||
| 138 | + ) | ||
| 139 | + }.height(42) | ||
| 140 | + | ||
| 141 | + Column() { | ||
| 142 | + /*评论内容*/ | ||
| 143 | + Text() { | ||
| 144 | + ImageSpan($r('app.media.WDBestCommentTitleDotIcon')) | ||
| 145 | + .width(12) | ||
| 146 | + .height(12) | ||
| 147 | + .objectFit(ImageFit.Fill) | ||
| 148 | + .offset({ | ||
| 149 | + y: -6 | ||
| 150 | + }) | ||
| 151 | + Span(' ' + this.item.commentContent) | ||
| 152 | + .fontSize(16) | ||
| 153 | + .fontColor('#222222') | ||
| 154 | + .fontWeight(FontWeight.Medium) | ||
| 155 | + }.margin({ top: 10 }) | ||
| 156 | + | ||
| 157 | + /*分割线*/ | ||
| 158 | + Row() { | ||
| 159 | + | ||
| 160 | + }.width('100%').margin({ top: 10, left: 0, right: 0 }).backgroundColor('#EDEDED').height(2.5); | ||
| 161 | + | ||
| 162 | + /*文章或者评论*/ | ||
| 163 | + Row() { | ||
| 164 | + Row() { | ||
| 165 | + Image($r('app.media.comment_img_link')).width(16).height(16) | ||
| 166 | + Text(this.item.shareInfo.shareTitle) | ||
| 167 | + .fontSize(14) | ||
| 168 | + .fontColor('#666666') | ||
| 169 | + .margin({ left: 6, right: 12 }) | ||
| 170 | + .maxLines(1) | ||
| 171 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 172 | + }.height(40).layoutWeight(1) | ||
| 173 | + | ||
| 174 | + Image($r('app.media.more')).width(12).height(12) | ||
| 175 | + | ||
| 176 | + }.width('100%').height(40).justifyContent(FlexAlign.SpaceBetween) | ||
| 177 | + | ||
| 178 | + } | ||
| 179 | + .backgroundColor('#F9F9F9') | ||
| 180 | + .width('100%') | ||
| 181 | + .alignItems(HorizontalAlign.Start) | ||
| 182 | + .borderRadius(4) | ||
| 183 | + .padding({ left: 12, right: 12 }) | ||
| 184 | + | ||
| 185 | + /*时间 点赞评论*/ | ||
| 186 | + Row() { | ||
| 187 | + | ||
| 188 | + Text(DateTimeUtils.getCommentTime(DateTimeUtils.getDateTimestamp(this.item.createTime))).fontSize(14).fontColor('#999999') | ||
| 189 | + | ||
| 190 | + Row({space:16}){ | ||
| 191 | + Row(){ | ||
| 192 | + Image($r('app.media.comment_icon_pinglun')).width(16).height(16) | ||
| 193 | + } | ||
| 194 | + | ||
| 195 | + Row(){ | ||
| 196 | + //comment_like_select | ||
| 197 | + Image($r(this.item.likeNum?'app.media.comment_like_select':'app.media.comment_like_normal')).width(16).height(16) | ||
| 198 | + if (this.item.likeNum){Text(this.item.likeNum).fontColor(this.item.isLike?'#ED2800':'#999999').fontSize(14).margin({left:3})} | ||
| 199 | + } | ||
| 200 | + } | ||
| 201 | + }.height(38).width('100%').justifyContent(FlexAlign.SpaceBetween) | ||
| 202 | + | ||
| 203 | + }.backgroundColor('#FFFFFF').padding({ top: 0, left: 16, right: 16 }).borderRadius(4) | ||
| 204 | + | ||
| 205 | + } | ||
| 206 | +} |
sight_harmony/features/wdComponent/src/main/ets/components/comment/viewmodel/CommentViewModel.ets
0 → 100644
| 1 | +import { Logger, ResourcesUtils } from 'wdKit/Index'; | ||
| 2 | +import { HttpUrlUtils, ResponseDTO } from 'wdNetwork/Index'; | ||
| 3 | +import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest'; | ||
| 4 | +import { commentItemModel, commentListModel } from '../model/CommentModel'; | ||
| 5 | +import HashMap from '@ohos.util.HashMap'; | ||
| 6 | + | ||
| 7 | +const TAG = "CommentViewModel" | ||
| 8 | + | ||
| 9 | +class CommentViewModel { | ||
| 10 | + private static instance: CommentViewModel | ||
| 11 | + /** | ||
| 12 | + * 单例模式 | ||
| 13 | + * @returns | ||
| 14 | + */ | ||
| 15 | + public static getInstance(): CommentViewModel { | ||
| 16 | + if (!CommentViewModel.instance) { | ||
| 17 | + CommentViewModel.instance = new CommentViewModel(); | ||
| 18 | + } | ||
| 19 | + return CommentViewModel.instance; | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + /*获取本地mock数据*/ | ||
| 24 | + async getCommentLocal(context: Context): Promise<commentListModel> { | ||
| 25 | + Logger.info(TAG, `getBottomNavDataMock start`); | ||
| 26 | + let compRes: ResponseDTO<commentListModel> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<commentListModel>>(context,'comment_local.json' ); | ||
| 27 | + if (!compRes || !compRes.data) { | ||
| 28 | + Logger.info(TAG, `getAppointmentListDataLocal compRes is empty`); | ||
| 29 | + return new commentListModel() | ||
| 30 | + } | ||
| 31 | + Logger.info(TAG, `getAppointmentListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`); | ||
| 32 | + return compRes.data | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + /*获取本地mock数据*/ | ||
| 36 | + async fetchQualityCommentListLocal(context: Context): Promise<commentListModel> { | ||
| 37 | + Logger.info(TAG, `getBottomNavDataMock start`); | ||
| 38 | + let compRes: ResponseDTO<commentListModel> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<commentListModel>>(context,'qualityComment_local.json' ); | ||
| 39 | + if (!compRes || !compRes.data) { | ||
| 40 | + Logger.info(TAG, `getAppointmentListDataLocal compRes is empty`); | ||
| 41 | + return new commentListModel() | ||
| 42 | + } | ||
| 43 | + Logger.info(TAG, `getAppointmentListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`); | ||
| 44 | + return compRes.data | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + | ||
| 48 | + | ||
| 49 | + //qualityComment_local.json | ||
| 50 | + fetchQualityCommentList(pageNum: string) { | ||
| 51 | + let url = HttpUrlUtils.getQualityCommentUrl() + `?&pageSize=${10}&pageNum=${pageNum}` | ||
| 52 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 53 | + return new Promise<commentListModel>((success, fail) => { | ||
| 54 | + HttpRequest.get<ResponseDTO<commentListModel>>(url, headers).then((data: ResponseDTO<commentListModel>) => { | ||
| 55 | + if (!data || !data.data) { | ||
| 56 | + fail("数据为空") | ||
| 57 | + return | ||
| 58 | + } | ||
| 59 | + if (data.code != 0) { | ||
| 60 | + fail(data.message) | ||
| 61 | + return | ||
| 62 | + } | ||
| 63 | + let listData = data.data as commentListModel | ||
| 64 | + | ||
| 65 | + success(listData) | ||
| 66 | + }, (error: Error) => { | ||
| 67 | + fail(error.message) | ||
| 68 | + Logger.debug(TAG, error.toString()) | ||
| 69 | + }) | ||
| 70 | + }) | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + | ||
| 74 | + // BaseGetRequest(contentID:number,contentType:string,pageNum:string){ | ||
| 75 | + // let url = HttpUrlUtils.getMyCollectionListDataUrl()+ `?type=${type}&operateTag=${1}&pageSize=${10}&pageNum=${pageNum}` | ||
| 76 | + // if (tagId.length > 0) { | ||
| 77 | + // url = url + `&tagId=${tagId}` | ||
| 78 | + // } | ||
| 79 | + // let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders() | ||
| 80 | + // return WDHttp.get<ResponseDTO<commentListModel>>(url, headers) | ||
| 81 | + // } | ||
| 82 | + // | ||
| 83 | + // | ||
| 84 | + // fetchCommentList(contentID:number,contentType:string,pageNum:string):Promise<commentListModel>{ | ||
| 85 | + // return new Promise<commentListModel>((success,error) => { | ||
| 86 | + // this.BaseGetRequest(contentID,contentType,pageNum).then((navResDTO: ResponseDTO<commentListModel>) => { | ||
| 87 | + // if (!navResDTO || navResDTO.code != 0) { | ||
| 88 | + // // success(this.getAppointmentListDataLocal(context)) | ||
| 89 | + // return | ||
| 90 | + // } | ||
| 91 | + // Logger.info(TAG, "getAppointmentList then,AppointmentResDTO.timeStamp:" + navResDTO.timestamp); | ||
| 92 | + // let listData = navResDTO.data as commentListModel | ||
| 93 | + // success(listData) | ||
| 94 | + // }).catch((err: Error) => { | ||
| 95 | + // Logger.error(TAG, `fetchAppointmentListDataApi catch, error.name : ${err.name}, error.message:${err.message}`); | ||
| 96 | + // error("page data invalid"); | ||
| 97 | + // }) | ||
| 98 | + // }) | ||
| 99 | + // } | ||
| 100 | + | ||
| 101 | + | ||
| 102 | +} | ||
| 103 | + | ||
| 104 | + | ||
| 105 | +const commentViewModel = CommentViewModel.getInstance(); | ||
| 106 | + | ||
| 107 | +export default commentViewModel as CommentViewModel |
| @@ -33,8 +33,8 @@ export default struct MinePageUserSimpleInfoUI { | @@ -33,8 +33,8 @@ export default struct MinePageUserSimpleInfoUI { | ||
| 33 | Stack(){ | 33 | Stack(){ |
| 34 | Image(this.headPhotoUrl) | 34 | Image(this.headPhotoUrl) |
| 35 | .alt($r('app.media.default_head')) | 35 | .alt($r('app.media.default_head')) |
| 36 | - .width('108lpx') | ||
| 37 | - .height('108lpx') | 36 | + .width('100lpx') |
| 37 | + .height('100lpx') | ||
| 38 | .objectFit(ImageFit.Cover) | 38 | .objectFit(ImageFit.Cover) |
| 39 | .borderRadius(50) | 39 | .borderRadius(50) |
| 40 | Image(this.levelHead) | 40 | Image(this.levelHead) |
| @@ -18,7 +18,7 @@ export struct FollowFirstTabsComponent{ | @@ -18,7 +18,7 @@ export struct FollowFirstTabsComponent{ | ||
| 18 | value.forEach((element)=>{ | 18 | value.forEach((element)=>{ |
| 19 | this.data.push(element) | 19 | this.data.push(element) |
| 20 | }) | 20 | }) |
| 21 | - console.log("ycg",this.data.length.toString()); | 21 | + |
| 22 | if(this.controller != null && this.data.length>1 && this.changeIndex === 1){ | 22 | if(this.controller != null && this.data.length>1 && this.changeIndex === 1){ |
| 23 | //个人主页 跳转 关注页 tab 2 | 23 | //个人主页 跳转 关注页 tab 2 |
| 24 | let intervalID = setInterval(() => { | 24 | let intervalID = setInterval(() => { |
| @@ -171,6 +171,7 @@ struct ChildComponent { | @@ -171,6 +171,7 @@ struct ChildComponent { | ||
| 171 | .fontSize('31lpx') | 171 | .fontSize('31lpx') |
| 172 | .lineHeight('38lpx') | 172 | .lineHeight('38lpx') |
| 173 | .fontColor($r('app.color.color_222222')) | 173 | .fontColor($r('app.color.color_222222')) |
| 174 | + .maxLines(1) | ||
| 174 | Text(`粉丝${this.data.cnFansNum}`) | 175 | Text(`粉丝${this.data.cnFansNum}`) |
| 175 | .fontColor($r('app.color.color_B0B0B0')) | 176 | .fontColor($r('app.color.color_B0B0B0')) |
| 176 | .fontSize('23lpx') | 177 | .fontSize('23lpx') |
sight_harmony/features/wdComponent/src/main/ets/components/mine/follow/FollowSecondTabsComponent.ets
| @@ -35,25 +35,45 @@ export struct FollowSecondTabsComponent{ | @@ -35,25 +35,45 @@ export struct FollowSecondTabsComponent{ | ||
| 35 | 35 | ||
| 36 | @Builder FollowSecondUI(){ | 36 | @Builder FollowSecondUI(){ |
| 37 | Row() { | 37 | Row() { |
| 38 | + Row(){ | ||
| 39 | + // 页签 | ||
| 40 | + Column({ space: 7 }) { | ||
| 41 | + Scroll() { | ||
| 42 | + Column() { | ||
| 43 | + ForEach(this.data[this.firstIndex].children, (item: FollowSecondListItem, index: number ) => { | ||
| 44 | + this.TabBuilder(index,item) | ||
| 45 | + }) | ||
| 46 | + } | ||
| 47 | + .justifyContent(FlexAlign.Start) | ||
| 48 | + } | ||
| 49 | + .align(Alignment.Top) | ||
| 50 | + .scrollable(ScrollDirection.Vertical) | ||
| 51 | + .scrollBar(BarState.Off) | ||
| 52 | + .height('100%') | ||
| 53 | + }.height('100%') | ||
| 54 | + .alignItems(HorizontalAlign.Center) | ||
| 55 | + } | ||
| 56 | + .alignItems(VerticalAlign.Top) | ||
| 57 | + .height('100%') | ||
| 58 | + | ||
| 38 | Tabs({ barPosition: BarPosition.Start, controller: this.controller }) { | 59 | Tabs({ barPosition: BarPosition.Start, controller: this.controller }) { |
| 39 | ForEach(this.data[this.firstIndex].children, (item: FollowSecondListItem, index: number ) => { | 60 | ForEach(this.data[this.firstIndex].children, (item: FollowSecondListItem, index: number ) => { |
| 40 | TabContent(){ | 61 | TabContent(){ |
| 41 | FollowThirdTabsComponent({data:$data,firstIndex:$firstIndex,secondIndex:index}) | 62 | FollowThirdTabsComponent({data:$data,firstIndex:$firstIndex,secondIndex:index}) |
| 42 | - }.tabBar(this.TabBuilder(index,item)) | 63 | + } |
| 43 | .backgroundColor($r('app.color.white')) | 64 | .backgroundColor($r('app.color.white')) |
| 44 | }, (item: FollowListItem, index: number) => index.toString()) | 65 | }, (item: FollowListItem, index: number) => index.toString()) |
| 45 | } | 66 | } |
| 46 | .vertical(true) | 67 | .vertical(true) |
| 47 | .barMode(BarMode.Scrollable) | 68 | .barMode(BarMode.Scrollable) |
| 48 | - .barWidth('140lpx') | ||
| 49 | .animationDuration(0) | 69 | .animationDuration(0) |
| 50 | .onChange((index: number) => { | 70 | .onChange((index: number) => { |
| 51 | this.currentIndex = index | 71 | this.currentIndex = index |
| 52 | }) | 72 | }) |
| 53 | - .width('100%') | 73 | + .barWidth(0) |
| 74 | + .height('100%') | ||
| 75 | + .layoutWeight(1) | ||
| 54 | }.width('100%') | 76 | }.width('100%') |
| 55 | - .alignItems(VerticalAlign.Top) | ||
| 56 | - .backgroundColor('#0FF') | ||
| 57 | } | 77 | } |
| 58 | 78 | ||
| 59 | @Builder TabBuilder(index: number, item: FollowSecondListItem) { | 79 | @Builder TabBuilder(index: number, item: FollowSecondListItem) { |
| @@ -73,6 +93,7 @@ export struct FollowSecondTabsComponent{ | @@ -73,6 +93,7 @@ export struct FollowSecondTabsComponent{ | ||
| 73 | }) | 93 | }) |
| 74 | .justifyContent(FlexAlign.Center) | 94 | .justifyContent(FlexAlign.Center) |
| 75 | .height('84lpx') | 95 | .height('84lpx') |
| 96 | + .width('140lpx') | ||
| 76 | .backgroundColor(this.currentIndex === index?$r('app.color.white'):$r('app.color.color_F9F9F9')) | 97 | .backgroundColor(this.currentIndex === index?$r('app.color.white'):$r('app.color.color_F9F9F9')) |
| 77 | } | 98 | } |
| 78 | 99 |
| @@ -34,19 +34,45 @@ export struct FollowThirdTabsComponent{ | @@ -34,19 +34,45 @@ export struct FollowThirdTabsComponent{ | ||
| 34 | .lineHeight('38lpx') | 34 | .lineHeight('38lpx') |
| 35 | .backgroundColor($r('app.color.color_F9F9F9')) | 35 | .backgroundColor($r('app.color.color_F9F9F9')) |
| 36 | .padding('13lpx') | 36 | .padding('13lpx') |
| 37 | + .maxLines(1) | ||
| 37 | } | 38 | } |
| 38 | .onClick(()=>{ | 39 | .onClick(()=>{ |
| 39 | this.currentIndex = index | 40 | this.currentIndex = index |
| 40 | this.controller.changeIndex(this.currentIndex) | 41 | this.controller.changeIndex(this.currentIndex) |
| 41 | }) | 42 | }) |
| 42 | - .height('100%') | 43 | + .height('84lpx') |
| 43 | .margin({right:'9lpx'}) | 44 | .margin({right:'9lpx'}) |
| 44 | .padding({left:'20lpx',right:index === this.data[this.firstIndex].children[this.secondIndex].children.length-1?"20lpx":"0lpx"}) | 45 | .padding({left:'20lpx',right:index === this.data[this.firstIndex].children[this.secondIndex].children.length-1?"20lpx":"0lpx"}) |
| 45 | .justifyContent(FlexAlign.Center) | 46 | .justifyContent(FlexAlign.Center) |
| 46 | } | 47 | } |
| 47 | 48 | ||
| 48 | @Builder FollowThirdUI(){ | 49 | @Builder FollowThirdUI(){ |
| 49 | - Row() { | 50 | + |
| 51 | + Column(){ | ||
| 52 | + Column() { | ||
| 53 | + // 页签 | ||
| 54 | + Row({ space: 7 }) { | ||
| 55 | + Scroll() { | ||
| 56 | + Row() { | ||
| 57 | + ForEach(this.data[this.firstIndex].children[this.secondIndex].children, (item: FollowThirdListItem, index: number ) => { | ||
| 58 | + this.TabBuilder(index,item) | ||
| 59 | + }) | ||
| 60 | + } | ||
| 61 | + .justifyContent(FlexAlign.Start) | ||
| 62 | + } | ||
| 63 | + .align(Alignment.Start) | ||
| 64 | + .scrollable(ScrollDirection.Horizontal) | ||
| 65 | + .scrollBar(BarState.Off) | ||
| 66 | + .width('90%') | ||
| 67 | + .padding({left:'11lpx'}) | ||
| 68 | + } | ||
| 69 | + .alignItems(VerticalAlign.Bottom) | ||
| 70 | + .width('100%') | ||
| 71 | + } | ||
| 72 | + .backgroundColor($r('app.color.white')) | ||
| 73 | + .alignItems(HorizontalAlign.Start) | ||
| 74 | + .width('100%') | ||
| 75 | + | ||
| 50 | Tabs({ barPosition: BarPosition.Start, controller: this.controller }) { | 76 | Tabs({ barPosition: BarPosition.Start, controller: this.controller }) { |
| 51 | ForEach(this.data[this.firstIndex].children[this.secondIndex].children, (item: FollowThirdListItem, index: number ) => { | 77 | ForEach(this.data[this.firstIndex].children[this.secondIndex].children, (item: FollowThirdListItem, index: number ) => { |
| 52 | TabContent(){ | 78 | TabContent(){ |
| @@ -58,20 +84,19 @@ export struct FollowThirdTabsComponent{ | @@ -58,20 +84,19 @@ export struct FollowThirdTabsComponent{ | ||
| 58 | .margin({left:'20lpx'}) | 84 | .margin({left:'20lpx'}) |
| 59 | FollowListDetailUI({creatorDirectoryId:this.data[this.firstIndex].children[this.secondIndex].children[index].id}) | 85 | FollowListDetailUI({creatorDirectoryId:this.data[this.firstIndex].children[this.secondIndex].children[index].id}) |
| 60 | } | 86 | } |
| 61 | - }.tabBar(this.TabBuilder(index,item)) | 87 | + } |
| 62 | .backgroundColor($r('app.color.white')) | 88 | .backgroundColor($r('app.color.white')) |
| 63 | }, (item: FollowListItem, index: number) => index.toString()) | 89 | }, (item: FollowListItem, index: number) => index.toString()) |
| 64 | } | 90 | } |
| 91 | + .barHeight(0) | ||
| 65 | .vertical(false) | 92 | .vertical(false) |
| 66 | .barMode(BarMode.Scrollable) | 93 | .barMode(BarMode.Scrollable) |
| 67 | - .barWidth('100%') | ||
| 68 | - .barHeight('84lpx') | ||
| 69 | .animationDuration(0) | 94 | .animationDuration(0) |
| 70 | .onChange((index: number) => { | 95 | .onChange((index: number) => { |
| 71 | this.currentIndex = index | 96 | this.currentIndex = index |
| 72 | }) | 97 | }) |
| 73 | .width('100%') | 98 | .width('100%') |
| 74 | - }.width('100%') | 99 | + } |
| 75 | } | 100 | } |
| 76 | 101 | ||
| 77 | } | 102 | } |
| @@ -288,7 +288,6 @@ struct ChannelDialog { | @@ -288,7 +288,6 @@ struct ChannelDialog { | ||
| 288 | .justifyContent(FlexAlign.Center) | 288 | .justifyContent(FlexAlign.Center) |
| 289 | .backgroundColor(item.homeChannel === '1' || item.movePermitted === 0 ? '#F5F5F5' : '#ffffff') | 289 | .backgroundColor(item.homeChannel === '1' || item.movePermitted === 0 ? '#F5F5F5' : '#ffffff') |
| 290 | .onClick(() => { | 290 | .onClick(() => { |
| 291 | - console.log('onTouch') | ||
| 292 | if (this.isEditIng) { | 291 | if (this.isEditIng) { |
| 293 | if (item.delPermitted === 1) { | 292 | if (item.delPermitted === 1) { |
| 294 | this.delChannelItem(index) | 293 | this.delChannelItem(index) |
| 1 | - | ||
| 2 | -import { Logger, DateTimeUtils, CollectionUtils } from 'wdKit'; | 1 | +import { CollectionUtils, DateTimeUtils, Logger } from 'wdKit'; |
| 3 | import { CommonConstants, CompStyle, ViewType } from 'wdConstant'; | 2 | import { CommonConstants, CompStyle, ViewType } from 'wdConstant'; |
| 4 | import PageViewModel from '../../viewmodel/PageViewModel'; | 3 | import PageViewModel from '../../viewmodel/PageViewModel'; |
| 5 | import { EmptyComponent } from '../view/EmptyComponent'; | 4 | import { EmptyComponent } from '../view/EmptyComponent'; |
| @@ -14,7 +13,7 @@ import CustomRefreshLoadLayout from './CustomRefreshLoadLayout'; | @@ -14,7 +13,7 @@ import CustomRefreshLoadLayout from './CustomRefreshLoadLayout'; | ||
| 14 | import { CompParser } from '../CompParser'; | 13 | import { CompParser } from '../CompParser'; |
| 15 | import { GroupInfoDTO } from 'wdBean/src/main/ets/bean/navigation/PageInfoDTO'; | 14 | import { GroupInfoDTO } from 'wdBean/src/main/ets/bean/navigation/PageInfoDTO'; |
| 16 | import { VideoChannelDetail } from 'wdDetailPlayShortVideo/Index'; | 15 | import { VideoChannelDetail } from 'wdDetailPlayShortVideo/Index'; |
| 17 | -import { CompDTO, LiveReviewDTO, PageDTO ,PageInfoDTO} from 'wdBean'; | 16 | +import { CompDTO, LiveReviewDTO, PageDTO, PageInfoBean } from 'wdBean'; |
| 18 | 17 | ||
| 19 | 18 | ||
| 20 | const TAG = 'PageComponent'; | 19 | const TAG = 'PageComponent'; |
| @@ -72,40 +71,44 @@ export struct PageComponent { | @@ -72,40 +71,44 @@ export struct PageComponent { | ||
| 72 | @Builder | 71 | @Builder |
| 73 | ListLayout() { | 72 | ListLayout() { |
| 74 | List() { | 73 | List() { |
| 75 | - // 下拉刷新 | ||
| 76 | - ListItem() { | ||
| 77 | - RefreshLayout({ | ||
| 78 | - refreshBean: new RefreshLayoutBean(this.pageModel.isVisiblePullDown, this.pageModel.pullDownRefreshImage, | ||
| 79 | - this.pageModel.pullDownRefreshText, this.pageModel.pullDownRefreshHeight) | ||
| 80 | - }) | 74 | + if (this.name !== '视频') { |
| 75 | + // 下拉刷新 | ||
| 76 | + ListItem() { | ||
| 77 | + RefreshLayout({ | ||
| 78 | + refreshBean: new RefreshLayoutBean(this.pageModel.isVisiblePullDown, this.pageModel.pullDownRefreshImage, | ||
| 79 | + this.pageModel.pullDownRefreshText, this.pageModel.pullDownRefreshHeight) | ||
| 80 | + }) | ||
| 81 | + } | ||
| 81 | } | 82 | } |
| 82 | 83 | ||
| 83 | - LazyForEach(this.pageModel.compList, (compDTO: CompDTO, compIndex: number) => { | ||
| 84 | - ListItem() { | ||
| 85 | - Column() { | ||
| 86 | - if (this.name == '视频') { | ||
| 87 | - VideoChannelDetail() | ||
| 88 | - } else { | 84 | + if (this.name === '视频') { |
| 85 | + VideoChannelDetail() | ||
| 86 | + } else { | ||
| 87 | + LazyForEach(this.pageModel.compList, (compDTO: CompDTO, compIndex: number) => { | ||
| 88 | + ListItem() { | ||
| 89 | + Column() { | ||
| 89 | CompParser({ compDTO: compDTO, compIndex: compIndex }); | 90 | CompParser({ compDTO: compDTO, compIndex: compIndex }); |
| 90 | } | 91 | } |
| 92 | + } | ||
| 93 | + }, | ||
| 94 | + (compDTO: CompDTO, compIndex: number) => compDTO.id + compIndex.toString() + this.pageModel.timestamp | ||
| 95 | + ) | ||
| 96 | + } | ||
| 91 | 97 | ||
| 98 | + if (this.name !== '视频') { | ||
| 99 | + // 加载更多 | ||
| 100 | + ListItem() { | ||
| 101 | + if (this.pageModel.hasMore) { | ||
| 102 | + LoadMoreLayout({ | ||
| 103 | + refreshBean: new RefreshLayoutBean(this.pageModel.isVisiblePullUpLoad, this.pageModel.pullUpLoadImage, | ||
| 104 | + this.pageModel.pullUpLoadText, this.pageModel.pullUpLoadHeight) | ||
| 105 | + }) | ||
| 106 | + } else { | ||
| 107 | + NoMoreLayout() | ||
| 92 | } | 108 | } |
| 93 | } | 109 | } |
| 94 | - }, | ||
| 95 | - (compDTO: CompDTO, compIndex: number) => compDTO.id + compIndex.toString() + this.pageModel.timestamp | ||
| 96 | - ) | ||
| 97 | - | ||
| 98 | - // 加载更多 | ||
| 99 | - ListItem() { | ||
| 100 | - if (this.pageModel.hasMore) { | ||
| 101 | - LoadMoreLayout({ | ||
| 102 | - refreshBean: new RefreshLayoutBean(this.pageModel.isVisiblePullUpLoad, this.pageModel.pullUpLoadImage, | ||
| 103 | - this.pageModel.pullUpLoadText, this.pageModel.pullUpLoadHeight) | ||
| 104 | - }) | ||
| 105 | - } else { | ||
| 106 | - NoMoreLayout() | ||
| 107 | - } | ||
| 108 | } | 110 | } |
| 111 | + | ||
| 109 | } | 112 | } |
| 110 | .scrollBar(BarState.Off) | 113 | .scrollBar(BarState.Off) |
| 111 | .cachedCount(8) | 114 | .cachedCount(8) |
| @@ -138,7 +141,8 @@ export struct PageComponent { | @@ -138,7 +141,8 @@ export struct PageComponent { | ||
| 138 | 141 | ||
| 139 | onChange() { | 142 | onChange() { |
| 140 | Logger.info(TAG, `onChangezz id: ${this.pageId} , ${this.channelId} , ${this.navIndex} , ${this.isFirstIn} , navIndex: ${this.currentTopNavSelectedIndex}`); | 143 | Logger.info(TAG, `onChangezz id: ${this.pageId} , ${this.channelId} , ${this.navIndex} , ${this.isFirstIn} , navIndex: ${this.currentTopNavSelectedIndex}`); |
| 141 | - if (this.navIndex === this.currentTopNavSelectedIndex && !this.isFirstIn) { | 144 | + // if (this.navIndex === this.currentTopNavSelectedIndex && !this.isFirstIn) { |
| 145 | + if (this.navIndex === this.currentTopNavSelectedIndex) { | ||
| 142 | this.getData(); | 146 | this.getData(); |
| 143 | } | 147 | } |
| 144 | } | 148 | } |
| @@ -158,6 +162,16 @@ export struct PageComponent { | @@ -158,6 +162,16 @@ export struct PageComponent { | ||
| 158 | this.pageModel.viewType = ViewType.EMPTY; | 162 | this.pageModel.viewType = ViewType.EMPTY; |
| 159 | return; | 163 | return; |
| 160 | } | 164 | } |
| 165 | + if (this.navIndex === 0) { | ||
| 166 | + await this.getVideoListData(pageInfo); | ||
| 167 | + } else { | ||
| 168 | + await this.getLiveListData(pageInfo); | ||
| 169 | + } | ||
| 170 | + | ||
| 171 | + | ||
| 172 | + } | ||
| 173 | + | ||
| 174 | + private async getVideoListData(pageInfo: PageInfoBean) { | ||
| 161 | let groupInfo: GroupInfoDTO = CollectionUtils.getElement(pageInfo.groups, 0); | 175 | let groupInfo: GroupInfoDTO = CollectionUtils.getElement(pageInfo.groups, 0); |
| 162 | if (groupInfo != null) { | 176 | if (groupInfo != null) { |
| 163 | this.pageModel.isRecGroup = groupInfo.groupStrategy === 1; | 177 | this.pageModel.isRecGroup = groupInfo.groupStrategy === 1; |
| @@ -165,7 +179,89 @@ export struct PageComponent { | @@ -165,7 +179,89 @@ export struct PageComponent { | ||
| 165 | } | 179 | } |
| 166 | // pageInfo.groups.forEach(async (group) => { 不能按顺序加载用for...of替代 | 180 | // pageInfo.groups.forEach(async (group) => { 不能按顺序加载用for...of替代 |
| 167 | // for (const group of pageInfo.groups) { | 181 | // for (const group of pageInfo.groups) { |
| 168 | - this.pageDto = await PageViewModel.getPageData(this.pageModel, getContext(this)) | 182 | + this.pageDto = await PageViewModel.getPageData(this.pageModel, getContext(this)); |
| 183 | + this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString(); | ||
| 184 | + if (this.pageDto && this.pageDto.compList && this.pageDto.compList.length > 0) { | ||
| 185 | + this.pageDto.compList.forEach((comp) => { | ||
| 186 | + if (comp.compStyle === CompStyle.Zh_Grid_Layout_02 && this.liveReviewDTO && this.liveReviewDTO.list && this.liveReviewDTO.list.length > 0) { | ||
| 187 | + comp.operDataList.push(...this.liveReviewDTO.list); | ||
| 188 | + } | ||
| 189 | + }); | ||
| 190 | + | ||
| 191 | + this.pageModel.viewType = ViewType.LOADED; | ||
| 192 | + this.pageModel.compList.push(...this.pageDto.compList); | ||
| 193 | + if (this.pageDto.compList.length === this.pageModel.pageSize) { | ||
| 194 | + this.pageModel.currentPage++; | ||
| 195 | + this.pageModel.hasMore = true; | ||
| 196 | + } else { | ||
| 197 | + this.pageModel.hasMore = false; | ||
| 198 | + } | ||
| 199 | + // // 二次请求,批查互动数据 | ||
| 200 | + // PageViewModel.getInteractData(pageDto.compList).then((data: CompDTO[]) => { | ||
| 201 | + // // 刷新,替换所有数据 | ||
| 202 | + // this.pageModel.compList.replaceAll(...data) | ||
| 203 | + // this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 204 | + // }) | ||
| 205 | + this.isFirstIn = false; | ||
| 206 | + Logger.debug(TAG, 'cj111'); | ||
| 207 | + // } else { | ||
| 208 | + // Logger.debug(TAG, 'aboutToAppear, data response page ' + this.pageId + ', comp list is empty.'); | ||
| 209 | + // this.pageModel.viewType = ViewType.EMPTY; | ||
| 210 | + // } | ||
| 211 | + } | ||
| 212 | + } | ||
| 213 | + | ||
| 214 | + // private async getLiveListData(pageInfo: PageInfoBean) { | ||
| 215 | + // // pageInfo.groups.forEach(async (group) => { 不能按顺序加载用for...of替代 | ||
| 216 | + // for (const group of pageInfo.groups) { | ||
| 217 | + // this.pageDto = await PageViewModel.getPageData(this.pageModel, getContext(this)); | ||
| 218 | + // this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString(); | ||
| 219 | + // if (this.pageDto && this.pageDto.compList && this.pageDto.compList.length > 0) { | ||
| 220 | + // this.pageDto.compList.forEach((comp) => { | ||
| 221 | + // if (comp.compStyle === CompStyle.Zh_Grid_Layout_02 && this.liveReviewDTO && this.liveReviewDTO.list && this.liveReviewDTO.list.length > 0) { | ||
| 222 | + // comp.operDataList.push(...this.liveReviewDTO.list); | ||
| 223 | + // } | ||
| 224 | + // }); | ||
| 225 | + // | ||
| 226 | + // this.pageModel.viewType = ViewType.LOADED; | ||
| 227 | + // this.pageModel.compList.push(...this.pageDto.compList); | ||
| 228 | + // if (this.pageDto.compList.length === this.pageModel.pageSize) { | ||
| 229 | + // this.pageModel.currentPage++; | ||
| 230 | + // this.pageModel.hasMore = true; | ||
| 231 | + // } else { | ||
| 232 | + // this.pageModel.hasMore = false; | ||
| 233 | + // } | ||
| 234 | + // // // 二次请求,批查互动数据 | ||
| 235 | + // // PageViewModel.getInteractData(pageDto.compList).then((data: CompDTO[]) => { | ||
| 236 | + // // // 刷新,替换所有数据 | ||
| 237 | + // // this.pageModel.compList.replaceAll(...data) | ||
| 238 | + // // this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 239 | + // // }) | ||
| 240 | + // this.isFirstIn = false; | ||
| 241 | + // Logger.debug(TAG, 'cj111'); | ||
| 242 | + // // } else { | ||
| 243 | + // // Logger.debug(TAG, 'aboutToAppear, data response page ' + this.pageId + ', comp list is empty.'); | ||
| 244 | + // // this.pageModel.viewType = ViewType.EMPTY; | ||
| 245 | + // } | ||
| 246 | + // } | ||
| 247 | + // } | ||
| 248 | + | ||
| 249 | + async getLiveListData(pageInfo: PageInfoBean) { | ||
| 250 | + // Logger.info(TAG, `getData id: ${this.pageId} , ${this.channelId} , navIndex: ${this.currentTopNavSelectedIndex}`); | ||
| 251 | + // this.pageModel.pageId = this.pageId; | ||
| 252 | + // this.pageModel.groupId = this.pageId; | ||
| 253 | + // this.pageModel.channelId = this.channelId; | ||
| 254 | + // this.pageModel.currentPage = 1; | ||
| 255 | + // let pageInfo = await PageViewModel.getPageUrlData(this.pageModel.pageId); | ||
| 256 | + // if (pageInfo == null) { | ||
| 257 | + // this.pageModel.viewType = ViewType.EMPTY; | ||
| 258 | + // return; | ||
| 259 | + // } | ||
| 260 | + Logger.debug(TAG, 'getPageUrlData ' + pageInfo.id); | ||
| 261 | + // pageInfo.groups.forEach(async (group) => { 不能按顺序加载用for...of替代 | ||
| 262 | + for (const group of pageInfo.groups) { | ||
| 263 | + this.pageDto = await PageViewModel.getLivePageData(this.pageModel.pageId, `${group.id}`, this.pageModel.channelId, group.groupStrategy | ||
| 264 | + , this.pageModel.currentPage, this.pageModel.pageSize, getContext(this)) | ||
| 169 | this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | 265 | this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() |
| 170 | if (this.pageDto && this.pageDto.compList && this.pageDto.compList.length > 0) { | 266 | if (this.pageDto && this.pageDto.compList && this.pageDto.compList.length > 0) { |
| 171 | this.pageDto.compList.forEach((comp) => { | 267 | this.pageDto.compList.forEach((comp) => { |
| @@ -182,20 +278,18 @@ export struct PageComponent { | @@ -182,20 +278,18 @@ export struct PageComponent { | ||
| 182 | } else { | 278 | } else { |
| 183 | this.pageModel.hasMore = false; | 279 | this.pageModel.hasMore = false; |
| 184 | } | 280 | } |
| 185 | - // // 二次请求,批查互动数据 | ||
| 186 | - // PageViewModel.getInteractData(pageDto.compList).then((data: CompDTO[]) => { | ||
| 187 | - // // 刷新,替换所有数据 | ||
| 188 | - // this.pageModel.compList.replaceAll(...data) | ||
| 189 | - // this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 190 | - // }) | 281 | + // 二次请求,批查互动数据 |
| 282 | + PageViewModel.getInteractData(this.pageDto.compList).then((data: CompDTO[]) => { | ||
| 283 | + // 刷新,替换所有数据 | ||
| 284 | + this.pageModel.compList.replaceAll(...data) | ||
| 285 | + this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 286 | + }) | ||
| 191 | this.isFirstIn = false | 287 | this.isFirstIn = false |
| 192 | - Logger.debug(TAG, 'cj111'); | ||
| 193 | - // } else { | ||
| 194 | - // Logger.debug(TAG, 'aboutToAppear, data response page ' + this.pageId + ', comp list is empty.'); | ||
| 195 | - // this.pageModel.viewType = ViewType.EMPTY; | ||
| 196 | - // } | 288 | + } else { |
| 289 | + Logger.debug(TAG, 'aboutToAppear, data response page ' + this.pageId + ', comp list is empty.'); | ||
| 290 | + this.pageModel.viewType = ViewType.EMPTY; | ||
| 291 | + } | ||
| 197 | } | 292 | } |
| 198 | - | ||
| 199 | } | 293 | } |
| 200 | 294 | ||
| 201 | async getPreviewData() { | 295 | async getPreviewData() { |
| @@ -128,7 +128,7 @@ export struct SearchComponent { | @@ -128,7 +128,7 @@ export struct SearchComponent { | ||
| 128 | * @param content | 128 | * @param content |
| 129 | */ | 129 | */ |
| 130 | getSearchHistoryResData(content:string,index:number){ | 130 | getSearchHistoryResData(content:string,index:number){ |
| 131 | - //删除单挑记录 | 131 | + //删除单条记录 |
| 132 | SearcherAboutDataModel.delSearchSingleHistoryData(index) | 132 | SearcherAboutDataModel.delSearchSingleHistoryData(index) |
| 133 | this.isClickedHistory = true | 133 | this.isClickedHistory = true |
| 134 | this.searchResData(content) | 134 | this.searchResData(content) |
| @@ -149,33 +149,6 @@ export struct SearchComponent { | @@ -149,33 +149,6 @@ export struct SearchComponent { | ||
| 149 | this.getSearchResultCountData() | 149 | this.getSearchResultCountData() |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | - getSearchResultCountData() { | ||
| 153 | - SearcherAboutDataModel.getSearchResultCountData(encodeURI(this.searchText),getContext(this)).then((value) => { | ||
| 154 | - if (value != null) { | ||
| 155 | - this.count = [] | ||
| 156 | - if(value.allTotal!=0){ | ||
| 157 | - this.count.push("全部") | ||
| 158 | - } | ||
| 159 | - if(value.cmsTotal!=0){ | ||
| 160 | - this.count.push("精选") | ||
| 161 | - } | ||
| 162 | - if(value.rmhTotal!=0){ | ||
| 163 | - this.count.push("人民号") | ||
| 164 | - } | ||
| 165 | - if(value.videoTotal!=0){ | ||
| 166 | - this.count.push("视频") | ||
| 167 | - } | ||
| 168 | - if(value.activityTotal!=0){ | ||
| 169 | - this.count.push("活动") | ||
| 170 | - } | ||
| 171 | - } | ||
| 172 | - }).catch((err: Error) => { | ||
| 173 | - console.log(TAG, JSON.stringify(err)) | ||
| 174 | - }) | ||
| 175 | - } | ||
| 176 | - | ||
| 177 | - | ||
| 178 | - | ||
| 179 | /** | 152 | /** |
| 180 | * 点击联想搜索列表回调 | 153 | * 点击联想搜索列表回调 |
| 181 | * @param content | 154 | * @param content |
| @@ -291,4 +264,30 @@ export struct SearchComponent { | @@ -291,4 +264,30 @@ export struct SearchComponent { | ||
| 291 | .padding({ left: '31lpx' }) | 264 | .padding({ left: '31lpx' }) |
| 292 | .alignItems(VerticalAlign.Center) | 265 | .alignItems(VerticalAlign.Center) |
| 293 | } | 266 | } |
| 267 | + | ||
| 268 | + | ||
| 269 | + getSearchResultCountData() { | ||
| 270 | + SearcherAboutDataModel.getSearchResultCountData(encodeURI(this.searchText),getContext(this)).then((value) => { | ||
| 271 | + if (value != null) { | ||
| 272 | + this.count = [] | ||
| 273 | + if(value.allTotal!=0){ | ||
| 274 | + this.count.push("全部") | ||
| 275 | + } | ||
| 276 | + if(value.cmsTotal!=0){ | ||
| 277 | + this.count.push("精选") | ||
| 278 | + } | ||
| 279 | + if(value.rmhTotal!=0){ | ||
| 280 | + this.count.push("人民号") | ||
| 281 | + } | ||
| 282 | + if(value.videoTotal!=0){ | ||
| 283 | + this.count.push("视频") | ||
| 284 | + } | ||
| 285 | + if(value.activityTotal!=0){ | ||
| 286 | + this.count.push("活动") | ||
| 287 | + } | ||
| 288 | + } | ||
| 289 | + }).catch((err: Error) => { | ||
| 290 | + console.log(TAG, JSON.stringify(err)) | ||
| 291 | + }) | ||
| 292 | + } | ||
| 294 | } | 293 | } |
| 1 | +import { SearchResultContentComponent } from './SearchResultContentComponent' | ||
| 1 | 2 | ||
| 2 | const TAG = "SearchResultComponent" | 3 | const TAG = "SearchResultComponent" |
| 3 | /** | 4 | /** |
| @@ -19,7 +20,7 @@ export struct SearchResultComponent{ | @@ -19,7 +20,7 @@ export struct SearchResultComponent{ | ||
| 19 | Tabs({ barPosition: BarPosition.Start, controller: this.controller }) { | 20 | Tabs({ barPosition: BarPosition.Start, controller: this.controller }) { |
| 20 | ForEach(this.count, (item: string, index: number ) => { | 21 | ForEach(this.count, (item: string, index: number ) => { |
| 21 | TabContent(){ | 22 | TabContent(){ |
| 22 | - Text(item) | 23 | + SearchResultContentComponent({keywords:this.searchText,searchType:item}) |
| 23 | }.tabBar(this.TabBuilder(index,item)) | 24 | }.tabBar(this.TabBuilder(index,item)) |
| 24 | }, (item: string, index: number) => index.toString()) | 25 | }, (item: string, index: number) => index.toString()) |
| 25 | } | 26 | } |
| @@ -63,4 +64,5 @@ export struct SearchResultComponent{ | @@ -63,4 +64,5 @@ export struct SearchResultComponent{ | ||
| 63 | .margin({right:'9lpx'}) | 64 | .margin({right:'9lpx'}) |
| 64 | .padding({left:'31lpx',right:index === this.count.length-1?"31lpx":"0lpx"}) | 65 | .padding({left:'31lpx',right:index === this.count.length-1?"31lpx":"0lpx"}) |
| 65 | } | 66 | } |
| 67 | + | ||
| 66 | } | 68 | } |
sight_harmony/features/wdComponent/src/main/ets/components/search/SearchResultContentComponent.ets
0 → 100644
| 1 | +import { ContentDTO, FullColumnImgUrlDTO, InteractDataDTO, RmhInfoDTO, VideoInfoDTO } from 'wdBean/Index' | ||
| 2 | +import { LiveInfoDTO } from 'wdBean/src/main/ets/bean/detail/LiveInfoDTO' | ||
| 3 | +import { VoiceInfoDTO } from 'wdBean/src/main/ets/bean/detail/VoiceInfoDTO' | ||
| 4 | +import { LazyDataSource, StringUtils } from 'wdKit/Index' | ||
| 5 | +import SearcherAboutDataModel from '../../model/SearcherAboutDataModel' | ||
| 6 | +import { CardParser } from '../CardParser' | ||
| 7 | +import { ListHasNoMoreDataUI } from '../reusable/ListHasNoMoreDataUI' | ||
| 8 | + | ||
| 9 | +const TAG = "SearchResultContentComponent" | ||
| 10 | + | ||
| 11 | +@Component | ||
| 12 | +export struct SearchResultContentComponent{ | ||
| 13 | + @State keywords:string = "" | ||
| 14 | + @State searchType:string = "" | ||
| 15 | + @State data: LazyDataSource<ContentDTO> = new LazyDataSource(); | ||
| 16 | + @State count:number = 0; | ||
| 17 | + @State isLoading:boolean = false | ||
| 18 | + @State hasMore:boolean = true | ||
| 19 | + curPageNum:number = 1; | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + aboutToAppear(): void { | ||
| 23 | + if(this.searchType == "全部"){ | ||
| 24 | + this.searchType = "all" | ||
| 25 | + }else if(this.searchType == "精选"){ | ||
| 26 | + this.searchType = "cms" | ||
| 27 | + }else if(this.searchType == "人民号"){ | ||
| 28 | + this.searchType = "rmh" | ||
| 29 | + }else if(this.searchType == "视频"){ | ||
| 30 | + this.searchType = "video" | ||
| 31 | + }else if(this.searchType == "活动"){ | ||
| 32 | + this.searchType = "activity" | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + this.keywords = encodeURI(this.keywords) | ||
| 36 | + this.getNewSearchResultData() | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + getNewSearchResultData(){ | ||
| 40 | + this.isLoading = true | ||
| 41 | + if(this.hasMore){ | ||
| 42 | + SearcherAboutDataModel.getSearchResultListData("20",`${this.curPageNum}`,this.searchType,this.keywords,getContext(this)).then((value)=>{ | ||
| 43 | + if (!this.data || value.list.length == 0){ | ||
| 44 | + this.hasMore = false | ||
| 45 | + }else{ | ||
| 46 | + value.list.forEach((value)=>{ | ||
| 47 | + | ||
| 48 | + let photos:FullColumnImgUrlDTO[] = [] | ||
| 49 | + if(value.data.appStyle === 4){ | ||
| 50 | + value.data.appStyleImages.split("&&").forEach((value)=>{ | ||
| 51 | + photos.push({url:value} as FullColumnImgUrlDTO) | ||
| 52 | + }) | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + //TODO 48 个赋值 | ||
| 56 | + let contentDTO:ContentDTO = { | ||
| 57 | + appStyle: value.data.appStyle + "", | ||
| 58 | + cityCode: value.data.cityCode, | ||
| 59 | + coverSize: "", | ||
| 60 | + coverType: -1, | ||
| 61 | + coverUrl: value.data.appStyleImages.split("&&")[0], | ||
| 62 | + description: value.data.description, | ||
| 63 | + districtCode: value.data.districtCode, | ||
| 64 | + endTime: value.data.endTime, | ||
| 65 | + hImageUrl: "", | ||
| 66 | + heatValue: "", | ||
| 67 | + innerUrl: "", | ||
| 68 | + landscape: Number.parseInt(value.data.landscape), | ||
| 69 | + // lengthTime:null, | ||
| 70 | + linkUrl: value.data.linkUrl, | ||
| 71 | + openLikes: Number.parseInt(value.data.openLikes), | ||
| 72 | + openUrl: "", | ||
| 73 | + pageId: value.data.pageId, | ||
| 74 | + programAuth: "", | ||
| 75 | + programId: "", | ||
| 76 | + programName: "", | ||
| 77 | + programSource: -1, | ||
| 78 | + programType: -1, | ||
| 79 | + provinceCode: value.data.provinceCode, | ||
| 80 | + showTitleEd: value.data.showTitleEd, | ||
| 81 | + showTitleIng: value.data.showTitleIng, | ||
| 82 | + showTitleNo: value.data.showTitleNo, | ||
| 83 | + startTime: value.data.startTime, | ||
| 84 | + subType: "", | ||
| 85 | + subtitle: "", | ||
| 86 | + title: value.data.title, | ||
| 87 | + vImageUrl: "", | ||
| 88 | + screenType: "", | ||
| 89 | + source: StringUtils.isEmpty(value.data.creatorName) ? value.data.sourceName : value.data.creatorName, | ||
| 90 | + objectId: "", | ||
| 91 | + objectType: value.data.type, | ||
| 92 | + channelId: value.data.channelId, | ||
| 93 | + relId: value.data.relId, | ||
| 94 | + relType: value.data.relType, | ||
| 95 | + newsTitle: value.data.titleLiteral, | ||
| 96 | + publishTime: value.data.publishTime, | ||
| 97 | + visitorComment: -1, | ||
| 98 | + fullColumnImgUrls: photos, | ||
| 99 | + newsSummary: "", | ||
| 100 | + hasMore: -1, | ||
| 101 | + slideShows: [], | ||
| 102 | + voiceInfo: {} as VoiceInfoDTO, | ||
| 103 | + tagWord: -1, | ||
| 104 | + isSelect: true, | ||
| 105 | + rmhInfo: {} as RmhInfoDTO, | ||
| 106 | + photoNum: -1, | ||
| 107 | + liveInfo: {} as LiveInfoDTO, | ||
| 108 | + videoInfo: { | ||
| 109 | + videoDuration: Number.parseInt(value.data.duration) | ||
| 110 | + } as VideoInfoDTO, | ||
| 111 | + interactData: {} as InteractDataDTO, | ||
| 112 | + corner: '', | ||
| 113 | + rmhPlatform: 0, | ||
| 114 | + newTags: '' | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + this.data.push(contentDTO) | ||
| 118 | + }) | ||
| 119 | + this.data.notifyDataReload() | ||
| 120 | + this.count = this.data.totalCount() | ||
| 121 | + if (this.data.totalCount() < value.totalCount) { | ||
| 122 | + this.curPageNum++ | ||
| 123 | + }else { | ||
| 124 | + this.hasMore = false | ||
| 125 | + } | ||
| 126 | + } | ||
| 127 | + }).catch((err:Error)=>{ | ||
| 128 | + console.log(TAG,JSON.stringify(err)) | ||
| 129 | + }) | ||
| 130 | + } | ||
| 131 | + this.isLoading = false | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + | ||
| 135 | + build() { | ||
| 136 | + Column() { | ||
| 137 | + if(this.count == 0){ | ||
| 138 | + ListHasNoMoreDataUI({style:2}) | ||
| 139 | + }else{ | ||
| 140 | + //List | ||
| 141 | + List({ space: '6lpx' }) { | ||
| 142 | + LazyForEach(this.data, (item: ContentDTO, index: number) => { | ||
| 143 | + ListItem() { | ||
| 144 | + CardParser({contentDTO:item}) | ||
| 145 | + } | ||
| 146 | + .onClick(()=>{ | ||
| 147 | + //TODO 跳转 | ||
| 148 | + }) | ||
| 149 | + }, (item: ContentDTO, index: number) => index.toString()) | ||
| 150 | + | ||
| 151 | + //没有更多数据 显示提示 | ||
| 152 | + if(!this.hasMore){ | ||
| 153 | + ListItem(){ | ||
| 154 | + ListHasNoMoreDataUI() | ||
| 155 | + } | ||
| 156 | + } | ||
| 157 | + }.cachedCount(4) | ||
| 158 | + .scrollBar(BarState.Off) | ||
| 159 | + .margin({top:'23lpx',left:'23lpx',right:'23lpx'}) | ||
| 160 | + .layoutWeight(1) | ||
| 161 | + .onReachEnd(()=>{ | ||
| 162 | + console.log(TAG,"触底了"); | ||
| 163 | + if(!this.isLoading){ | ||
| 164 | + //加载分页数据 | ||
| 165 | + this.getNewSearchResultData() | ||
| 166 | + } | ||
| 167 | + }) | ||
| 168 | + } | ||
| 169 | + } | ||
| 170 | + .backgroundColor($r('app.color.white')) | ||
| 171 | + .height('100%') | ||
| 172 | + .width('100%') | ||
| 173 | + } | ||
| 174 | +} |
| 1 | import { Params } from 'wdBean'; | 1 | import { Params } from 'wdBean'; |
| 2 | import { WDRouterPage, WDRouterRule } from 'wdRouter'; | 2 | import { WDRouterPage, WDRouterRule } from 'wdRouter'; |
| 3 | -import featureAbility from '@ohos.ability.featureAbility'; | 3 | +import { EnvironmentCustomDialog } from './EnvironmentCustomDialog'; |
| 4 | 4 | ||
| 5 | const TAG = 'AboutPageUI'; | 5 | const TAG = 'AboutPageUI'; |
| 6 | 6 | ||
| 7 | @Component | 7 | @Component |
| 8 | -export struct AboutPageUI { | 8 | +export struct AboutPageUI { |
| 9 | @State listData: Array<string | Array<string>> = ['隐私授权协议', '软件许可及用户协议']; | 9 | @State listData: Array<string | Array<string>> = ['隐私授权协议', '软件许可及用户协议']; |
| 10 | @State message: string = '京ICP备16066560号-6A Copyright © 人民日报客户端\nall rights reserved.' | 10 | @State message: string = '京ICP备16066560号-6A Copyright © 人民日报客户端\nall rights reserved.' |
| 11 | @State version: string = '版本号:v' | 11 | @State version: string = '版本号:v' |
| 12 | + clickTimes: number = 0 | ||
| 13 | + dialogController: CustomDialogController = new CustomDialogController({ | ||
| 14 | + builder: EnvironmentCustomDialog({ | ||
| 15 | + cancel: () => { | ||
| 12 | 16 | ||
| 17 | + }, | ||
| 18 | + confirm: () => { | ||
| 19 | + } | ||
| 20 | + }), | ||
| 21 | + customStyle: true, | ||
| 22 | + alignment: DialogAlignment.Center | ||
| 23 | + }) | ||
| 13 | 24 | ||
| 14 | build() { | 25 | build() { |
| 15 | Navigation() { | 26 | Navigation() { |
| @@ -19,18 +30,24 @@ export struct AboutPageUI { | @@ -19,18 +30,24 @@ export struct AboutPageUI { | ||
| 19 | .title('关于') | 30 | .title('关于') |
| 20 | } | 31 | } |
| 21 | 32 | ||
| 22 | - aboutToAppear(){ | 33 | + aboutToAppear() { |
| 23 | let context = getContext(); | 34 | let context = getContext(); |
| 24 | context.getApplicationContext(); | 35 | context.getApplicationContext(); |
| 25 | } | 36 | } |
| 26 | 37 | ||
| 27 | - @Builder aboutUi() { | 38 | + @Builder |
| 39 | + aboutUi() { | ||
| 28 | Column() { | 40 | Column() { |
| 29 | Image($r('app.media.setting_about_logo')) | 41 | Image($r('app.media.setting_about_logo')) |
| 30 | .width('278lpx') | 42 | .width('278lpx') |
| 31 | .height('154lpx') | 43 | .height('154lpx') |
| 32 | - .margin({top:'173lpx',bottom:'154lpx'}) | ||
| 33 | - | 44 | + .margin({ top: '173lpx', bottom: '154lpx' }) |
| 45 | + .onClick(() => { | ||
| 46 | + this.clickTimes++ | ||
| 47 | + if (this.clickTimes > 2) { | ||
| 48 | + this.dialogController.open() | ||
| 49 | + } | ||
| 50 | + }) | ||
| 34 | // Row(){ | 51 | // Row(){ |
| 35 | // | 52 | // |
| 36 | // }.backgroundColor(Color.Yellow) | 53 | // }.backgroundColor(Color.Yellow) |
| @@ -44,19 +61,17 @@ export struct AboutPageUI { | @@ -44,19 +61,17 @@ export struct AboutPageUI { | ||
| 44 | // .height('97lpx') | 61 | // .height('97lpx') |
| 45 | 62 | ||
| 46 | 63 | ||
| 47 | - | ||
| 48 | - | ||
| 49 | - List(){ | ||
| 50 | - ForEach(this.listData, (item:string, index : number) =>{ | 64 | + List() { |
| 65 | + ForEach(this.listData, (item: string, index: number) => { | ||
| 51 | ListItem() { | 66 | ListItem() { |
| 52 | this.getArrowCell(item, index) | 67 | this.getArrowCell(item, index) |
| 53 | - }.onClick(() =>{ | 68 | + }.onClick(() => { |
| 54 | if (index == 0) { | 69 | if (index == 0) { |
| 55 | - let bean={contentId:"1",pageID:""} as Params | ||
| 56 | - WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage,bean) | ||
| 57 | - }else{ | ||
| 58 | - let bean={contentId:"2",pageID:""} as Params | ||
| 59 | - WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage,bean) | 70 | + let bean = { contentId: "1", pageID: "" } as Params |
| 71 | + WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage, bean) | ||
| 72 | + } else { | ||
| 73 | + let bean = { contentId: "2", pageID: "" } as Params | ||
| 74 | + WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage, bean) | ||
| 60 | } | 75 | } |
| 61 | }) | 76 | }) |
| 62 | }) | 77 | }) |
| @@ -77,42 +92,39 @@ export struct AboutPageUI { | @@ -77,42 +92,39 @@ export struct AboutPageUI { | ||
| 77 | .fontSize('25lpx') | 92 | .fontSize('25lpx') |
| 78 | .textAlign(TextAlign.Center) | 93 | .textAlign(TextAlign.Center) |
| 79 | .fontColor($r("app.color.color_666666")) | 94 | .fontColor($r("app.color.color_666666")) |
| 80 | - .margin({bottom:'31lpx'}) | 95 | + .margin({ bottom: '31lpx' }) |
| 81 | 96 | ||
| 82 | Text(this.message) | 97 | Text(this.message) |
| 83 | .fontSize('19lpx') | 98 | .fontSize('19lpx') |
| 84 | .textAlign(TextAlign.Center) | 99 | .textAlign(TextAlign.Center) |
| 85 | .fontColor($r("app.color.color_999999")) | 100 | .fontColor($r("app.color.color_999999")) |
| 86 | - .margin({bottom:'35lpx'}) | 101 | + .margin({ bottom: '35lpx' }) |
| 87 | } | 102 | } |
| 88 | .width('100%') | 103 | .width('100%') |
| 89 | .height('100%') | 104 | .height('100%') |
| 90 | } | 105 | } |
| 91 | 106 | ||
| 92 | - | ||
| 93 | - | ||
| 94 | // 右文字+箭头cell | 107 | // 右文字+箭头cell |
| 95 | - @Builder getArrowCell(item:string, index:number) { | ||
| 96 | - | ||
| 97 | - Row() { | ||
| 98 | - // 左侧标题 | ||
| 99 | - Text(`${item}`) | ||
| 100 | - .fontColor('#666666') | ||
| 101 | - .fontSize('31lpx') | ||
| 102 | - | ||
| 103 | - Image($r('app.media.mine_user_arrow')) | ||
| 104 | - .width('27lpx') | ||
| 105 | - .height('27lpx') | ||
| 106 | - .objectFit(ImageFit.Auto) | ||
| 107 | - } | ||
| 108 | - .alignItems(VerticalAlign.Center) | ||
| 109 | - .justifyContent(FlexAlign.SpaceBetween) | ||
| 110 | - .height('97lpx') | ||
| 111 | - .width('100%') | ||
| 112 | - .padding({left:'29lpx',right:'29lpx'}) | 108 | + @Builder |
| 109 | + getArrowCell(item: string, index: number) { | ||
| 110 | + | ||
| 111 | + Row() { | ||
| 112 | + // 左侧标题 | ||
| 113 | + Text(`${item}`) | ||
| 114 | + .fontColor('#666666') | ||
| 115 | + .fontSize('31lpx') | ||
| 116 | + | ||
| 117 | + Image($r('app.media.mine_user_arrow')) | ||
| 118 | + .width('27lpx') | ||
| 119 | + .height('27lpx') | ||
| 120 | + .objectFit(ImageFit.Auto) | ||
| 121 | + } | ||
| 122 | + .alignItems(VerticalAlign.Center) | ||
| 123 | + .justifyContent(FlexAlign.SpaceBetween) | ||
| 124 | + .height('97lpx') | ||
| 125 | + .width('100%') | ||
| 126 | + .padding({ left: '29lpx', right: '29lpx' }) | ||
| 113 | } | 127 | } |
| 114 | - | ||
| 115 | - | ||
| 116 | } | 128 | } |
| 117 | 129 | ||
| 118 | 130 |
| @@ -17,6 +17,7 @@ import { Router } from '@ohos.arkui.UIContext'; | @@ -17,6 +17,7 @@ import { Router } from '@ohos.arkui.UIContext'; | ||
| 17 | import promptAction from '@ohos.promptAction'; | 17 | import promptAction from '@ohos.promptAction'; |
| 18 | import { LogoutViewModel } from '../../viewmodel/LogoutViewModel'; | 18 | import { LogoutViewModel } from '../../viewmodel/LogoutViewModel'; |
| 19 | import { CustomLogoutDialog } from './CustomLogoutDialog'; | 19 | import { CustomLogoutDialog } from './CustomLogoutDialog'; |
| 20 | +import { emitter } from '@kit.BasicServicesKit'; | ||
| 20 | 21 | ||
| 21 | export { SettingPasswordParams } from "wdLogin" | 22 | export { SettingPasswordParams } from "wdLogin" |
| 22 | 23 | ||
| @@ -41,9 +42,11 @@ export struct AccountAndSecurityLayout { | @@ -41,9 +42,11 @@ export struct AccountAndSecurityLayout { | ||
| 41 | alignment: DialogAlignment.Center | 42 | alignment: DialogAlignment.Center |
| 42 | }) | 43 | }) |
| 43 | 44 | ||
| 45 | + | ||
| 44 | aboutToAppear() { | 46 | aboutToAppear() { |
| 45 | // 获取设置页面数据 | 47 | // 获取设置页面数据 |
| 46 | this.getAccountAndSecurityData() | 48 | this.getAccountAndSecurityData() |
| 49 | + this.addEmitEvent() | ||
| 47 | } | 50 | } |
| 48 | 51 | ||
| 49 | async getAccountAndSecurityData() { | 52 | async getAccountAndSecurityData() { |
| @@ -56,6 +59,28 @@ export struct AccountAndSecurityLayout { | @@ -56,6 +59,28 @@ export struct AccountAndSecurityLayout { | ||
| 56 | 59 | ||
| 57 | } | 60 | } |
| 58 | 61 | ||
| 62 | + addEmitEvent(){ | ||
| 63 | + // 定义一个eventId为1的事件 | ||
| 64 | + let event: emitter.InnerEvent = { | ||
| 65 | + eventId: 10010 | ||
| 66 | + }; | ||
| 67 | + | ||
| 68 | + // 收到eventId为1的事件后执行该回调 | ||
| 69 | + let callback = (eventData: emitter.EventData): void => { | ||
| 70 | + promptAction.showToast({ | ||
| 71 | + message: JSON.stringify(eventData) | ||
| 72 | + }); | ||
| 73 | + if(eventData&&eventData.data){ | ||
| 74 | + this.listData[0].subTitle = eventData.data['content'] | ||
| 75 | + } | ||
| 76 | + Logger.debug( 'event callback:' + JSON.stringify(eventData)); | ||
| 77 | + }; | ||
| 78 | + | ||
| 79 | + // 订阅eventId为1的事件 | ||
| 80 | + emitter.on(event, callback); | ||
| 81 | + | ||
| 82 | + } | ||
| 83 | + | ||
| 59 | build() { | 84 | build() { |
| 60 | Column(){ | 85 | Column(){ |
| 61 | if(this.isAccountPage){ | 86 | if(this.isAccountPage){ |
| @@ -106,7 +131,8 @@ export struct AccountAndSecurityLayout { | @@ -106,7 +131,8 @@ export struct AccountAndSecurityLayout { | ||
| 106 | ListItem() { | 131 | ListItem() { |
| 107 | if (item.type == 0) { | 132 | if (item.type == 0) { |
| 108 | Column() { | 133 | Column() { |
| 109 | - this.getArrowCell(item) | 134 | + // this.getArrowCell(item) |
| 135 | + AccountArrowCell({ item:item}) | ||
| 110 | }.padding({ left: '27lpx' }).height('117lpx').justifyContent(FlexAlign.Center) | 136 | }.padding({ left: '27lpx' }).height('117lpx').justifyContent(FlexAlign.Center) |
| 111 | } else if (item.type == 1) { | 137 | } else if (item.type == 1) { |
| 112 | Column() { | 138 | Column() { |
| @@ -285,7 +311,7 @@ export struct AccountAndSecurityLayout { | @@ -285,7 +311,7 @@ export struct AccountAndSecurityLayout { | ||
| 285 | }.alignItems(VerticalAlign.Center) | 311 | }.alignItems(VerticalAlign.Center) |
| 286 | 312 | ||
| 287 | Row() { | 313 | Row() { |
| 288 | - Text("登录") | 314 | + Text("注销账户") |
| 289 | .borderRadius(4) | 315 | .borderRadius(4) |
| 290 | .fontColor(this.protocolState ? "#FFFFFFFF" : "#66FFFFFF") | 316 | .fontColor(this.protocolState ? "#FFFFFFFF" : "#66FFFFFF") |
| 291 | .fontSize(18) | 317 | .fontSize(18) |
| @@ -404,4 +430,47 @@ export struct AccountAndSecurityLayout { | @@ -404,4 +430,47 @@ export struct AccountAndSecurityLayout { | ||
| 404 | securityNum = phoneNum.replace(needSecurityString,'****') | 430 | securityNum = phoneNum.replace(needSecurityString,'****') |
| 405 | return securityNum; | 431 | return securityNum; |
| 406 | } | 432 | } |
| 433 | +} | ||
| 434 | + | ||
| 435 | +@Component | ||
| 436 | +export struct AccountArrowCell{ | ||
| 437 | + @ObjectLink item: MineMainSettingFunctionItem | ||
| 438 | + build() { | ||
| 439 | + Column() { | ||
| 440 | + Row() { | ||
| 441 | + // 左侧logo和标题 | ||
| 442 | + Row() { | ||
| 443 | + // 判断有没有图片 | ||
| 444 | + if (this.item.imgSrc) { | ||
| 445 | + Image(this.item.imgSrc) | ||
| 446 | + .height('38lpx') | ||
| 447 | + .margin({ right: '5lpx' }) | ||
| 448 | + } | ||
| 449 | + Text(`${this.item.title}`) | ||
| 450 | + .margin({ top: '8lpx' }) | ||
| 451 | + .height('38lpx') | ||
| 452 | + .fontColor('#333333') | ||
| 453 | + .fontSize('29lpx') | ||
| 454 | + }.width('60%') | ||
| 455 | + | ||
| 456 | + // 右侧文案和右箭头 | ||
| 457 | + Row() { | ||
| 458 | + Text(this.item.subTitle ? this.item.subTitle : '') | ||
| 459 | + .fontColor('#999999') | ||
| 460 | + .maxLines(1) | ||
| 461 | + Image($r('app.media.mine_user_arrow')) | ||
| 462 | + .width('27lpx') | ||
| 463 | + .height('27lpx') | ||
| 464 | + .objectFit(ImageFit.Auto) | ||
| 465 | + Column().width('29lpx') | ||
| 466 | + }.width('40%') | ||
| 467 | + .margin({ right: '29lpx' }) | ||
| 468 | + .justifyContent(FlexAlign.End) | ||
| 469 | + | ||
| 470 | + } | ||
| 471 | + .alignItems(VerticalAlign.Center) | ||
| 472 | + .justifyContent(FlexAlign.SpaceBetween) | ||
| 473 | + } | ||
| 474 | + .height('54lpx') | ||
| 475 | + } | ||
| 407 | } | 476 | } |
sight_harmony/features/wdComponent/src/main/ets/components/setting/EnvironmentCustomDialog.ets
0 → 100644
| 1 | +import { SPHelper } from 'wdKit/Index'; | ||
| 2 | +import { HttpUrlUtils } from 'wdNetwork/Index'; | ||
| 3 | + | ||
| 4 | +@CustomDialog | ||
| 5 | +export struct EnvironmentCustomDialog { | ||
| 6 | + currentEnvironment: string = HttpUrlUtils.HOST_PRODUCT; | ||
| 7 | + controller: CustomDialogController | ||
| 8 | + cancel: () => void = () => { | ||
| 9 | + } | ||
| 10 | + confirm: () => void = () => { | ||
| 11 | + } | ||
| 12 | + | ||
| 13 | + build() { | ||
| 14 | + Column() { | ||
| 15 | + Text("请选择环境") | ||
| 16 | + .fontColor("#222222") | ||
| 17 | + .fontSize(18) | ||
| 18 | + .width("100%") | ||
| 19 | + .fontWeight(FontWeight.Bold) | ||
| 20 | + .textAlign(TextAlign.Center) | ||
| 21 | + .margin({ top: 20 }) | ||
| 22 | + Row() { | ||
| 23 | + Radio({ value: 'Radio1', group: 'radioGroup' }) | ||
| 24 | + .checked(true) | ||
| 25 | + .height(20) | ||
| 26 | + .width(20) | ||
| 27 | + .onChange((isChecked: boolean) => { | ||
| 28 | + if (isChecked) { | ||
| 29 | + this.currentEnvironment = HttpUrlUtils.HOST_SIT; | ||
| 30 | + } | ||
| 31 | + }) | ||
| 32 | + Text('切换到SIT(测试)环境,重启应用生效') | ||
| 33 | + .fontSize(14) | ||
| 34 | + } | ||
| 35 | + .justifyContent(FlexAlign.Start) | ||
| 36 | + .width('90%') | ||
| 37 | + | ||
| 38 | + Row() { | ||
| 39 | + Radio({ value: 'Radio1', group: 'radioGroup' }) | ||
| 40 | + .checked(true) | ||
| 41 | + .height(20) | ||
| 42 | + .width(20) | ||
| 43 | + .onChange((isChecked: boolean) => { | ||
| 44 | + if (isChecked) { | ||
| 45 | + this.currentEnvironment = HttpUrlUtils.HOST_UAT; | ||
| 46 | + } | ||
| 47 | + }) | ||
| 48 | + Text('切换到UAT(预发布)环境,重启应用生效') | ||
| 49 | + .fontSize(14) | ||
| 50 | + } | ||
| 51 | + .width('90%') | ||
| 52 | + .justifyContent(FlexAlign.Start) | ||
| 53 | + | ||
| 54 | + Row() { | ||
| 55 | + Radio({ value: 'Radio1', group: 'radioGroup' }) | ||
| 56 | + .checked(true) | ||
| 57 | + .height(20) | ||
| 58 | + .width(20) | ||
| 59 | + .onChange((isChecked: boolean) => { | ||
| 60 | + if (isChecked) { | ||
| 61 | + this.currentEnvironment = HttpUrlUtils.HOST_PRODUCT; | ||
| 62 | + } | ||
| 63 | + }) | ||
| 64 | + Text('切换到PROD(现网)环境,重启应用生效') | ||
| 65 | + .fontSize(14) | ||
| 66 | + } | ||
| 67 | + .width('90%') | ||
| 68 | + .justifyContent(FlexAlign.Start) | ||
| 69 | + | ||
| 70 | + Row() { | ||
| 71 | + Radio({ value: 'Radio1', group: 'radioGroup' }) | ||
| 72 | + .checked(true) | ||
| 73 | + .height(20) | ||
| 74 | + .width(20) | ||
| 75 | + .onChange((isChecked: boolean) => { | ||
| 76 | + if (isChecked) { | ||
| 77 | + this.currentEnvironment = HttpUrlUtils.HOST_DEV; | ||
| 78 | + } | ||
| 79 | + }) | ||
| 80 | + Text('切换到DEV(开发)环境,重启应用生效') | ||
| 81 | + .fontSize(14) | ||
| 82 | + } | ||
| 83 | + .width('90%') | ||
| 84 | + .justifyContent(FlexAlign.Start) | ||
| 85 | + | ||
| 86 | + Button('确认') | ||
| 87 | + .margin({ top: 20 }) | ||
| 88 | + .onClick(() => { | ||
| 89 | + // HttpUrlUtils.hostUrl = this.currentEnvironment | ||
| 90 | + SPHelper.default.saveSync('hostUrl', this.currentEnvironment); | ||
| 91 | + this.controller.close() | ||
| 92 | + this.confirm() | ||
| 93 | + }) | ||
| 94 | + }.height(261).backgroundColor(Color.White).borderRadius(6).width('74%') | ||
| 95 | + | ||
| 96 | + } | ||
| 97 | +} |
sight_harmony/features/wdComponent/src/main/ets/components/view/AlbumCardComponent.ets
deleted
100644 → 0
| 1 | -import { Action, CompDTO, Params } from 'wdBean'; | ||
| 2 | -import { ExtraDTO } from 'wdBean/src/main/ets/bean/component/extra/ExtraDTO'; | ||
| 3 | -import { CommonConstants } from 'wdConstant/Index'; | ||
| 4 | -import { DateTimeUtils, Logger } from 'wdKit'; | ||
| 5 | -import { WDRouterRule } from 'wdRouter'; | ||
| 6 | - | ||
| 7 | -const TAG = 'AlbumCardComponent'; | ||
| 8 | - | ||
| 9 | -@Preview | ||
| 10 | -@Component | ||
| 11 | -export struct AlbumCardComponent { | ||
| 12 | - @State compDTO: CompDTO = {} as CompDTO | ||
| 13 | - | ||
| 14 | - aboutToAppear() { | ||
| 15 | - Logger.debug(TAG + "this.compDTO.operDataList" + JSON.stringify(this.compDTO.operDataList)); | ||
| 16 | - | ||
| 17 | - } | ||
| 18 | - | ||
| 19 | - build() { | ||
| 20 | - Column({ space: 8 }) { | ||
| 21 | - Text(this.compDTO.operDataList[0].newsTitle) | ||
| 22 | - .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 23 | - .fontSize(17) | ||
| 24 | - .fontColor(0x222222) | ||
| 25 | - .lineHeight(25) | ||
| 26 | - .maxLines(3) | ||
| 27 | - .width(CommonConstants.FULL_WIDTH) | ||
| 28 | - | ||
| 29 | - RelativeContainer() { | ||
| 30 | - Image(this.compDTO.operDataList[0].fullColumnImgUrls[0].url) | ||
| 31 | - .width('66.6%') | ||
| 32 | - .aspectRatio(16/9) | ||
| 33 | - .alignRules({ | ||
| 34 | - top: { anchor: "__container__", align: VerticalAlign.Top }, | ||
| 35 | - left: { anchor: "__container__", align: HorizontalAlign.Start } | ||
| 36 | - }) | ||
| 37 | - .id('mainImage') | ||
| 38 | - | ||
| 39 | - Image(this.compDTO.operDataList[0].fullColumnImgUrls[1].url) | ||
| 40 | - .width('33%') | ||
| 41 | - .aspectRatio(16/9) | ||
| 42 | - .alignRules({ | ||
| 43 | - top: { anchor: "__container__", align: VerticalAlign.Top }, | ||
| 44 | - right: { anchor: "__container__", align: HorizontalAlign.End } | ||
| 45 | - }) | ||
| 46 | - .id('subTopImage') | ||
| 47 | - | ||
| 48 | - Image(this.compDTO.operDataList[0].fullColumnImgUrls[2].url) | ||
| 49 | - .width('33%') | ||
| 50 | - .aspectRatio(16/9) | ||
| 51 | - .alignRules({ | ||
| 52 | - right: { anchor: "__container__", align: HorizontalAlign.End }, | ||
| 53 | - bottom: { anchor: "__container__", align: VerticalAlign.Bottom } | ||
| 54 | - }) | ||
| 55 | - .id('subBottomImage') | ||
| 56 | - // 下面是渲染右下角图标 | ||
| 57 | - Shape() { | ||
| 58 | - Rect().width(33).height(18) | ||
| 59 | - } | ||
| 60 | - // .viewPort({ x: -2, y: -2, width: 304, height: 130 }) | ||
| 61 | - .fill(0x000000) | ||
| 62 | - .fillOpacity(0.3) | ||
| 63 | - // .strokeDashArray([20]) | ||
| 64 | - // .strokeDashOffset(10) | ||
| 65 | - .strokeLineCap(LineCapStyle.Round) | ||
| 66 | - .strokeLineJoin(LineJoinStyle.Round) | ||
| 67 | - .antiAlias(true) | ||
| 68 | - .id('shape') | ||
| 69 | - .alignRules({ | ||
| 70 | - right: { anchor: "__container__", align: HorizontalAlign.End }, | ||
| 71 | - bottom: { anchor: "__container__", align: VerticalAlign.Bottom } | ||
| 72 | - }) | ||
| 73 | - .margin({ right: 4, | ||
| 74 | - bottom: 4 }) | ||
| 75 | - | ||
| 76 | - Image($r('app.media.album_card_shape')) | ||
| 77 | - .width(22) | ||
| 78 | - .height(18) | ||
| 79 | - .alignRules({ | ||
| 80 | - left: { anchor: "shape", align: HorizontalAlign.Start }, | ||
| 81 | - top: { anchor: "shape", align: VerticalAlign.Top } | ||
| 82 | - }) | ||
| 83 | - .id('shapeSubImage') | ||
| 84 | - | ||
| 85 | - Text(this.compDTO.operDataList[0].fullColumnImgUrls.length + '') | ||
| 86 | - .fontSize(13) | ||
| 87 | - .fontColor(0xFFFFFF) | ||
| 88 | - .id('pageIndex') | ||
| 89 | - .alignRules({ | ||
| 90 | - right: { anchor: "shape", align: HorizontalAlign.End }, | ||
| 91 | - top: { anchor: "shape", align: VerticalAlign.Top } | ||
| 92 | - }) | ||
| 93 | - .margin({ right: 2 }) | ||
| 94 | - .textAlign(TextAlign.Center) | ||
| 95 | - .width(17) | ||
| 96 | - .height(17) | ||
| 97 | - } | ||
| 98 | - .width(CommonConstants.FULL_WIDTH) | ||
| 99 | - .aspectRatio(24/9) | ||
| 100 | - .onClick((event: ClickEvent) => { | ||
| 101 | - let taskAction: Action = { | ||
| 102 | - type: 'JUMP_DETAIL_PAGE', | ||
| 103 | - params: { | ||
| 104 | - detailPageType: 17, | ||
| 105 | - contentID: this.compDTO.operDataList?.[0].objectId, | ||
| 106 | - extra: { | ||
| 107 | - relType: this.compDTO.operDataList?.[0].relType, | ||
| 108 | - relId: `${this.compDTO.operDataList?.[0].relId}`, | ||
| 109 | - } as ExtraDTO | ||
| 110 | - } as Params, | ||
| 111 | - }; | ||
| 112 | - WDRouterRule.jumpWithAction(taskAction) | ||
| 113 | - }) | ||
| 114 | - | ||
| 115 | - Row() { | ||
| 116 | - if (this.compDTO.operDataList[0].source) { | ||
| 117 | - Text(this.compDTO.operDataList[0].source) | ||
| 118 | - .fontSize(13) | ||
| 119 | - .fontColor(0xB0B0B0) | ||
| 120 | - Image($r('app.media.point')) | ||
| 121 | - .width(16) | ||
| 122 | - .height(16) | ||
| 123 | - } | ||
| 124 | - if (this.compDTO.operDataList[0].publishTime && this.compDTO.operDataList[0].publishTime.length === 13) { | ||
| 125 | - Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.compDTO.operDataList[0].publishTime))) | ||
| 126 | - .fontSize(13) | ||
| 127 | - .fontColor(0xB0B0B0) | ||
| 128 | - } | ||
| 129 | - Text('328评') | ||
| 130 | - .fontSize(13) | ||
| 131 | - .fontColor(0xB0B0B0) | ||
| 132 | - .margin({ | ||
| 133 | - left: 6 | ||
| 134 | - }) | ||
| 135 | - } | ||
| 136 | - .width(CommonConstants.FULL_WIDTH) | ||
| 137 | - .height(16) | ||
| 138 | - .id('label') | ||
| 139 | - } | ||
| 140 | - .width(CommonConstants.FULL_WIDTH) | ||
| 141 | - .padding({ | ||
| 142 | - top: 14, | ||
| 143 | - left: 16, | ||
| 144 | - right: 16, | ||
| 145 | - bottom: 14 | ||
| 146 | - }) | ||
| 147 | - } | ||
| 148 | -} |
| 1 | -import { CompDTO, slideShows } from 'wdBean'; | ||
| 2 | -import { CommonConstants } from 'wdConstant' | ||
| 3 | -import { DateTimeUtils } from 'wdKit'; | ||
| 4 | -import { ProcessUtils } from '../../utils/ProcessUtils'; | ||
| 5 | -/** | ||
| 6 | - * 时间链卡--CompStyle: 09 | ||
| 7 | - */ | ||
| 8 | -@Component | ||
| 9 | -export struct CompStyle_09 { | ||
| 10 | - @State compDTO: CompDTO = {} as CompDTO | ||
| 11 | - | ||
| 12 | - build() { | ||
| 13 | - Column(){ | ||
| 14 | - // 顶部标题,最多两行 | ||
| 15 | - if(this.compDTO.operDataList[0].newsTitle) { | ||
| 16 | - Text(this.compDTO.operDataList[0].newsTitle) | ||
| 17 | - .width(CommonConstants.FULL_WIDTH) | ||
| 18 | - .fontSize($r('app.float.font_size_17')) | ||
| 19 | - .fontWeight(600) | ||
| 20 | - .maxLines(2) | ||
| 21 | - .textOverflow({overflow: TextOverflow.Ellipsis}) | ||
| 22 | - .margin({ bottom: 19 }) | ||
| 23 | - } | ||
| 24 | - // 大图 | ||
| 25 | - Stack(){ | ||
| 26 | - Image(this.compDTO.operDataList[0].coverUrl) | ||
| 27 | - .width('100%') | ||
| 28 | - .borderRadius({topLeft: $r('app.float.image_border_radius'), topRight: $r('app.float.image_border_radius')}) | ||
| 29 | - Text('专题') | ||
| 30 | - .fontSize($r('app.float.font_size_12')) | ||
| 31 | - .padding({left: 8, right: 8, top: 3, bottom: 3}) | ||
| 32 | - .backgroundColor(Color.Red) | ||
| 33 | - .fontColor(Color.White) | ||
| 34 | - .borderRadius($r('app.float.button_border_radius')) | ||
| 35 | - .margin({left: 5, bottom: 5}) | ||
| 36 | - }.alignContent(Alignment.BottomStart) | ||
| 37 | - // 时间线--后端返回三个, | ||
| 38 | - Column(){ | ||
| 39 | - ForEach(this.compDTO.operDataList[0].slideShows, (item:slideShows, index:number) => { | ||
| 40 | - this.timelineItem(item, index) | ||
| 41 | - }) | ||
| 42 | - } | ||
| 43 | - // 底部-查看更多。根据接口返回的isMore判断是否显示查看更多 | ||
| 44 | - if(this.compDTO.operDataList[0].hasMore == 1) { | ||
| 45 | - Row() { | ||
| 46 | - Text("查看更多") | ||
| 47 | - .fontSize($r("app.float.font_size_14")) | ||
| 48 | - .fontColor($r("app.color.color_222222")) | ||
| 49 | - .margin({ right: 1 }) | ||
| 50 | - Image($r("app.media.more")) | ||
| 51 | - .width(14) | ||
| 52 | - .height(14) | ||
| 53 | - } | ||
| 54 | - .backgroundColor($r('app.color.color_F5F5F5')) | ||
| 55 | - .width(CommonConstants.FULL_WIDTH) | ||
| 56 | - .height(40) | ||
| 57 | - .borderRadius($r('app.float.button_border_radius')) | ||
| 58 | - .justifyContent(FlexAlign.Center) | ||
| 59 | - .margin({top: 5}) | ||
| 60 | - } | ||
| 61 | - } | ||
| 62 | - .width(CommonConstants.FULL_WIDTH) | ||
| 63 | - .padding({ | ||
| 64 | - top: 14, | ||
| 65 | - left: 16, | ||
| 66 | - right: 16, | ||
| 67 | - bottom: 14 | ||
| 68 | - }) | ||
| 69 | - .backgroundColor($r("app.color.white")) | ||
| 70 | - .margin({ bottom: 8 }) | ||
| 71 | - .onClick((event: ClickEvent) => { | ||
| 72 | - ProcessUtils.processPage(this.compDTO?.operDataList[0]) | ||
| 73 | - }) | ||
| 74 | - } | ||
| 75 | - | ||
| 76 | - @Builder timelineItem (item:slideShows, index:number) { | ||
| 77 | - Column(){ | ||
| 78 | - Stack() { | ||
| 79 | - if(index < this.compDTO.operDataList[0].slideShows.length - 1) { | ||
| 80 | - Divider() | ||
| 81 | - .vertical(true) | ||
| 82 | - .color($r('app.color.color_EDEDED')) | ||
| 83 | - .strokeWidth(1) | ||
| 84 | - .margin({top: index > 0 ? 0 : 16, left: 4}) | ||
| 85 | - } | ||
| 86 | - if(index > 0 && index == this.compDTO.operDataList[0].slideShows.length - 1) { | ||
| 87 | - Divider() | ||
| 88 | - .vertical(true) | ||
| 89 | - .color($r('app.color.color_EDEDED')) | ||
| 90 | - .strokeWidth(1) | ||
| 91 | - .height(16) | ||
| 92 | - .margin({left: 4}) | ||
| 93 | - } | ||
| 94 | - | ||
| 95 | - Column(){ | ||
| 96 | - Row() { | ||
| 97 | - // 标题 | ||
| 98 | - Image($r("app.media.point_icon")) | ||
| 99 | - .width(9) | ||
| 100 | - .height(9) | ||
| 101 | - .margin({ right: 5 }) | ||
| 102 | - Text(DateTimeUtils.formatDate(item.publishTime, "MM月dd日 HH:mm")) | ||
| 103 | - .fontSize($r('app.float.font_size_12')) | ||
| 104 | - .fontColor($r('app.color.color_222222')) | ||
| 105 | - .fontWeight(600) | ||
| 106 | - } | ||
| 107 | - .width(CommonConstants.FULL_WIDTH) | ||
| 108 | - .height(32) | ||
| 109 | - .alignItems(VerticalAlign.Center) | ||
| 110 | - Row() { | ||
| 111 | - Text(item.newsTitle) | ||
| 112 | - .fontSize($r('app.float.font_size_17')) | ||
| 113 | - .fontWeight(400) | ||
| 114 | - .fontColor($r('app.color.color_222222')) | ||
| 115 | - .layoutWeight(1) | ||
| 116 | - .maxLines(2) | ||
| 117 | - .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 118 | - .alignSelf(ItemAlign.Center) | ||
| 119 | - .margin({left: 12}) | ||
| 120 | - if(item.fullColumnImgUrls[0] && item.fullColumnImgUrls[0].url) { | ||
| 121 | - Image(item.fullColumnImgUrls[0].url) | ||
| 122 | - .width(90) | ||
| 123 | - .height(60) | ||
| 124 | - .borderRadius($r('app.float.image_border_radius')) | ||
| 125 | - } | ||
| 126 | - } | ||
| 127 | - } | ||
| 128 | - } | ||
| 129 | - .alignContent(Alignment.TopStart) | ||
| 130 | - } | ||
| 131 | - .height(item.fullColumnImgUrls[0] && item.fullColumnImgUrls[0].url ? 100 : 78) | ||
| 132 | - .alignItems(HorizontalAlign.Start) | ||
| 133 | - } | ||
| 134 | -} |
| 1 | -import { CompDTO, ContentDTO, slideShows } from 'wdBean'; | ||
| 2 | -import { CommonConstants } from 'wdConstant' | ||
| 3 | -import { DateTimeUtils } from 'wdKit'; | ||
| 4 | -import { ProcessUtils } from '../../utils/ProcessUtils'; | ||
| 5 | - | ||
| 6 | - | ||
| 7 | -/** | ||
| 8 | - * 大专题卡--CompStyle: 10 | ||
| 9 | - */ | ||
| 10 | -@Component | ||
| 11 | -export struct CompStyle_10 { | ||
| 12 | - @State compDTO: CompDTO = {} as CompDTO | ||
| 13 | - | ||
| 14 | - build() { | ||
| 15 | - Column(){ | ||
| 16 | - // 顶部标题,最多两行 | ||
| 17 | - if(this.compDTO.operDataList[0].newsTitle) { | ||
| 18 | - Text(this.compDTO.operDataList[0].newsTitle) | ||
| 19 | - .width(CommonConstants.FULL_WIDTH) | ||
| 20 | - .fontSize($r('app.float.font_size_17')) | ||
| 21 | - .fontWeight(600) | ||
| 22 | - .maxLines(2) | ||
| 23 | - .textOverflow({overflow: TextOverflow.Ellipsis}) | ||
| 24 | - .margin({ bottom: 19 }) | ||
| 25 | - } | ||
| 26 | - // 大图 | ||
| 27 | - Stack(){ | ||
| 28 | - Image(this.compDTO.operDataList[0] && this.compDTO.operDataList[0].coverUrl) | ||
| 29 | - .width('100%') | ||
| 30 | - .borderRadius({topLeft: $r('app.float.image_border_radius'), topRight: $r('app.float.image_border_radius')}) | ||
| 31 | - .onClick((event: ClickEvent) => { | ||
| 32 | - ProcessUtils.processPage(this.compDTO?.operDataList[0]) | ||
| 33 | - }) | ||
| 34 | - Text('专题') | ||
| 35 | - .fontSize($r('app.float.font_size_12')) | ||
| 36 | - .padding({left: 8, right: 8, top: 3, bottom: 3}) | ||
| 37 | - .backgroundColor(Color.Red) | ||
| 38 | - .fontColor(Color.White) | ||
| 39 | - .borderRadius($r('app.float.button_border_radius')) | ||
| 40 | - .margin({left: 5, bottom: 5}) | ||
| 41 | - }.alignContent(Alignment.BottomStart) | ||
| 42 | - // 专题列表--后端返回三个, | ||
| 43 | - Column(){ | ||
| 44 | - ForEach(this.compDTO.operDataList[0].slideShows, (item:slideShows, index:number) => { | ||
| 45 | - this.timelineItem(item, index) | ||
| 46 | - }) | ||
| 47 | - } | ||
| 48 | - // 底部-查看更多。根据接口返回的isMore判断是否显示查看更多 | ||
| 49 | - if(this.compDTO.operDataList[0].hasMore == 1) { | ||
| 50 | - Row() { | ||
| 51 | - Text("查看更多") | ||
| 52 | - .fontSize($r("app.float.font_size_14")) | ||
| 53 | - .fontColor($r("app.color.color_222222")) | ||
| 54 | - .margin({ right: 1 }) | ||
| 55 | - Image($r("app.media.more")) | ||
| 56 | - .width(14) | ||
| 57 | - .height(14) | ||
| 58 | - } | ||
| 59 | - .backgroundColor($r('app.color.color_F5F5F5')) | ||
| 60 | - .width(CommonConstants.FULL_WIDTH) | ||
| 61 | - .height(40) | ||
| 62 | - .borderRadius($r('app.float.button_border_radius')) | ||
| 63 | - .justifyContent(FlexAlign.Center) | ||
| 64 | - .margin({top: 5}) | ||
| 65 | - .onClick((event: ClickEvent) => { | ||
| 66 | - ProcessUtils.processPage(this.compDTO?.operDataList[0]) | ||
| 67 | - }) | ||
| 68 | - } | ||
| 69 | - } | ||
| 70 | - .width(CommonConstants.FULL_WIDTH) | ||
| 71 | - .padding({ | ||
| 72 | - top: 14, | ||
| 73 | - left: 16, | ||
| 74 | - right: 16, | ||
| 75 | - bottom: 14 | ||
| 76 | - }) | ||
| 77 | - .backgroundColor($r("app.color.white")) | ||
| 78 | - .margin({ bottom: 8 }) | ||
| 79 | - } | ||
| 80 | - @Builder timelineItem (item:slideShows, index:number) { | ||
| 81 | - Row() { | ||
| 82 | - Column(){ | ||
| 83 | - Text(item.newsTitle) | ||
| 84 | - .fontSize($r('app.float.font_size_17')) | ||
| 85 | - .fontWeight(400) | ||
| 86 | - .fontColor($r('app.color.color_222222')) | ||
| 87 | - .maxLines(2) | ||
| 88 | - .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 89 | - Row(){ | ||
| 90 | - // 展示发稿人 | ||
| 91 | - if(item.source) { | ||
| 92 | - Text(item.source) | ||
| 93 | - .fontSize($r('app.float.font_size_12')) | ||
| 94 | - .fontColor($r('app.color.color_B0B0B0')) | ||
| 95 | - .textOverflow({overflow: TextOverflow.Ellipsis}) | ||
| 96 | - .maxLines(1) | ||
| 97 | - .width(item.source.length > 10 ? '60%' : '') | ||
| 98 | - | ||
| 99 | - Image($r('app.media.point')) | ||
| 100 | - .width(16) | ||
| 101 | - .height(16) | ||
| 102 | - } | ||
| 103 | - Text(DateTimeUtils.getCommentTime(Number.parseFloat(String(item.publishTime)))) | ||
| 104 | - .fontSize($r("app.float.font_size_12")) | ||
| 105 | - .fontColor($r("app.color.color_B0B0B0")) | ||
| 106 | - } | ||
| 107 | - .margin({top: 12}) | ||
| 108 | - } | ||
| 109 | - .layoutWeight(1) | ||
| 110 | - .alignItems(HorizontalAlign.Start) | ||
| 111 | - | ||
| 112 | - // 右侧图片 | ||
| 113 | - if(item.fullColumnImgUrls[0] && item.fullColumnImgUrls[0].url) { | ||
| 114 | - Image(item.fullColumnImgUrls[0].url) | ||
| 115 | - .width(117) | ||
| 116 | - .height(78) | ||
| 117 | - .objectFit(ImageFit.Cover) | ||
| 118 | - .borderRadius($r('app.float.image_border_radius')) | ||
| 119 | - .margin({left: 12}) | ||
| 120 | - } | ||
| 121 | - } | ||
| 122 | - .padding({top: 10, bottom: 10}) | ||
| 123 | - .onClick((event: ClickEvent) => { | ||
| 124 | - const str: string = JSON.stringify(this.compDTO.operDataList[0]); | ||
| 125 | - const data: ContentDTO = JSON.parse(str) | ||
| 126 | - data.objectId = item.newsId | ||
| 127 | - data.relId = item.relId | ||
| 128 | - data.objectType = String(item.objectType) | ||
| 129 | - ProcessUtils.processPage(data) | ||
| 130 | - }) | ||
| 131 | - } | ||
| 132 | -} |
sight_harmony/features/wdComponent/src/main/ets/components/view/HeadPictureCardComponent.ets
deleted
100644 → 0
| 1 | -import { CompDTO } from 'wdBean'; | ||
| 2 | -import { CommonConstants } from 'wdConstant'; | ||
| 3 | -import { ProcessUtils } from '../../utils/ProcessUtils'; | ||
| 4 | - | ||
| 5 | -@Component | ||
| 6 | -export struct HeadPictureCardComponent { | ||
| 7 | - @State compDTO: CompDTO = {} as CompDTO | ||
| 8 | - | ||
| 9 | - build() { | ||
| 10 | - Stack() { | ||
| 11 | - Image(this.compDTO.operDataList[0].coverUrl) | ||
| 12 | - .width(CommonConstants.FULL_WIDTH) | ||
| 13 | - .autoResize(true) | ||
| 14 | - .borderRadius($r('app.float.image_border_radius')) | ||
| 15 | - if (this.compDTO.operDataList[0].newsTitle) { | ||
| 16 | - Row() | ||
| 17 | - .width(CommonConstants.FULL_WIDTH) | ||
| 18 | - .height(59) | ||
| 19 | - .linearGradient({ | ||
| 20 | - colors: [ | ||
| 21 | - ['rgba(0, 0, 0, 0.0)', 0.0], ['rgba(0, 0, 0, 0.3)', 1.0] | ||
| 22 | - ] | ||
| 23 | - }) | ||
| 24 | - Row() { | ||
| 25 | - Text(this.compDTO.operDataList[0].newsTitle) | ||
| 26 | - .width(CommonConstants.FULL_WIDTH) | ||
| 27 | - .height(CommonConstants.FULL_HEIGHT) | ||
| 28 | - .fontColor(Color.White) | ||
| 29 | - .fontSize($r('app.float.normal_text_size')) | ||
| 30 | - .fontWeight(FontWeight.Bold) | ||
| 31 | - .maxLines(2) | ||
| 32 | - .align(Alignment.Bottom) | ||
| 33 | - } | ||
| 34 | - .justifyContent(FlexAlign.Start) | ||
| 35 | - .height(40) | ||
| 36 | - .margin({ left: 12, bottom: 10, right: 12 }) | ||
| 37 | - } | ||
| 38 | - } | ||
| 39 | - .alignContent(Alignment.Bottom) | ||
| 40 | - .width(CommonConstants.FULL_WIDTH) | ||
| 41 | - .padding( | ||
| 42 | - { top: 16, bottom: 16, left: 14, right: 14 }) | ||
| 43 | - .onClick((event: ClickEvent) => { | ||
| 44 | - ProcessUtils.processPage(this.compDTO?.operDataList[0]) | ||
| 45 | - }) | ||
| 46 | - } | ||
| 47 | -} |
| @@ -27,11 +27,11 @@ export struct RecommendList { | @@ -27,11 +27,11 @@ export struct RecommendList { | ||
| 27 | .width(CommonConstants.FULL_PARENT) | 27 | .width(CommonConstants.FULL_PARENT) |
| 28 | .justifyContent(FlexAlign.Start) | 28 | .justifyContent(FlexAlign.Start) |
| 29 | } | 29 | } |
| 30 | - ForEach(this.recommendList, (item: ContentDTO) => { | ||
| 31 | - Row(){ | 30 | + ForEach(this.recommendList, (item: ContentDTO, index: number) => { |
| 31 | + Row() { | ||
| 32 | CardParser({ contentDTO: item }); | 32 | CardParser({ contentDTO: item }); |
| 33 | }.border({ | 33 | }.border({ |
| 34 | - width:{bottom: 1}, | 34 | + width: { bottom: this.recommendList.length === index + 1 ? 0 : 1 }, |
| 35 | color: '#f5f5f5' | 35 | color: '#f5f5f5' |
| 36 | }) | 36 | }) |
| 37 | }, (item: ContentDTO) => JSON.stringify(item)) | 37 | }, (item: ContentDTO) => JSON.stringify(item)) |
| 1 | -import { Action, CompDTO, ContentDTO, Params } from 'wdBean'; | ||
| 2 | -import { CompStyle } from 'wdConstant'; | ||
| 3 | -import { Logger, DateTimeUtils } from 'wdKit'; | ||
| 4 | -import { WDRouterRule } from 'wdRouter'; | ||
| 5 | - | ||
| 6 | -const TAG = 'SingleImageCardAppComponent'; | ||
| 7 | -const FULL_PARENT: string = '100%'; | ||
| 8 | - | ||
| 9 | -/** | ||
| 10 | - * 单图卡-3行标题/2行标题 | ||
| 11 | - * 枚举值13 | ||
| 12 | - * | ||
| 13 | - * 重磅推荐/精选/电视剧/电影/综艺/短剧/更多>/ | ||
| 14 | - */ | ||
| 15 | -@Entry | ||
| 16 | -@Component | ||
| 17 | -export struct SingleImageCardAppComponent { | ||
| 18 | - // @State compDTO: CompDTO = {} as CompDTO | ||
| 19 | - | ||
| 20 | - @State compDTO: CompDTO = { | ||
| 21 | - operDataList: [ | ||
| 22 | - { | ||
| 23 | - coverSize: '660*371', | ||
| 24 | - coverType: 1, | ||
| 25 | - visitorComment: 10, | ||
| 26 | - coverUrl: 'https://cdnjdphoto.aikan.pdnews.cn/zhbj-20240116/image/content/a9028e7011bb440e94ba7c63d80b39b7.png?x-oss-process=image/resize,w_550/quality,q_90/format,jpg', | ||
| 27 | - newsTitle: '一条江豚的自述', | ||
| 28 | - newsSummary: '我是生活在长江里的一头江豚,是长江中唯一的水生哺乳动物,更是国家一级保护动物。但曾几何时,我和我的江中小伙伴出现了生存危机……直到有一天,我突然发现,打渔人变成护渔人,江水变清澈了,长江逐渐恢复了生机,我的家族数量上升到了1249头。当长江之水再一次悠悠流淌,我们相拥在清澈波光中起舞。长江,我的家园。', | ||
| 29 | - videoInfo: { | ||
| 30 | - // clarity: 1, | ||
| 31 | - resolutionHeight: 20, | ||
| 32 | - resolutionWidth: 20, | ||
| 33 | - videoDuration: 229, | ||
| 34 | - videoLandScape: 1, | ||
| 35 | - videoType: 1, | ||
| 36 | - videoUrl: "https://cdnjdout.aikan.pdnews.cn/zhbj-20240116/vod/content/output/c72f4170db2c4d34befa453f60d39a69_opt.mp4", | ||
| 37 | - firstFrameImageUri: "", // 首帧图;【视频内容,contentPictures中】 | ||
| 38 | - }, | ||
| 39 | - | ||
| 40 | - } as ContentDTO | ||
| 41 | - ] | ||
| 42 | - } as CompDTO | ||
| 43 | - | ||
| 44 | - aboutToAppear() { | ||
| 45 | - } | ||
| 46 | - | ||
| 47 | - build() { | ||
| 48 | - Column() { | ||
| 49 | - Text(this.compDTO.operDataList[0].newsTitle) | ||
| 50 | - .fontSize(16) | ||
| 51 | - .fontWeight(FontWeight.Bold) | ||
| 52 | - .alignSelf(ItemAlign.Start) | ||
| 53 | - .maxLines(3) | ||
| 54 | - .textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。 | ||
| 55 | - if (this.compDTO.operDataList[0].coverUrl) { | ||
| 56 | - Stack() { | ||
| 57 | - Image(this.compDTO.operDataList[0].coverUrl) | ||
| 58 | - .borderRadius(5) | ||
| 59 | - .aspectRatio(16 / 9) | ||
| 60 | - .padding({ top: 10 }) | ||
| 61 | - if (this.compDTO.operDataList[0].videoInfo) { | ||
| 62 | - Row() { | ||
| 63 | - Image($r('app.media.iv_card_play_yellow_flag')) | ||
| 64 | - .width(22) | ||
| 65 | - .height(18) | ||
| 66 | - Text(DateTimeUtils.getFormattedDuration(this.compDTO.operDataList[0].videoInfo.videoDuration * 1000)) | ||
| 67 | - .fontSize($r('app.float.font_size_13')) | ||
| 68 | - .fontWeight(400) | ||
| 69 | - .fontColor($r('app.color.color_fff')) | ||
| 70 | - } | ||
| 71 | - .alignItems(VerticalAlign.Bottom) | ||
| 72 | - .height(18) | ||
| 73 | - .padding({ right: 4 }) | ||
| 74 | - .margin({ | ||
| 75 | - right: 4, | ||
| 76 | - bottom: 4 | ||
| 77 | - }) | ||
| 78 | - .backgroundColor($r('app.color.color_4d000000')) | ||
| 79 | - } | ||
| 80 | - }.alignContent(Alignment.BottomEnd) | ||
| 81 | - } | ||
| 82 | - if (this.compDTO.operDataList[0].newsSummary) { | ||
| 83 | - Text(this.compDTO.operDataList[0].newsSummary) | ||
| 84 | - .fontSize(14) | ||
| 85 | - .padding({ top: 10 }) | ||
| 86 | - .alignSelf(ItemAlign.Start) | ||
| 87 | - .maxLines(3) | ||
| 88 | - .textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。 | ||
| 89 | - } | ||
| 90 | - Row() { | ||
| 91 | - Text(this.compDTO.operDataList[0].visitorComment + "评") | ||
| 92 | - .fontSize(12) | ||
| 93 | - .fontColor(Color.Gray) | ||
| 94 | - Image($r('app.media.icon_share')) | ||
| 95 | - .width(16) | ||
| 96 | - .height(16) | ||
| 97 | - .margin(10) | ||
| 98 | - }.width(FULL_PARENT) | ||
| 99 | - .justifyContent(FlexAlign.SpaceBetween) | ||
| 100 | - } | ||
| 101 | - .margin(22) | ||
| 102 | - } | ||
| 103 | -} |
sight_harmony/features/wdComponent/src/main/ets/components/view/SingleImageCardComponent.ets
deleted
100644 → 0
| 1 | -import { Action, CompDTO, Params } from 'wdBean'; | ||
| 2 | -import { ExtraDTO } from 'wdBean/src/main/ets/bean/component/extra/ExtraDTO'; | ||
| 3 | -import { CompStyle } from 'wdConstant'; | ||
| 4 | -import { Logger, DateTimeUtils } from 'wdKit'; | ||
| 5 | -import { WDRouterRule } from 'wdRouter'; | ||
| 6 | -import { ProcessUtils } from '../../utils/ProcessUtils'; | ||
| 7 | - | ||
| 8 | -const TAG = 'SingleImageCardComponent'; | ||
| 9 | -const FULL_PARENT: string = '100%'; | ||
| 10 | - | ||
| 11 | -/** | ||
| 12 | - * 单图卡-3行标题/2行标题 | ||
| 13 | - * 枚举值13 | ||
| 14 | - * ImageCard-03 | ||
| 15 | - * 重磅推荐/精选/电视剧/电影/综艺/短剧/更多>/ | ||
| 16 | - */ | ||
| 17 | - | ||
| 18 | -@Component | ||
| 19 | -export struct SingleImageCardComponent { | ||
| 20 | - @State compDTO: CompDTO = {} as CompDTO | ||
| 21 | - | ||
| 22 | - aboutToAppear() { | ||
| 23 | - //Logger.debug(TAG + "" + JSON.stringify(this.compDTO.operDataList)); | ||
| 24 | - | ||
| 25 | - } | ||
| 26 | - | ||
| 27 | - build() { | ||
| 28 | - Row() { | ||
| 29 | - Column() { | ||
| 30 | - Column() { | ||
| 31 | - Text(this.compDTO.operDataList[0].newsTitle) | ||
| 32 | - .fontSize(16) | ||
| 33 | - .fontWeight(FontWeight.Normal) | ||
| 34 | - .maxLines(3)// | ||
| 35 | - .alignSelf(ItemAlign.Start) | ||
| 36 | - .textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。 | ||
| 37 | - }.height("80%") | ||
| 38 | - .justifyContent(FlexAlign.Start) | ||
| 39 | - | ||
| 40 | - Row() { | ||
| 41 | - if (this.compDTO.operDataList[0].source) { | ||
| 42 | - Text(this.compDTO.operDataList[0].source) | ||
| 43 | - .fontSize($r('app.float.font_size_12')) | ||
| 44 | - .fontColor(Color.Gray) | ||
| 45 | - .maxLines(1) | ||
| 46 | - .textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。 | ||
| 47 | - .width(this.compDTO.operDataList[0].source.length > 8 ? '50%' : '') | ||
| 48 | - Image($r('app.media.point')) | ||
| 49 | - .width(16) | ||
| 50 | - .height(16) | ||
| 51 | - } | ||
| 52 | - if (this.compDTO.operDataList[0].publishTime && this.compDTO.operDataList[0].publishTime.length === 13) { | ||
| 53 | - Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.compDTO.operDataList[0].publishTime))) | ||
| 54 | - .fontSize($r('app.float.font_size_12')) | ||
| 55 | - .fontColor(Color.Gray) | ||
| 56 | - } | ||
| 57 | - Text(this.compDTO.operDataList[0].visitorComment + '评') | ||
| 58 | - .fontSize($r('app.float.font_size_12')) | ||
| 59 | - .fontColor(Color.Gray) | ||
| 60 | - .padding({ | ||
| 61 | - left: 5 | ||
| 62 | - }) | ||
| 63 | - }.alignSelf(ItemAlign.Start) | ||
| 64 | - .height("20%") | ||
| 65 | - .justifyContent(FlexAlign.Start) | ||
| 66 | - } | ||
| 67 | - .alignItems(HorizontalAlign.Start) | ||
| 68 | - .justifyContent(FlexAlign.Start) | ||
| 69 | - .width('58%') | ||
| 70 | - | ||
| 71 | - Blank(16) | ||
| 72 | - if (this.compDTO.operDataList[0].coverUrl) { | ||
| 73 | - Stack() { | ||
| 74 | - Image(this.compDTO.operDataList[0].coverUrl) | ||
| 75 | - .borderRadius(5) | ||
| 76 | - .aspectRatio(this.compDTO.compStyle === CompStyle.Card_13 ? 3 / 2 : 3 / 4) | ||
| 77 | - .height(this.compDTO.compStyle === CompStyle.Card_13 ? 90 : 180) | ||
| 78 | - if (this.compDTO.operDataList[0].videoInfo) { | ||
| 79 | - Row() { | ||
| 80 | - Image($r('app.media.iv_card_play_yellow_flag')) | ||
| 81 | - .width(22) | ||
| 82 | - .height(18) | ||
| 83 | - Text(DateTimeUtils.getFormattedDuration(this.compDTO.operDataList[0].videoInfo.videoDuration * 1000)) | ||
| 84 | - .fontSize($r('app.float.font_size_13')) | ||
| 85 | - .fontWeight(400) | ||
| 86 | - .fontColor($r('app.color.color_fff')) | ||
| 87 | - } | ||
| 88 | - .alignItems(VerticalAlign.Bottom) | ||
| 89 | - .height(18) | ||
| 90 | - .padding({ right: 4 }) | ||
| 91 | - .margin({ | ||
| 92 | - right: 4, | ||
| 93 | - bottom: 4 | ||
| 94 | - }) | ||
| 95 | - .backgroundColor($r('app.color.color_4d000000')) | ||
| 96 | - } else if(this.compDTO.operDataList[0].voiceInfo) { | ||
| 97 | - Row() { | ||
| 98 | - Image($r('app.media.icon_listen')) | ||
| 99 | - .width(22) | ||
| 100 | - .height(18) | ||
| 101 | - Text(DateTimeUtils.getFormattedDuration(this.compDTO.operDataList[0].voiceInfo | ||
| 102 | - .voiceDuration * 1000)) | ||
| 103 | - .fontSize($r('app.float.font_size_13')) | ||
| 104 | - .fontWeight(400) | ||
| 105 | - .fontColor($r('app.color.color_fff')) | ||
| 106 | - } | ||
| 107 | - .alignItems(VerticalAlign.Bottom) | ||
| 108 | - .height(18) | ||
| 109 | - .padding({ right: 4 }) | ||
| 110 | - .margin({ | ||
| 111 | - right: 4, | ||
| 112 | - bottom: 4 | ||
| 113 | - }) | ||
| 114 | - .backgroundColor($r('app.color.color_4d000000')) | ||
| 115 | - } | ||
| 116 | - }.alignContent(Alignment.BottomEnd) | ||
| 117 | - } | ||
| 118 | - } | ||
| 119 | - .onClick((event: ClickEvent) => { | ||
| 120 | - ProcessUtils.processPage(this.compDTO?.operDataList[0]) | ||
| 121 | - }) | ||
| 122 | - .padding( | ||
| 123 | - { top: 16, bottom: 16, left: 14, right: 14 }) | ||
| 124 | - .width(FULL_PARENT) | ||
| 125 | - .height(this.compDTO.compStyle === CompStyle.Card_13 ? 127 : 217) | ||
| 126 | - .justifyContent(FlexAlign.SpaceBetween) | ||
| 127 | - } | ||
| 128 | -} |
-
Please register or login to post a comment