张善主

Merge remote-tracking branch 'origin/main'

Showing 68 changed files with 2098 additions and 1530 deletions

Too many changes to show.

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

... ... @@ -11,8 +11,13 @@ export class SpConstants{
static USER_TEMP_TOKEN="tempToken"
static USER_PHONE = "user_phone"
//协议相关
static USER_PROTOCOL = "user_protocol" //用户协议
static PRIVATE_PROTOCOL = "private_protocol" //隐私协议
static NET_SERVICE_PROTOCOL = "user_protocol" //人民日报客户端网络服务使用协议
static PRIVATE_PROTOCOL = "private_protocol" //人民日报客户端用户隐私协议
static LOGOUT_PROTOCOL = "logout_protocol" //人民日报客户端app注销协议
static MESSAGE_BOARD_USER_PROTOCOL = "message_board_user_protocol" //"留言板-用户协议"
static MESSAGE_BOARD_NOTICE_PROTOCOL = "message_board_notice_protocol" //留言板-留言须知
static MESSAGE_BOARD_QUESTION_PROTOCOL = "message_board_question_protocol" //"留言板-发布提问规定""
static MESSAGE_BOARD_PRIVATE_PROTOCOL = "message_board_private_protocol" //"留言板-隐私政策"
//设置页面
static SETTING_WIFI_IMAGE_SWITCH = "setting_wifi_switch" //wifi 图片开关
static SETTING_WIFI_VIDEO_SWITCH = "setting_wifi_switch" //wifi 视频开关
... ...
/**
* https://developer.huawei.com/consumer/cn/doc/harmonyos-references/js-apis-window-0000001820880785#ZH-CN_TOPIC_0000001811317218__systembarproperties
* 状态栏、导航栏的属性。
*/
/**
* 状态栏背景颜色 statusBarColor
* 导航栏背景颜色 navigationBarColor
*/
export const enum SysStatusBarColor {
WHITE = '#ffffff',
BLACK = '#000000',
DEFAULT = '#0x66000000'
}
/**
* 状态栏文字颜色 statusBarContentColor8
* 导航栏文字颜色 navigationBarContentColor8
*/
export const enum SysBarContentColor {
WHITE = '#ffffff',
BLACK = '#000000',
DEFAULT = '0xE5FFFFFF'
}
... ...
import { Action } from './Action';
interface dataObject {
webViewHeight?: string
dataJson?: string
}
/**
* 消息Message
*/
... ... @@ -7,7 +10,7 @@ export class Message {
callbackId: string = ""; //callbackId
responseId: string = ""; //responseId
responseData: string = ""; //responseData
data?: object; //data of message
data?: dataObject; //data of message
handlerName: string = ""; //name of handler
/**
... ...
... ... @@ -36,7 +36,7 @@ export { UserDataLocal } from './src/main/ets/utils/UserDataLocal'
export { NumberFormatterUtils } from './src/main/ets/utils/NumberFormatterUtils'
// export { PermissionUtils } from './src/main/ets/utils/PermissionUtils'
export { PermissionUtils } from './src/main/ets/utils/PermissionUtils'
export { ErrorToastUtils } from './src/main/ets/utils/ErrorToastUtils'
... ...
import emitter from '@ohos.events.emitter';
import HashMap from '@ohos.util.HashMap';
const TAG: string = 'EmitterUtils';
/**
* 线程间通信简单工具
* TODO 待优化
*/
export class EmitterUtils {
/**
... ... @@ -23,15 +21,17 @@ export class EmitterUtils {
/**
* 发送消息
* @param eventId 事件id
* @param data 数据
* @param str 字符串数据
*/
static sendEvent(eventId: number, data: { [key: string]: any; }) {
static sendEvent(eventId: number, str?: string) {
let event: emitter.InnerEvent = {
eventId: eventId,
priority: emitter.EventPriority.LOW
};
let eventData: emitter.EventData = {
data: data
data: {
jsonStr: str
}
};
emitter.emit(event, eventData);
}
... ... @@ -41,18 +41,29 @@ export class EmitterUtils {
* @param eventId 事件id
* @param callback 回调函数
*/
static receiveEvent(eventId: number, callback: (data?: { [key: string]: any; }) => void) {
static receiveEvent(eventId: number, callback: (str?: string) => void) {
let event: emitter.InnerEvent = {
eventId: eventId
};
// 收到eventId为1的事件后执行该回调
let callback1 = (eventData: emitter.EventData): void => {
callback(eventData.data)
// 收到eventId事件后执行该回调
let callback1 = (eventData?: emitter.EventData): void => {
if (eventData && eventData.data) {
try {
let jsonObject: EmitterBean = JSON.parse(JSON.stringify(eventData.data))
callback(jsonObject.jsonStr)
} catch (err) {
callback()
}
} else {
callback()
}
};
// 订阅eventId为1的事件
// 订阅eventId事件
emitter.on(event, callback1);
}
}
interface EmitterBean {
jsonStr: string
}
... ...
... ... @@ -7,7 +7,17 @@ export namespace ErrorToastUtils {
NET_CORE_PAGE_ERROR_NETWORK, //网络出小差了,请检查网络后重试
NET_CORE_LOAD_ERROR_NETWORK, //加载失败,请重试
NET_CORE_ENTER_ERROR_NETWORK, //很抱歉,当前内容无法加载,请点击重试
LIVE_CORE_NO_NETWORK, //网络出小差了,请检查下网络
//直播异常
LIVE_CORE_NO_NETWORK, //直播 无网络 网络出小差了,请检查下网络
LIVE_CORE_WEAK_NETWORK, //直播 弱网 网络出小差了,请检查下网络
LIVE_CORE_IO_NETWORK, //直播 直播流异常 直播加载异常
LIVE_CORE_SERVICE_NETWORK, //直播 服务端接口异常 直播加载异常
LIVE_CORE_SWITCH_FLOW_NETWORK, //直播 网络切换到流量 正在使用流量,请注意流量使用
//审核后异常报错
AUDITING_CORE_CONTENT_DISTRIBUTE, //审核 内容分发下线规则 内容已下线
AUDITING_CORE_ACCOUNT_ERROR, //审核 账号有问题下线规则 内容已下线
}
... ... @@ -32,6 +42,27 @@ export namespace ErrorToastUtils {
case ErrorType.LIVE_CORE_NO_NETWORK:
ToastUtils.shortToast($r('app.string.live_core_no_network'))
break
case ErrorType.LIVE_CORE_WEAK_NETWORK:
ToastUtils.shortToast($r('app.string.live_core_weak_network'))
break
case ErrorType.LIVE_CORE_IO_NETWORK:
ToastUtils.shortToast($r('app.string.live_core_io_network'))
break
case ErrorType.LIVE_CORE_SERVICE_NETWORK:
ToastUtils.shortToast($r('app.string.live_core_service_network'))
break
case ErrorType.LIVE_CORE_SWITCH_FLOW_NETWORK:
ToastUtils.shortToast($r('app.string.live_core_switch_flow_network'))
break
case ErrorType.LIVE_CORE_SWITCH_FLOW_NETWORK:
ToastUtils.shortToast($r('app.string.live_core_switch_flow_network'))
break
case ErrorType.AUDITING_CORE_CONTENT_DISTRIBUTE:
ToastUtils.shortToast($r('app.string.auditing_core_error'))
break
case ErrorType.AUDITING_CORE_ACCOUNT_ERROR:
ToastUtils.shortToast($r('app.string.auditing_core_error'))
break
}
}
... ...
// import { abilityAccessCtrl, bundleManager, common, Permissions, Want } from '@kit.AbilityKit'
// import { BusinessError } from '@kit.BasicServicesKit'
// import { AppUtils } from './AppUtils'
// import { Logger } from './Logger'
//
// /**
// * 权限工具类
// * */
// export class PermissionUtils {
// //相机权限
// static CAMERA: Permissions = 'ohos.permission.CAMERA'
// //文件权限
// static READ_MEDIA: Permissions = 'ohos.permission.READ_MEDIA'
// static WRITE_MEDIA: Permissions = 'ohos.permission.WRITE_MEDIA'
// private static tokenId: number = 0
//
// /**检查权限是否授权*/
// static async checkPermissions(permission: Permissions): Promise<boolean> {
// let hasPermissions = false;
// let grantStatus: abilityAccessCtrl.GrantStatus = await PermissionUtils.checkAccessToken(permission);
//
// if (grantStatus === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) {
// // 已经授权,可以继续访问目标操作
// hasPermissions = true;
// } else {
// hasPermissions = false;
// // 申请日历权限
// }
// return hasPermissions;
// }
//
// /**动态申请权限*/
// static reqPermissionsFromUser(permissions: Array<Permissions>, component: Object): Promise<boolean> {
//
// return new Promise((resolve, fail) => {
// let context = getContext(component) as common.UIAbilityContext;
// let atManager = abilityAccessCtrl.createAtManager();
// atManager.requestPermissionsFromUser(context, permissions).then((data) => {
// let grantStatus: Array<number> = data.authResults;
// let length: number = grantStatus.length;
//
// for (let i = 0; i < length; i++) {
// if (grantStatus[i] === 0) {
// // 用户授权,可以继续访问目标操作
// resolve(true);
// } else {
// resolve(false)
// }
// }
// }).catch((err: Error) => {
// fail(err)
// })
// });
// }
//
// /**跳转设置页面*/
// static openPermissionsInSystemSettings(context: Object): void {
// let uiContext = getContext(context) as common.UIAbilityContext;
// let wantInfo: Want = {
// bundleName: 'com.huawei.hmos.settings',
// abilityName: 'com.huawei.hmos.settings.MainAbility',
// uri: 'application_info_entry',
// parameters: {
// pushParams: AppUtils.getPackageName(uiContext) // 打开指定应用的设置页面
// }
// }
// uiContext.startAbility(wantInfo)
// }
//
// private static async checkAccessToken(permission: Permissions): Promise<abilityAccessCtrl.GrantStatus> {
// let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager();
// let grantStatus: abilityAccessCtrl.GrantStatus = abilityAccessCtrl.GrantStatus.PERMISSION_DENIED;
//
// // 获取应用程序的accessTokenID
// if (PermissionUtils.tokenId == 0) {
// try {
// let bundleInfo: bundleManager.BundleInfo = await bundleManager.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION);
// let appInfo: bundleManager.ApplicationInfo = bundleInfo.appInfo;
// PermissionUtils.tokenId = appInfo.accessTokenId;
// } catch (error) {
// const err: BusinessError = error as BusinessError;
// }
// }
// // 校验应用是否被授予权限
// try {
// grantStatus = await atManager.checkAccessToken(PermissionUtils.tokenId, permission);
// } catch (error) {
// const err: BusinessError = error as BusinessError;
// }
//
// return grantStatus;
// }
//
// }
\ No newline at end of file
import { abilityAccessCtrl, bundleManager, common, Permissions, Want } from '@kit.AbilityKit'
import { BusinessError } from '@kit.BasicServicesKit'
import { AppUtils } from './AppUtils'
import { Logger } from './Logger'
/**
* 权限工具类
* */
export class PermissionUtils {
//相机权限
static CAMERA: Permissions = 'ohos.permission.CAMERA'
//文件权限
static READ_MEDIA: Permissions = 'ohos.permission.READ_MEDIA'
static WRITE_MEDIA: Permissions = 'ohos.permission.WRITE_MEDIA'
private static tokenId: number = 0
/**检查权限是否授权*/
static async checkPermissions(permission: Permissions): Promise<boolean> {
let hasPermissions = false;
let grantStatus: abilityAccessCtrl.GrantStatus = await PermissionUtils.checkAccessToken(permission);
if (grantStatus === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) {
// 已经授权,可以继续访问目标操作
hasPermissions = true;
} else {
hasPermissions = false;
// 申请日历权限
}
return hasPermissions;
}
/**动态申请权限*/
static reqPermissionsFromUser(permissions: Array<Permissions>, component: Object): Promise<boolean> {
return new Promise((resolve, fail) => {
let context = getContext(component) as common.UIAbilityContext;
let atManager = abilityAccessCtrl.createAtManager();
atManager.requestPermissionsFromUser(context, permissions).then((data) => {
let grantStatus: Array<number> = data.authResults;
let length: number = grantStatus.length;
for (let i = 0; i < length; i++) {
if (grantStatus[i] === 0) {
// 用户授权,可以继续访问目标操作
resolve(true);
} else {
resolve(false)
}
}
}).catch((err: Error) => {
fail(err)
})
});
}
/**跳转设置页面*/
static openPermissionsInSystemSettings(context: Object): void {
let uiContext = getContext(context) as common.UIAbilityContext;
let wantInfo: Want = {
bundleName: 'com.huawei.hmos.settings',
abilityName: 'com.huawei.hmos.settings.MainAbility',
uri: 'application_info_entry',
parameters: {
pushParams: AppUtils.getPackageName(uiContext) // 打开指定应用的设置页面
}
}
uiContext.startAbility(wantInfo)
}
private static async checkAccessToken(permission: Permissions): Promise<abilityAccessCtrl.GrantStatus> {
let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager();
let grantStatus: abilityAccessCtrl.GrantStatus = abilityAccessCtrl.GrantStatus.PERMISSION_DENIED;
// 获取应用程序的accessTokenID
if (PermissionUtils.tokenId == 0) {
try {
let bundleInfo: bundleManager.BundleInfo = await bundleManager.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION);
let appInfo: bundleManager.ApplicationInfo = bundleInfo.appInfo;
PermissionUtils.tokenId = appInfo.accessTokenId;
} catch (error) {
const err: BusinessError = error as BusinessError;
}
}
// 校验应用是否被授予权限
try {
grantStatus = await atManager.checkAccessToken(PermissionUtils.tokenId, permission);
} catch (error) {
const err: BusinessError = error as BusinessError;
}
return grantStatus;
}
}
\ No newline at end of file
... ...
import window from '@ohos.window';
import { BusinessError } from '@ohos.base';
import { AsyncCallback, BusinessError } from '@ohos.base';
import deviceInfo from '@ohos.deviceInfo'
import display from '@ohos.display';
interface SystemBarProperties {
statusBarColor?: string;
isStatusBarLightIcon?: boolean;
statusBarContentColor?: string;
navigationBarColor?: string;
isNavigationBarLightIcon?: boolean;
navigationBarContentColor?: string;
}
export class Size {
width: number = 0
height: number = 0
... ... @@ -15,17 +25,23 @@ export class Size {
export class WindowModel {
private windowStage?: window.WindowStage;
private windowClass?: window.Window;
static shared: WindowModel = new WindowModel()
static TAG = "WindowModel";
setWindowStage(windowStage: window.WindowStage) {
this.windowStage = windowStage;
this.windowClass = windowStage.getMainWindowSync();
}
getWindowStage(): window.WindowStage {
return this.windowStage as window.WindowStage
}
getWindowClass(): window.Window {
return this.windowClass as window.Window
}
setMainWindowFullScreen(fullScreen: boolean) {
if (deviceInfo.deviceType != "phone") {
return
... ... @@ -103,5 +119,17 @@ export class WindowModel {
});
})
}
/**
* 设置窗口全屏模式时窗口内导航栏、状态栏的属性,使用callback异步回调。
* @param systemBarProperties
* @param callback
*/
setWindowSystemBarProperties(systemBarProperties: SystemBarProperties, callback?: AsyncCallback<void>): void {
this.windowClass?.setWindowSystemBarProperties(systemBarProperties, (err: BusinessError) => {
callback && callback(err)
})
}
}
... ...
... ... @@ -27,6 +27,26 @@
{
"name": "live_core_no_network",
"value": "网络出小差了,请检查下网络"
},
{
"name": "live_core_weak_network",
"value": "网络出小差了,请检查下网络"
},
{
"name": "live_core_io_network",
"value": "直播加载异常"
},
{
"name": "live_core_service_network",
"value": "直播加载异常"
},
{
"name": "live_core_switch_flow_network",
"value": "正在使用流量,请注意流量使用"
},
{
"name": "auditing_core_error",
"value": "内容已下线"
}
]
}
\ No newline at end of file
... ...
... ... @@ -46,6 +46,10 @@ export class HttpUrlUtils {
* 批查接口,查询互动相关数据,如收藏数、评论数等
*/
static readonly INTERACT_DATA_PATH: string = "/api/rmrb-contact/contact/zh/c/content/interactData";
/**
* 查询视频频道推荐楼层
*/
static readonly DISPLAY_REC_COMPINFO: string = "/api/rmrb-bff-display-zh/display/zh/c/rec/compInfo";
// 多图(图集)详情页
/**
* 批量查询内容当前用户点赞、收藏状态
... ... @@ -196,7 +200,6 @@ export class HttpUrlUtils {
* 搜索联想词
*/
static readonly RELATED_SEARCH_CONTENT_DATA_PATH: string = "/api/rmrb-search-api/zh/c/suggestions/";
/**
* 直播详情
*/
... ... @@ -205,7 +208,6 @@ export class HttpUrlUtils {
* 直播详情-直播间列表
*/
static readonly LIVE_LIST_PATH: string = "/api/live-center-message/zh/a/live/message/video/list";
/**
* 直播详情-大家聊列表
*/
... ... @@ -215,6 +217,10 @@ export class HttpUrlUtils {
* 搜索结果 显示tab 数
*/
static readonly SEARCH_RESULT_COUNT_DATA_PATH: string = "/api/rmrb-search-api/zh/c/count?keyword=";
/**
* 搜索结果 显示list 详情
*/
static readonly SEARCH_RESULT_LIST_DATA_PATH: string = "/api/rmrb-search-api/zh/c/search";
/**
* 早晚报列表
... ... @@ -497,13 +503,14 @@ export class HttpUrlUtils {
/*优质评论页*/
static getQualityCommentUrl() {
let url = HttpUrlUtils._hostUrl + "api/rmrb-comment/comment/zh/c/highQuality"
let url = HttpUrlUtils._hostUrl + "/api/rmrb-comment/comment/zh/c/highQuality";
return url
}
/*获取详情页评论列表*/
static getContentCommentListDataUrl() {
let url = HttpUrlUtils._hostUrl + "api/rmrb-comment/comment/zh/c/contentCommentList"
let url = HttpUrlUtils._hostUrl + "/api/rmrb-comment/comment/zh/c/contentCommentList"
return url
}
... ... @@ -520,6 +527,12 @@ export class HttpUrlUtils {
return url;
}
//获取用户安全页信息
static querySecurity() {
let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-center/user/zh/c/security/query";
return url;
}
static getAppointmentListDataUrl() {
let url = HttpUrlUtils._hostUrl + HttpUrlUtils.APPOINTMENT_LIST_DATA_PATH
return url
... ... @@ -645,6 +658,16 @@ export class HttpUrlUtils {
return url
}
static getSearchResultListDataUrl() {
let url = HttpUrlUtils._hostUrl + HttpUrlUtils.SEARCH_RESULT_LIST_DATA_PATH
return url
}
static getInteractListDataUrl() {
let url = HttpUrlUtils._hostUrl + HttpUrlUtils.INTERACT_DATA_PATH
return url
}
// static getYcgCommonHeaders(): HashMap<string, string> {
// let headers: HashMap<string, string> = new HashMap<string, string>()
//
... ...
... ... @@ -8,6 +8,8 @@ export class H5CallNativeType {
static jsCall_getAppPublicInfo = 'jsCall_getAppPublicInfo'
static jsCall_getArticleDetailBussinessData = 'jsCall_getArticleDetailBussinessData'
static jsCall_callAppService = 'jsCall_callAppService'
static jsCall_appInnerLinkMethod = 'jsCall_appInnerLinkMethod'
static jsCall_receiveH5Data = 'jsCall_receiveH5Data'
// TODO 业务自行新增类型、自行在JsBridgeBiz#performJSCallNative里添加接收分支处理。
static {
... ... @@ -15,6 +17,8 @@ export class H5CallNativeType {
H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_getAppPublicInfo)
H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_getArticleDetailBussinessData)
H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_callAppService)
H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_appInnerLinkMethod)
H5CallNativeType.JsCallTypeList.push(H5CallNativeType.jsCall_receiveH5Data)
}
}
... ...
... ... @@ -2,6 +2,9 @@ import { Callback, BridgeWebViewControl } from 'wdJsBridge';
import { Message } from 'wdJsBridge/src/main/ets/bean/Message';
import { Logger, StringUtils, } from 'wdKit';
import { H5CallNativeType } from './H5CallNativeType';
import { ContentDTO } from 'wdBean';
//TODO 这里引用了 features模块,是否考虑将跳转抽到公共模块
import { ProcessUtils } from '../../../../../../features/wdComponent/src/main/ets/utils/ProcessUtils';
const TAG = 'JsBridgeBiz'
... ... @@ -11,7 +14,7 @@ const TAG = 'JsBridgeBiz'
* @param call
*/
export function performJSCallNative(data: Message, call: Callback) {
Logger.debug(TAG, 'performJSCallNative handlerName: ' + data.handlerName + ', data: ' + data.data)
Logger.debug(TAG, 'performJSCallNative handlerName: ' + data.handlerName + ', data: ' + JSON.stringify(data.data))
switch (data.handlerName) {
case H5CallNativeType.jsCall_currentPageOperate:
break;
... ... @@ -23,6 +26,9 @@ export function performJSCallNative(data: Message, call: Callback) {
break;
case H5CallNativeType.jsCall_callAppService:
break;
case H5CallNativeType.jsCall_receiveH5Data:
handleH5Data(JSON.parse(data?.data?.dataJson || '{}'))
break;
case 'changeNativeMessage':
call("this is change Web Message")
break;
... ... @@ -50,4 +56,7 @@ function getAppPublicInfo(): string {
return result;
}
function handleH5Data(content:ContentDTO) {
ProcessUtils.processPage(content)
}
... ...
import router from '@ohos.router';
import { Action } from 'wdBean';
import { ConfigConstants } from 'wdConstant';
import { Logger } from 'wdKit';
import { BridgeHandler, BridgeUtil, BridgeWebViewControl, Callback } from 'wdJsBridge';
import { BridgeUtil, BridgeWebViewControl, Callback } from 'wdJsBridge';
import { Logger } from 'wdKit/Index';
import { performJSCallNative } from './JsBridgeBiz';
import { setDefaultNativeWebSettings } from './WebComponentUtil';
import { Message } from 'wdJsBridge/src/main/ets/bean/Message';
import { H5CallNativeType } from './H5CallNativeType';
import { Message } from 'wdJsBridge/src/main/ets/bean/Message';
const TAG = 'WdWebComponent';
const TAG = 'WdWebLocalComponent';
@Component
export struct WdWebComponent {
private webviewControl: BridgeWebViewControl = new BridgeWebViewControl()
//TODO 默认网页
webUrl: string | Resource = ConfigConstants.DETAIL_URL
/**
* 对外暴露webview的回调,能力
*/
onPageBegin: (url?: string) => void = () => {
}
onPageEnd: (url?: string) => void = () => {
}
onLoadIntercept: (url?: string) => boolean = () => {
return false
}
onHttpErrorReceive: (url?: string) => boolean = () => {
return false
}
webviewControl: BridgeWebViewControl = new BridgeWebViewControl()
@Prop backVisibility: boolean = false
@Prop webUrl: string = ''
@Prop @Watch('onReloadStateChanged') reload: number = 0
/**
* 默认【CallNative】逻辑处理
*/
private defaultPerformJSCallNative: (data: Message, f: Callback) => void = (data: Message, f: Callback) => {
performJSCallNative(data, f)
}
/**
* jsBridge的处理
*/
handleInfo: [string, BridgeHandler][] = []
backVisibility: boolean = false
defaultRegisterHandler(): void {
this.webviewControl.registerHandler("CallNative", {
handle: (data: Message, f: Callback) => {
this.defaultPerformJSCallNative(data, f)
}
});
}
build() {
Column() {
... ... @@ -72,21 +36,13 @@ export struct WdWebComponent {
.zoomAccess(false)
.horizontalScrollBarAccess(false)
.verticalScrollBarAccess(false)
.onHttpErrorReceive((event) => {
//TODO 页面加载不成功的时候处理
Logger.info(TAG, 'onHttpErrorReceive event.request.getRequestUrl:' + event?.request.getRequestUrl());
Logger.info(TAG, 'onHttpErrorReceive event.response.getResponseCode:' + event?.response.getResponseCode());
.onPageBegin((event) => {
console.log(this.webUrl,"yzl")
this.onPageBegin(event?.url);
})
.onPageEnd((event) => {
this.onPageEnd(event?.url)
})
.onPageBegin((event) => {
this.onPageBegin(event?.url);
this.registerHandlers();
setTimeout(() => {
BridgeUtil.webViewLoadLocalJs(getContext(this), this.webviewControl)
}, 200)
})
.onLoadIntercept((event) => {
let url: string = event.data.getRequestUrl().toString()
url = url.replace("%(?![0-9a-fA-F]{2})", "%25")
... ... @@ -97,30 +53,51 @@ export struct WdWebComponent {
return true
}
if (url.startsWith(BridgeUtil.YY_OVERRIDE_SCHEMA)) {
Logger.debug(TAG, 'flushMessageQueue');
this.webviewControl.flushMessageQueue()
return true
}
return this.onLoadIntercept(event.data.getRequestUrl().toString())
return this.onLoadIntercept(event.data.getRequestUrl().toString());
})
}
}
onReloadStateChanged() {
Logger.info(TAG, `onReloadStateChanged:::refresh, this.reload: ${this.reload}`);
if (this.reload > 0) {
this.webviewControl.refresh()
}
}
private registerHandlers(): void {
// 注册h5调用js相关
for (let i = 0; i < H5CallNativeType.JsCallTypeList.length; i++) {
let handleName = H5CallNativeType.JsCallTypeList[i];
console.log('handleName:', handleName)
let handle = (data: Message, f: Callback) => {
this.defaultPerformJSCallNative(data, f)
} ;
};
this.webviewControl.registerHandler(handleName, { handle: handle });
}
}
/**
* 默认【CallNative】逻辑处理
*/
private defaultPerformJSCallNative: (data: Message, f: Callback) => void = (data: Message, f: Callback) => {
performJSCallNative(data, f)
}
onPageBegin: (url?: string) => void = () => {
Logger.debug(TAG, 'onPageBegin');
this.registerHandlers();
BridgeUtil.webViewLoadLocalJs(getContext(this), this.webviewControl)
}
onPageEnd: (url?: string) => void = () => {
Logger.debug(TAG, 'onPageEnd');
}
onLoadIntercept: (url?: string) => boolean = () => {
Logger.debug(TAG, 'onLoadIntercept return false');
return false
}
onReloadStateChanged() {
Logger.info(TAG, `onReloadStateChanged:::refresh, this.reload: ${this.reload}`);
if (this.reload > 0) {
this.webviewControl.refresh()
}
}
}
... ...
... ... @@ -11,9 +11,10 @@ const TAG = 'WdWebLocalComponent';
@Component
export struct WdWebLocalComponent {
private webviewControl: BridgeWebViewControl = new BridgeWebViewControl()
backVisibility: boolean = false
webResource: Resource = {} as Resource
webviewControl: BridgeWebViewControl = new BridgeWebViewControl()
@Prop backVisibility: boolean = false
@Prop webResource: Resource = {} as Resource
@State webHeight : string = '100%'
build() {
Column() {
... ... @@ -31,19 +32,16 @@ export struct WdWebLocalComponent {
.visibility(this.backVisibility ? Visibility.Visible : Visibility.None)
Web({ src: this.webResource, controller: this.webviewControl })
.layoutMode(WebLayoutMode.FIT_CONTENT)
.domStorageAccess(true)
.databaseAccess(true)
.javaScriptAccess(true)
// .imageAccess(true)
// .onlineImageAccess(true)
// .fileAccess(true)
.imageAccess(true)
.mixedMode(MixedMode.All)
.onlineImageAccess(true)
.enableNativeEmbedMode(true)
.height(this.webHeight === '100%' ? '100%' : Number(this.webHeight))
.onPageBegin((event) => {
this.onPageBegin(event?.url);
this.registerHandlers();
setTimeout(() => {
BridgeUtil.webViewLoadLocalJs(getContext(this), this.webviewControl)
}, 200)
})
.onPageEnd((event) => {
this.onPageEnd(event?.url)
... ... @@ -72,12 +70,20 @@ export struct WdWebLocalComponent {
for (let i = 0; i < H5CallNativeType.JsCallTypeList.length; i++) {
let handleName = H5CallNativeType.JsCallTypeList[i];
let handle = (data: Message, f: Callback) => {
this.setCurrentPageOperate(data)
this.defaultPerformJSCallNative(data, f)
} ;
};
this.webviewControl.registerHandler(handleName, { handle: handle });
}
}
//webview 高度设置
private setCurrentPageOperate: (data: Message) => void = (data) => {
console.log("setCurrentPageOperate",JSON.stringify(data))
if (data.handlerName === H5CallNativeType.jsCall_currentPageOperate) {
this.webHeight = data?.data?.webViewHeight || '100%'
}
}
/**
* 默认【CallNative】逻辑处理
*/
... ... @@ -86,6 +92,10 @@ export struct WdWebLocalComponent {
}
onPageBegin: (url?: string) => void = () => {
Logger.debug(TAG, 'onPageBegin');
this.registerHandlers();
// setTimeout(() => {
BridgeUtil.webViewLoadLocalJs(getContext(this), this.webviewControl)
// }, 100)
}
onPageEnd: (url?: string) => void = () => {
Logger.debug(TAG, 'onPageEnd');
... ...
... ... @@ -69,6 +69,8 @@ export interface ContentDTO {
isSelect: boolean;
rmhInfo: RmhInfoDTO; // 人民号信息
photoNum: number;
corner: string;
rmhPlatform: number;
newTags: string;
isSearch?: boolean; // 是否是搜索的结果,区分搜索和主页的数据
}
\ No newline at end of file
... ...
... ... @@ -43,20 +43,14 @@ export { ImageAndTextWebComponent } from "./src/main/ets/components/ImageAndText
export { DetailViewModel } from "./src/main/ets/viewmodel/DetailViewModel"
export { SingleImageCardComponent } from "./src/main/ets/components/view/SingleImageCardComponent"
export { TriPicCardComponent } from "./src/main/ets/components/view/TriPicCardComponent"
export { BigPicCardComponent } from "./src/main/ets/components/view/BigPicCardComponent"
export { HeadPictureCardComponent } from "./src/main/ets/components/view/HeadPictureCardComponent"
export { ZhGridLayoutComponent } from "./src/main/ets/components/view/ZhGridLayoutComponent"
export { MultiPictureDetailPageComponent } from "./src/main/ets/components/MultiPictureDetailPageComponent"
export { AudioDetailComponent } from "./src/main/ets/components/AudioDetailComponent"
export { AudioSuspensionModel } from "./src/main/ets/viewmodel/AudioSuspensionModel"
export { BroadcastPageComponent } from "./src/main/ets/components/broadcast/BroadcastPageComponent"
export { FirstTabTopSearchComponent } from "./src/main/ets/components/search/FirstTabTopSearchComponent"
... ...
... ... @@ -12,6 +12,7 @@ import { Card17Component } from './cardview/Card17Component';
import { Card15Component } from './cardview/Card15Component';
import { Card19Component } from './cardview/Card19Component';
import { Card20Component } from './cardview/Card20Component';
import { Card21Component } from './cardview/Card21Component';
/**
* card适配器,卡片样式汇总,依据ContentDTO#appStyle
... ... @@ -52,6 +53,8 @@ export struct CardParser {
Card19Component({ contentDTO })
} else if (contentDTO.appStyle === CompStyle.Card_20) {
Card20Component({ contentDTO })
} else if (contentDTO.appStyle === CompStyle.Card_21) {
Card21Component({ contentDTO })
}
else {
// todo:组件未实现 / Component Not Implemented
... ...
... ... @@ -22,13 +22,6 @@ import { PageRepository } from '../repository/PageRepository';
const TAG = 'ImageAndTextPageComponent'
export interface OperationItem {
icon: Resource;
icon_check?: Resource;
text: string | Resource;
num?: number; // 个数
}
@Component
export struct ImageAndTextPageComponent {
scroller: Scroller = new Scroller();
... ... @@ -37,7 +30,6 @@ export struct ImageAndTextPageComponent {
@State recommendList: ContentDTO[] = []
@State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态
@State interactData: InteractDataDTO = {} as InteractDataDTO
build() {
Column() {
// 发布时间
... ... @@ -64,66 +56,28 @@ export struct ImageAndTextPageComponent {
.objectFit(ImageFit.Cover)
.margin({ top: 10 })
}
.padding({ left: 15, right: 15, })
.padding({ left: 15, right: 15 })
.backgroundColor(Color.White)
Stack({ alignContent: Alignment.Bottom }) {
List() {
//详情展示区
ListItem() {
Scroll(this.scroller) {
Column() {
ImageAndTextWebComponent({
contentDetailData: this.contentDetailData,
action: this.action,
action: this.action
})
}.width(CommonConstants.FULL_WIDTH)
.height(CommonConstants.FULL_HEIGHT)
Column() {
if (this.recommendList.length > 0) {
RecommendList({ recommendList: this.recommendList })
}
if (this.contentDetailData[0]?.openLikes === 1) {
ListItem() {
// 点赞
Row() {
Row() {
if (this.newsStatusOfUser?.likeStatus === '1') {
Image(this.contentDetailData[0]?.likesStyle === 1 ? $r('app.media.ic_like_check') : (this.contentDetailData[0]?.likesStyle === 2 ? $r('app.media.icon_prayer_active') : $r('app.media.icon_candle_active')))
.width(24)
.height(24)
.margin({ right: 5 })
} else {
Image(this.contentDetailData[0]?.likesStyle === 1 ? $r('app.media.icon_like') : (this.contentDetailData[0]?.likesStyle === 2 ? $r('app.media.icon_prayer') : $r('app.media.icon_candle')))
.width(24)
.height(24)
.margin({ right: 5 })
}
Text(`${this.interactData?.likeNum || 0}`)
.fontSize(16)
.fontColor(this.newsStatusOfUser?.likeStatus === '1' ? '#ED2800' : '#999999')
.fontWeight(500)
}.alignItems(VerticalAlign.Center)
.onClick(() => {
this.toggleLikeStatus()
})
}.width(CommonConstants.FULL_WIDTH).height(80)
.justifyContent(FlexAlign.Center)
}
.border({
width: { bottom: 5 },
color: '#f5f5f5',
})
}
// 相关推荐区
ListItem() {
RecommendList({ recommendList: this.recommendList })
}
}
.width(CommonConstants.FULL_WIDTH)
.height(CommonConstants.FULL_HEIGHT)
.padding({ bottom: 56 })
.scrollBar(BarState.Off)
.edgeEffect(EdgeEffect.None)
.padding({ bottom: 76 })
// .scrollBar(BarState.Off)
//底部交互区
Row() {
... ... @@ -163,11 +117,143 @@ export struct ImageAndTextPageComponent {
.justifyContent(FlexAlign.SpaceBetween)
.backgroundColor(Color.White)
}
}.width(CommonConstants.FULL_WIDTH).height(CommonConstants.FULL_HEIGHT)
.backgroundColor(Color.White)
}
.width(CommonConstants.FULL_WIDTH)
.height(CommonConstants.FULL_HEIGHT)
}
// build() {
// Column() {
// // 发布时间
// Row() {
// Image($r('app.media.icon_ren_min_ri_bao'))
// .width(70)
// .height(28)
// Text(this.contentDetailData[0]?.publishTime)
// .fontColor($r('app.color.color_B0B0B0'))
// .fontSize($r('app.float.font_size_13'))
// .height('100%')
// .align(Alignment.End)
// }
// .width(CommonConstants.FULL_WIDTH)
// .height(32)
// .padding({ left: 15, right: 15, })
// .justifyContent(FlexAlign.SpaceBetween)
// .backgroundColor(Color.White)
//
// Row() {
// Image($r('app.media.line'))
// .width('100%')
// .height(6)
// .objectFit(ImageFit.Cover)
// .margin({ top: 10 })
// }
// .padding({ left: 15, right: 15, })
// .backgroundColor(Color.White)
//
// Stack({ alignContent: Alignment.Bottom }) {
//
// List() {
// //详情展示区
// ListItem() {
// Column() {
// ImageAndTextWebComponent({
// contentDetailData: this.contentDetailData,
// action: this.action,
// })
// }.width(CommonConstants.FULL_WIDTH)
// // .height(CommonConstants.FULL_HEIGHT)
// }
//
// if (this.contentDetailData[0]?.openLikes === 1) {
// ListItem() {
// // 点赞
// Row() {
// Row() {
// if (this.newsStatusOfUser?.likeStatus === '1') {
// Image(this.contentDetailData[0]?.likesStyle === 1 ? $r('app.media.ic_like_check') : (this.contentDetailData[0]?.likesStyle === 2 ? $r('app.media.icon_prayer_active') : $r('app.media.icon_candle_active')))
// .width(24)
// .height(24)
// .margin({ right: 5 })
// } else {
// Image(this.contentDetailData[0]?.likesStyle === 1 ? $r('app.media.icon_like') : (this.contentDetailData[0]?.likesStyle === 2 ? $r('app.media.icon_prayer') : $r('app.media.icon_candle')))
// .width(24)
// .height(24)
// .margin({ right: 5 })
// }
// Text(`${this.interactData?.likeNum || 0}`)
// .fontSize(16)
// .fontColor(this.newsStatusOfUser?.likeStatus === '1' ? '#ED2800' : '#999999')
// .fontWeight(500)
// }.alignItems(VerticalAlign.Center)
// .onClick(() => {
// this.toggleLikeStatus()
// })
//
// }.width(CommonConstants.FULL_WIDTH).height(80)
// .justifyContent(FlexAlign.Center)
// }
// .border({
// width: { bottom: 5 },
// color: '#f5f5f5',
// })
// }
//
// // 相关推荐区
// ListItem() {
// RecommendList({ recommendList: this.recommendList })
// }
// }
// .width(CommonConstants.FULL_WIDTH)
// .height(CommonConstants.FULL_HEIGHT)
// .padding({ bottom: 56 })
// .scrollBar(BarState.Off)
// .edgeEffect(EdgeEffect.None)
//
// //底部交互区
// Row() {
// Image($r('app.media.icon_arrow_left'))
// .width(24)
// .height(24)
// .onClick((event: ClickEvent) => {
// router.back()
// })
//
// Row() {
// Image($r('app.media.icon_comment'))
// .width(24)
// .height(24)
// .margin({ right: 24 })
// .id('comment')
//
// Image($r('app.media.icon_star'))
// .width(24)
// .height(24)
// .margin({ right: 24 })
//
// Image($r('app.media.icon_listen'))
// .width(24)
// .height(24)
// .margin({ right: 24 })
//
// Image($r('app.media.icon_forward'))
// .width(24)
// .height(24)
//
// }
// }
// .width(CommonConstants.FULL_WIDTH)
// .height(56)
// .padding({ left: 15, right: 15, bottom: 50, top: 20 })
// .justifyContent(FlexAlign.SpaceBetween)
// .backgroundColor(Color.White)
// }
//
// }.width(CommonConstants.FULL_WIDTH).height(CommonConstants.FULL_HEIGHT)
// .backgroundColor(Color.White)
//
// }
private async getDetail() {
let contentId: string = ''
let relId: string = ''
... ... @@ -199,7 +285,6 @@ export struct ImageAndTextPageComponent {
}
}
private async getRecommend() {
let params: postRecommendListParams = {
imei: "8272c108-4fa2-34ce-80b9-bc425a7c2a7e",
... ... @@ -211,10 +296,8 @@ export struct ImageAndTextPageComponent {
channelId: String(this.contentDetailData[0]?.reLInfo?.channelId)
}
let recommendList = await DetailViewModel.postRecommendList(params)
if (recommendList && recommendList.length > 0) {
this.recommendList = recommendList;
}
}
// 已登录->查询用户对作品点赞、收藏状态
private async getInteractDataStatus() {
... ...
import { Action, ContentDetailDTO, ContentDTO, batchLikeAndCollectResult, InteractDataDTO, } from 'wdBean';
import { Action, ContentDetailDTO, } from 'wdBean';
import DetailViewModel from '../viewmodel/DetailViewModel';
import { OperRowListView } from './view/OperRowListView';
import { WdWebComponent } from 'wdWebComponent';
import router from '@ohos.router';
import { CommonConstants } from 'wdConstant'
import { BridgeWebViewControl } from 'wdJsBridge/Index';
const TAG = 'SpacialTopicPageComponent'
@Component
export struct SpacialTopicPageComponent {
webviewControl: BridgeWebViewControl = new BridgeWebViewControl()
scroller: Scroller = new Scroller();
action: Action = {} as Action
private webUrl?: string;
@State contentDetailData: ContentDetailDTO [] = [] as ContentDetailDTO []
@State recommendList: ContentDTO[] = []
@State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态
@State interactData: InteractDataDTO = {} as InteractDataDTO
@State webUrl: string = '';
build() {
Column() {
Stack({ alignContent: Alignment.Bottom }) {
Column() {
WdWebComponent({
webviewControl: this.webviewControl,
webUrl: this.webUrl,
backVisibility: false
backVisibility: false,
})
}
.padding({bottom:56})
.padding({ bottom: 56 })
.width(CommonConstants.FULL_WIDTH)
.height(CommonConstants.FULL_HEIGHT)
... ... @@ -72,36 +69,11 @@ export struct SpacialTopicPageComponent {
.backgroundColor(Color.White)
}
// private async getDetail() {
// let contentId: string = ''
// let relId: string = ''
// let relType: string = ''
// if (this.action && this.action.params) {
// if (this.action.params.contentID) {
// contentId = this.action.params.contentID;
// }
// if (this.action && this.action.params && this.action.params.extra) {
// if (this.action.params.extra.relId) {
// relId = this.action.params.extra.relId;
// }
// if (this.action.params.extra.relType) {
// relType = this.action.params.extra.relType
// }
//
// }
// let detailBeans = await DetailViewModel.getDetailPageData(relId, contentId, relType)
// if (detailBeans && detailBeans.length > 0) {
// this.contentDetailData = detailBeans;
// }
// }
// }
aboutToAppear() {
let action: Action = router.getParams() as Action
if (action) {
this.webUrl = action.params?.url
this.webUrl = action.params?.url || ''
}
// this.getDetail()
}
aboutToDisappear() {
... ...
... ... @@ -10,56 +10,60 @@ import { DateTimeUtils } from 'wdKit/Index'
@Component
export struct CardMediaInfo {
@State contentDTO: ContentDTO = {} as ContentDTO // 如果有duraion,代表点播,显示时长;如果不传或者传0,显示直播中
// objectType 0:不跳转 1:点播,2:直播,3:活动,4:广告,5:专题,6:链接,7:榜单,8:图文,9:组图,10:H5新闻,11:频道,12:组件,13:音频,
// 14动态图文,15动态视频16问政;100人民号,101标签
build() {
Row() {
if(this.contentDTO.objectType === '1' || this.contentDTO.objectType === '15' ) {
if (this.contentDTO.objectType === '1' || this.contentDTO.objectType === '15') {
// 点播、动态视频
Row(){
Image($r('app.media.videoTypeIcon'))
Row() {
Image($r('app.media.card_play'))
.mediaLogo()
Text(DateTimeUtils.getFormattedDuration(this.contentDTO.videoInfo.videoDuration * 1000))
.mediaText()
}
.backgroundColor('#4d000000')
.borderRadius($r('app.float.button_border_radius'))
} else if(this.contentDTO.objectType === '2') {
} else if (this.contentDTO.objectType === '2') {
// liveInfo.liveState 直播新闻-直播状态 wait待开播running直播中end已结束cancel已取消paused暂停
// 显示直播信息
Row(){
if(this.contentDTO.liveInfo.liveState === 'running') {
Image($r('app.media.icon_live'))
Row() {
if(this.contentDTO.liveInfo.liveState === 'wait') {
Image($r('app.media.card_wait'))
.mediaLogo()
Text('预约')
.mediaText()
} else if (this.contentDTO.liveInfo.liveState === 'running') {
Image($r('app.media.card_live'))
.mediaLogo()
Text('直播中')
.mediaText()
} else if(this.contentDTO.liveInfo.liveState === 'end'){
Image($r('app.media.videoTypeIcon'))
} else if (this.contentDTO.liveInfo.liveState === 'end' && this.contentDTO.liveInfo.replayUri) {
Image($r('app.media.card_play'))
.mediaLogo()
Text('回看')
.mediaText()
} else if(this.contentDTO.liveInfo.liveState === 'end' && this.contentDTO.liveInfo
.replayUri) {
// Image($r('app.media.card_live'))
// .mediaLogo()
Text('直播结束')
.mediaText()
}
}
.backgroundColor('#4d000000')
.borderRadius($r('app.float.button_border_radius'))
} else if(this.contentDTO.objectType === '9') {
} else if (this.contentDTO.objectType === '9') {
// 显示组图;图片数量
Row(){
Image($r('app.media.album_card_shape'))
Row() {
Image($r('app.media.card_image'))
.mediaLogo()
Text(`${this.contentDTO.photoNum}`)
.mediaText()
.width(20)
}
.backgroundColor('#4d000000')
.borderRadius($r('app.float.button_border_radius'))
} else if(this.contentDTO.objectType === '13') {
} else if (this.contentDTO.objectType === '13') {
// 显示音频信息
Row(){
Image($r('app.media.broadcast_listen'))
.height(14)
.borderRadius($r('app.float.button_border_radius'))
Row() {
Image($r('app.media.card_audio'))
.mediaLogo()
Text(DateTimeUtils.getFormattedDuration(this.contentDTO.voiceInfo.voiceDuration * 1000))
.mediaText()
}
... ... @@ -68,18 +72,27 @@ export struct CardMediaInfo {
.margin(6)
}
@Styles mediaLogo() {
.width(22)
.height(18)
.borderRadius($r('app.float.button_border_radius'))
@Styles
mediaLogo() {
.width(14)
.height(14)
.margin({ right: 3 })
.shadow({
radius: 2,
color: 'rgba(0,0,0,0.3)',
offsetY: 2
})
}
}
@Extend(Text) function mediaText() {
@Extend(Text)
function mediaText() {
.fontColor($r('app.color.color_fff'))
.fontSize($r('app.float.font_size_12'))
.width(40)
.height(18)
.textAlign(TextAlign.Center)
.margin({ left: -3 })
.fontSize($r('app.float.font_size_14'))
.lineHeight(18)
.textShadow({
radius: 2,
color: 'rgba(0,0,0,0.3)',
offsetY: 2
})
}
\ No newline at end of file
... ...
import { ContentDTO } from 'wdBean'
import { CommonConstants } from 'wdConstant/Index';
import { DateTimeUtils } from 'wdKit/Index';
@Component
export struct CardSourceInfo {
@State contentDTO: ContentDTO = {} as ContentDTO;
build() {
Flex() {
if(this.contentDTO.corner) {
Text(this.contentDTO.corner)
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_ED2800"))
.margin({right: 2})
}
if(this.contentDTO.rmhPlatform === 1) {
Text(this.contentDTO.rmhInfo.rmhName)
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_B0B0B0"))
.maxLines(1)
.textOverflow({overflow: TextOverflow.Ellipsis})
Image($r("app.media.point"))
.width(16)
.height(16)
} else if(this.contentDTO.source) {
Text(`${this.contentDTO.source}`)
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_B0B0B0"))
.maxLines(1)
.textOverflow({overflow: TextOverflow.Ellipsis})
}
// 新闻tab下的卡片,2天之前的不显示时间。但是如果是搜索情况下展示的卡片,显示时间
if(this.contentDTO.isSearch || !this.contentDTO.isSearch && DateTimeUtils.getCommentTime
(Number
.parseFloat(this
.contentDTO.publishTime))
.indexOf
('-') === -1) {
Image($r("app.media.point"))
.width(16)
.height(16)
Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime)))
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_B0B0B0"))
.margin({ right: 6 })
.flexShrink(0)
}
if(this.contentDTO?.interactData?.commentNum) {
Text(`${this.contentDTO.interactData.commentNum}评`)
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_B0B0B0"))
.flexShrink(0)
}
}
.width(CommonConstants.FULL_WIDTH)
.margin({ top: 8 })
}
}
\ No newline at end of file
... ...
... ... @@ -2,7 +2,8 @@ import { ContentDTO, slideShows } from 'wdBean';
import { CommonConstants } from 'wdConstant'
import { DateTimeUtils } from 'wdKit';
import { ProcessUtils } from '../../utils/ProcessUtils';
import { CardSourceInfo } from '../cardCommon/CardSourceInfo'
import { CardMediaInfo } from '../cardCommon/CardMediaInfo'
/**
* 大专题卡--CompStyle: 10
... ... @@ -76,10 +77,10 @@ export struct Card10Component {
}
.width(CommonConstants.FULL_WIDTH)
.padding({
top: 14,
left: 16,
right: 16,
bottom: 14
left: $r('app.float.card_comp_pagePadding_lf'),
right: $r('app.float.card_comp_pagePadding_lf'),
top: $r('app.float.card_comp_pagePadding_tb'),
bottom: $r('app.float.card_comp_pagePadding_tb')
})
.backgroundColor($r("app.color.white"))
.margin({ bottom: 8 })
... ... @@ -95,25 +96,14 @@ export struct Card10Component {
.fontColor($r('app.color.color_222222'))
.maxLines(2)
.textOverflow({ overflow: TextOverflow.Ellipsis })
Row() {
// 展示发稿人
if (item.source) {
Text(item.source)
.fontSize($r('app.float.font_size_12'))
.fontColor($r('app.color.color_B0B0B0'))
.textOverflow({ overflow: TextOverflow.Ellipsis })
.maxLines(1)
.width(item.source.length > 10 ? '60%' : '')
Image($r('app.media.point'))
.width(16)
.height(16)
}
Text(DateTimeUtils.getCommentTime(Number.parseFloat(String(item.publishTime))))
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_B0B0B0"))
CardSourceInfo(
{
contentDTO: {
publishTime: item.publishTime || '',
source: item.source || ''
} as ContentDTO
}
.margin({ top: 12 })
)
}
.layoutWeight(1)
.alignItems(HorizontalAlign.Start)
... ...
... ... @@ -3,7 +3,7 @@ import { CommonConstants } from 'wdConstant'
import { ContentDTO } from 'wdBean'
import { DateTimeUtils } from 'wdKit'
import { ProcessUtils } from '../../utils/ProcessUtils';
import { CardSourceInfo } from '../cardCommon/CardSourceInfo'
const TAG = 'Card11Component';
/**
... ... @@ -21,29 +21,8 @@ export struct Card11Component {
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.width(CommonConstants.FULL_WIDTH)
Row() {
if (this.contentDTO.source) {
Text(this.contentDTO.source)
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_B0B0B0"))
.margin({ left: 6 })
Image($r("app.media.point"))
.width(16)
.height(16)
}
Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime)))
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_B0B0B0"))
.margin({ right: 6 })
// TODO '评论取哪个字段'
// Text(`1806评`)
// .fontSize($r("app.float.font_size_12"))
// .fontColor($r("app.color.color_B0B0B0"))
}.width(CommonConstants.FULL_WIDTH)
.justifyContent(FlexAlign.Start)
.margin({ top: 8 })
// 评论等信息
CardSourceInfo({ contentDTO: this.contentDTO })
}.width(CommonConstants.FULL_WIDTH)
.padding({
left: $r('app.float.card_comp_pagePadding_lf'),
... ...
import { ContentDTO } from 'wdBean';
import { RmhTitle } from '../cardCommon/RmhTitle'
import { CardMediaInfo } from '../cardCommon/CardMediaInfo'
import { CommonConstants } from 'wdConstant/Index';
const TAG = 'Card12Component';
/**
* 人民号-动态---12:人民号无图卡;
*/
@Component
export struct Card12Component {
@State contentDTO: ContentDTO = {
appStyle: '20',
coverType: 1,
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',
fullColumnImgUrls: [
{
landscape: 1,
size: 1,
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',
weight: 1600
}
],
newsTitle: '好玩!》10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人',
rmhInfo: {
authIcon:
'https://cdnjdphoto.aikan.pdnews.cn/creator-category/icon/auth/yellow.png',
authTitle: '10后音乐人王烁然个人人民号',
authTitle2: '10后音乐人王烁然个人人民号',
banControl: 0,
cnIsAttention: 1,
rmhDesc: '10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人',
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',
rmhName: '王烁然',
userId: '522435359667845',
userType: '2'
},
objectType: '1',
videoInfo: {
firstFrameImageUri: '',
videoDuration: 37,
videoUrl: 'https://rmrbcmsonline.peopleapp.com/upload/user_app/gov_dynamic/video/mp4/202105/rmrb_GSNARt6P1622451310.mp4'
}
} as ContentDTO;
aboutToAppear(): void {
}
build() {
Column() {
// rmh信息
RmhTitle({ rmhInfo: this.contentDTO.rmhInfo })
// 标题
if (this.contentDTO.newsTitle) {
Text(this.contentDTO.newsTitle)
.fontSize($r('app.float.font_size_17'))
.fontColor($r('app.color.color_222222'))
.width(CommonConstants.FULL_WIDTH)
.textOverflowStyle(3)
.margin({ bottom: 8 })
.height(75)
.lineHeight(25)
.fontFamily('PingFang SC-Regular')
}
// if (this.contentDTO.fullColumnImgUrls?.[0]) {
// createImg({ contentDTO: this.contentDTO })
// }
//TODO 底部的:分享、评论、点赞 功能;需要引用一个公共组件
}
.padding({
left: $r('app.float.card_comp_pagePadding_lf'),
right: $r('app.float.card_comp_pagePadding_lf'),
top: $r('app.float.card_comp_pagePadding_tb'),
bottom: $r('app.float.card_comp_pagePadding_tb')
})
}
}
interface radiusType {
topLeft: number | Resource;
topRight: number | Resource;
bottomLeft: number | Resource;
bottomRight: number | Resource;
}
@Component
struct createImg {
@Prop contentDTO: ContentDTO
build() {
GridRow() {
if (this.contentDTO.fullColumnImgUrls[0].landscape === 1) {
// 横屏
GridCol({
span: { xs: 12 }
}) {
Stack() {
Image(this.contentDTO.coverUrl)
.width(CommonConstants.FULL_WIDTH)
.aspectRatio(16 / 9)
.borderRadius($r('app.float.image_border_radius'))
CardMediaInfo({ contentDTO: this.contentDTO })
}
.align(Alignment.BottomEnd)
}
} else {
// 竖图显示,宽度占50%,高度自适应
GridCol({
span: { xs: 6 }
}) {
Stack() {
Image(this.contentDTO.coverUrl)
.width(CommonConstants.FULL_WIDTH)
.borderRadius($r('app.float.image_border_radius'))
CardMediaInfo({ contentDTO: this.contentDTO })
}
.align(Alignment.BottomEnd)
}
}
}
}
}
@Extend(Text)
function textOverflowStyle(maxLine: number) {
.maxLines(maxLine)
.textOverflow({ overflow: TextOverflow.Ellipsis })
}
\ No newline at end of file
... ...
import { ContentDTO } from 'wdBean';
import { RmhTitle } from '../cardCommon/RmhTitle'
import { CardMediaInfo } from '../cardCommon/CardMediaInfo'
import { CommonConstants } from 'wdConstant/Index';
const TAG = 'Card14Component';
/**
* 人民号-动态---14:人民号单图卡;
*/
@Component
export struct Card14Component {
@State contentDTO: ContentDTO = {
// appStyle: '20',
// coverType: 1,
// 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',
// fullColumnImgUrls: [
// {
// landscape: 1,
// size: 1,
// 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',
// weight: 1600
// }
// ],
// newsTitle: '好玩!》10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人',
// rmhInfo: {
// authIcon:
// 'https://cdnjdphoto.aikan.pdnews.cn/creator-category/icon/auth/yellow.png',
// authTitle: '10后音乐人王烁然个人人民号',
// authTitle2: '10后音乐人王烁然个人人民号',
// banControl: 0,
// cnIsAttention: 1,
// rmhDesc: '10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人',
// 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',
// rmhName: '王烁然',
// userId: '522435359667845',
// userType: '2'
// },
// objectType: '1',
// videoInfo: {
// firstFrameImageUri: '',
// videoDuration: 37,
// videoUrl: 'https://rmrbcmsonline.peopleapp.com/upload/user_app/gov_dynamic/video/mp4/202105/rmrb_GSNARt6P1622451310.mp4'
// }
} as ContentDTO;
aboutToAppear(): void {
}
build() {
Column() {
// rmh信息
RmhTitle({ rmhInfo: this.contentDTO.rmhInfo })
// 左标题,右图
Flex({ direction: FlexDirection.Row }) {
Text(this.contentDTO.newsTitle)
.fontSize($r('app.float.font_size_17'))
.fontColor($r('app.color.color_222222'))
.textOverflowStyle(3)
.lineHeight(25)
.fontFamily('PingFang SC-Regular')
.textAlign(TextAlign.Start)
.flexBasis('auto')
.margin({right: 12})
Image(this.contentDTO.coverUrl)
.flexBasis(174)
.height(75)
.borderRadius($r('app.float.image_border_radius'))
// .flexBasis(160)
.backgroundImageSize(ImageSize.Auto)
}
.width(CommonConstants.FULL_WIDTH)
.margin({ bottom: 8 })
.height(75)
//TODO 底部的:分享、评论、点赞 功能;需要引用一个公共组件
}
.padding({
left: $r('app.float.card_comp_pagePadding_lf'),
right: $r('app.float.card_comp_pagePadding_lf'),
top: $r('app.float.card_comp_pagePadding_tb'),
bottom: $r('app.float.card_comp_pagePadding_tb')
})
}
}
interface radiusType {
topLeft: number | Resource;
topRight: number | Resource;
bottomLeft: number | Resource;
bottomRight: number | Resource;
}
@Extend(Text)
function textOverflowStyle(maxLine: number) {
.maxLines(maxLine)
.textOverflow({ overflow: TextOverflow.Ellipsis })
}
\ No newline at end of file
... ...
import { ContentDTO } from 'wdBean';
import { RmhTitle } from '../cardCommon/RmhTitle'
import { CardMediaInfo } from '../cardCommon/CardMediaInfo'
import { CommonConstants } from 'wdConstant/Index';
const TAG = 'Card16Component';
/**
* 人民号-动态---16:人民号三图卡;
*/
@Component
export struct Card16Component {
@State contentDTO: ContentDTO = {
appStyle: '20',
coverType: 1,
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;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;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',
fullColumnImgUrls: [
{
landscape: 1,
size: 1,
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',
weight: 1600
}
],
newsTitle: '好玩!》10后音乐人王烁然个人人民号10后音乐人王烁然个人人民号10后音乐人王烁然个人人民号10后音乐人王烁然个人人民号10后音乐人王烁然个人人民号10后音乐人王烁然个人人民号',
rmhInfo: {
authIcon:
'https://cdnjdphoto.aikan.pdnews.cn/creator-category/icon/auth/yellow.png',
authTitle: '10后音乐人王烁然个人人民号',
authTitle2: '10后音乐人王烁然个人人民号',
banControl: 0,
cnIsAttention: 1,
rmhDesc: '10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人',
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',
rmhName: '王烁然',
userId: '522435359667845',
userType: '2'
},
objectType: '1',
videoInfo: {
firstFrameImageUri: '',
videoDuration: 37,
videoUrl: 'https://rmrbcmsonline.peopleapp.com/upload/user_app/gov_dynamic/video/mp4/202105/rmrb_GSNARt6P1622451310.mp4'
}
} as ContentDTO;
aboutToAppear(): void {
}
build() {
Column() {
// rmh信息
RmhTitle({ rmhInfo: this.contentDTO.rmhInfo })
// 标题
if (this.contentDTO.newsTitle) {
Text(this.contentDTO.newsTitle)
.fontSize($r('app.float.font_size_17'))
.fontColor($r('app.color.color_222222'))
.width(CommonConstants.FULL_WIDTH)
.textOverflowStyle(2)
.margin({ bottom: 8 })
.lineHeight(25)
}
if (this.contentDTO.coverUrl) {
Flex() {
ForEach(this.contentDTO.coverUrl?.split(';'), (item: string) => {
Image(item).flexBasis(113).height(75).margin({right: 2})
})
}
}
//TODO 底部的:分享、评论、点赞 功能;需要引用一个公共组件
}
.padding({
left: $r('app.float.card_comp_pagePadding_lf'),
right: $r('app.float.card_comp_pagePadding_lf'),
top: $r('app.float.card_comp_pagePadding_tb'),
bottom: $r('app.float.card_comp_pagePadding_tb')
})
}
}
interface radiusType {
topLeft: number | Resource;
topRight: number | Resource;
bottomLeft: number | Resource;
bottomRight: number | Resource;
}
@Component
struct createImg {
@Prop contentDTO: ContentDTO
build() {
GridRow() {
if (this.contentDTO.fullColumnImgUrls[0].landscape === 1) {
// 横屏
GridCol({
span: { xs: 12 }
}) {
Stack() {
Image(this.contentDTO.coverUrl)
.width(CommonConstants.FULL_WIDTH)
.aspectRatio(16 / 9)
.borderRadius($r('app.float.image_border_radius'))
CardMediaInfo({ contentDTO: this.contentDTO })
}
.align(Alignment.BottomEnd)
}
} else {
// 竖图显示,宽度占50%,高度自适应
GridCol({
span: { xs: 6 }
}) {
Stack() {
Image(this.contentDTO.coverUrl)
.width(CommonConstants.FULL_WIDTH)
.borderRadius($r('app.float.image_border_radius'))
CardMediaInfo({ contentDTO: this.contentDTO })
}
.align(Alignment.BottomEnd)
}
}
}
}
}
@Extend(Text)
function textOverflowStyle(maxLine: number) {
.maxLines(maxLine)
.textOverflow({ overflow: TextOverflow.Ellipsis })
}
\ No newline at end of file
... ...
... ... @@ -4,7 +4,7 @@ import { CommonConstants } from 'wdConstant/Index';
import { DateTimeUtils } from 'wdKit';
import { WDRouterRule } from 'wdRouter';
import { CardMediaInfo } from '../cardCommon/CardMediaInfo'
import { CardSourceInfo } from '../cardCommon/CardSourceInfo'
const TAG = 'Card17Component';
/**
... ... @@ -81,25 +81,8 @@ export struct Card17Component {
};
WDRouterRule.jumpWithAction(taskAction)
})
Row() {
if (this.contentDTO.source) {
Text(this.contentDTO.source)
.fontSize($r('app.float.font_size_13'))
.fontColor($r('app.color.color_B0B0B0'))
Image($r('app.media.point'))
.width(16)
.height(16)
}
if (this.contentDTO.publishTime && this.contentDTO.publishTime.length === 13) {
Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime)))
.fontSize($r('app.float.font_size_13'))
.fontColor($r('app.color.color_B0B0B0'))
}
}
.width(CommonConstants.FULL_WIDTH)
.height(16)
.id('label')
// 评论等信息
CardSourceInfo({ contentDTO: this.contentDTO })
}
.width(CommonConstants.FULL_WIDTH)
.padding({
... ...
... ... @@ -13,7 +13,7 @@ export struct Card19Component {
// coverUrl: 'https://rmrbcmsonline.peopleapp.com/upload/ueditor/image/20240323/a_955994160362418176.png?x-oss-process=image/resize,w_550/quality,q_90/format,jpg',
// fullColumnImgUrls: [
// {
// fullUrl: 'https://rmrbcmsonline.peopleapp.com/upload/ueditor/image/20240323/a_955994160362418176.png?x-oss-process=image/quality,q_90/auto-orient,1',
// fullUrl: 'https://rmrbcmsonline.peopleapp.com/upload/ueditor/image/20240323/a_955994155727712256.png?x-oss-process=image/quality,q_90/auto-orient,1',
// height: 1500,
// landscape: 1,
// size: 1,
... ... @@ -107,6 +107,8 @@ interface radiusType {
@Component
struct createImg {
@Prop fullColumnImgUrls: FullColumnImgUrlDTO[]
@State picWidth: number = 0;
@State picHeight: number = 0;
aboutToAppear(): void {
if(this.fullColumnImgUrls.length === 4) { // 为了使用栅格布局以便于占用三分之二的宽度,加一个占位
this.fullColumnImgUrls.splice(2,0, {
... ... @@ -137,18 +139,77 @@ struct createImg {
return radius
}
getPicType(){
if (this.picWidth && this.picWidth) {
if (this.picWidth / this.picHeight > 343/172) {
return 1; //横长图
} else if (this.picHeight / this.picWidth > 305/228) {
return 2; //竖长图
} else {
return 3
}
} else {
return 3; //普通图
}
}
build() {
GridRow({
gutter: { x: 2, y: 2 }
}) {
ForEach(this.fullColumnImgUrls, (item: FullColumnImgUrlDTO, index: number) => {
if (this.fullColumnImgUrls.length === 1) {
if (this.getPicType() !== 3) {
GridCol({
span: this.getPicType() === 1 ? 12 : 8
}){
Stack({
alignContent: Alignment.BottomEnd
}) {
if (this.getPicType() === 1) {
Image(item.fullUrl)
.width('100%')
.height(172)
.autoResize(true)
.borderRadius(this.caclImageRadius(index))
} else if (this.getPicType() === 2) {
Image(item.fullUrl)
.width('100%')
.height(305)
.autoResize(true)
.borderRadius(this.caclImageRadius(index))
}
Flex({ direction: FlexDirection.Row }) {
Image($r('app.media.icon_long_pic'))
.width(14)
.height(14)
.margin({right: 4})
Text('长图')
.fontSize(12)
.fontWeight(400)
.fontColor(0xffffff)
.fontFamily('PingFang SC')
}
.width(48)
.padding({bottom: 9})
}
}
} else {
GridCol({
span: { xs: 8 }
}) {
Image(item.fullUrl)
.width('100%')
.borderRadius(this.caclImageRadius(index))
.autoResize(true)
.opacity(!this.picWidth && !this.picHeight ? 0 : 1)
.onComplete(callback => {
this.picWidth = callback?.width || 0;
this.picHeight = callback?.height || 0;
})
}
}
} else if (this.fullColumnImgUrls.length === 4) {
GridCol({
... ...
import { ContentDTO } from 'wdBean';
import { CommonConstants, CompStyle } from 'wdConstant';
import { ProcessUtils } from '../../utils/ProcessUtils';
import { RmhTitle } from '../cardCommon/RmhTitle'
import { CardMediaInfo } from '../cardCommon/CardMediaInfo'
const TAG: string = 'Card6Component-Card13Component';
/**
* 卡片样式:"appStyle":"21" 小视频卡人民号
*/
@Component
export struct Card21Component {
@State contentDTO: ContentDTO = {} as ContentDTO;
build() {
Column() {
// 顶部 rmh信息
RmhTitle({ rmhInfo: this.contentDTO.rmhInfo })
// 中间内容
Grid() {
GridItem() {
Text(`${this.contentDTO.newsTitle}`)
.fontSize($r('app.float.selected_text_size'))
.fontColor($r('app.color.color_222222'))
.width(CommonConstants.FULL_WIDTH)
.maxLines(4)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.padding({ right: 12 })
.lineHeight(26)
}
GridItem() {
Stack() {
Image(this.contentDTO.coverUrl)
.width(CommonConstants.FULL_WIDTH)
.borderRadius($r('app.float.image_border_radius'))
CardMediaInfo({ contentDTO: this.contentDTO })
}
.alignContent(Alignment.BottomEnd)
}
}
.columnsTemplate('2fr 1fr')
.maxCount(1)
//TODO 底部的:分享、评论、点赞 功能;需要引用一个公共组件
}
.onClick((event: ClickEvent) => {
ProcessUtils.processPage(this.contentDTO)
})
.padding({
left: $r('app.float.card_comp_pagePadding_lf'),
right: $r('app.float.card_comp_pagePadding_lf'),
top: $r('app.float.card_comp_pagePadding_tb'),
bottom: $r('app.float.card_comp_pagePadding_tb')
})
.width(CommonConstants.FULL_WIDTH)
}
}
\ No newline at end of file
... ...
//全标题 "appStyle":"2",
import { ContentDTO } from 'wdBean';
import { CommonConstants } from 'wdConstant/Index';
import { DateTimeUtils } from 'wdKit/Index';
import { ProcessUtils } from '../../utils/ProcessUtils';
import { CardMediaInfo } from '../cardCommon/CardMediaInfo'
import { CardSourceInfo } from '../cardCommon/CardSourceInfo'
const TAG: string = 'Card2Component';
/**
... ... @@ -60,21 +59,8 @@ export struct Card2Component {
.alignItems(HorizontalAlign.Start)
//bottom
Row() {
Text(this.contentDTO.source)
.bottomTextStyle()
//间隔点
Image($r('app.media.point'))
.width(12)
.height(12)
Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime)))
.bottomTextStyle()
}
.width(CommonConstants.FULL_WIDTH)
.height(18)
.justifyContent(FlexAlign.Start)
.margin({ top: 8 })
// 评论等信息
CardSourceInfo({ contentDTO: this.contentDTO })
}
.width(CommonConstants.FULL_WIDTH)
.padding({
... ...
import { ContentDTO } from 'wdBean';
import { CommonConstants } from 'wdConstant'
import { DateTimeUtils } from 'wdKit/src/main/ets/utils/DateTimeUtils'
import { ProcessUtils } from '../../utils/ProcessUtils';
import { CardSourceInfo } from '../cardCommon/CardSourceInfo'
/**
* 卡片样式:"appStyle":"3"
... ... @@ -27,30 +27,8 @@ export struct Card3Component {
.fontSize($r("app.float.font_size_16"))
.fontColor($r("app.color.color_222222"))
.width(CommonConstants.FULL_WIDTH)
Row() {
// TODO "锐评"取得哪个字段,什么时候显示。
// Text("锐评")
// .fontSize($r("app.float.font_size_12"))
// .fontColor($r("app.color.color_ED2800"))
if(this.contentDTO.source) {
Text(this.contentDTO.source)
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_B0B0B0"))
Image($r("app.media.point"))
.width(16)
.height(16)
}
Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime)))
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_B0B0B0"))
.margin({ right: 6 })
// TODO '评论取哪个字段'
Text(`${this.contentDTO?.interactData?.commentNum}评`)
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_B0B0B0"))
}.width(CommonConstants.FULL_WIDTH)
.justifyContent(FlexAlign.Start)
.margin({ top: 8 })
// 评论等信息
CardSourceInfo({ contentDTO: this.contentDTO })
}
.width(CommonConstants.FULL_WIDTH)
.padding({
... ...
import { ContentDTO, FullColumnImgUrlDTO } from 'wdBean';
import { CommonConstants } from 'wdConstant/Index';
import { ProcessUtils } from '../../utils/ProcessUtils';
import { DateTimeUtils } from 'wdKit/Index';
import { CardSourceInfo } from '../cardCommon/CardSourceInfo'
const TAG: string = 'Card4Component';
/**
... ... @@ -110,25 +109,8 @@ export struct Card4Component {
.onClick((event: ClickEvent) => {
ProcessUtils.processPage(this.contentDTO)
})
//bottom
Row() {
Text(this.contentDTO.source)
.bottomTextStyle()
//间隔点
Image($r('app.media.point'))
.width(12)
.height(12)
Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime)))
.bottomTextStyle()
// TODO 评论字段取值
// Text('518条评论')
// .bottomTextStyle()
}
.width('100%')
.justifyContent(FlexAlign.Start)
.margin({ top: 8 })
//bottom 评论等信息
CardSourceInfo({ contentDTO: this.contentDTO })
}
.width(CommonConstants.FULL_WIDTH)
.padding({
... ...
import { ContentDTO } from 'wdBean';
import { CommonConstants, CompStyle } from 'wdConstant';
import { DateTimeUtils } from 'wdKit';
import { ProcessUtils } from '../../utils/ProcessUtils';
import { CardSourceInfo } from '../cardCommon/CardSourceInfo'
import { CardMediaInfo } from '../cardCommon/CardMediaInfo'
const TAG: string = 'Card6Component-Card13Component';
const FULL_PARENT: string = '100%';
/**
* 卡片样式:"appStyle":"6"以及13
* 卡片样式:"appStyle":"6"以及13--- 小视频卡
*/
@Component
export struct Card6Component {
... ... @@ -17,7 +16,17 @@ export struct Card6Component {
Row() {
Column() {
Column() {
Text(this.contentDTO.newsTitle)
// TODO 这个tag涉及样式问题。待优化。
// if (this.contentDTO.newTags) {
// Text(this.contentDTO.newTags)
// .backgroundColor($r('app.color.color_ED2800'))
// .borderRadius($r('app.float.button_border_radius'))
// .fontColor($r('app.color.color_fff'))
// .fontSize($r('app.float.font_size_12'))
// .padding(2)
// .margin({ right: 2 })
// }
Text(`${this.contentDTO.newsTitle}`)
.fontSize(16)
.fontWeight(FontWeight.Normal)
.maxLines(3)//
... ... @@ -26,93 +35,35 @@ export struct Card6Component {
}.height("80%")
.justifyContent(FlexAlign.Start)
Row() {
if (this.contentDTO.source) {
Text(this.contentDTO.source)
.fontSize($r('app.float.font_size_12'))
.fontColor(Color.Gray)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。
.width(this.contentDTO.source.length > 8 ? '50%' : '')
Image($r('app.media.point'))
.width(16)
.height(16)
}
if (this.contentDTO.publishTime && this.contentDTO.publishTime.length === 13) {
Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime)))
.fontSize($r('app.float.font_size_12'))
.fontColor(Color.Gray)
}
Text(this.contentDTO.visitorComment + '评')
.fontSize($r('app.float.font_size_12'))
.fontColor(Color.Gray)
.padding({
left: 5
})
}.alignSelf(ItemAlign.Start)
.height("20%")
.justifyContent(FlexAlign.Start)
//bottom 评论等信息
CardSourceInfo({ contentDTO: this.contentDTO })
}
.alignItems(HorizontalAlign.Start)
.justifyContent(FlexAlign.Start)
.width('58%')
Blank(16)
if (this.contentDTO.coverUrl) {
Stack() {
Image(this.contentDTO.coverUrl)
.borderRadius(5)
.aspectRatio(this.contentDTO.appStyle === CompStyle.Card_13 ? 3 / 2 : 3 / 4)
.height(this.contentDTO.appStyle === CompStyle.Card_13 ? 90 : 180)
if (this.contentDTO.videoInfo) {
Row() {
Image($r('app.media.iv_card_play_yellow_flag'))
.width(22)
.height(18)
Text(DateTimeUtils.getFormattedDuration(this.contentDTO.videoInfo.videoDuration * 1000))
.fontSize($r('app.float.font_size_13'))
.fontWeight(400)
.fontColor($r('app.color.color_fff'))
CardMediaInfo({ contentDTO: this.contentDTO })
}
.alignItems(VerticalAlign.Bottom)
.height(18)
.padding({ right: 4 })
.margin({
right: 4,
bottom: 4
})
.backgroundColor($r('app.color.color_4d000000'))
} else if (this.contentDTO.voiceInfo) {
Row() {
Image($r('app.media.icon_listen'))
.width(22)
.height(18)
Text(DateTimeUtils.getFormattedDuration(this.contentDTO.voiceInfo
.voiceDuration * 1000))
.fontSize($r('app.float.font_size_13'))
.fontWeight(400)
.fontColor($r('app.color.color_fff'))
}
.alignItems(VerticalAlign.Bottom)
.height(18)
.padding({ right: 4 })
.margin({
right: 4,
bottom: 4
})
.backgroundColor($r('app.color.color_4d000000'))
}
}.alignContent(Alignment.BottomEnd)
.alignContent(Alignment.BottomEnd)
}
}
.onClick((event: ClickEvent) => {
ProcessUtils.processPage(this.contentDTO)
})
.padding(
{ top: 16, bottom: 16, left: 14, right: 14 })
.width(FULL_PARENT)
.padding({
left: $r('app.float.card_comp_pagePadding_lf'),
right: $r('app.float.card_comp_pagePadding_lf'),
top: $r('app.float.card_comp_pagePadding_tb'),
bottom: $r('app.float.card_comp_pagePadding_tb')
})
.width(CommonConstants.FULL_WIDTH)
.height(this.contentDTO.appStyle === CompStyle.Card_13 ? 127 : 217)
.justifyContent(FlexAlign.SpaceBetween)
}
}
\ No newline at end of file
... ...
... ... @@ -104,7 +104,7 @@ export struct Card9Component {
Column() {
Row() {
// 标题
Image($r("app.media.point_icon"))
Image($r("app.media.timeline_rect"))
.width(9)
.height(9)
.margin({ right: 5 })
... ...
... ... @@ -157,11 +157,11 @@ struct CreatorItem {
.width(44)
.height(44)
if (this.isSelected) {
Image($r('app.media.MyCollection_selected_icon'))
Image($r('app.media.rmh_selected'))
.width(16)
.height(16)
} else {
Image($r('app.media.ic_succeed_refresh'))
Image($r('app.media.rmh_unselected'))
.width(16)
.height(16)
}
... ...
... ... @@ -36,6 +36,7 @@ export class commentListModel extends PageModel{
}
@Observed
export class commentItemModel {
authorLike: string = ''
avatarFrame: string = ''
... ... @@ -92,7 +93,7 @@ export class commentItemModel {
targetRelType:string = '';
targetType:string = '';
visitorComment:string = '';
shareInfo:commentItemShareInfoModel[] = []
shareInfo:commentItemShareInfoModel = new commentItemShareInfoModel;
// targetId:string = '';
// targetId:string = '';
// targetId:string = '';
... ...
import ArrayList from '@ohos.util.ArrayList'
import { ViewType } from 'wdConstant/Index';
import { LazyDataSource } from 'wdKit/Index';
import { DateTimeUtils, LazyDataSource } from 'wdKit/Index';
import PageModel from '../../../viewmodel/PageModel';
import { commentItemModel, commentListModel, WDPublicUserType } from '../model/CommentModel';
import commentViewModel from '../viewmodel/CommentViewModel'
... ... @@ -166,7 +166,9 @@ export struct CommentComponent {
// ///1小时~1天:x小时前
// ///1天~2天:1天前
// ///2天~:日期隐藏
Text(item.createTime)
Text(DateTimeUtils.getCommentTime(Number.parseFloat(item.createTime)))
.fontColor($r('app.color.color_B0B0B0'))
.fontSize(12)
... ...
import { ViewType } from 'wdConstant/Index'
import { LazyDataSource } from 'wdKit/Index'
import { DateTimeUtils, LazyDataSource, WindowModel } from 'wdKit/Index'
import { commentItemModel, commentListModel } from '../model/CommentModel'
import commentViewModel from '../viewmodel/CommentViewModel'
import { window } from '@kit.ArkUI'
const TAG = 'QualityCommentsComponent';
@Entry
@Preview
@Component
export struct QualityCommentsComponent {
bottomSafeHeight: string = AppStorage.get<number>('bottomSafeHeight') + 'px';
@State private browSingModel: commentListModel = new commentListModel()
isloading: boolean = false
lastWindowColor:string = '#ffffff'
currentWindowColor:string = '#FF4202'
@State allDatas: LazyDataSource<commentItemModel> = new LazyDataSource();
aboutToDisappear(): void {
const windowStage = WindowModel.shared.getWindowStage() as window.WindowStage
const windowClass: window.Window = windowStage.getMainWindowSync(); // 获取应用主窗口
windowClass.setWindowBackgroundColor(this.lastWindowColor)
windowClass.setWindowLayoutFullScreen(false)
// windowClass.setWindowSystemBarProperties({ statusBarColor: '#000' })
}
aboutToAppear(): void {
commentViewModel.fetchQualityCommentList('1').then((commentListModel)=>{
if (commentListModel && commentListModel.list && commentListModel.list.length > 0) {
commentListModel.hasMore = true;
this.browSingModel.viewType = ViewType.LOADED;
this.fullScreen();
commentViewModel.fetchQualityCommentListLocal(getContext()).then(commentListModel => {
this.allDatas.push(...commentListModel.list)
if (commentListModel.list.length === this.browSingModel.pageSize) {
this.browSingModel.currentPage++;
this.browSingModel.hasMore = true;
} else {
this.browSingModel.hasMore = false;
})
// commentViewModel.fetchQualityCommentList('1').then((commentListModel) => {
// if (commentListModel && commentListModel.list && commentListModel.list.length > 0) {
// // commentListModel.hasMore = true;
// // this.browSingModel.viewType = ViewType.LOADED;
// this.allDatas.push(...commentListModel.list)
// // if (commentListModel.list.length === this.browSingModel.pageSize) {
// // this.browSingModel.currentPage++;
// // this.browSingModel.hasMore = true;
// // } else {
// // this.browSingModel.hasMore = false;
// // }
// } else {
// this.browSingModel.viewType = ViewType.EMPTY;
// }
// })
}
} else {
this.browSingModel.viewType = ViewType.EMPTY;
fullScreen() {
const windowStage = WindowModel.shared.getWindowStage() as window.WindowStage
const windowClass: window.Window = windowStage.getMainWindowSync(); // 获取应用主窗口
// windowClass.setWindowBackgroundColor(this.currentWindowColor)
windowClass.setWindowLayoutFullScreen(true)
// windowClass.setWindowSystemBarProperties({ statusBarColor: '#fff' })
// windowClass.setWindowLayoutFullScreen(true).then(() => {
// console.log(TAG + 'setWindowLayoutFullScreen');
// })
}
@Builder
titleHeader() {
Row() {
Image($r('app.media.comment_img_banner')).width('100%').aspectRatio(375 / 283);
}
}
build() {
Column() {
// this.titleHeader()
List({ space: 28 }) {
ListItemGroup({ header: this.titleHeader() })
LazyForEach(this.allDatas, (item: commentItemModel, index: number) => {
ListItem() {
QualityCommentItem({ item: item }).margin({ left: 12, right: 12 })
}
// .offset({
// y:-87
// })
})
}
// .contentStartOffset(- 87)
.edgeEffect(EdgeEffect.Spring)
.margin({bottom:this.bottomSafeHeight})
// .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM])
}.backgroundColor(this.currentWindowColor).height('100%').width('100%')
}
}
@Component
struct QualityCommentItem {
@ObjectLink item: commentItemModel
build() {
Column() {
/*头像以及昵称*/
RelativeContainer() {
Image(this.item.fromUserHeader)
.width(50)
.height(50)
.borderRadius(25)
.borderWidth(2)
.borderColor(Color.White)
.id('image1')
.alignRules({
top: { anchor: "__container__", align: VerticalAlign.Top },
left: { anchor: "__container__", align: HorizontalAlign.Start }
})
.offset(
{
y: -16
}
)
Text(this.item.fromUserName)
.fontSize(14)
.fontColor('#222222')
.fontWeight(FontWeight.Medium)
.id('text1')
.alignRules({
bottom: { anchor: "image1", align: VerticalAlign.Bottom },
left: { anchor: "image1", align: HorizontalAlign.End }
})
.offset(
{
x: 6,
y: -6 - 16
}
)
}.height(42)
Column() {
/*评论内容*/
Text() {
ImageSpan($r('app.media.WDBestCommentTitleDotIcon'))
.width(12)
.height(12)
.objectFit(ImageFit.Fill)
.offset({
y: -6
})
Span(' ' + this.item.commentContent)
.fontSize(16)
.fontColor('#222222')
.fontWeight(FontWeight.Medium)
}.margin({ top: 10 })
/*分割线*/
Row() {
}.width('100%').margin({ top: 10, left: 0, right: 0 }).backgroundColor('#EDEDED').height(2.5);
/*文章或者评论*/
Row() {
Row() {
Image($r('app.media.comment_img_link')).width(16).height(16)
Text(this.item.shareInfo.shareTitle)
.fontSize(14)
.fontColor('#666666')
.margin({ left: 6, right: 12 })
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
}.height(40).layoutWeight(1)
Image($r('app.media.more')).width(12).height(12)
}.width('100%').height(40).justifyContent(FlexAlign.SpaceBetween)
}
.backgroundColor('#F9F9F9')
.width('100%')
.alignItems(HorizontalAlign.Start)
.borderRadius(4)
.padding({ left: 12, right: 12 })
/*时间 点赞评论*/
Row() {
Text(DateTimeUtils.getCommentTime(DateTimeUtils.getDateTimestamp(this.item.createTime))).fontSize(14).fontColor('#999999')
Row({space:16}){
Row(){
Image($r('app.media.comment_icon_pinglun')).width(16).height(16)
}
Row(){
//comment_like_select
Image($r(this.item.likeNum?'app.media.comment_like_select':'app.media.comment_like_normal')).width(16).height(16)
if (this.item.likeNum){Text(this.item.likeNum).fontColor(this.item.isLike?'#ED2800':'#999999').fontSize(14).margin({left:3})}
}
}
}.height(38).width('100%').justifyContent(FlexAlign.SpaceBetween)
}.backgroundColor('#FFFFFF').padding({ top: 0, left: 16, right: 16 }).borderRadius(4)
}
}
\ No newline at end of file
... ...
... ... @@ -32,7 +32,21 @@ class CommentViewModel {
return compRes.data
}
/*获取本地mock数据*/
async fetchQualityCommentListLocal(context: Context): Promise<commentListModel> {
Logger.info(TAG, `getBottomNavDataMock start`);
let compRes: ResponseDTO<commentListModel> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<commentListModel>>(context,'qualityComment_local.json' );
if (!compRes || !compRes.data) {
Logger.info(TAG, `getAppointmentListDataLocal compRes is empty`);
return new commentListModel()
}
Logger.info(TAG, `getAppointmentListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
//qualityComment_local.json
fetchQualityCommentList(pageNum: string) {
let url = HttpUrlUtils.getQualityCommentUrl() + `?&pageSize=${10}&pageNum=${pageNum}`
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
... ...
... ... @@ -33,8 +33,8 @@ export default struct MinePageUserSimpleInfoUI {
Stack(){
Image(this.headPhotoUrl)
.alt($r('app.media.default_head'))
.width('108lpx')
.height('108lpx')
.width('100lpx')
.height('100lpx')
.objectFit(ImageFit.Cover)
.borderRadius(50)
Image(this.levelHead)
... ...
... ... @@ -18,7 +18,7 @@ export struct FollowFirstTabsComponent{
value.forEach((element)=>{
this.data.push(element)
})
console.log("ycg",this.data.length.toString());
if(this.controller != null && this.data.length>1 && this.changeIndex === 1){
//个人主页 跳转 关注页 tab 2
let intervalID = setInterval(() => {
... ...
... ... @@ -171,6 +171,7 @@ struct ChildComponent {
.fontSize('31lpx')
.lineHeight('38lpx')
.fontColor($r('app.color.color_222222'))
.maxLines(1)
Text(`粉丝${this.data.cnFansNum}`)
.fontColor($r('app.color.color_B0B0B0'))
.fontSize('23lpx')
... ...
... ... @@ -35,25 +35,45 @@ export struct FollowSecondTabsComponent{
@Builder FollowSecondUI(){
Row() {
Row(){
// 页签
Column({ space: 7 }) {
Scroll() {
Column() {
ForEach(this.data[this.firstIndex].children, (item: FollowSecondListItem, index: number ) => {
this.TabBuilder(index,item)
})
}
.justifyContent(FlexAlign.Start)
}
.align(Alignment.Top)
.scrollable(ScrollDirection.Vertical)
.scrollBar(BarState.Off)
.height('100%')
}.height('100%')
.alignItems(HorizontalAlign.Center)
}
.alignItems(VerticalAlign.Top)
.height('100%')
Tabs({ barPosition: BarPosition.Start, controller: this.controller }) {
ForEach(this.data[this.firstIndex].children, (item: FollowSecondListItem, index: number ) => {
TabContent(){
FollowThirdTabsComponent({data:$data,firstIndex:$firstIndex,secondIndex:index})
}.tabBar(this.TabBuilder(index,item))
}
.backgroundColor($r('app.color.white'))
}, (item: FollowListItem, index: number) => index.toString())
}
.vertical(true)
.barMode(BarMode.Scrollable)
.barWidth('140lpx')
.animationDuration(0)
.onChange((index: number) => {
this.currentIndex = index
})
.width('100%')
.barWidth(0)
.height('100%')
.layoutWeight(1)
}.width('100%')
.alignItems(VerticalAlign.Top)
.backgroundColor('#0FF')
}
@Builder TabBuilder(index: number, item: FollowSecondListItem) {
... ... @@ -73,6 +93,7 @@ export struct FollowSecondTabsComponent{
})
.justifyContent(FlexAlign.Center)
.height('84lpx')
.width('140lpx')
.backgroundColor(this.currentIndex === index?$r('app.color.white'):$r('app.color.color_F9F9F9'))
}
... ...
... ... @@ -34,19 +34,45 @@ export struct FollowThirdTabsComponent{
.lineHeight('38lpx')
.backgroundColor($r('app.color.color_F9F9F9'))
.padding('13lpx')
.maxLines(1)
}
.onClick(()=>{
this.currentIndex = index
this.controller.changeIndex(this.currentIndex)
})
.height('100%')
.height('84lpx')
.margin({right:'9lpx'})
.padding({left:'20lpx',right:index === this.data[this.firstIndex].children[this.secondIndex].children.length-1?"20lpx":"0lpx"})
.justifyContent(FlexAlign.Center)
}
@Builder FollowThirdUI(){
Column(){
Column() {
// 页签
Row({ space: 7 }) {
Scroll() {
Row() {
ForEach(this.data[this.firstIndex].children[this.secondIndex].children, (item: FollowThirdListItem, index: number ) => {
this.TabBuilder(index,item)
})
}
.justifyContent(FlexAlign.Start)
}
.align(Alignment.Start)
.scrollable(ScrollDirection.Horizontal)
.scrollBar(BarState.Off)
.width('90%')
.padding({left:'11lpx'})
}
.alignItems(VerticalAlign.Bottom)
.width('100%')
}
.backgroundColor($r('app.color.white'))
.alignItems(HorizontalAlign.Start)
.width('100%')
Tabs({ barPosition: BarPosition.Start, controller: this.controller }) {
ForEach(this.data[this.firstIndex].children[this.secondIndex].children, (item: FollowThirdListItem, index: number ) => {
TabContent(){
... ... @@ -58,20 +84,19 @@ export struct FollowThirdTabsComponent{
.margin({left:'20lpx'})
FollowListDetailUI({creatorDirectoryId:this.data[this.firstIndex].children[this.secondIndex].children[index].id})
}
}.tabBar(this.TabBuilder(index,item))
}
.backgroundColor($r('app.color.white'))
}, (item: FollowListItem, index: number) => index.toString())
}
.barHeight(0)
.vertical(false)
.barMode(BarMode.Scrollable)
.barWidth('100%')
.barHeight('84lpx')
.animationDuration(0)
.onChange((index: number) => {
this.currentIndex = index
})
.width('100%')
}.width('100%')
}
}
}
\ No newline at end of file
... ...
... ... @@ -90,6 +90,7 @@ export struct OtherHomePageBottomCommentComponent{
MinePageDatasModel.getOtherCommentListData(object,getContext(this)).then((value)=>{
if (!this.data_comment || value.list.length == 0){
this.hasMore = false
this.isLoading = false
}else{
this.getCommentListStatus(value)
}
... ...
... ... @@ -60,6 +60,7 @@ export struct BottomNavigationComponent {
MinePageComponent()
} else {
TopNavigationComponent({
groupId: navItem.id,
topNavList: navItem.topNavChannelList,
_currentNavIndex: this.currentNavIndex,
changeBarBackgroundColor: (color: Color) => {
... ...
... ... @@ -84,9 +84,13 @@ struct EditUserInfoPage {
Blank()
Text(r.subTitle)
.textOverflow({overflow:TextOverflow.Ellipsis})
.maxLines(1)
.fontSize(16)
.fontColor(Color.Gray)
.padding({right:10})
.width('70%')
.textAlign(TextAlign.End)
Image($r('app.media.mine_user_edit'))
.width('12')
... ... @@ -130,10 +134,11 @@ struct EditUserInfoPage {
})
}else if(i === 5){
TextPickerDialog.show({
range:['女','男'],
range:['男','女'],
canLoop:false,
selected:0,
onAccept:(value:TextPickerResult) => {
this.currentUserInfo.userExtend.sex = value.index as number;
this.currentUserInfo.userExtend.sex = value.index == 0?1:0;
this.currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_sex
this.updateEditModel()
}
... ...
... ... @@ -2,7 +2,7 @@ import { CustomTitleAndEditUI } from '../reusable/CustomTitleAndEditUI'
import MyCollectionViewModel from '../../viewmodel/MyCollectionViewModel';
import PageModel from '../../viewmodel/PageModel';
import { CommonConstants, ViewType } from 'wdConstant'
import { EmptyComponent } from '../view/EmptyComponent'
import { EmptyComponent,WDViewDefaultType } from '../view/EmptyComponent'
import { ErrorComponent } from '../view/ErrorComponent'
import RefreshLayout from './RefreshLayout'
import { RefreshLayoutBean } from './RefreshLayoutBean';
... ... @@ -43,7 +43,7 @@ struct MyCollectionListPage {
}else if(this.browSingModel.viewType == ViewType.ERROR){
ErrorComponent()
}else if(this.browSingModel.viewType == ViewType.EMPTY){
EmptyComponent()
EmptyComponent({emptyType:WDViewDefaultType.WDViewDefaultType_NoCollection})
}else {
this.ListLayout()
}
... ...
import { Logger, DateTimeUtils, CollectionUtils } from 'wdKit';
import { CollectionUtils, DateTimeUtils, Logger } from 'wdKit';
import { CommonConstants, CompStyle, ViewType } from 'wdConstant';
import PageViewModel from '../../viewmodel/PageViewModel';
import { EmptyComponent } from '../view/EmptyComponent';
... ... @@ -13,8 +12,7 @@ import LoadMoreLayout from './LoadMoreLayout';
import CustomRefreshLoadLayout from './CustomRefreshLoadLayout';
import { CompParser } from '../CompParser';
import { GroupInfoDTO } from 'wdBean/src/main/ets/bean/navigation/PageInfoDTO';
import { VideoChannelDetail } from 'wdDetailPlayShortVideo/Index';
import { CompDTO, LiveReviewDTO, PageDTO ,PageInfoDTO} from 'wdBean';
import { CompDTO, LiveReviewDTO, PageDTO, PageInfoBean } from 'wdBean';
const TAG = 'PageComponent';
... ... @@ -41,7 +39,6 @@ export struct PageComponent {
totalCount: 0,
list: []
};
name: string = "";
@Link @Watch('onChange') currentTopNavSelectedIndex: number
build() {
... ... @@ -72,6 +69,7 @@ export struct PageComponent {
@Builder
ListLayout() {
List() {
// 下拉刷新
ListItem() {
RefreshLayout({
... ... @@ -83,13 +81,8 @@ export struct PageComponent {
LazyForEach(this.pageModel.compList, (compDTO: CompDTO, compIndex: number) => {
ListItem() {
Column() {
if (this.name == '视频') {
VideoChannelDetail()
} else {
CompParser({ compDTO: compDTO, compIndex: compIndex });
}
}
}
},
(compDTO: CompDTO, compIndex: number) => compDTO.id + compIndex.toString() + this.pageModel.timestamp
... ... @@ -106,6 +99,7 @@ export struct PageComponent {
NoMoreLayout()
}
}
}
.scrollBar(BarState.Off)
.cachedCount(8)
... ... @@ -138,7 +132,8 @@ export struct PageComponent {
onChange() {
Logger.info(TAG, `onChangezz id: ${this.pageId} , ${this.channelId} , ${this.navIndex} , ${this.isFirstIn} , navIndex: ${this.currentTopNavSelectedIndex}`);
if (this.navIndex === this.currentTopNavSelectedIndex && !this.isFirstIn) {
// if (this.navIndex === this.currentTopNavSelectedIndex && !this.isFirstIn) {
if (this.navIndex === this.currentTopNavSelectedIndex) {
this.getData();
}
}
... ... @@ -158,6 +153,16 @@ export struct PageComponent {
this.pageModel.viewType = ViewType.EMPTY;
return;
}
if (this.navIndex === 0) {
await this.getVideoListData(pageInfo);
} else {
await this.getLiveListData(pageInfo);
}
}
private async getVideoListData(pageInfo: PageInfoBean) {
let groupInfo: GroupInfoDTO = CollectionUtils.getElement(pageInfo.groups, 0);
if (groupInfo != null) {
this.pageModel.isRecGroup = groupInfo.groupStrategy === 1;
... ... @@ -165,7 +170,89 @@ export struct PageComponent {
}
// pageInfo.groups.forEach(async (group) => { 不能按顺序加载用for...of替代
// for (const group of pageInfo.groups) {
this.pageDto = await PageViewModel.getPageData(this.pageModel, getContext(this))
this.pageDto = await PageViewModel.getPageData(this.pageModel, getContext(this));
this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString();
if (this.pageDto && this.pageDto.compList && this.pageDto.compList.length > 0) {
this.pageDto.compList.forEach((comp) => {
if (comp.compStyle === CompStyle.Zh_Grid_Layout_02 && this.liveReviewDTO && this.liveReviewDTO.list && this.liveReviewDTO.list.length > 0) {
comp.operDataList.push(...this.liveReviewDTO.list);
}
});
this.pageModel.viewType = ViewType.LOADED;
this.pageModel.compList.push(...this.pageDto.compList);
if (this.pageDto.compList.length === this.pageModel.pageSize) {
this.pageModel.currentPage++;
this.pageModel.hasMore = true;
} else {
this.pageModel.hasMore = false;
}
// // 二次请求,批查互动数据
// PageViewModel.getInteractData(pageDto.compList).then((data: CompDTO[]) => {
// // 刷新,替换所有数据
// this.pageModel.compList.replaceAll(...data)
// this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString()
// })
this.isFirstIn = false;
Logger.debug(TAG, 'cj111');
// } else {
// Logger.debug(TAG, 'aboutToAppear, data response page ' + this.pageId + ', comp list is empty.');
// this.pageModel.viewType = ViewType.EMPTY;
// }
}
}
// private async getLiveListData(pageInfo: PageInfoBean) {
// // pageInfo.groups.forEach(async (group) => { 不能按顺序加载用for...of替代
// for (const group of pageInfo.groups) {
// this.pageDto = await PageViewModel.getPageData(this.pageModel, getContext(this));
// this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString();
// if (this.pageDto && this.pageDto.compList && this.pageDto.compList.length > 0) {
// this.pageDto.compList.forEach((comp) => {
// if (comp.compStyle === CompStyle.Zh_Grid_Layout_02 && this.liveReviewDTO && this.liveReviewDTO.list && this.liveReviewDTO.list.length > 0) {
// comp.operDataList.push(...this.liveReviewDTO.list);
// }
// });
//
// this.pageModel.viewType = ViewType.LOADED;
// this.pageModel.compList.push(...this.pageDto.compList);
// if (this.pageDto.compList.length === this.pageModel.pageSize) {
// this.pageModel.currentPage++;
// this.pageModel.hasMore = true;
// } else {
// this.pageModel.hasMore = false;
// }
// // // 二次请求,批查互动数据
// // PageViewModel.getInteractData(pageDto.compList).then((data: CompDTO[]) => {
// // // 刷新,替换所有数据
// // this.pageModel.compList.replaceAll(...data)
// // this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString()
// // })
// this.isFirstIn = false;
// Logger.debug(TAG, 'cj111');
// // } else {
// // Logger.debug(TAG, 'aboutToAppear, data response page ' + this.pageId + ', comp list is empty.');
// // this.pageModel.viewType = ViewType.EMPTY;
// }
// }
// }
async getLiveListData(pageInfo: PageInfoBean) {
// Logger.info(TAG, `getData id: ${this.pageId} , ${this.channelId} , navIndex: ${this.currentTopNavSelectedIndex}`);
// this.pageModel.pageId = this.pageId;
// this.pageModel.groupId = this.pageId;
// this.pageModel.channelId = this.channelId;
// this.pageModel.currentPage = 1;
// let pageInfo = await PageViewModel.getPageUrlData(this.pageModel.pageId);
// if (pageInfo == null) {
// this.pageModel.viewType = ViewType.EMPTY;
// return;
// }
Logger.debug(TAG, 'getPageUrlData ' + pageInfo.id);
// pageInfo.groups.forEach(async (group) => { 不能按顺序加载用for...of替代
for (const group of pageInfo.groups) {
this.pageDto = await PageViewModel.getLivePageData(this.pageModel.pageId, `${group.id}`, this.pageModel.channelId, group.groupStrategy
, this.pageModel.currentPage, this.pageModel.pageSize, getContext(this))
this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString()
if (this.pageDto && this.pageDto.compList && this.pageDto.compList.length > 0) {
this.pageDto.compList.forEach((comp) => {
... ... @@ -189,12 +276,11 @@ export struct PageComponent {
this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString()
})
this.isFirstIn = false
// } else {
// Logger.debug(TAG, 'aboutToAppear, data response page ' + this.pageId + ', comp list is empty.');
// this.pageModel.viewType = ViewType.EMPTY;
// }
} else {
Logger.debug(TAG, 'aboutToAppear, data response page ' + this.pageId + ', comp list is empty.');
this.pageModel.viewType = ViewType.EMPTY;
}
}
}
async getPreviewData() {
... ...
... ... @@ -6,6 +6,7 @@ import { ChannelSubscriptionLayout } from './ChannelSubscriptionLayout';
import { FirstTabTopSearchComponent } from '../search/FirstTabTopSearchComponent';
import window from '@ohos.window';
import { WindowModel } from 'wdKit';
import { VideoChannelDetail } from 'wdDetailPlayShortVideo/Index';
const TAG = 'TopNavigationComponent';
... ... @@ -20,6 +21,7 @@ const storage = LocalStorage.getShared();
@Entry(storage)
@Component
export struct TopNavigationComponent {
private groupId: number = 0
private tabsController: TabsController = new TabsController()
private changeBarBackgroundColor: (color: Color) => void = () => {
}
... ... @@ -236,13 +238,21 @@ export struct TopNavigationComponent {
Tabs({ index: this.currentTopNavSelectedIndex, controller: this.tabsController }) {
ForEach(this._currentNavIndex === 0 ? this.myChannelList : this.topNavList, (navItem: TopNavDTO, index: number) => {
TabContent() {
if (this._currentNavIndex === 2 && navItem.name === '视频') {
VideoChannelDetail({
bottomNavIndex: this._currentNavIndex,
topNavIndex: this.currentTopNavSelectedIndex,
groupId: this.groupId + '',
pageId: navItem.pageId + '',
channelId: navItem.channelId + '',
})
} else
if (!this.isBroadcast(navItem) && !this.isLayout(navItem)) {
PageComponent({
currentTopNavSelectedIndex: $currentTopNavSelectedIndex,
navIndex: index,
pageId: navItem.pageId + '',
channelId: navItem.channelId + '',
name: navItem.name
})
}
}
... ...
... ... @@ -128,7 +128,7 @@ export struct SearchComponent {
* @param content
*/
getSearchHistoryResData(content:string,index:number){
//删除单记录
//删除单记录
SearcherAboutDataModel.delSearchSingleHistoryData(index)
this.isClickedHistory = true
this.searchResData(content)
... ... @@ -149,33 +149,6 @@ export struct SearchComponent {
this.getSearchResultCountData()
}
getSearchResultCountData() {
SearcherAboutDataModel.getSearchResultCountData(encodeURI(this.searchText),getContext(this)).then((value) => {
if (value != null) {
this.count = []
if(value.allTotal!=0){
this.count.push("全部")
}
if(value.cmsTotal!=0){
this.count.push("精选")
}
if(value.rmhTotal!=0){
this.count.push("人民号")
}
if(value.videoTotal!=0){
this.count.push("视频")
}
if(value.activityTotal!=0){
this.count.push("活动")
}
}
}).catch((err: Error) => {
console.log(TAG, JSON.stringify(err))
})
}
/**
* 点击联想搜索列表回调
* @param content
... ... @@ -291,4 +264,30 @@ export struct SearchComponent {
.padding({ left: '31lpx' })
.alignItems(VerticalAlign.Center)
}
getSearchResultCountData() {
SearcherAboutDataModel.getSearchResultCountData(encodeURI(this.searchText),getContext(this)).then((value) => {
if (value != null) {
this.count = []
if(value.allTotal!=0){
this.count.push("全部")
}
if(value.cmsTotal!=0){
this.count.push("精选")
}
if(value.rmhTotal!=0){
this.count.push("人民号")
}
if(value.videoTotal!=0){
this.count.push("视频")
}
if(value.activityTotal!=0){
this.count.push("活动")
}
}
}).catch((err: Error) => {
console.log(TAG, JSON.stringify(err))
})
}
}
\ No newline at end of file
... ...
import { SearchResultContentComponent } from './SearchResultContentComponent'
const TAG = "SearchResultComponent"
/**
... ... @@ -19,7 +20,7 @@ export struct SearchResultComponent{
Tabs({ barPosition: BarPosition.Start, controller: this.controller }) {
ForEach(this.count, (item: string, index: number ) => {
TabContent(){
Text(item)
SearchResultContentComponent({keywords:this.searchText,searchType:item})
}.tabBar(this.TabBuilder(index,item))
}, (item: string, index: number) => index.toString())
}
... ... @@ -63,4 +64,5 @@ export struct SearchResultComponent{
.margin({right:'9lpx'})
.padding({left:'31lpx',right:index === this.count.length-1?"31lpx":"0lpx"})
}
}
\ No newline at end of file
... ...
import { ContentDTO,
contentListParams,
FullColumnImgUrlDTO, InteractDataDTO, RmhInfoDTO, VideoInfoDTO } from 'wdBean/Index'
import { LiveInfoDTO } from 'wdBean/src/main/ets/bean/detail/LiveInfoDTO'
import { VoiceInfoDTO } from 'wdBean/src/main/ets/bean/detail/VoiceInfoDTO'
import { LazyDataSource, StringUtils } from 'wdKit/Index'
import SearcherAboutDataModel from '../../model/SearcherAboutDataModel'
import { SearchResultContentData } from '../../viewmodel/SearchResultContentData'
import { SearchRmhDescription } from '../../viewmodel/SearchResultContentItem'
import { CardParser } from '../CardParser'
import { ListHasNoMoreDataUI } from '../reusable/ListHasNoMoreDataUI'
const TAG = "SearchResultContentComponent"
@Component
export struct SearchResultContentComponent{
@State keywords:string = ""
@State searchType:string = ""
@State data: LazyDataSource<ContentDTO> = new LazyDataSource();
@State data_rmh: SearchRmhDescription[] = []
@State count:number = 0;
@State isLoading:boolean = false
@State hasMore:boolean = true
curPageNum:number = 1;
aboutToAppear(): void {
if(this.searchType == "全部"){
this.searchType = "all"
}else if(this.searchType == "精选"){
this.searchType = "cms"
}else if(this.searchType == "人民号"){
this.searchType = "rmh"
}else if(this.searchType == "视频"){
this.searchType = "video"
}else if(this.searchType == "活动"){
this.searchType = "activity"
}
this.keywords = encodeURI(this.keywords)
this.getNewSearchResultData()
}
getNewSearchResultData(){
this.isLoading = true
if(this.hasMore){
SearcherAboutDataModel.getSearchResultListData("20",`${this.curPageNum}`,this.searchType,this.keywords,getContext(this)).then((value)=>{
if (!this.data || value.list.length == 0){
this.hasMore = false
this.isLoading = false
}else{
if(value.list[0].dataList!=null){
this.data_rmh = value.list[0].dataList
//TODO 查询创作者详情接口
}
this.getInteractData(value)
}
}).catch((err:Error)=>{
console.log(TAG,JSON.stringify(err))
this.isLoading = false
})
}
}
getInteractData(resultData:SearchResultContentData){
if(resultData.list[0].dataList!=null){
resultData.list.splice(0,1)
}
let data : contentListParams = {
contentList: []
}
resultData.list.forEach((item)=>{
data.contentList.push({
contentId: item.data.id + '',
contentType: Number.parseInt(item.data.type)
})
})
SearcherAboutDataModel.getInteractListData(data,getContext(this)).then((newValue)=>{
newValue.forEach((item)=>{
resultData.list.forEach((data)=>{
if (item.contentId == data.data.id) {
data.data.collectNum = item.collectNum+""
data.data.commentNum = item.commentNum+""
data.data.likeNum = item.likeNum+""
data.data.readNum = item.readNum+""
data.data.shareNum = item.shareNum+""
}
})
})
resultData.list.forEach((value)=>{
let photos:FullColumnImgUrlDTO[] = []
if(value.data.appStyle === 4){
value.data.appStyleImages.split("&&").forEach((value)=>{
photos.push({url:value} as FullColumnImgUrlDTO)
})
}
//TODO 48 个赋值
let contentDTO:ContentDTO = {
appStyle: value.data.appStyle + "",
cityCode: value.data.cityCode,
coverSize: "",
coverType: -1,
coverUrl: value.data.appStyleImages.split("&&")[0],
description: value.data.description,
districtCode: value.data.districtCode,
endTime: value.data.endTime,
hImageUrl: "",
heatValue: "",
innerUrl: "",
landscape: Number.parseInt(value.data.landscape),
// lengthTime:null,
linkUrl: value.data.linkUrl,
openLikes: Number.parseInt(value.data.openLikes),
openUrl: "",
pageId: value.data.pageId,
programAuth: "",
programId: "",
programName: "",
programSource: -1,
programType: -1,
provinceCode: value.data.provinceCode,
showTitleEd: value.data.showTitleEd,
showTitleIng: value.data.showTitleIng,
showTitleNo: value.data.showTitleNo,
startTime: value.data.startTime,
subType: "",
subtitle: "",
title: value.data.title,
vImageUrl: "",
screenType: "",
source: StringUtils.isEmpty(value.data.creatorName) ? value.data.sourceName : value.data.creatorName,
objectId: "",
objectType: value.data.type,
channelId: value.data.channelId,
relId: value.data.relId,
relType: value.data.relType,
newsTitle: value.data.titleLiteral,
publishTime: value.data.publishTime,
visitorComment: -1,
fullColumnImgUrls: photos,
newsSummary: "",
hasMore: -1,
slideShows: [],
voiceInfo: {} as VoiceInfoDTO,
tagWord: -1,
isSelect: true,
rmhInfo: {} as RmhInfoDTO,
photoNum: -1,
liveInfo: {} as LiveInfoDTO,
videoInfo: {
videoDuration: Number.parseInt(value.data.duration)
} as VideoInfoDTO,
interactData: {} as InteractDataDTO,
corner: '',
rmhPlatform: 0,
newTags: '',
isSearch: true
}
this.data.push(contentDTO)
})
this.data.notifyDataReload()
this.count = this.data.totalCount()
if (this.data.totalCount() < resultData.totalCount) {
this.curPageNum++
}else {
this.hasMore = false
}
this.isLoading = false
}).catch((err:Error)=>{
console.log(TAG,"请求失败")
this.isLoading = false
})
}
build() {
Column() {
if(this.count == 0){
ListHasNoMoreDataUI({style:2})
}else{
Column(){
if (this.data_rmh!=null && this.data_rmh.length > 0) {
//List
List() {
ForEach(this.data_rmh, (item: SearchRmhDescription, index: number) => {
ListItem() {
Column(){
Image($r('app.media.default_head'))
.width('84lpx')
.height('84lpx')
.margin({bottom:'15lpx'})
Text(item.creatorName)
.fontSize('20lpx')
}.alignItems(HorizontalAlign.Center)
}.onClick(()=>{
//TODO 跳转
})
.width('150lpx')
})
}
.cachedCount(6)
.edgeEffect(EdgeEffect.None)
.scrollBar(BarState.Off)
.listDirection(Axis.Horizontal)
.width('100%')
.height('150lpx')
.onReachEnd(()=>{
if(!this.isLoading){
//进入更多关注页
}
})
}
//List
List({ space: '6lpx' }) {
LazyForEach(this.data, (item: ContentDTO, index: number) => {
ListItem() {
Column(){
CardParser({contentDTO:item})
if(index != this.data.totalCount()-1 ){
Divider()
.width('100%')
.height('1lpx')
.color($r('app.color.color_F5F5F5'))
.strokeWidth('1lpx')
}
}
}
.onClick(()=>{
//TODO 跳转
})
}, (item: ContentDTO, index: number) => index.toString())
//没有更多数据 显示提示
if(!this.hasMore){
ListItem(){
ListHasNoMoreDataUI()
}
}
}.cachedCount(6)
.edgeEffect(EdgeEffect.None)
.scrollBar(BarState.Off)
.margin({top:'23lpx',left:'23lpx',right:'23lpx'})
.layoutWeight(1)
.onReachEnd(()=>{
console.log(TAG,"触底了");
if(!this.isLoading){
//加载分页数据
this.getNewSearchResultData()
}
})
}
}
}
.backgroundColor($r('app.color.white'))
.height('100%')
.width('100%')
}
}
\ No newline at end of file
... ...
import { Params } from 'wdBean';
import { WDRouterPage, WDRouterRule } from 'wdRouter';
import featureAbility from '@ohos.ability.featureAbility';
import { EnvironmentCustomDialog } from './EnvironmentCustomDialog';
const TAG = 'AboutPageUI';
... ... @@ -9,7 +9,18 @@ export struct AboutPageUI {
@State listData: Array<string | Array<string>> = ['隐私授权协议', '软件许可及用户协议'];
@State message: string = '京ICP备16066560号-6A Copyright © 人民日报客户端\nall rights reserved.'
@State version: string = '版本号:v'
clickTimes: number = 0
dialogController: CustomDialogController = new CustomDialogController({
builder: EnvironmentCustomDialog({
cancel: () => {
},
confirm: () => {
}
}),
customStyle: true,
alignment: DialogAlignment.Center
})
build() {
Navigation() {
... ... @@ -19,18 +30,24 @@ export struct AboutPageUI {
.title('关于')
}
aboutToAppear(){
aboutToAppear() {
let context = getContext();
context.getApplicationContext();
}
@Builder aboutUi() {
@Builder
aboutUi() {
Column() {
Image($r('app.media.setting_about_logo'))
.width('278lpx')
.height('154lpx')
.margin({top:'173lpx',bottom:'154lpx'})
.margin({ top: '173lpx', bottom: '154lpx' })
.onClick(() => {
this.clickTimes++
if (this.clickTimes > 2) {
this.dialogController.open()
}
})
// Row(){
//
// }.backgroundColor(Color.Yellow)
... ... @@ -44,19 +61,17 @@ export struct AboutPageUI {
// .height('97lpx')
List(){
ForEach(this.listData, (item:string, index : number) =>{
List() {
ForEach(this.listData, (item: string, index: number) => {
ListItem() {
this.getArrowCell(item, index)
}.onClick(() =>{
}.onClick(() => {
if (index == 0) {
let bean={contentId:"1",pageID:""} as Params
WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage,bean)
}else{
let bean={contentId:"2",pageID:""} as Params
WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage,bean)
let bean = { contentID: "2", pageID: "" } as Params
WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage, bean)
} else {
let bean = { contentID: "1", pageID: "" } as Params
WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage, bean)
}
})
})
... ... @@ -77,22 +92,21 @@ export struct AboutPageUI {
.fontSize('25lpx')
.textAlign(TextAlign.Center)
.fontColor($r("app.color.color_666666"))
.margin({bottom:'31lpx'})
.margin({ bottom: '31lpx' })
Text(this.message)
.fontSize('19lpx')
.textAlign(TextAlign.Center)
.fontColor($r("app.color.color_999999"))
.margin({bottom:'35lpx'})
.margin({ bottom: '35lpx' })
}
.width('100%')
.height('100%')
}
// 右文字+箭头cell
@Builder getArrowCell(item:string, index:number) {
@Builder
getArrowCell(item: string, index: number) {
Row() {
// 左侧标题
... ... @@ -109,10 +123,8 @@ export struct AboutPageUI {
.justifyContent(FlexAlign.SpaceBetween)
.height('97lpx')
.width('100%')
.padding({left:'29lpx',right:'29lpx'})
.padding({ left: '29lpx', right: '29lpx' })
}
}
... ...
... ... @@ -17,6 +17,7 @@ import { Router } from '@ohos.arkui.UIContext';
import promptAction from '@ohos.promptAction';
import { LogoutViewModel } from '../../viewmodel/LogoutViewModel';
import { CustomLogoutDialog } from './CustomLogoutDialog';
import { emitter } from '@kit.BasicServicesKit';
export { SettingPasswordParams } from "wdLogin"
... ... @@ -41,9 +42,11 @@ export struct AccountAndSecurityLayout {
alignment: DialogAlignment.Center
})
aboutToAppear() {
// 获取设置页面数据
this.getAccountAndSecurityData()
this.addEmitEvent()
}
async getAccountAndSecurityData() {
... ... @@ -56,6 +59,28 @@ export struct AccountAndSecurityLayout {
}
addEmitEvent(){
// 定义一个eventId为1的事件
let event: emitter.InnerEvent = {
eventId: 10010
};
// 收到eventId为1的事件后执行该回调
let callback = (eventData: emitter.EventData): void => {
promptAction.showToast({
message: JSON.stringify(eventData)
});
if(eventData&&eventData.data){
this.listData[0].subTitle = eventData.data['content']
}
Logger.debug( 'event callback:' + JSON.stringify(eventData));
};
// 订阅eventId为1的事件
emitter.on(event, callback);
}
build() {
Column(){
if(this.isAccountPage){
... ... @@ -106,7 +131,8 @@ export struct AccountAndSecurityLayout {
ListItem() {
if (item.type == 0) {
Column() {
this.getArrowCell(item)
// this.getArrowCell(item)
AccountArrowCell({ item:item})
}.padding({ left: '27lpx' }).height('117lpx').justifyContent(FlexAlign.Center)
} else if (item.type == 1) {
Column() {
... ... @@ -285,7 +311,7 @@ export struct AccountAndSecurityLayout {
}.alignItems(VerticalAlign.Center)
Row() {
Text("登录")
Text("注销账户")
.borderRadius(4)
.fontColor(this.protocolState ? "#FFFFFFFF" : "#66FFFFFF")
.fontSize(18)
... ... @@ -405,3 +431,46 @@ export struct AccountAndSecurityLayout {
return securityNum;
}
}
@Component
export struct AccountArrowCell{
@ObjectLink item: MineMainSettingFunctionItem
build() {
Column() {
Row() {
// 左侧logo和标题
Row() {
// 判断有没有图片
if (this.item.imgSrc) {
Image(this.item.imgSrc)
.height('38lpx')
.margin({ right: '5lpx' })
}
Text(`${this.item.title}`)
.margin({ top: '8lpx' })
.height('38lpx')
.fontColor('#333333')
.fontSize('29lpx')
}.width('60%')
// 右侧文案和右箭头
Row() {
Text(this.item.subTitle ? this.item.subTitle : '')
.fontColor('#999999')
.maxLines(1)
Image($r('app.media.mine_user_arrow'))
.width('27lpx')
.height('27lpx')
.objectFit(ImageFit.Auto)
Column().width('29lpx')
}.width('40%')
.margin({ right: '29lpx' })
.justifyContent(FlexAlign.End)
}
.alignItems(VerticalAlign.Center)
.justifyContent(FlexAlign.SpaceBetween)
}
.height('54lpx')
}
}
\ No newline at end of file
... ...
import { SPHelper } from 'wdKit/Index';
import { HttpUrlUtils } from 'wdNetwork/Index';
@CustomDialog
export struct EnvironmentCustomDialog {
currentEnvironment: string = HttpUrlUtils.HOST_PRODUCT;
controller: CustomDialogController
cancel: () => void = () => {
}
confirm: () => void = () => {
}
build() {
Column() {
Text("请选择环境")
.fontColor("#222222")
.fontSize(18)
.width("100%")
.fontWeight(FontWeight.Bold)
.textAlign(TextAlign.Center)
.margin({ top: 20 })
Row() {
Radio({ value: 'Radio1', group: 'radioGroup' })
.checked(true)
.height(20)
.width(20)
.onChange((isChecked: boolean) => {
if (isChecked) {
this.currentEnvironment = HttpUrlUtils.HOST_SIT;
}
})
Text('切换到SIT(测试)环境,重启应用生效')
.fontSize(14)
}
.justifyContent(FlexAlign.Start)
.width('90%')
Row() {
Radio({ value: 'Radio1', group: 'radioGroup' })
.checked(true)
.height(20)
.width(20)
.onChange((isChecked: boolean) => {
if (isChecked) {
this.currentEnvironment = HttpUrlUtils.HOST_UAT;
}
})
Text('切换到UAT(预发布)环境,重启应用生效')
.fontSize(14)
}
.width('90%')
.justifyContent(FlexAlign.Start)
Row() {
Radio({ value: 'Radio1', group: 'radioGroup' })
.checked(true)
.height(20)
.width(20)
.onChange((isChecked: boolean) => {
if (isChecked) {
this.currentEnvironment = HttpUrlUtils.HOST_PRODUCT;
}
})
Text('切换到PROD(现网)环境,重启应用生效')
.fontSize(14)
}
.width('90%')
.justifyContent(FlexAlign.Start)
Row() {
Radio({ value: 'Radio1', group: 'radioGroup' })
.checked(true)
.height(20)
.width(20)
.onChange((isChecked: boolean) => {
if (isChecked) {
this.currentEnvironment = HttpUrlUtils.HOST_DEV;
}
})
Text('切换到DEV(开发)环境,重启应用生效')
.fontSize(14)
}
.width('90%')
.justifyContent(FlexAlign.Start)
Button('确认')
.margin({ top: 20 })
.onClick(() => {
// HttpUrlUtils.hostUrl = this.currentEnvironment
SPHelper.default.saveSync('hostUrl', this.currentEnvironment);
this.controller.close()
this.confirm()
})
}.height(261).backgroundColor(Color.White).borderRadius(6).width('74%')
}
}
\ No newline at end of file
... ...
import { Action, CompDTO, Params } from 'wdBean';
import { ExtraDTO } from 'wdBean/src/main/ets/bean/component/extra/ExtraDTO';
import { CommonConstants } from 'wdConstant/Index';
import { DateTimeUtils, Logger } from 'wdKit';
import { WDRouterRule } from 'wdRouter';
const TAG = 'AlbumCardComponent';
@Preview
@Component
export struct AlbumCardComponent {
@State compDTO: CompDTO = {} as CompDTO
aboutToAppear() {
Logger.debug(TAG + "this.compDTO.operDataList" + JSON.stringify(this.compDTO.operDataList));
}
build() {
Column({ space: 8 }) {
Text(this.compDTO.operDataList[0].newsTitle)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.fontSize(17)
.fontColor(0x222222)
.lineHeight(25)
.maxLines(3)
.width(CommonConstants.FULL_WIDTH)
RelativeContainer() {
Image(this.compDTO.operDataList[0].fullColumnImgUrls[0].url)
.width('66.6%')
.aspectRatio(16/9)
.alignRules({
top: { anchor: "__container__", align: VerticalAlign.Top },
left: { anchor: "__container__", align: HorizontalAlign.Start }
})
.id('mainImage')
Image(this.compDTO.operDataList[0].fullColumnImgUrls[1].url)
.width('33%')
.aspectRatio(16/9)
.alignRules({
top: { anchor: "__container__", align: VerticalAlign.Top },
right: { anchor: "__container__", align: HorizontalAlign.End }
})
.id('subTopImage')
Image(this.compDTO.operDataList[0].fullColumnImgUrls[2].url)
.width('33%')
.aspectRatio(16/9)
.alignRules({
right: { anchor: "__container__", align: HorizontalAlign.End },
bottom: { anchor: "__container__", align: VerticalAlign.Bottom }
})
.id('subBottomImage')
// 下面是渲染右下角图标
Shape() {
Rect().width(33).height(18)
}
// .viewPort({ x: -2, y: -2, width: 304, height: 130 })
.fill(0x000000)
.fillOpacity(0.3)
// .strokeDashArray([20])
// .strokeDashOffset(10)
.strokeLineCap(LineCapStyle.Round)
.strokeLineJoin(LineJoinStyle.Round)
.antiAlias(true)
.id('shape')
.alignRules({
right: { anchor: "__container__", align: HorizontalAlign.End },
bottom: { anchor: "__container__", align: VerticalAlign.Bottom }
})
.margin({ right: 4,
bottom: 4 })
Image($r('app.media.album_card_shape'))
.width(22)
.height(18)
.alignRules({
left: { anchor: "shape", align: HorizontalAlign.Start },
top: { anchor: "shape", align: VerticalAlign.Top }
})
.id('shapeSubImage')
Text(this.compDTO.operDataList[0].fullColumnImgUrls.length + '')
.fontSize(13)
.fontColor(0xFFFFFF)
.id('pageIndex')
.alignRules({
right: { anchor: "shape", align: HorizontalAlign.End },
top: { anchor: "shape", align: VerticalAlign.Top }
})
.margin({ right: 2 })
.textAlign(TextAlign.Center)
.width(17)
.height(17)
}
.width(CommonConstants.FULL_WIDTH)
.aspectRatio(24/9)
.onClick((event: ClickEvent) => {
let taskAction: Action = {
type: 'JUMP_DETAIL_PAGE',
params: {
detailPageType: 17,
contentID: this.compDTO.operDataList?.[0].objectId,
extra: {
relType: this.compDTO.operDataList?.[0].relType,
relId: `${this.compDTO.operDataList?.[0].relId}`,
} as ExtraDTO
} as Params,
};
WDRouterRule.jumpWithAction(taskAction)
})
Row() {
if (this.compDTO.operDataList[0].source) {
Text(this.compDTO.operDataList[0].source)
.fontSize(13)
.fontColor(0xB0B0B0)
Image($r('app.media.point'))
.width(16)
.height(16)
}
if (this.compDTO.operDataList[0].publishTime && this.compDTO.operDataList[0].publishTime.length === 13) {
Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.compDTO.operDataList[0].publishTime)))
.fontSize(13)
.fontColor(0xB0B0B0)
}
Text('328评')
.fontSize(13)
.fontColor(0xB0B0B0)
.margin({
left: 6
})
}
.width(CommonConstants.FULL_WIDTH)
.height(16)
.id('label')
}
.width(CommonConstants.FULL_WIDTH)
.padding({
top: 14,
left: 16,
right: 16,
bottom: 14
})
}
}
\ No newline at end of file
... ... @@ -52,8 +52,7 @@ export struct BannerComponent {
.borderRadius($r('app.float.image_border_radius'))
.displayCount(this.buildDisplayCount()) // 仅展示1个图片
.cachedCount(2)
.index(1) // The default index of Swiper.
.autoPlay(true)
.index(0) // The default index of Swiper.
.indicator(Indicator.dot()
.right(5)
.itemWidth(4)
... ...
import { CompDTO, slideShows } from 'wdBean';
import { CommonConstants } from 'wdConstant'
import { DateTimeUtils } from 'wdKit';
import { ProcessUtils } from '../../utils/ProcessUtils';
/**
* 时间链卡--CompStyle: 09
*/
@Component
export struct CompStyle_09 {
@State compDTO: CompDTO = {} as CompDTO
build() {
Column(){
// 顶部标题,最多两行
if(this.compDTO.operDataList[0].newsTitle) {
Text(this.compDTO.operDataList[0].newsTitle)
.width(CommonConstants.FULL_WIDTH)
.fontSize($r('app.float.font_size_17'))
.fontWeight(600)
.maxLines(2)
.textOverflow({overflow: TextOverflow.Ellipsis})
.margin({ bottom: 19 })
}
// 大图
Stack(){
Image(this.compDTO.operDataList[0].coverUrl)
.width('100%')
.borderRadius({topLeft: $r('app.float.image_border_radius'), topRight: $r('app.float.image_border_radius')})
Text('专题')
.fontSize($r('app.float.font_size_12'))
.padding({left: 8, right: 8, top: 3, bottom: 3})
.backgroundColor(Color.Red)
.fontColor(Color.White)
.borderRadius($r('app.float.button_border_radius'))
.margin({left: 5, bottom: 5})
}.alignContent(Alignment.BottomStart)
// 时间线--后端返回三个,
Column(){
ForEach(this.compDTO.operDataList[0].slideShows, (item:slideShows, index:number) => {
this.timelineItem(item, index)
})
}
// 底部-查看更多。根据接口返回的isMore判断是否显示查看更多
if(this.compDTO.operDataList[0].hasMore == 1) {
Row() {
Text("查看更多")
.fontSize($r("app.float.font_size_14"))
.fontColor($r("app.color.color_222222"))
.margin({ right: 1 })
Image($r("app.media.more"))
.width(14)
.height(14)
}
.backgroundColor($r('app.color.color_F5F5F5'))
.width(CommonConstants.FULL_WIDTH)
.height(40)
.borderRadius($r('app.float.button_border_radius'))
.justifyContent(FlexAlign.Center)
.margin({top: 5})
}
}
.width(CommonConstants.FULL_WIDTH)
.padding({
top: 14,
left: 16,
right: 16,
bottom: 14
})
.backgroundColor($r("app.color.white"))
.margin({ bottom: 8 })
.onClick((event: ClickEvent) => {
ProcessUtils.processPage(this.compDTO?.operDataList[0])
})
}
@Builder timelineItem (item:slideShows, index:number) {
Column(){
Stack() {
if(index < this.compDTO.operDataList[0].slideShows.length - 1) {
Divider()
.vertical(true)
.color($r('app.color.color_EDEDED'))
.strokeWidth(1)
.margin({top: index > 0 ? 0 : 16, left: 4})
}
if(index > 0 && index == this.compDTO.operDataList[0].slideShows.length - 1) {
Divider()
.vertical(true)
.color($r('app.color.color_EDEDED'))
.strokeWidth(1)
.height(16)
.margin({left: 4})
}
Column(){
Row() {
// 标题
Image($r("app.media.point_icon"))
.width(9)
.height(9)
.margin({ right: 5 })
Text(DateTimeUtils.formatDate(item.publishTime, "MM月dd日 HH:mm"))
.fontSize($r('app.float.font_size_12'))
.fontColor($r('app.color.color_222222'))
.fontWeight(600)
}
.width(CommonConstants.FULL_WIDTH)
.height(32)
.alignItems(VerticalAlign.Center)
Row() {
Text(item.newsTitle)
.fontSize($r('app.float.font_size_17'))
.fontWeight(400)
.fontColor($r('app.color.color_222222'))
.layoutWeight(1)
.maxLines(2)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.alignSelf(ItemAlign.Center)
.margin({left: 12})
if(item.fullColumnImgUrls[0] && item.fullColumnImgUrls[0].url) {
Image(item.fullColumnImgUrls[0].url)
.width(90)
.height(60)
.borderRadius($r('app.float.image_border_radius'))
}
}
}
}
.alignContent(Alignment.TopStart)
}
.height(item.fullColumnImgUrls[0] && item.fullColumnImgUrls[0].url ? 100 : 78)
.alignItems(HorizontalAlign.Start)
}
}
\ No newline at end of file
import { CompDTO, ContentDTO, slideShows } from 'wdBean';
import { CommonConstants } from 'wdConstant'
import { DateTimeUtils } from 'wdKit';
import { ProcessUtils } from '../../utils/ProcessUtils';
/**
* 大专题卡--CompStyle: 10
*/
@Component
export struct CompStyle_10 {
@State compDTO: CompDTO = {} as CompDTO
build() {
Column(){
// 顶部标题,最多两行
if(this.compDTO.operDataList[0].newsTitle) {
Text(this.compDTO.operDataList[0].newsTitle)
.width(CommonConstants.FULL_WIDTH)
.fontSize($r('app.float.font_size_17'))
.fontWeight(600)
.maxLines(2)
.textOverflow({overflow: TextOverflow.Ellipsis})
.margin({ bottom: 19 })
}
// 大图
Stack(){
Image(this.compDTO.operDataList[0] && this.compDTO.operDataList[0].coverUrl)
.width('100%')
.borderRadius({topLeft: $r('app.float.image_border_radius'), topRight: $r('app.float.image_border_radius')})
.onClick((event: ClickEvent) => {
ProcessUtils.processPage(this.compDTO?.operDataList[0])
})
Text('专题')
.fontSize($r('app.float.font_size_12'))
.padding({left: 8, right: 8, top: 3, bottom: 3})
.backgroundColor(Color.Red)
.fontColor(Color.White)
.borderRadius($r('app.float.button_border_radius'))
.margin({left: 5, bottom: 5})
}.alignContent(Alignment.BottomStart)
// 专题列表--后端返回三个,
Column(){
ForEach(this.compDTO.operDataList[0].slideShows, (item:slideShows, index:number) => {
this.timelineItem(item, index)
})
}
// 底部-查看更多。根据接口返回的isMore判断是否显示查看更多
if(this.compDTO.operDataList[0].hasMore == 1) {
Row() {
Text("查看更多")
.fontSize($r("app.float.font_size_14"))
.fontColor($r("app.color.color_222222"))
.margin({ right: 1 })
Image($r("app.media.more"))
.width(14)
.height(14)
}
.backgroundColor($r('app.color.color_F5F5F5'))
.width(CommonConstants.FULL_WIDTH)
.height(40)
.borderRadius($r('app.float.button_border_radius'))
.justifyContent(FlexAlign.Center)
.margin({top: 5})
.onClick((event: ClickEvent) => {
ProcessUtils.processPage(this.compDTO?.operDataList[0])
})
}
}
.width(CommonConstants.FULL_WIDTH)
.padding({
top: 14,
left: 16,
right: 16,
bottom: 14
})
.backgroundColor($r("app.color.white"))
.margin({ bottom: 8 })
}
@Builder timelineItem (item:slideShows, index:number) {
Row() {
Column(){
Text(item.newsTitle)
.fontSize($r('app.float.font_size_17'))
.fontWeight(400)
.fontColor($r('app.color.color_222222'))
.maxLines(2)
.textOverflow({ overflow: TextOverflow.Ellipsis })
Row(){
// 展示发稿人
if(item.source) {
Text(item.source)
.fontSize($r('app.float.font_size_12'))
.fontColor($r('app.color.color_B0B0B0'))
.textOverflow({overflow: TextOverflow.Ellipsis})
.maxLines(1)
.width(item.source.length > 10 ? '60%' : '')
Image($r('app.media.point'))
.width(16)
.height(16)
}
Text(DateTimeUtils.getCommentTime(Number.parseFloat(String(item.publishTime))))
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_B0B0B0"))
}
.margin({top: 12})
}
.layoutWeight(1)
.alignItems(HorizontalAlign.Start)
// 右侧图片
if(item.fullColumnImgUrls[0] && item.fullColumnImgUrls[0].url) {
Image(item.fullColumnImgUrls[0].url)
.width(117)
.height(78)
.objectFit(ImageFit.Cover)
.borderRadius($r('app.float.image_border_radius'))
.margin({left: 12})
}
}
.padding({top: 10, bottom: 10})
.onClick((event: ClickEvent) => {
const str: string = JSON.stringify(this.compDTO.operDataList[0]);
const data: ContentDTO = JSON.parse(str)
data.objectId = item.newsId
data.relId = item.relId
data.objectType = String(item.objectType)
ProcessUtils.processPage(data)
})
}
}
\ No newline at end of file
... ... @@ -4,6 +4,42 @@ import { Logger } from 'wdKit';
const TAG = 'EmptyComponent';
/**
* WDViewDefaultType 缺省页
*/
export const enum WDViewDefaultType {
///默认
WDViewDefaultType_Default,
///无网
WDViewDefaultType_NoNetwork,
///暂无内容(列表页)
WDViewDefaultType_NoListContent,
///内容找不到了(内容详情页)
WDViewDefaultType_NoContent,
///无搜索内容
WDViewDefaultType_NoSearchResult,
///无消息内容
WDViewDefaultType_NoMessage,
///无收藏内容
WDViewDefaultType_NoCollection,
///无历史记录
WDViewDefaultType_NoHistory,
///网络失败
WDViewDefaultType_NetworkFailed,
///内容获取失败
WDViewDefaultType_ContentFailed,
///无预约内容
WDViewDefaultType_NoBooking,
///无评论内容
WDViewDefaultType_NoComment,
///暂无作品
WDViewDefaultType_NoCreation,
///该号主无法访问
WDViewDefaultType_NoVisitAccount,
///暂无关注
WDViewDefaultType_NoFollow
}
/**
* 空数据/无数据
*/
@Component
... ... @@ -11,18 +47,19 @@ export struct EmptyComponent {
// private emptySize: SizeOptions = {};
@State emptyWidth: string | number = CommonConstants.FULL_PARENT;
@State emptyHeight: string | number = CommonConstants.FULL_PARENT;
@State emptyType:number = WDViewDefaultType.WDViewDefaultType_Default
/**
* The empty image width percentage setting.
*/
readonly EMPTY_IMAGE_WIDTH: string = '50%';
readonly EMPTY_IMAGE_WIDTH: string = '15%';
/**
* The empty image height percentage setting.
*/
readonly EMPTY_IMAGE_HEIGHT: string = '30%';
readonly EMPTY_IMAGE_HEIGHT: string = '15%';
/**
* The empty data text component margin top.
*/
readonly EMPTY_TIP_TEXT_MARGIN_TOP: string = '2%';
readonly EMPTY_TIP_TEXT_MARGIN_TOP: string = '10';
/**
* The empty data text opacity.
*/
... ... @@ -38,11 +75,11 @@ export struct EmptyComponent {
@Builder
noProgrammeData() {
Column() {
// Image($r('app.media.icon_no_content'))
// .width(this.EMPTY_IMAGE_WIDTH)
// .height(this.EMPTY_IMAGE_HEIGHT)
// .objectFit(ImageFit.Contain)
// // .border({ width: 1, color: Color.Red, radius: 6 })
Image(this.buildNoDataTipImage())
.width('this.EMPTY_IMAGE_WIDTH')
.height(this.EMPTY_IMAGE_HEIGHT)
.objectFit(ImageFit.Contain)
// .border({ width: 1, color: Color.Red, radius: 6 })
Text(this.buildNoDataTip())
.fontSize($r('app.float.normal_text_size'))
... ... @@ -59,8 +96,22 @@ export struct EmptyComponent {
.height(this.emptyHeight)
}
buildNoDataTip(): Resource | string {
buildNoDataTip(): string {
Logger.info(TAG, "buildNoDataTip");
let contentString: string = '暂无内容'
if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoCollection) {
contentString = '暂无收藏'
}
return contentString
}
buildNoDataTipImage(): Resource | string {
Logger.info(TAG, "buildNoDataTip");
return $r('app.string.load_net_data_none')
let imageString: Resource | string = $r('app.media.icon_no_content')
if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoCollection) {
imageString = $r('app.media.icon_no_collection')
}
return imageString
}
}
\ No newline at end of file
... ...
import { CompDTO } from 'wdBean';
import { CommonConstants } from 'wdConstant';
import { ProcessUtils } from '../../utils/ProcessUtils';
@Component
export struct HeadPictureCardComponent {
@State compDTO: CompDTO = {} as CompDTO
build() {
Stack() {
Image(this.compDTO.operDataList[0].coverUrl)
.width(CommonConstants.FULL_WIDTH)
.autoResize(true)
.borderRadius($r('app.float.image_border_radius'))
if (this.compDTO.operDataList[0].newsTitle) {
Row()
.width(CommonConstants.FULL_WIDTH)
.height(59)
.linearGradient({
colors: [
['rgba(0, 0, 0, 0.0)', 0.0], ['rgba(0, 0, 0, 0.3)', 1.0]
]
})
Row() {
Text(this.compDTO.operDataList[0].newsTitle)
.width(CommonConstants.FULL_WIDTH)
.height(CommonConstants.FULL_HEIGHT)
.fontColor(Color.White)
.fontSize($r('app.float.normal_text_size'))
.fontWeight(FontWeight.Bold)
.maxLines(2)
.align(Alignment.Bottom)
}
.justifyContent(FlexAlign.Start)
.height(40)
.margin({ left: 12, bottom: 10, right: 12 })
}
}
.alignContent(Alignment.Bottom)
.width(CommonConstants.FULL_WIDTH)
.padding(
{ top: 16, bottom: 16, left: 14, right: 14 })
.onClick((event: ClickEvent) => {
ProcessUtils.processPage(this.compDTO?.operDataList[0])
})
}
}
... ... @@ -27,11 +27,11 @@ export struct RecommendList {
.width(CommonConstants.FULL_PARENT)
.justifyContent(FlexAlign.Start)
}
ForEach(this.recommendList, (item: ContentDTO) => {
Row(){
ForEach(this.recommendList, (item: ContentDTO, index: number) => {
Row() {
CardParser({ contentDTO: item });
}.border({
width:{bottom: 1},
width: { bottom: this.recommendList.length === index + 1 ? 0 : 1 },
color: '#f5f5f5'
})
}, (item: ContentDTO) => JSON.stringify(item))
... ...
import { Action, CompDTO, ContentDTO, Params } from 'wdBean';
import { CompStyle } from 'wdConstant';
import { Logger, DateTimeUtils } from 'wdKit';
import { WDRouterRule } from 'wdRouter';
const TAG = 'SingleImageCardAppComponent';
const FULL_PARENT: string = '100%';
/**
* 单图卡-3行标题/2行标题
* 枚举值13
*
* 重磅推荐/精选/电视剧/电影/综艺/短剧/更多>/
*/
@Entry
@Component
export struct SingleImageCardAppComponent {
// @State compDTO: CompDTO = {} as CompDTO
@State compDTO: CompDTO = {
operDataList: [
{
coverSize: '660*371',
coverType: 1,
visitorComment: 10,
coverUrl: 'https://cdnjdphoto.aikan.pdnews.cn/zhbj-20240116/image/content/a9028e7011bb440e94ba7c63d80b39b7.png?x-oss-process=image/resize,w_550/quality,q_90/format,jpg',
newsTitle: '一条江豚的自述',
newsSummary: '我是生活在长江里的一头江豚,是长江中唯一的水生哺乳动物,更是国家一级保护动物。但曾几何时,我和我的江中小伙伴出现了生存危机……直到有一天,我突然发现,打渔人变成护渔人,江水变清澈了,长江逐渐恢复了生机,我的家族数量上升到了1249头。当长江之水再一次悠悠流淌,我们相拥在清澈波光中起舞。长江,我的家园。',
videoInfo: {
// clarity: 1,
resolutionHeight: 20,
resolutionWidth: 20,
videoDuration: 229,
videoLandScape: 1,
videoType: 1,
videoUrl: "https://cdnjdout.aikan.pdnews.cn/zhbj-20240116/vod/content/output/c72f4170db2c4d34befa453f60d39a69_opt.mp4",
firstFrameImageUri: "", // 首帧图;【视频内容,contentPictures中】
},
} as ContentDTO
]
} as CompDTO
aboutToAppear() {
}
build() {
Column() {
Text(this.compDTO.operDataList[0].newsTitle)
.fontSize(16)
.fontWeight(FontWeight.Bold)
.alignSelf(ItemAlign.Start)
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。
if (this.compDTO.operDataList[0].coverUrl) {
Stack() {
Image(this.compDTO.operDataList[0].coverUrl)
.borderRadius(5)
.aspectRatio(16 / 9)
.padding({ top: 10 })
if (this.compDTO.operDataList[0].videoInfo) {
Row() {
Image($r('app.media.iv_card_play_yellow_flag'))
.width(22)
.height(18)
Text(DateTimeUtils.getFormattedDuration(this.compDTO.operDataList[0].videoInfo.videoDuration * 1000))
.fontSize($r('app.float.font_size_13'))
.fontWeight(400)
.fontColor($r('app.color.color_fff'))
}
.alignItems(VerticalAlign.Bottom)
.height(18)
.padding({ right: 4 })
.margin({
right: 4,
bottom: 4
})
.backgroundColor($r('app.color.color_4d000000'))
}
}.alignContent(Alignment.BottomEnd)
}
if (this.compDTO.operDataList[0].newsSummary) {
Text(this.compDTO.operDataList[0].newsSummary)
.fontSize(14)
.padding({ top: 10 })
.alignSelf(ItemAlign.Start)
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。
}
Row() {
Text(this.compDTO.operDataList[0].visitorComment + "评")
.fontSize(12)
.fontColor(Color.Gray)
Image($r('app.media.icon_share'))
.width(16)
.height(16)
.margin(10)
}.width(FULL_PARENT)
.justifyContent(FlexAlign.SpaceBetween)
}
.margin(22)
}
}
\ No newline at end of file
import { Action, CompDTO, Params } from 'wdBean';
import { ExtraDTO } from 'wdBean/src/main/ets/bean/component/extra/ExtraDTO';
import { CompStyle } from 'wdConstant';
import { Logger, DateTimeUtils } from 'wdKit';
import { WDRouterRule } from 'wdRouter';
import { ProcessUtils } from '../../utils/ProcessUtils';
const TAG = 'SingleImageCardComponent';
const FULL_PARENT: string = '100%';
/**
* 单图卡-3行标题/2行标题
* 枚举值13
* ImageCard-03
* 重磅推荐/精选/电视剧/电影/综艺/短剧/更多>/
*/
@Component
export struct SingleImageCardComponent {
@State compDTO: CompDTO = {} as CompDTO
aboutToAppear() {
//Logger.debug(TAG + "" + JSON.stringify(this.compDTO.operDataList));
}
build() {
Row() {
Column() {
Column() {
Text(this.compDTO.operDataList[0].newsTitle)
.fontSize(16)
.fontWeight(FontWeight.Normal)
.maxLines(3)//
.alignSelf(ItemAlign.Start)
.textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。
}.height("80%")
.justifyContent(FlexAlign.Start)
Row() {
if (this.compDTO.operDataList[0].source) {
Text(this.compDTO.operDataList[0].source)
.fontSize($r('app.float.font_size_12'))
.fontColor(Color.Gray)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。
.width(this.compDTO.operDataList[0].source.length > 8 ? '50%' : '')
Image($r('app.media.point'))
.width(16)
.height(16)
}
if (this.compDTO.operDataList[0].publishTime && this.compDTO.operDataList[0].publishTime.length === 13) {
Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.compDTO.operDataList[0].publishTime)))
.fontSize($r('app.float.font_size_12'))
.fontColor(Color.Gray)
}
Text(this.compDTO.operDataList[0].visitorComment + '评')
.fontSize($r('app.float.font_size_12'))
.fontColor(Color.Gray)
.padding({
left: 5
})
}.alignSelf(ItemAlign.Start)
.height("20%")
.justifyContent(FlexAlign.Start)
}
.alignItems(HorizontalAlign.Start)
.justifyContent(FlexAlign.Start)
.width('58%')
Blank(16)
if (this.compDTO.operDataList[0].coverUrl) {
Stack() {
Image(this.compDTO.operDataList[0].coverUrl)
.borderRadius(5)
.aspectRatio(this.compDTO.compStyle === CompStyle.Card_13 ? 3 / 2 : 3 / 4)
.height(this.compDTO.compStyle === CompStyle.Card_13 ? 90 : 180)
if (this.compDTO.operDataList[0].videoInfo) {
Row() {
Image($r('app.media.iv_card_play_yellow_flag'))
.width(22)
.height(18)
Text(DateTimeUtils.getFormattedDuration(this.compDTO.operDataList[0].videoInfo.videoDuration * 1000))
.fontSize($r('app.float.font_size_13'))
.fontWeight(400)
.fontColor($r('app.color.color_fff'))
}
.alignItems(VerticalAlign.Bottom)
.height(18)
.padding({ right: 4 })
.margin({
right: 4,
bottom: 4
})
.backgroundColor($r('app.color.color_4d000000'))
} else if(this.compDTO.operDataList[0].voiceInfo) {
Row() {
Image($r('app.media.icon_listen'))
.width(22)
.height(18)
Text(DateTimeUtils.getFormattedDuration(this.compDTO.operDataList[0].voiceInfo
.voiceDuration * 1000))
.fontSize($r('app.float.font_size_13'))
.fontWeight(400)
.fontColor($r('app.color.color_fff'))
}
.alignItems(VerticalAlign.Bottom)
.height(18)
.padding({ right: 4 })
.margin({
right: 4,
bottom: 4
})
.backgroundColor($r('app.color.color_4d000000'))
}
}.alignContent(Alignment.BottomEnd)
}
}
.onClick((event: ClickEvent) => {
ProcessUtils.processPage(this.compDTO?.operDataList[0])
})
.padding(
{ top: 16, bottom: 16, left: 14, right: 14 })
.width(FULL_PARENT)
.height(this.compDTO.compStyle === CompStyle.Card_13 ? 127 : 217)
.justifyContent(FlexAlign.SpaceBetween)
}
}
\ No newline at end of file
// import { CommonConstants } from 'wdConstant/src/main/ets/constants/CommonConstants'
@Entry
@Component
export struct SmallVideoCardComponent {
build() {
Row() {
Column() {
Text('“畅享亚运”新模式活动打卡,看杭州打开“金角银边活动启动 跟着体育明星云打卡,看杭州打开“金角银边')
.fontWeight(400)
.fontSize($r('app.float.font_size_17'))
.maxLines(4)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.fontColor($r('app.color.color_222222'))
.lineHeight(25)
Row() {
Text('人民日报')
.labelTextStyle()
Image($r('app.media.point'))
.width(16)
.height(16)
Text('20分钟前')
.labelTextStyle()
.margin({
right: 6
})
Text('2000评')
.labelTextStyle()
}
}
.height(156)
.layoutWeight(1)
.justifyContent(FlexAlign.SpaceBetween)
.alignItems(HorizontalAlign.Start)
.margin({ right: 12 })
Stack({ alignContent: Alignment.BottomEnd }) {
Image('https://www.harmonyos.com/resource/image/partner/harmonyos-connect/pic_shengtai_connect_qudao_xianxia.jpg')
.width(117)
.aspectRatio(117 / 156)
.border({ radius: 4 })
Row() {
Image($r('app.media.iv_card_play_yellow_flag'))
.width(22)
.height(18)
Text('10:00')
.fontSize($r('app.float.font_size_13'))
.fontWeight(400)
.fontColor($r('app.color.color_fff'))
}
.height(18)
.padding({ right: 4 })
.margin({
right: 4,
bottom: 4
})
.backgroundColor($r('app.color.color_4d000000'))
}
}
// .width(CommonConstants.FULL_WIDTH)
.width('100%')
.height(184)
.padding({
top: 14,
bottom: 14,
left: 16,
right: 16
})
}
}
@Extend(Text) function labelTextStyle() {
.fontSize($r('app.float.font_size_12'))
.fontWeight(400)
.fontColor($r('app.color.color_B0B0B0'))
}
\ No newline at end of file
//缩略标题
import { CommonConstants } from 'wdConstant'
import { CompDTO } from 'wdBean'
import { DateTimeUtils } from 'wdKit'
@Component
export struct TitleAbbrComponent {
@State compDTO: CompDTO = {} as CompDTO
build() {
Column() {
Text(this.compDTO.operDataList[0].newsTitle)
.fontSize($r("app.float.font_size_16"))
.fontColor($r("app.color.color_222222"))
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.width(CommonConstants.FULL_WIDTH)
Row() {
Text("锐评")
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_ED2800"))
Text(this.compDTO.operDataList[0].source)
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_B0B0B0"))
.margin({ left: 6 })
Image($r("app.media.point"))
.width(16)
.height(16)
Text(DateTimeUtils.formatDate(Number.parseFloat(this.compDTO.operDataList[0].publishTime)))
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_B0B0B0"))
}.width(CommonConstants.FULL_WIDTH)
.justifyContent(FlexAlign.Start)
.margin({ top: 8 })
}.width(CommonConstants.FULL_WIDTH)
.padding({
top: 14,
left: 16,
right: 16,
bottom: 14
})
.backgroundColor($r("app.color.white"))
.margin({ bottom: 8 })
}
}
\ No newline at end of file
//全标题 "compStyle":"3",
import { CommonConstants } from 'wdConstant'
import { CompDTO } from 'wdBean'
import { DateTimeUtils } from 'wdKit/src/main/ets/utils/DateTimeUtils'
import { Logger } from 'wdKit/src/main/ets/utils/Logger'
import { ProcessUtils } from '../../utils/ProcessUtils'
@Component
export struct TitleAllComponent {
@State compDTO: CompDTO = {} as CompDTO
build() {
Column() {
Text(this.compDTO.operDataList[0].newsTitle)
.fontSize($r("app.float.font_size_16"))
.fontColor($r("app.color.color_222222"))
.width(CommonConstants.FULL_WIDTH)
Row() {
Text("锐评")
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_ED2800"))
Text(this.compDTO.operDataList[0].source)
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_B0B0B0"))
.margin({ left: 6 })
Image($r("app.media.point"))
.width(16)
.height(16)
Text(DateTimeUtils.formatDate(Number.parseFloat(this.compDTO.operDataList[0].publishTime)))
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_B0B0B0"))
}.width(CommonConstants.FULL_WIDTH)
.justifyContent(FlexAlign.Start)
.margin({ top: 8 })
}.width("100%")
.padding({
top: 14,
left: 16,
right: 16,
bottom: 14
})
.backgroundColor($r("app.color.white"))
.margin({ bottom: 8 })
.onClick((event: ClickEvent)=>{
ProcessUtils.processPage(this.compDTO.operDataList[0])
})
}
aboutToAppear(){
// Logger.info("ssx",JSON.stringify(this.compDTO.operDataList[0]))
}
}
\ No newline at end of file