Showing
13 changed files
with
239 additions
and
91 deletions
| 1 | import { Action } from './Action'; | 1 | import { Action } from './Action'; |
| 2 | interface dataObject { | 2 | interface dataObject { |
| 3 | + // dataSource: | ||
| 4 | + // 1、图文详情数据 | ||
| 5 | + // 2、英文端跳转推荐内容数据 | ||
| 6 | + // 3、显示图片预览 | ||
| 7 | + // 4、专题pageinfo数据 | ||
| 8 | + // 5、专题comp运营位点击跳转(传给App记录浏览历史) | ||
| 9 | + // 6、图文详情引用内容跳转 | ||
| 10 | + // 7、专题分享海报图上的数据列表(H5可选第一页前5条运营位数据) | ||
| 11 | + // 8、活动投稿 文章跳转 | ||
| 12 | + // 9、活动投稿 视频跳转 | ||
| 13 | + // 10、活动投稿 动态跳转 | ||
| 14 | + // 11、活动投稿 图集跳转 | ||
| 3 | dataSource: number | 15 | dataSource: number |
| 4 | operateType?: string | 16 | operateType?: string |
| 5 | webViewHeight?: string | 17 | webViewHeight?: string |
| @@ -22,6 +22,11 @@ export class Logger { | @@ -22,6 +22,11 @@ export class Logger { | ||
| 22 | private static domain: number = 0xFF00; | 22 | private static domain: number = 0xFF00; |
| 23 | private static prefix: string = 'SightApp'; | 23 | private static prefix: string = 'SightApp'; |
| 24 | private static format: string = `%{public}s, %{public}s`; | 24 | private static format: string = `%{public}s, %{public}s`; |
| 25 | + private static format_ext: string = `%{public}s`; | ||
| 26 | + /** | ||
| 27 | + * 暂时没找到限制大小相关文档,尝试4000是不行的,3500可以。可以后续优化 | ||
| 28 | + */ | ||
| 29 | + private static CHUNK_SIZE: number = 3500; | ||
| 25 | static isDebug: boolean = true; | 30 | static isDebug: boolean = true; |
| 26 | 31 | ||
| 27 | /** | 32 | /** |
| @@ -36,46 +41,113 @@ export class Logger { | @@ -36,46 +41,113 @@ export class Logger { | ||
| 36 | } | 41 | } |
| 37 | 42 | ||
| 38 | static debug(...args: string[]) { | 43 | static debug(...args: string[]) { |
| 39 | - if(!Logger.isDebug){ | 44 | + if (!Logger.isDebug) { |
| 40 | return | 45 | return |
| 41 | } | 46 | } |
| 42 | - hilog.debug(Logger.domain, Logger.prefix, Logger.format, args); | 47 | + Logger.logContent(LogLevel.DEBUG, ...args) |
| 43 | } | 48 | } |
| 44 | 49 | ||
| 45 | static info(...args: string[]) { | 50 | static info(...args: string[]) { |
| 46 | - if(!Logger.isDebug){ | 51 | + if (!Logger.isDebug) { |
| 47 | return | 52 | return |
| 48 | } | 53 | } |
| 49 | - hilog.info(Logger.domain, Logger.prefix, Logger.format, args); | 54 | + Logger.logContent(LogLevel.INFO, ...args) |
| 50 | } | 55 | } |
| 51 | 56 | ||
| 52 | static warn(...args: string[]) { | 57 | static warn(...args: string[]) { |
| 53 | - if(!Logger.isDebug){ | 58 | + if (!Logger.isDebug) { |
| 54 | return | 59 | return |
| 55 | } | 60 | } |
| 56 | - hilog.warn(Logger.domain, Logger.prefix, Logger.format, args); | 61 | + Logger.logContent(LogLevel.WARN, ...args) |
| 57 | } | 62 | } |
| 58 | 63 | ||
| 59 | static error(...args: string[]) { | 64 | static error(...args: string[]) { |
| 60 | - if(!Logger.isDebug){ | 65 | + if (!Logger.isDebug) { |
| 61 | return | 66 | return |
| 62 | } | 67 | } |
| 63 | - hilog.error(Logger.domain, Logger.prefix, Logger.format, args); | 68 | + Logger.logContent(LogLevel.ERROR, ...args) |
| 64 | } | 69 | } |
| 65 | 70 | ||
| 66 | static fatal(...args: string[]) { | 71 | static fatal(...args: string[]) { |
| 67 | - if(!Logger.isDebug){ | 72 | + if (!Logger.isDebug) { |
| 68 | return | 73 | return |
| 69 | } | 74 | } |
| 70 | - hilog.fatal(Logger.domain, Logger.prefix, Logger.format, args); | 75 | + Logger.logContent(LogLevel.FATAL, ...args) |
| 71 | } | 76 | } |
| 72 | 77 | ||
| 73 | static isLoggable(level: LogLevel) { | 78 | static isLoggable(level: LogLevel) { |
| 74 | - if(!Logger.isDebug){ | 79 | + if (!Logger.isDebug) { |
| 75 | return | 80 | return |
| 76 | } | 81 | } |
| 82 | + // 判断是否打印 TODO | ||
| 77 | hilog.isLoggable(Logger.domain, Logger.prefix, level); | 83 | hilog.isLoggable(Logger.domain, Logger.prefix, level); |
| 78 | } | 84 | } |
| 85 | + | ||
| 86 | + static logContent(level: LogLevel, ...args: string[]) { | ||
| 87 | + let msg = Logger.getMsg(...args) | ||
| 88 | + let length = msg.length | ||
| 89 | + if (length < Logger.CHUNK_SIZE) { | ||
| 90 | + // 不超限,保持原来的打印 | ||
| 91 | + Logger.print(level, ...args) | ||
| 92 | + } else { | ||
| 93 | + // 超限,分段打印 | ||
| 94 | + for (let i = 0; i < length; i += Logger.CHUNK_SIZE) { | ||
| 95 | + let count = Math.min(length - i, Logger.CHUNK_SIZE); | ||
| 96 | + Logger.printExt(level, msg.substring(i, i + count)); | ||
| 97 | + } | ||
| 98 | + } | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + static print(level: LogLevel, ...msg: string[]) { | ||
| 102 | + switch (level) { | ||
| 103 | + case LogLevel.DEBUG: | ||
| 104 | + hilog.debug(Logger.domain, Logger.prefix, Logger.format, msg); | ||
| 105 | + break | ||
| 106 | + case LogLevel.INFO: | ||
| 107 | + hilog.info(Logger.domain, Logger.prefix, Logger.format, msg); | ||
| 108 | + break | ||
| 109 | + case LogLevel.WARN: | ||
| 110 | + hilog.warn(Logger.domain, Logger.prefix, Logger.format, msg); | ||
| 111 | + break | ||
| 112 | + case LogLevel.ERROR: | ||
| 113 | + hilog.error(Logger.domain, Logger.prefix, Logger.format, msg); | ||
| 114 | + break | ||
| 115 | + case LogLevel.FATAL: | ||
| 116 | + hilog.fatal(Logger.domain, Logger.prefix, Logger.format, msg); | ||
| 117 | + break | ||
| 118 | + } | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + static printExt(level: LogLevel, msg: string) { | ||
| 122 | + switch (level) { | ||
| 123 | + case LogLevel.DEBUG: | ||
| 124 | + hilog.debug(Logger.domain, Logger.prefix, Logger.format_ext, msg); | ||
| 125 | + break | ||
| 126 | + case LogLevel.INFO: | ||
| 127 | + hilog.info(Logger.domain, Logger.prefix, Logger.format_ext, msg); | ||
| 128 | + break | ||
| 129 | + case LogLevel.WARN: | ||
| 130 | + hilog.warn(Logger.domain, Logger.prefix, Logger.format_ext, msg); | ||
| 131 | + break | ||
| 132 | + case LogLevel.ERROR: | ||
| 133 | + hilog.error(Logger.domain, Logger.prefix, Logger.format_ext, msg); | ||
| 134 | + break | ||
| 135 | + case LogLevel.FATAL: | ||
| 136 | + hilog.fatal(Logger.domain, Logger.prefix, Logger.format_ext, msg); | ||
| 137 | + break | ||
| 138 | + } | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + static getMsg(...args: string[]): string { | ||
| 142 | + if (args == null || args.length <= 0) { | ||
| 143 | + return ''; | ||
| 144 | + } | ||
| 145 | + let msg = '' | ||
| 146 | + args.forEach((v) => { | ||
| 147 | + msg = msg.concat(', ').concat(v) | ||
| 148 | + }) | ||
| 149 | + return msg.substring(2, msg.length); | ||
| 150 | + } | ||
| 79 | } | 151 | } |
| 80 | 152 | ||
| 81 | export default new Logger('SightApp', 0xFF00) | 153 | export default new Logger('SightApp', 0xFF00) |
| @@ -12,8 +12,17 @@ export interface ResponseDTO<T = string> { | @@ -12,8 +12,17 @@ export interface ResponseDTO<T = string> { | ||
| 12 | 12 | ||
| 13 | // 响应结果 | 13 | // 响应结果 |
| 14 | data?: T; | 14 | data?: T; |
| 15 | + | ||
| 16 | + /** | ||
| 17 | + * @deprecated | ||
| 18 | + */ | ||
| 15 | totalCount?: number; | 19 | totalCount?: number; |
| 20 | + meta?: MetaDTO; | ||
| 16 | 21 | ||
| 17 | // 请求响应时间戳(unix格式) | 22 | // 请求响应时间戳(unix格式) |
| 18 | timestamp?: number; | 23 | timestamp?: number; |
| 19 | } | 24 | } |
| 25 | + | ||
| 26 | +export interface MetaDTO { | ||
| 27 | + md5: string; | ||
| 28 | +} |
| @@ -38,6 +38,7 @@ instance.interceptors.request.use( | @@ -38,6 +38,7 @@ instance.interceptors.request.use( | ||
| 38 | } | 38 | } |
| 39 | // 公共请求参数 | 39 | // 公共请求参数 |
| 40 | // config.params.key = key | 40 | // config.params.key = key |
| 41 | + Logger.debug('HttpRequest', 'request: ' + config.url) | ||
| 41 | return config; | 42 | return config; |
| 42 | }, | 43 | }, |
| 43 | (error: AxiosError) => { | 44 | (error: AxiosError) => { |
| @@ -85,9 +86,9 @@ instance.interceptors.response.use(// 响应拦截器response类型就是Axios.r | @@ -85,9 +86,9 @@ instance.interceptors.response.use(// 响应拦截器response类型就是Axios.r | ||
| 85 | // return Promise.reject(new Error(message)) | 86 | // return Promise.reject(new Error(message)) |
| 86 | // } | 87 | // } |
| 87 | // const data: ResponseBean<any> = response.data | 88 | // const data: ResponseBean<any> = response.data |
| 88 | - Logger.debug('HttpRequest', 'response ======start======= ') | 89 | + Logger.debug('HttpRequest', 'response ==============start=================') |
| 89 | Logger.debug('HttpRequest', 'response: ' + JSON.stringify(response.data)) | 90 | Logger.debug('HttpRequest', 'response: ' + JSON.stringify(response.data)) |
| 90 | - Logger.debug('HttpRequest', 'response ======end======= ') | 91 | + Logger.debug('HttpRequest', 'response ==============end=================') |
| 91 | // 改造返回的数据,即将AxiosResponse的data返回,服务端返回的数据 | 92 | // 改造返回的数据,即将AxiosResponse的data返回,服务端返回的数据 |
| 92 | return response.data; | 93 | return response.data; |
| 93 | } else { | 94 | } else { |
| @@ -102,7 +103,7 @@ instance.interceptors.response.use(// 响应拦截器response类型就是Axios.r | @@ -102,7 +103,7 @@ instance.interceptors.response.use(// 响应拦截器response类型就是Axios.r | ||
| 102 | // console.log(error.request) | 103 | // console.log(error.request) |
| 103 | // console.log(error.response) | 104 | // console.log(error.response) |
| 104 | // 这里用来处理http常见错误,进行全局提示 | 105 | // 这里用来处理http常见错误,进行全局提示 |
| 105 | - if(error!=null && error.response!=null ){ | 106 | + if (error != null && error.response != null) { |
| 106 | let message = buildErrorMsg(error.response.status); | 107 | let message = buildErrorMsg(error.response.status); |
| 107 | // 错误消息可以使用全局弹框展示出来 | 108 | // 错误消息可以使用全局弹框展示出来 |
| 108 | console.log(`httpStatus:${error.response?.status}-${message},请检查网络或联系管理员!`) | 109 | console.log(`httpStatus:${error.response?.status}-${message},请检查网络或联系管理员!`) |
| @@ -14,6 +14,7 @@ const TAG = 'JsBridgeBiz' | @@ -14,6 +14,7 @@ const TAG = 'JsBridgeBiz' | ||
| 14 | */ | 14 | */ |
| 15 | export function performJSCallNative(data: Message, call: Callback) { | 15 | export function performJSCallNative(data: Message, call: Callback) { |
| 16 | Logger.debug(TAG, 'performJSCallNative handlerName: ' + data.handlerName + ', data: ' + JSON.stringify(data.data)) | 16 | Logger.debug(TAG, 'performJSCallNative handlerName: ' + data.handlerName + ', data: ' + JSON.stringify(data.data)) |
| 17 | + | ||
| 17 | switch (data.handlerName) { | 18 | switch (data.handlerName) { |
| 18 | case H5CallNativeType.jsCall_currentPageOperate: | 19 | case H5CallNativeType.jsCall_currentPageOperate: |
| 19 | break; | 20 | break; |
| @@ -24,12 +25,13 @@ export function performJSCallNative(data: Message, call: Callback) { | @@ -24,12 +25,13 @@ export function performJSCallNative(data: Message, call: Callback) { | ||
| 24 | case H5CallNativeType.jsCall_getArticleDetailBussinessData: | 25 | case H5CallNativeType.jsCall_getArticleDetailBussinessData: |
| 25 | break; | 26 | break; |
| 26 | case H5CallNativeType.jsCall_callAppService: | 27 | case H5CallNativeType.jsCall_callAppService: |
| 28 | + handleJsCallCallAppService(data) | ||
| 27 | break; | 29 | break; |
| 28 | case H5CallNativeType.jsCall_receiveH5Data: | 30 | case H5CallNativeType.jsCall_receiveH5Data: |
| 29 | - if(data?.data?.dataSource === 5){ | ||
| 30 | - handleH5Data(JSON.parse(data?.data?.dataJson || '{}')) | ||
| 31 | - | ||
| 32 | - } | 31 | + handleJsCallReceiveH5Data(data) |
| 32 | + break; | ||
| 33 | + case H5CallNativeType.jsCall_appInnerLinkMethod: | ||
| 34 | + handleJsCallAppInnerLinkMethod(data) | ||
| 33 | break; | 35 | break; |
| 34 | case 'changeNativeMessage': | 36 | case 'changeNativeMessage': |
| 35 | call("this is change Web Message") | 37 | call("this is change Web Message") |
| @@ -51,17 +53,35 @@ class AppInfo { | @@ -51,17 +53,35 @@ class AppInfo { | ||
| 51 | * 获取App公共信息 | 53 | * 获取App公共信息 |
| 52 | */ | 54 | */ |
| 53 | function getAppPublicInfo(): string { | 55 | function getAppPublicInfo(): string { |
| 56 | + | ||
| 54 | let info = new AppInfo() | 57 | let info = new AppInfo() |
| 55 | info.plat = 'Phone' | 58 | info.plat = 'Phone' |
| 56 | // 直接用Android,后续适配再新增鸿蒙 | 59 | // 直接用Android,后续适配再新增鸿蒙 |
| 57 | info.system = 'Android' | 60 | info.system = 'Android' |
| 58 | info.networkStatus = 1 | 61 | info.networkStatus = 1 |
| 59 | let result = JSON.stringify(info) | 62 | let result = JSON.stringify(info) |
| 63 | + Logger.debug(TAG, 'getAppPublicInfo: ' + JSON.stringify(info)) | ||
| 64 | + | ||
| 60 | return result; | 65 | return result; |
| 61 | } | 66 | } |
| 62 | 67 | ||
| 63 | -function handleH5Data(content:ContentDTO) { | ||
| 64 | - Logger.debug(TAG, 'handleH5Data' + ', content: ' + JSON.stringify(content)) | ||
| 65 | - ProcessUtils.processPage(content) | 68 | +function handleJsCallReceiveH5Data(data: Message) { |
| 69 | + switch (data?.data?.dataSource) { | ||
| 70 | + case 5: | ||
| 71 | + if (data?.data?.dataSource === 5) { | ||
| 72 | + ProcessUtils.processPage(JSON.parse(data?.data?.dataJson || '{}')) | ||
| 73 | + } | ||
| 74 | + break; | ||
| 75 | + default: | ||
| 76 | + | ||
| 77 | + break; | ||
| 78 | + } | ||
| 79 | +} | ||
| 80 | + | ||
| 81 | +function handleJsCallCallAppService(data: Message) { | ||
| 82 | + | ||
| 83 | +} | ||
| 84 | + | ||
| 85 | +function handleJsCallAppInnerLinkMethod(data: Message) { | ||
| 66 | } | 86 | } |
| 67 | 87 |
| @@ -67,11 +67,10 @@ export struct BottomNavigationComponent { | @@ -67,11 +67,10 @@ export struct BottomNavigationComponent { | ||
| 67 | TopNavigationComponent({ | 67 | TopNavigationComponent({ |
| 68 | groupId: navItem.id, | 68 | groupId: navItem.id, |
| 69 | topNavList: navItem.topNavChannelList.filter(item => item.channelId != 2073), | 69 | topNavList: navItem.topNavChannelList.filter(item => item.channelId != 2073), |
| 70 | - _currentNavIndex: this.currentNavIndex, | 70 | + _currentNavIndex: $currentNavIndex, |
| 71 | currentBottomNavName: navItem.name, | 71 | currentBottomNavName: navItem.name, |
| 72 | - changeBarBackgroundColor: (color: Color) => { | ||
| 73 | - this.barBackgroundColor = color | ||
| 74 | - } | 72 | + barBackgroundColor: $barBackgroundColor |
| 73 | + | ||
| 75 | }) | 74 | }) |
| 76 | } | 75 | } |
| 77 | 76 | ||
| @@ -92,7 +91,8 @@ export struct BottomNavigationComponent { | @@ -92,7 +91,8 @@ export struct BottomNavigationComponent { | ||
| 92 | // this.onBottomNavigationIndexChange() | 91 | // this.onBottomNavigationIndexChange() |
| 93 | }) | 92 | }) |
| 94 | .backgroundColor(this.barBackgroundColor) | 93 | .backgroundColor(this.barBackgroundColor) |
| 95 | - .padding({ bottom: this.bottomRectHeight + 'px', top: this.topRectHeight + 'px' }) // 此处margin具体数值在实际中应与导航条区域高度保持一致 | 94 | + |
| 95 | + // .padding({ bottom: this.bottomRectHeight + 'px', top: this.topRectHeight + 'px' }) // 此处margin具体数值在实际中应与导航条区域高度保持一致 | ||
| 96 | 96 | ||
| 97 | } | 97 | } |
| 98 | 98 |
| @@ -125,14 +125,15 @@ export struct PageComponent { | @@ -125,14 +125,15 @@ export struct PageComponent { | ||
| 125 | this.pageModel.groupId = this.pageId; | 125 | this.pageModel.groupId = this.pageId; |
| 126 | this.pageModel.channelId = this.channelId; | 126 | this.pageModel.channelId = this.channelId; |
| 127 | this.pageModel.currentPage = 1; | 127 | this.pageModel.currentPage = 1; |
| 128 | - let pageInfo = await PageViewModel.getPageInfo(this.pageModel.pageId); | ||
| 129 | - if (pageInfo == null) { | ||
| 130 | - this.pageModel.viewType = ViewType.EMPTY; | ||
| 131 | - return; | ||
| 132 | - } | ||
| 133 | - this.pageModel.pageInfo = pageInfo; | ||
| 134 | - this.pageModel.loadStrategy = 1 | ||
| 135 | - PageHelper.parseGroup(this.pageModel) | 128 | + PageHelper.getInitData(this.pageModel) |
| 129 | + // let pageInfo = await PageViewModel.getPageInfo(this.pageModel.pageId); | ||
| 130 | + // if (pageInfo == null) { | ||
| 131 | + // this.pageModel.viewType = ViewType.EMPTY; | ||
| 132 | + // return; | ||
| 133 | + // } | ||
| 134 | + // this.pageModel.pageInfo = pageInfo; | ||
| 135 | + // this.pageModel.loadStrategy = 1 | ||
| 136 | + // PageHelper.parseGroup(this.pageModel) | ||
| 136 | } | 137 | } |
| 137 | } | 138 | } |
| 138 | 139 |
| @@ -24,17 +24,15 @@ export struct TopNavigationComponent { | @@ -24,17 +24,15 @@ export struct TopNavigationComponent { | ||
| 24 | private groupId: number = 0 | 24 | private groupId: number = 0 |
| 25 | private currentBottomNavName: string = '' | 25 | private currentBottomNavName: string = '' |
| 26 | private tabsController: TabsController = new TabsController() | 26 | private tabsController: TabsController = new TabsController() |
| 27 | - private changeBarBackgroundColor: (color: Color) => void = () => { | ||
| 28 | - } | ||
| 29 | @Consume isLayoutFullScreen: boolean | 27 | @Consume isLayoutFullScreen: boolean |
| 30 | @Consume bottomRectHeight: number | 28 | @Consume bottomRectHeight: number |
| 31 | @Consume topRectHeight: number | 29 | @Consume topRectHeight: number |
| 32 | @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 | 30 | @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 |
| 33 | @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 | 31 | @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 |
| 34 | - @State barBackgroundColor: Color = Color.Transparent | ||
| 35 | - @Prop @Watch('indexChange') _currentNavIndex?: number; | 32 | + @Link barBackgroundColor: Color |
| 33 | + @Link _currentNavIndex?: number; | ||
| 36 | // 顶导当前选中/焦点下标 | 34 | // 顶导当前选中/焦点下标 |
| 37 | - @State @Watch('indexChange') currentTopNavSelectedIndex: number = 0; | 35 | + @State currentTopNavSelectedIndex: number = 0; |
| 38 | // 顶导数据 | 36 | // 顶导数据 |
| 39 | @State @Watch('onTopNavigationDataUpdated') topNavList: TopNavDTO[] = [] | 37 | @State @Watch('onTopNavigationDataUpdated') topNavList: TopNavDTO[] = [] |
| 40 | @State compList: LazyDataSource<CompDTO> = new LazyDataSource(); | 38 | @State compList: LazyDataSource<CompDTO> = new LazyDataSource(); |
| @@ -151,29 +149,6 @@ export struct TopNavigationComponent { | @@ -151,29 +149,6 @@ export struct TopNavigationComponent { | ||
| 151 | WDRouterRule.jumpWithAction(taskAction) | 149 | WDRouterRule.jumpWithAction(taskAction) |
| 152 | } | 150 | } |
| 153 | 151 | ||
| 154 | - indexChange() { | ||
| 155 | - | ||
| 156 | - // 判断视频频道待处理 | ||
| 157 | - if (this._currentNavIndex === 2 && this.currentTopNavSelectedIndex == 0) { | ||
| 158 | - this.barBackgroundColor = Color.Black | ||
| 159 | - this.changeBarBackgroundColor && this.changeBarBackgroundColor(this.barBackgroundColor) | ||
| 160 | - // WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#ffffff', }) | ||
| 161 | - // WindowModel.shared.setWindowLayoutFullScreen(true) | ||
| 162 | - // this.isLayoutFullScreen = true | ||
| 163 | - // this.bottomRectHeight = this.bottomSafeHeight | ||
| 164 | - // this.topRectHeight = this.topSafeHeight | ||
| 165 | - | ||
| 166 | - } else { | ||
| 167 | - this.barBackgroundColor = Color.Transparent | ||
| 168 | - this.changeBarBackgroundColor && this.changeBarBackgroundColor(this.barBackgroundColor) | ||
| 169 | - // WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#000000', }) | ||
| 170 | - // WindowModel.shared.setWindowLayoutFullScreen(false) | ||
| 171 | - // this.isLayoutFullScreen = false | ||
| 172 | - // this.bottomRectHeight = 0 | ||
| 173 | - // this.topRectHeight = 0 | ||
| 174 | - } | ||
| 175 | - } | ||
| 176 | - | ||
| 177 | build() { | 152 | build() { |
| 178 | Column() { | 153 | Column() { |
| 179 | // 顶部搜索、日报logo、早晚报 | 154 | // 顶部搜索、日报logo、早晚报 |
| @@ -230,11 +205,12 @@ export struct TopNavigationComponent { | @@ -230,11 +205,12 @@ export struct TopNavigationComponent { | ||
| 230 | TabContent() { | 205 | TabContent() { |
| 231 | if (this.currentBottomNavName === '视频' && navItem.name === '视频') { | 206 | if (this.currentBottomNavName === '视频' && navItem.name === '视频') { |
| 232 | VideoChannelDetail({ | 207 | VideoChannelDetail({ |
| 233 | - bottomNavIndex: this._currentNavIndex, | ||
| 234 | - topNavIndex: this.currentTopNavSelectedIndex, | 208 | + bottomNavIndex: $_currentNavIndex, |
| 209 | + topNavIndex: $currentTopNavSelectedIndex, | ||
| 235 | groupId: this.groupId + '', | 210 | groupId: this.groupId + '', |
| 236 | pageId: navItem.pageId + '', | 211 | pageId: navItem.pageId + '', |
| 237 | channelId: navItem.channelId + '', | 212 | channelId: navItem.channelId + '', |
| 213 | + barBackgroundColor: $barBackgroundColor | ||
| 238 | }) | 214 | }) |
| 239 | } else | 215 | } else |
| 240 | if (!this.isBroadcast(navItem) && !this.isLayout(navItem)) { | 216 | if (!this.isBroadcast(navItem) && !this.isLayout(navItem)) { |
| @@ -14,9 +14,9 @@ | @@ -14,9 +14,9 @@ | ||
| 14 | <meta name="apple-mobile-web-app-capable" content="yes" /> | 14 | <meta name="apple-mobile-web-app-capable" content="yes" /> |
| 15 | <!-- 设置苹果工具栏颜色 --> | 15 | <!-- 设置苹果工具栏颜色 --> |
| 16 | <meta name="apple-mobile-web-app-status-bar-style" content="black" /> | 16 | <meta name="apple-mobile-web-app-status-bar-style" content="black" /> |
| 17 | - <script src="./js/plugin/vconsole.min.js"></script> | 17 | +<!-- <script src="./js/plugin/vconsole.min.js"></script>--> |
| 18 | <script> | 18 | <script> |
| 19 | - new VConsole() | 19 | + //new VConsole() |
| 20 | var hasDetails = false | 20 | var hasDetails = false |
| 21 | 21 | ||
| 22 | function getTime() { | 22 | function getTime() { |
| @@ -137,7 +137,6 @@ export struct DetailVideoListPage { | @@ -137,7 +137,6 @@ export struct DetailVideoListPage { | ||
| 137 | Column() { | 137 | Column() { |
| 138 | Swiper(this.swiperController) { | 138 | Swiper(this.swiperController) { |
| 139 | ForEach(this.data, (item: ContentDetailDTO, index: number) => { | 139 | ForEach(this.data, (item: ContentDetailDTO, index: number) => { |
| 140 | - Column() { | ||
| 141 | DetailPlayShortVideoPage({ | 140 | DetailPlayShortVideoPage({ |
| 142 | switchVideoStatus: $switchVideoStatus, | 141 | switchVideoStatus: $switchVideoStatus, |
| 143 | contentDetailData: item, | 142 | contentDetailData: item, |
| @@ -145,18 +144,15 @@ export struct DetailVideoListPage { | @@ -145,18 +144,15 @@ export struct DetailVideoListPage { | ||
| 145 | index: index, | 144 | index: index, |
| 146 | interactData: this.interactDataList[index] | 145 | interactData: this.interactDataList[index] |
| 147 | }) | 146 | }) |
| 148 | - }.width('100%') | ||
| 149 | - .height('100%') | ||
| 150 | - | ||
| 151 | }, (item: ContentDetailDTO) => item.newsId + '') | 147 | }, (item: ContentDetailDTO) => item.newsId + '') |
| 152 | } | 148 | } |
| 153 | - .clip(false) | ||
| 154 | - .cachedCount(-1) | ||
| 155 | .indicator(false) | 149 | .indicator(false) |
| 156 | .vertical(true) | 150 | .vertical(true) |
| 157 | .loop(false) | 151 | .loop(false) |
| 158 | .width('100%') | 152 | .width('100%') |
| 159 | .height('100%') | 153 | .height('100%') |
| 154 | + .cachedCount(3) | ||
| 155 | + .displayCount(1, true) | ||
| 160 | .onChange((index: number) => { | 156 | .onChange((index: number) => { |
| 161 | this.currentIndex = index | 157 | this.currentIndex = index |
| 162 | console.info('onChange==', index.toString()) | 158 | console.info('onChange==', index.toString()) |
| 1 | +import { Logger } from 'wdKit'; | ||
| 2 | + | ||
| 3 | +const TAG = 'PictureLoading'; | ||
| 4 | + | ||
| 5 | +@Component | ||
| 6 | +export struct PictureLoading { | ||
| 7 | + private imagePath: string = '' | ||
| 8 | + //alt app.media.picture_loading 设计稿尺寸 | ||
| 9 | + @State imageWidth: string | number = 167 | ||
| 10 | + @State ratio: number = 167 / 60 | ||
| 11 | + | ||
| 12 | + async aboutToAppear() { | ||
| 13 | + Logger.info(TAG, 'pictures preview') | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + build() { | ||
| 17 | + Row() { | ||
| 18 | + Image(this.imagePath) | ||
| 19 | + .alt($r('app.media.picture_loading')) | ||
| 20 | + .width(this.imageWidth) | ||
| 21 | + .aspectRatio(this.ratio) | ||
| 22 | + .objectFit(ImageFit.Fill) | ||
| 23 | + .interpolation(ImageInterpolation.High) | ||
| 24 | + .onComplete((event) => { | ||
| 25 | + if (event) { | ||
| 26 | + this.imageWidth = '100%' | ||
| 27 | + this.ratio = event.width / event.height | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + }) | ||
| 31 | + } | ||
| 32 | + .height('100%') | ||
| 33 | + .width('100%') | ||
| 34 | + .backgroundColor(Color.Black) | ||
| 35 | + .justifyContent(FlexAlign.Center) | ||
| 36 | + } | ||
| 37 | +} |
| @@ -14,6 +14,7 @@ import { | @@ -14,6 +14,7 @@ import { | ||
| 14 | } from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest'; | 14 | } from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest'; |
| 15 | import { Logger, WindowModel } from 'wdKit/Index'; | 15 | import { Logger, WindowModel } from 'wdKit/Index'; |
| 16 | import { BusinessError } from '@kit.BasicServicesKit'; | 16 | import { BusinessError } from '@kit.BasicServicesKit'; |
| 17 | +import { PictureLoading } from './PictureLoading'; | ||
| 17 | 18 | ||
| 18 | interface loadMoreData { | 19 | interface loadMoreData { |
| 19 | pageNum: number; | 20 | pageNum: number; |
| @@ -39,6 +40,7 @@ export struct VideoChannelDetail { | @@ -39,6 +40,7 @@ export struct VideoChannelDetail { | ||
| 39 | // private recommend?: string = '' // 0.非推荐,1.推荐; | 40 | // private recommend?: string = '' // 0.非推荐,1.推荐; |
| 40 | @Link @Watch('navIndexChange') bottomNavIndex: number | 41 | @Link @Watch('navIndexChange') bottomNavIndex: number |
| 41 | @Link @Watch('navIndexChange') topNavIndex: number | 42 | @Link @Watch('navIndexChange') topNavIndex: number |
| 43 | + @Link barBackgroundColor: Color | ||
| 42 | private swiperController: SwiperController = new SwiperController() | 44 | private swiperController: SwiperController = new SwiperController() |
| 43 | @Provide showComment: boolean = false | 45 | @Provide showComment: boolean = false |
| 44 | @State data: ContentDetailDTO[] = [] | 46 | @State data: ContentDetailDTO[] = [] |
| @@ -46,26 +48,29 @@ export struct VideoChannelDetail { | @@ -46,26 +48,29 @@ export struct VideoChannelDetail { | ||
| 46 | @State interactDataList: InteractDataDTO[] = [] | 48 | @State interactDataList: InteractDataDTO[] = [] |
| 47 | @State totalCount: number = 0 | 49 | @State totalCount: number = 0 |
| 48 | @State switchVideoStatus: boolean = false | 50 | @State switchVideoStatus: boolean = false |
| 51 | + @State isMouted: boolean = false | ||
| 49 | 52 | ||
| 50 | /** | 53 | /** |
| 51 | * 监听视频频道激活或失活 | 54 | * 监听视频频道激活或失活 |
| 52 | */ | 55 | */ |
| 53 | navIndexChange() { | 56 | navIndexChange() { |
| 54 | - if (timer) clearTimeout(timer) | 57 | + // if (timer) clearTimeout(timer) |
| 58 | + console.log('navIndexChange', this.bottomNavIndex, this.topNavIndex) | ||
| 59 | + // timer = setTimeout(() => { | ||
| 55 | 60 | ||
| 56 | - timer = setTimeout(() => { | ||
| 57 | if (this.bottomNavIndex === 2 && this.topNavIndex === 0) { | 61 | if (this.bottomNavIndex === 2 && this.topNavIndex === 0) { |
| 58 | // 如果视频在暂停则播放视频 | 62 | // 如果视频在暂停则播放视频 |
| 59 | this.switchVideoStatus = true | 63 | this.switchVideoStatus = true |
| 60 | - WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#ffffff', statusBarColor: '#000000' }) | 64 | + this.barBackgroundColor = Color.Black |
| 65 | + this.openFullScreen() | ||
| 61 | } else { | 66 | } else { |
| 62 | // 如果视频在播放则暂停视频 | 67 | // 如果视频在播放则暂停视频 |
| 63 | this.switchVideoStatus = false | 68 | this.switchVideoStatus = false |
| 64 | - WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#000000', statusBarColor: '#ffffff' }) | ||
| 65 | - // WindowModel.shared.setWindowLayoutFullScreen(false) | 69 | + this.barBackgroundColor = Color.Transparent |
| 70 | + this.closeFullScreen() | ||
| 66 | } | 71 | } |
| 67 | - timer = -1 | ||
| 68 | - }, 100) | 72 | + // timer = -1 |
| 73 | + // }, 100) | ||
| 69 | 74 | ||
| 70 | 75 | ||
| 71 | } | 76 | } |
| @@ -82,22 +87,27 @@ export struct VideoChannelDetail { | @@ -82,22 +87,27 @@ export struct VideoChannelDetail { | ||
| 82 | Logger.info(TAG, 'aboutToDisappear'); | 87 | Logger.info(TAG, 'aboutToDisappear'); |
| 83 | } | 88 | } |
| 84 | 89 | ||
| 85 | - // onPageShow(): void { | ||
| 86 | - // this.openFullScreen() | ||
| 87 | - // Logger.info(TAG, 'onPageShow'); | ||
| 88 | - // } | ||
| 89 | - // | ||
| 90 | - // onPageHide(): void { | ||
| 91 | - // this.closeFullScreen() | ||
| 92 | - // Logger.info(TAG, 'onPageHide'); | ||
| 93 | - // } | 90 | + onPageShow(): void { |
| 91 | + this.openFullScreen() | ||
| 92 | + Logger.info(TAG, 'onPageShow'); | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + onPageHide(): void { | ||
| 96 | + this.closeFullScreen() | ||
| 97 | + Logger.info(TAG, 'onPageHide'); | ||
| 98 | + } | ||
| 94 | 99 | ||
| 95 | /** | 100 | /** |
| 96 | * 开启沉浸式 | 101 | * 开启沉浸式 |
| 97 | * TODO:颜色待根据业务接口修改 | 102 | * TODO:颜色待根据业务接口修改 |
| 98 | */ | 103 | */ |
| 99 | openFullScreen() { | 104 | openFullScreen() { |
| 100 | - WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#ffffff', }) | 105 | + WindowModel.shared.setWindowSystemBarProperties({ |
| 106 | + statusBarContentColor: '#ffffff', | ||
| 107 | + statusBarColor: '#000000', | ||
| 108 | + // navigationBarColor: '#000000', | ||
| 109 | + // navigationBarContentColor: '#ffffff' | ||
| 110 | + }) | ||
| 101 | // WindowModel.shared.setWindowLayoutFullScreen(true) | 111 | // WindowModel.shared.setWindowLayoutFullScreen(true) |
| 102 | // WindowModel.shared.setWindowSystemBarEnable([]) | 112 | // WindowModel.shared.setWindowSystemBarEnable([]) |
| 103 | } | 113 | } |
| @@ -107,7 +117,13 @@ export struct VideoChannelDetail { | @@ -107,7 +117,13 @@ export struct VideoChannelDetail { | ||
| 107 | * TODO:颜色待根据业务接口修改 | 117 | * TODO:颜色待根据业务接口修改 |
| 108 | */ | 118 | */ |
| 109 | closeFullScreen() { | 119 | closeFullScreen() { |
| 110 | - WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#000000', }) | 120 | + WindowModel.shared.setWindowSystemBarProperties({ |
| 121 | + statusBarContentColor: '#000000', | ||
| 122 | + statusBarColor: '#ffffff', | ||
| 123 | + // navigationBarColor: '#0x66000000', | ||
| 124 | + // navigationBarContentColor: '#0xE5FFFFFF' | ||
| 125 | + | ||
| 126 | + }) | ||
| 111 | // WindowModel.shared.setWindowLayoutFullScreen(false) | 127 | // WindowModel.shared.setWindowLayoutFullScreen(false) |
| 112 | // WindowModel.shared.setWindowSystemBarEnable(['status', 'navigation']) | 128 | // WindowModel.shared.setWindowSystemBarEnable(['status', 'navigation']) |
| 113 | } | 129 | } |
| @@ -162,6 +178,9 @@ export struct VideoChannelDetail { | @@ -162,6 +178,9 @@ export struct VideoChannelDetail { | ||
| 162 | 178 | ||
| 163 | this.batchContentDetail(list1) | 179 | this.batchContentDetail(list1) |
| 164 | this.getContentInteract(list2) | 180 | this.getContentInteract(list2) |
| 181 | + setTimeout(() => { | ||
| 182 | + this.isMouted = true | ||
| 183 | + }, 500) | ||
| 165 | 184 | ||
| 166 | }) | 185 | }) |
| 167 | } | 186 | } |
| @@ -192,6 +211,7 @@ export struct VideoChannelDetail { | @@ -192,6 +211,7 @@ export struct VideoChannelDetail { | ||
| 192 | 211 | ||
| 193 | build() { | 212 | build() { |
| 194 | Column() { | 213 | Column() { |
| 214 | + PictureLoading().visibility(this.isMouted ? Visibility.None : Visibility.Visible) | ||
| 195 | Swiper(this.swiperController) { | 215 | Swiper(this.swiperController) { |
| 196 | ForEach(this.data, (item: ContentDetailDTO, index: number) => { | 216 | ForEach(this.data, (item: ContentDetailDTO, index: number) => { |
| 197 | Column() { | 217 | Column() { |
| @@ -206,6 +226,7 @@ export struct VideoChannelDetail { | @@ -206,6 +226,7 @@ export struct VideoChannelDetail { | ||
| 206 | .height('100%') | 226 | .height('100%') |
| 207 | }, (item: ContentDetailDTO) => item.newsId + '') | 227 | }, (item: ContentDetailDTO) => item.newsId + '') |
| 208 | } | 228 | } |
| 229 | + .visibility(this.isMouted ? Visibility.Visible : Visibility.None) | ||
| 209 | .cachedCount(-1) | 230 | .cachedCount(-1) |
| 210 | .indicator(false) | 231 | .indicator(false) |
| 211 | .vertical(true) | 232 | .vertical(true) |
| @@ -226,6 +247,9 @@ export struct VideoChannelDetail { | @@ -226,6 +247,9 @@ export struct VideoChannelDetail { | ||
| 226 | } | 247 | } |
| 227 | }) | 248 | }) |
| 228 | 249 | ||
| 229 | - }.width('100%').height('100%') | 250 | + } |
| 251 | + .width('100%') | ||
| 252 | + .height('100%') | ||
| 253 | + .backgroundColor('#000000') | ||
| 230 | } | 254 | } |
| 231 | } | 255 | } |
-
Please register or login to post a comment