diff --git a/entry/src/main/ets/constants/BreakpointConstants.ets b/entry/src/main/ets/constants/BreakpointConstants.ets index e94fa5ad7e1458cbce84086142a7ca54873c26ff..927d716311f9dd6405020e67eea582073e3aecce 100644 --- a/entry/src/main/ets/constants/BreakpointConstants.ets +++ b/entry/src/main/ets/constants/BreakpointConstants.ets @@ -21,117 +21,94 @@ export class BreakpointConstants { * Breakpoints that represent small device types. */ public static readonly BREAKPOINT_SM: string = 'sm'; - /** * Breakpoints that represent middle device types. */ public static readonly BREAKPOINT_MD: string = 'md'; - /** * Breakpoints that represent large device types. */ public static readonly BREAKPOINT_LG: string = 'lg'; - /** * Breakpoints representing the type of oversized equipment. */ public static readonly BREAKPOINT_XL: string = 'xl'; - /** * Breakpoint range sm */ public static readonly RANGE_SM: string = '(320vp<=width<600vp)'; - /** * Breakpoint range md */ public static readonly RANGE_MD: string = '(600vp<=width<840vp)'; - /** * Breakpoint range lg */ public static readonly RANGE_LG: string = '(840vp<=width)'; - /** * Breakpoint value sm/md/lg */ public static readonly BREAKPOINT_VALUE: Array = ['320vp', '600vp', '840vp']; - /** * AppStorage key breakpoint */ public static readonly BREAKPOINT_NAME: string = 'breakpoint'; - /** * Grid num two */ public static readonly GRID_NUM_TWO = '1fr 1fr'; - /** * Grid num three */ public static readonly GRID_NUM_THREE = '1fr 1fr 1fr'; - /** * Grid num four */ public static readonly GRID_NUM_FOUR = '1fr 1fr 1fr 1fr'; - /** * SearchBar and WATER_FLOW margin left sm */ public static readonly SEARCHBAR_AND_WATER_FLOW_MARGIN_LEFT_SM: number = 16; - /** * SearchBar and WATER_FLOW margin left md */ public static readonly SEARCHBAR_AND_WATER_FLOW_MARGIN_LEFT_MD: number = 24; - /** * SearchBar and WATER_FLOW margin left LG */ public static readonly SEARCHBAR_AND_WATER_FLOW_MARGIN_LEFT_LG: number = 32; - /** * SearchBar and WATER_FLOW margin right sm */ public static readonly SEARCHBAR_AND_WATER_FLOW_MARGIN_RIGHT_SM: number = 16; - /** * SearchBar and WATER_FLOW margin right md */ public static readonly SEARCHBAR_AND_WATER_FLOW_MARGIN_RIGHT_MD: number = 24; - /** * SearchBar and WATER_FLOW margin right lg */ public static readonly SEARCHBAR_AND_WATER_FLOW_MARGIN_RIGHT_LG: number = 32; - /** * Function margin right sm */ public static readonly FUNCTION_MARGIN_RIGHT_SM: number = 10; - /** * Function margin right md */ public static readonly FUNCTION_MARGIN_RIGHT_MD: number = 24; - /** * Function margin right lg */ public static readonly FUNCTION_MARGIN_RIGHT_LG: number = 24; - /** * Function margin left sm */ public static readonly FUNCTION_MARGIN_LEFT_SM: number = 10; - /** * Function margin left md */ public static readonly FUNCTION_MARGIN_LEFT_MD: number = 24; - /** * Function margin left lg */ diff --git a/entry/src/main/ets/constants/CommonConstants.ets b/entry/src/main/ets/constants/CommonConstants.ets index c3aaeb5bbe280ec6c94ad7bc3d092e627eb5b7b9..c4a3c1245b26b5852fe657d4cb7a39e1c225f697 100644 --- a/entry/src/main/ets/constants/CommonConstants.ets +++ b/entry/src/main/ets/constants/CommonConstants.ets @@ -25,248 +25,199 @@ export class CommonConstants { * Full percent. */ public static readonly FULL_PERCENT: string = '100%'; - /** * 20 percent. */ public static readonly TWENTY_PERCENT: string = '20%'; - /** * Interface Path */ public static readonly MOCK_INTERFACE_PATH_NAME = 'smoothSlide'; - /** * the api fileName of function area */ public static readonly MOCK_INTERFACE_FUNCTION_FILE_NAME: string = 'entry.json'; - /** * the api fileName of waterFlow area */ public static readonly MOCK_INTERFACE_WATER_FLOW_FILE_NAME: string = 'waterFlow.json'; - /** * Waterflow cached count. */ public static readonly WATER_FLOW_CACHED_COUNT: number = 10; - /** * Function page number */ public static readonly FUNCTION_PAGE_NUMBER: number = 1; - /** * Function page size */ public static readonly FUNCTION_PAGE_SIZE: number = 25; - /** * waterFlow page size */ public static readonly WATER_FLOW_PAGE_SIZE: number = 20; - /** * waterFlow page start index */ public static readonly WATER_FLOW_PAGE_START_INDEX: number = 1; - /** * Function page one */ public static readonly FUNCTION_FIRST_INDEX: number = 0; - /** * Function page one. */ public static readonly FUNCTION_SECOND_INDEX: number = 1; - /** * Function page one. */ public static readonly FUNCTION_FIRST_COUNT: number = 10; - /** * Grid data count under md breakpoint. */ public static readonly FUNCTION_FIRST_COUNT_MD: number = 12; - /** * Grid data count under lg breakpoint. */ public static readonly FUNCTION_FIRST_COUNT_LG: number = 16; - /** * Function page one */ public static readonly FUNCTION_SECOND_COUNT: number = 15; - /** * water flow default page count */ public static readonly WATER_FLOW_DEFAULT_PAGE_COUNT: number = 6; - /** * waterFlow image card reuseId */ public static readonly WATER_FLOW_IMAGE_REUSE_ID: string = 'image'; - /** * waterFlow image card type */ public static readonly WATER_FLOW_IMAGE_TYPE: string = 'image'; - /** * waterFlow video card reuseId */ public static readonly WATER_FLOW_VIDEO_REUSE_ID: string = 'video'; - /** * waterFlow image card type */ public static readonly WATER_FLOW_VIDEO_TYPE: string = 'video'; - /** * * waterFlow living card reuseId */ public static readonly WATER_FLOW_LIVING_REUSE_ID: string = 'living'; - /** * waterFlow living card type */ public static readonly WATER_FLOW_LIVING_TYPE: string = 'living'; - /** * waterFlow living card struct id */ public static readonly WATER_FLOW_LIVING_STRUCT_ID: string = 'livingCard'; - /** * waterFlow card max count */ public static readonly WATER_FLOW_MAX_COUNT: number = 20; - /** * string default value: '' */ public static readonly STRING_DEFAULT_VALUE: string = ''; - /** * number default value: 0 */ public static readonly NUMBER_DEFAULT_VALUE: number = 0; - /** * toast show time */ public static readonly TOAST_SHOW_TIME: number = 3000; - /** * toast show time */ public static readonly TOAST_SHOW_MARGIN_BOTTOM: number = 108; - /** * the height of pull to refresh */ public static readonly PULL_TO_REFRESH_HEIGHT: number = 64; - /** * toast show time */ public static readonly ANIMATION_DURATION_TIME: number = 300; - /** * vip sign */ public static readonly VIP_SIGN: string = '1'; - /** * space */ public static readonly SPACE_FOUR: number = 4; - /** * space */ public static readonly SPACE_EIGHT: number = 8; - /** * font weight */ public static readonly TEXT_FONT_WEIGHT_500: number = 500; - /** * font weight */ public static readonly TEXT_FONT_WEIGHT_400: number = 400; - /** * text max lines */ public static readonly TEXT_MAX_LINES: number = 2; - /** * zIndex */ public static readonly LARGE_INDEX: number = 1; - /** * the first index of arr */ public static readonly ARR_FIRST_INDEX: number = 0; - /** * the count 1 of arr that should be deal */ public static readonly DEAL_COUNT_ONE: number = 1; - /** * phone critical value */ public static readonly CRITICAL_VALUE: number = 500; - /** * water flow two columns */ public static readonly WATER_FLOW_TWO_COLUMNS: number = 2; - /** * water flow three columns */ public static readonly WATER_FLOW_THREE_COLUMNS: number = 3; - /** * water flow column gap */ public static readonly WATER_FLOW_COLUMN_GAP: number = 8; - /** * description margin left */ public static readonly DESCRIPTION_MARGIN_LEFT: number = 12; - /** * description two lines height */ public static readonly DESCRIPTION_TWO_LINES_HEIGHT: number = 65; - /** * description three lines height */ public static readonly DESCRIPTION_THREE_LINES_HEIGHT: number = 80; - /** * language */ public static readonly LANGUAGE: string = 'language'; - /** * chinese language */ public static readonly CHINESE_LANGUAGE: string = 'zh'; - /** * Duration. */ diff --git a/entry/src/main/ets/constants/HomeConstants.ets b/entry/src/main/ets/constants/HomeConstants.ets index 47792f9f112fc74fc63e0eeba841ccaeb401cdc8..e0931f2b53af51efccebc08f338fa24fd76d1fe6 100644 --- a/entry/src/main/ets/constants/HomeConstants.ets +++ b/entry/src/main/ets/constants/HomeConstants.ets @@ -18,71 +18,58 @@ export class HomeConstants { * Footer tab topics. */ public static readonly FOOTER_TOPIC_LIST: string[] = ['首页', '分类', '发现', '购物袋', '我的']; - /** * Footer tab english topics. */ public static readonly FOOTER_TOPIC_LIST_EN: string[] = ['home', 'categorize', 'found', 'shopping', 'me']; - /** * Footer topic icons. */ public static readonly FOOTER_TOPIC_ICONS: Resource[] = [$r('app.media.ic_public_home_filled'), $r('app.media.ic_public_class'), $r('app.media.ic_public_discover'), $r('app.media.ic_public_shopping'), $r('app.media.ic_public_mine')]; - /** * Footer topic icons. */ public static readonly FOOTER_TOPIC_ICONS_SELECTED: Resource[] = [$r('app.media.ic_public_home_filled'), $r('app.media.ic_public_class'), $r('app.media.ic_public_discover'), $r('app.media.ic_public_shopping'), $r('app.media.ic_public_mine')]; - /** * Function default icons. */ public static readonly FUNCTION_DEFAULT_ICONS: number[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; - /** * Function area two lines height */ public static readonly FUNCTION_TWO_LINES_HEIGHT: number = 176; - /** * Function area three lines height */ public static readonly FUNCTION_THREE_LINES_HEIGHT: number = 254; - /** * Function rows page one. */ public static readonly FUNCTION_ROWS_PAGE_ONE: string = '1fr 1fr'; - /** * Function rows page two. */ public static readonly FUNCTION_ROWS_PAGE_TWO: string = '1fr 1fr 1fr'; - /** * Function column page two. */ public static readonly FUNCTION_COLUMN: string = '1fr 1fr 1fr 1fr 1fr'; - /** * Columns template under md breakpoint. */ public static readonly FUNCTION_COLUMN_MD: string = '1fr 1fr 1fr 1fr 1fr 1fr'; - /** * Columns template under lg breakpoint. */ public static readonly FUNCTION_COLUMN_LG: string = '1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr'; - /** * index page. */ public static readonly INDEX_PAGE: string = '首页'; - /** * english index page. */ diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 12d903e58318099773f530385bc1867592274ec4..640fae8f7dc191a095b360a713e4cdf914fd5ffb 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -43,6 +43,7 @@ export default class EntryAbility extends UIAbility { } hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); } + // [End on_create] onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void { @@ -87,6 +88,7 @@ export default class EntryAbility extends UIAbility { this.context.restoreWindowStage(new LocalStorage()); } + // [End continue_restore] // [Start on_continue] @@ -121,6 +123,7 @@ export default class EntryAbility extends UIAbility { return AbilityConstant.OnContinueResult.AGREE; } + // [End on_continue] onDestroy(): void { @@ -142,7 +145,8 @@ export default class EntryAbility extends UIAbility { this.uiContext = data.getUIContext(); data.on('windowSizeChange', this.onWindowSizeChange); }).catch((err: BusinessError) => { - hilog.error(0x0000, 'WebAbility', `Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); + hilog.error(0x0000, 'WebAbility', + `Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); }); hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); }); @@ -163,7 +167,8 @@ export default class EntryAbility extends UIAbility { this.uiContext = data.getUIContext(); data.on('windowSizeChange', this.onWindowSizeChange); }).catch((err: BusinessError) => { - hilog.error(0x0000, 'WebAbility', `Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); + hilog.error(0x0000, 'WebAbility', + `Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); }); hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); }); diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 5b84e69d75d162c7580312ff05afd4d959d31f12..188969829fa4f25e429b88bfd7df1a99d03db6a2 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -47,7 +47,8 @@ struct Index { onConfigurationUpdated(config) { AppStorage.set(CommonConstants.LANGUAGE, config.language); }, - onMemoryLevel(level) {} + onMemoryLevel(level) { + } }; try { let applicationContext = this.getUIContext().getHostContext()?.getApplicationContext(); diff --git a/entry/src/main/ets/utils/NetworkUtil.ets b/entry/src/main/ets/utils/NetworkUtil.ets index d0c6e648374a9009269c34d83aec4c27497627cb..f2032f457d6c536ec0c0427629ba3d6bba1cf9f5 100644 --- a/entry/src/main/ets/utils/NetworkUtil.ets +++ b/entry/src/main/ets/utils/NetworkUtil.ets @@ -47,7 +47,7 @@ export class NetworkUtil { usingCache: true, }); const endTime = systemDateTime.getTime() - beginTime; - hilog.info(0x000, 'progress', 'getResponse success, url:' + url + ', cost: ' + endTime); + hilog.info(0x000, 'progress', 'getResponse success, url:' + url + ', cost: ' + endTime); if (data && data.responseCode === http.ResponseCode.OK && typeof data.result === 'string') { let arr: Record = JSON.parse(data.result); return arr; @@ -55,7 +55,7 @@ export class NetworkUtil { return null; } } catch (err) { - hilog.error(0x000, 'progress', 'getResponse err:', JSON.stringify(err)); + hilog.error(0x000, 'progress', 'getResponse err:', JSON.stringify(err)); return null; } } @@ -78,7 +78,7 @@ export class NetworkUtil { return result; } } catch (err) { - hilog.error(0x000, 'progress', 'getFunctionEntryData err:', JSON.stringify(err)); + hilog.error(0x000, 'progress', 'getFunctionEntryData err:', JSON.stringify(err)); } return result; } @@ -106,7 +106,7 @@ export class NetworkUtil { return result; } } catch (err) { - hilog.error(0x000, 'progress', 'getWaterFlowData err: ', JSON.stringify(err)); + hilog.error(0x000, 'progress', 'getWaterFlowData err: ', JSON.stringify(err)); } return result; } diff --git a/entry/src/main/ets/view/longlist/FunctionView.ets b/entry/src/main/ets/view/longlist/FunctionView.ets index 055a27bdd1d965532f4bbb6240c6330cc94b3721..aaab60f833a29b3356f8fb106c78b8975f149391 100644 --- a/entry/src/main/ets/view/longlist/FunctionView.ets +++ b/entry/src/main/ets/view/longlist/FunctionView.ets @@ -24,7 +24,7 @@ import { CommonConstants } from '../../constants/CommonConstants'; export struct FunctionView { @StorageLink(BreakpointConstants.BREAKPOINT_NAME) @Watch('getData') currentBreakpoint: string = BreakpointConstants.BREAKPOINT_LG; - @StorageLink(CommonConstants.LANGUAGE) language:string = CommonConstants.CHINESE_LANGUAGE; + @StorageLink(CommonConstants.LANGUAGE) language: string = CommonConstants.CHINESE_LANGUAGE; @Watch('aboutToAppear') @Link freshFlag: boolean; @State functionEntryListData: FunctionEntryListData = new FunctionEntryListData(); @State functionEntryData: FunctionEntryData[] = []; diff --git a/entry/src/main/ets/view/longlist/HomeContent.ets b/entry/src/main/ets/view/longlist/HomeContent.ets index 7d42a9bee61cd306b9af1e4bc7382895962ddfcd..87664a0404e7bc3c5a64368eae8f166acaaa4bd9 100644 --- a/entry/src/main/ets/view/longlist/HomeContent.ets +++ b/entry/src/main/ets/view/longlist/HomeContent.ets @@ -49,7 +49,7 @@ export struct HomeContent { let netCon: connection.NetConnection = connection.createNetConnection(); let loading: boolean = false; netCon.register((error: BusinessError) => { - hilog.info(0x000, 'progress', JSON.stringify(error)); + hilog.info(0x000, 'progress', JSON.stringify(error)); }); netCon.on('netUnavailable', () => { if (!loading) { @@ -69,7 +69,8 @@ export struct HomeContent { } catch (error) { let message = (error as BusinessError).message; let code = (error as BusinessError).code; - hilog.error(0x000, 'progress', 'showToast args error code is ', code.toString(), 'message is ', message.toString()); + hilog.error(0x000, 'progress', 'showToast args error code is ', code.toString(), 'message is ', + message.toString()); } } } @@ -93,7 +94,7 @@ export struct HomeContent { setTimeout(() => { this.isRefreshing = false; netCon.unregister((error: BusinessError) => { - hilog.error(0x000, 'progress', 'unregister err:' + JSON.stringify(error)); + hilog.error(0x000, 'progress', 'unregister err:' + JSON.stringify(error)); }); }, 1000); } @@ -104,12 +105,13 @@ export struct HomeContent { // [Start on_did_build] onDidBuild(): void { - hilog.info(0x000, 'progress', `onDidBuild ${this.setCurrentOffset} ${this.continueOffset}`); - if(this.setCurrentOffset){ - this.scroller.scrollTo({xOffset: 0, yOffset: this.continueOffset}); + hilog.info(0x000, 'progress', `onDidBuild ${this.setCurrentOffset} ${this.continueOffset}`); + if (this.setCurrentOffset) { + this.scroller.scrollTo({ xOffset: 0, yOffset: this.continueOffset }); this.setCurrentOffset = false; } } + // [End on_did_build] build() { @@ -117,14 +119,14 @@ export struct HomeContent { if (this.currentBreakpoint === BreakpointConstants.BREAKPOINT_LG || this.currentBreakpoint === BreakpointConstants.BREAKPOINT_XL) { Row() { - Row(){ + Row() { Image($r('app.media.back')) .width(40) .height(40) .margin({ - right:8 + right: 8 }) - .onClick(()=>{ + .onClick(() => { this.pageInfo.pop(); }) Text($r('app.string.button1')) @@ -137,9 +139,10 @@ export struct HomeContent { .justifyContent(FlexAlign.Start) .padding({ - left:19, - right:19 + left: 19, + right: 19 }) + SearchBarView() .width(400) .height(56) @@ -152,14 +155,14 @@ export struct HomeContent { bottom: 16 }) } else { - Row(){ + Row() { Image($r('app.media.back')) .width(40) .height(40) .margin({ - right:8 + right: 8 }) - .onClick(()=>{ + .onClick(() => { this.pageInfo.pop(); }) Text($r('app.string.button1')) @@ -175,9 +178,10 @@ export struct HomeContent { top: this.topHeight }) .padding({ - left:19, - right:19 + left: 19, + right: 19 }) + SearchBarView() .margin({ bottom: 16 @@ -212,8 +216,8 @@ export struct HomeContent { } } // [EndExclude scroll_water_flow_view] - .onDidScroll((xOffset: number, yOffset: number, scrollState: ScrollState)=>{ - if(!this.setCurrentOffset){ + .onDidScroll((xOffset: number, yOffset: number, scrollState: ScrollState) => { + if (!this.setCurrentOffset) { this.currentOffset = this.scroller.currentOffset().yOffset; } }) diff --git a/entry/src/main/ets/view/longlist/NavigationBarView.ets b/entry/src/main/ets/view/longlist/NavigationBarView.ets index 7d8d1575d9759f1a442fe33bd64557d0d1d3fd3e..c90951f31311e7fa43f45a2b34bcac539eb5a8ec 100644 --- a/entry/src/main/ets/view/longlist/NavigationBarView.ets +++ b/entry/src/main/ets/view/longlist/NavigationBarView.ets @@ -44,7 +44,7 @@ export struct NavigationBarView { build() { Flex({ direction: this.currentBreakpoint === 'lg' || this.currentBreakpoint === 'xl' ? FlexDirection.Column : - FlexDirection.Row, + FlexDirection.Row, justifyContent: this.currentBreakpoint === 'xl' ? FlexAlign.Start : FlexAlign.SpaceBetween }) { ForEach(this.iconArr, (item: FooterTab, index: number) => { @@ -75,7 +75,7 @@ export struct NavigationBarView { adaptiveColor: AdaptiveColor.DEFAULT, policy: this.currentBreakpoint === BreakpointConstants.BREAKPOINT_LG || this.currentBreakpoint === BreakpointConstants.BREAKPOINT_XL ? BlurStyleActivePolicy.ALWAYS_INACTIVE : - BlurStyleActivePolicy.ALWAYS_ACTIVE + BlurStyleActivePolicy.ALWAYS_ACTIVE }) .padding({ top: this.currentBreakpoint === BreakpointConstants.BREAKPOINT_XL ? 56 : 0, diff --git a/entry/src/main/ets/view/longlist/WaterFlowView.ets b/entry/src/main/ets/view/longlist/WaterFlowView.ets index 9b95208e2e59abba994971272fa36ba249b935e5..de3fe6ccf2f22133317296b2250b5f18464490a9 100644 --- a/entry/src/main/ets/view/longlist/WaterFlowView.ets +++ b/entry/src/main/ets/view/longlist/WaterFlowView.ets @@ -37,7 +37,7 @@ export struct WaterFlowView { @StorageLink('windowWidth') windowWidth: number = 0; @StorageLink('continueBreakpoint') continueBreakpoint: string = ''; @StorageLink('continueHeight') continueHeight: number = 0; - @State loadFinish:boolean = false; + @State loadFinish: boolean = false; @State listDataCount: number = CommonConstants.NUMBER_DEFAULT_VALUE; @State waterFlowItemWidth: number = CommonConstants.NUMBER_DEFAULT_VALUE; @State waterFlowHeight: number = 0; @@ -52,7 +52,7 @@ export struct WaterFlowView { listenNetworkEvent() { let netCon: connection.NetConnection = connection.createNetConnection(); netCon.register((error: BusinessError) => { - hilog.info(0x000, 'progress', 'register info:' + JSON.stringify(error)); + hilog.info(0x000, 'progress', 'register info:' + JSON.stringify(error)); }); netCon.on('netUnavailable', () => { if (this.isShowFoot === true) { @@ -67,7 +67,8 @@ export struct WaterFlowView { } catch (error) { let message = (error as BusinessError).message; let code = (error as BusinessError).code; - hilog.error(0x000, 'progress', 'showToast args error code is ', code.toString(), 'message is ', message.toString()); + hilog.error(0x000, 'progress', 'showToast args error code is ', code.toString(), 'message is ', + message.toString()); } }); netCon.on('netAvailable', () => { @@ -77,7 +78,7 @@ export struct WaterFlowView { }); setTimeout(() => { netCon.unregister((error: BusinessError) => { - hilog.info(0x000, 'progress', 'unregister info:' + JSON.stringify(error)); + hilog.info(0x000, 'progress', 'unregister info:' + JSON.stringify(error)); }); }, 500); } @@ -186,10 +187,19 @@ export struct WaterFlowView { } this.listDataCount = this.waterFlowListData.dataSource.totalCount(); this.loadFinish = true; - let imageWidth = this.waterFlowListData.dataSource.getData(0).waterFlowHead.width; - let imageHeight = this.waterFlowListData.dataSource.getData(0).waterFlowHead.height; + let imageWidth = this.waterFlowListData.dataSource.getData(0) + .waterFlowHead + .width; + let imageHeight = this.waterFlowListData.dataSource.getData(0) + .waterFlowHead + .height; this.listItemHeight = imageHeight / imageWidth * this.getUIContext().px2vp(this.windowWidth) / - new BreakpointType({ sm: 2, md: 3, lg: 4, xl: 4 }).getValue(this.currentBreakpoint); + new BreakpointType({ + sm: 2, + md: 3, + lg: 4, + xl: 4 + }).getValue(this.currentBreakpoint); }) }, (item: WaterFlowData) => { return item.waterFlowDescription.index.toString(); @@ -198,11 +208,11 @@ export struct WaterFlowView { } .restoreId(1) // [End water_flow] - .onDisAppear(()=>{ + .onDisAppear(() => { this.continueIndex = this.waterFlowScroller.currentOffset().yOffset; }) - .onScrollIndex((first:number, last:number)=>{ - if (!this.continueEntry){ + .onScrollIndex((first: number, last: number) => { + if (!this.continueEntry) { this.continueIndex = this.waterFlowScroller.currentOffset().yOffset; } }) @@ -234,17 +244,22 @@ export struct WaterFlowView { }) .onAreaChange((oldArea: Area, newArea: Area) => { let height = oldArea.height; - hilog.info(0x000, 'progress', `onAreaChange ${this.continueEntry} ${this.continueWaterOffset} + hilog.info(0x000, 'progress', `onAreaChange ${this.continueEntry} ${this.continueWaterOffset} ${this.listItemHeight}`); - if (this.continueEntry && height != 0){ + if (this.continueEntry && height != 0) { if (this.continueBreakpoint !== '' && this.continueBreakpoint !== this.currentBreakpoint) { - let countBreakPoint = new BreakpointType({ sm: 2, md: 3, lg: 4, xl: 4 }); + let countBreakPoint = new BreakpointType({ + sm: 2, + md: 3, + lg: 4, + xl: 4 + }); let index = this.continueWaterOffset / this.continueHeight * - countBreakPoint.getValue(this.continueBreakpoint); + countBreakPoint.getValue(this.continueBreakpoint); let offset = index / countBreakPoint.getValue(this.currentBreakpoint) * this.listItemHeight; - this.waterFlowScroller.scrollTo({xOffset: 0, yOffset: offset}); + this.waterFlowScroller.scrollTo({ xOffset: 0, yOffset: offset }); } else { - this.waterFlowScroller.scrollTo({xOffset: 0, yOffset: this.continueWaterOffset}); + this.waterFlowScroller.scrollTo({ xOffset: 0, yOffset: this.continueWaterOffset }); } this.continueEntry = false; } diff --git a/entry/src/main/ets/view/video/ExitVideo.ets b/entry/src/main/ets/view/video/ExitVideo.ets index 4eb5841f36ace0e2acf5ef98b12bb9b22a91fc1b..d8cc6681ae0beec93ba68c1343a4c8ca524400d1 100644 --- a/entry/src/main/ets/view/video/ExitVideo.ets +++ b/entry/src/main/ets/view/video/ExitVideo.ets @@ -42,6 +42,7 @@ export struct ExitVideo { duration: 2000, }); } + @Builder listBuilder() { Column() { @@ -64,7 +65,7 @@ export struct ExitVideo { .fontWeight(400) .textAlign(TextAlign.Center) .fontColor('rgb(10, 89, 247)') - }else { + } else { Text($r('app.string.click_change')) .fontSize(14) .opacity($r('app.float.size_zero_six')) @@ -82,7 +83,7 @@ export struct ExitVideo { .width('100%') .height(58) .margin({ - bottom:10 + bottom: 10 }) .onClick(async () => { if (index === 2) { @@ -106,16 +107,16 @@ export struct ExitVideo { .resourceManager.getStringValue(this.videoList[this.videoSelect]); this.avPlayManage.videoChoose(str); }) - }, (index: number) => JSON.stringify(index)) + }, (index: number) => JSON.stringify(index)) } .scrollBar(BarState.Off) .width('100%') .height('200vp') } .padding({ - left:16, - right:16, - bottom:28 + left: 16, + right: 16, + bottom: 28 }) .onClick(() => { this.show = false; @@ -124,11 +125,11 @@ export struct ExitVideo { build() { Flex({ - direction:FlexDirection.Row, - justifyContent:FlexAlign.SpaceBetween + direction: FlexDirection.Row, + justifyContent: FlexAlign.SpaceBetween }) { // Exit - Row(){ + Row() { Image($r("app.media.ic_back")) .id('Exit') .width(40) @@ -143,10 +144,11 @@ export struct ExitVideo { .fontSize($r('app.float.size_24')) .margin({ left: 8 }) } + Image($r('app.media.list')) .width(40) .height(40) - .onClick(()=>{ + .onClick(() => { this.show = true; }) .bindSheet($$this.show, this.listBuilder, { @@ -156,6 +158,6 @@ export struct ExitVideo { detents: [SheetSize.FIT_CONTENT, SheetSize.FIT_CONTENT, 200], }) } - .margin({ top: $r('app.float.size_20'), left: 16, right:16}) + .margin({ top: $r('app.float.size_20'), left: 16, right: 16 }) } } \ No newline at end of file diff --git a/entry/src/main/ets/view/video/VideoPageComponent.ets b/entry/src/main/ets/view/video/VideoPageComponent.ets index faeed1ee185e39da915b70fc8cf6ace49068fcd7..af7d40e7539dd4ec24e2ae4ca03de0e410f1c68e 100644 --- a/entry/src/main/ets/view/video/VideoPageComponent.ets +++ b/entry/src/main/ets/view/video/VideoPageComponent.ets @@ -59,10 +59,10 @@ struct VideoPageComponent { @StorageLink('currentTime') currentTime: number = 0; @StorageLink('show') show: boolean = false; // Indicates whether the videoPanel component is displayed. @StorageLink('videoSelect') videoSelect: number = 0; - @StorageLink('videoState') @Watch('continueChange')videoState: string = ''; + @StorageLink('videoState') @Watch('continueChange') videoState: string = ''; @StorageLink('videoName') videoName: Resource = $r('app.string.video_res_1'); @StorageLink('videoIndex') videoIndex: number = 0; - @StorageLink('continue') @Watch('continueChange')continue: boolean = false; + @StorageLink('continue') @Watch('continueChange') continue: boolean = false; @StorageLink('bottomHeight') bottomHeight: number = 0; @StorageLink('topHeight') topHeight: number = 0; @StorageLink('windowWidth') windowWidth: number = 0; @@ -85,12 +85,13 @@ struct VideoPageComponent { private timeout: number = 0; // Timer ID private xComponentController: XComponentController = new XComponentController(); - continueChange(){ + continueChange() { if (this.videoState === 'playing' && this.continue) { this.avPlayManage.videoSeek(this.currentTime); AppStorage.set('continue', false); } } + setTimer(): void { let that = this; this.timeout = setTimeout(() => { @@ -163,7 +164,7 @@ struct VideoPageComponent { this.isCalcWHFinished = true; this.durationTime = this.avPlayManage.getDurationTime(); this.clearTimer(); - if(!this.flag){ + if (!this.flag) { this.avPlayManage.videoPause() } }) @@ -287,7 +288,7 @@ struct VideoPageComponent { if (!this.flag) { this.clearTimer(); } - hilog.info(0x000, 'progress', 'onShown currentPage ' + this.currentPage); + hilog.info(0x000, 'progress', 'onShown currentPage ' + this.currentPage); }) .onHidden(() => { this.avPlayManage.videoPause(); diff --git a/entry/src/main/ets/view/web/WebPageComponent.ets b/entry/src/main/ets/view/web/WebPageComponent.ets index 4a1fc8f99c1243c1dade93fb162db71735b6e67a..4a9df56d81f342f21091951d5b5a7246df259d66 100644 --- a/entry/src/main/ets/view/web/WebPageComponent.ets +++ b/entry/src/main/ets/view/web/WebPageComponent.ets @@ -46,7 +46,6 @@ struct WebPageComponent { @State controller: webview.WebviewController = new webview.WebviewController(); @State statusBarHeight: number = 0; @State sliderBarHeight: number = 56; - arkTSObj: ArkTSFunModel = { jumpOrderConfirm: (detailStr: string) => this.jumpOrderConfirm(detailStr) }; @@ -116,9 +115,10 @@ struct WebPageComponent { .margin({ top: this.topHeight }) + // [Start web_on_page_end] Web({ src: this.pageUrl, controller: this.controller }) - // [StartExclude web_on_page_end] + // [StartExclude web_on_page_end] .layoutWeight(1) .javaScriptProxy({ object: this.arkTSObj, @@ -134,7 +134,7 @@ struct WebPageComponent { return false; }) .layoutWeight(1) - // [EndExclude web_on_page_end] + // [EndExclude web_on_page_end] .onPageEnd(async () => { // [StartExclude web_on_page_end] this.changeWebListCount(); @@ -163,7 +163,7 @@ struct WebPageComponent { } } }) - // [End web_on_page_end] + // [End web_on_page_end] } .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP]) .width(CommonConstants.FULL_PERCENT) @@ -175,17 +175,18 @@ struct WebPageComponent { } .hideTitleBar(true) .onAppear(() => { - let url = AppStorage.get('pageUrl') as string; + let url = AppStorage.get('pageUrl') as string; if (!url) { this.pageUrl = 'resource://rawfile/product_list.html'; } webview.WebviewController.setWebDebuggingAccess(true); window.getLastWindow(this.getUIContext().getHostContext(), (err: BusinessError, windowClass: window.Window) => { if (err.code) { - hilog.error(0x000, 'progress', TAG, 'Failed to obtain the main window. Cause: ' + JSON.stringify(err)); + hilog.error(0x000, 'progress', TAG, 'Failed to obtain the main window. Cause: ' + JSON.stringify(err)); return; } - hilog.info(0x000, 'progress', TAG, 'Succeeded in obtaining the main window. Data: ' + JSON.stringify(windowClass)); + hilog.info(0x000, 'progress', TAG, + 'Succeeded in obtaining the main window. Data: ' + JSON.stringify(windowClass)); // Realize the immersive effect. try { @@ -200,7 +201,8 @@ struct WebPageComponent { windowClass.setWindowLayoutFullScreen(true); } } catch (exception) { - hilog.error(0x000, 'progress', TAG, 'Failed to set the system bar properties. Cause: ' + JSON.stringify(exception)); + hilog.error(0x000, 'progress', TAG, + 'Failed to set the system bar properties. Cause: ' + JSON.stringify(exception)); } }); }) @@ -215,7 +217,7 @@ struct WebPageComponent { return true; }) .onShown(() => { - hilog.info(0x000, 'progress', 'onShown currentPage ' + this.currentPage); + hilog.info(0x000, 'progress', 'onShown currentPage ' + this.currentPage); }) } } diff --git a/entry/src/main/ets/viewmodel/longlist/WaterFlowDescriptionData.ets b/entry/src/main/ets/viewmodel/longlist/WaterFlowDescriptionData.ets index 42551f346c072cbcc3e0d390a3f2194fa161c53a..51be67175d63a1b1a781d9cfd84ad03031df2c72 100644 --- a/entry/src/main/ets/viewmodel/longlist/WaterFlowDescriptionData.ets +++ b/entry/src/main/ets/viewmodel/longlist/WaterFlowDescriptionData.ets @@ -34,5 +34,4 @@ export class WaterFlowDescriptionData { this.url = url; this.index = index; } - } \ No newline at end of file diff --git a/entry/src/main/ets/viewmodel/video/AvPlayManager.ets b/entry/src/main/ets/viewmodel/video/AvPlayManager.ets index b032dd0e39066ca1706e90bee8034d22054facd1..ba8b74a49e2222fca8815a4db5552e9ea8dd5e79 100644 --- a/entry/src/main/ets/viewmodel/video/AvPlayManager.ets +++ b/entry/src/main/ets/viewmodel/video/AvPlayManager.ets @@ -67,7 +67,7 @@ export default class AvPlayManage { this.fileDescriptor = await this.mgr.getRawFd(this.fileSrc); this.avPlayer.fdSrc = this.fileDescriptor; } - }catch(e){ + } catch (e) { hilog.error(0x000, 'progress', `setAVPlayerCallback Invoke avPlayer failed, code is ${e.code}, message is ${e.message}`); } @@ -79,7 +79,7 @@ export default class AvPlayManage { return; } this.avPlayer.on('seekDone', (seekDoneTime) => { - hilog.info(0x000, 'progress', `setAVPlayerCallback AVPlayer seek succeeded, seek time is ${seekDoneTime}`); + hilog.info(0x000, 'progress', `setAVPlayerCallback AVPlayer seek succeeded, seek time is ${seekDoneTime}`); }); this.avPlayer.on('error', (err) => { if (this.avPlayer === null) { @@ -202,7 +202,7 @@ export default class AvPlayManage { try { this.avPlayer.play(); } catch (e) { - hilog.error(0x000, 'progress', `videoPlay = ${JSON.stringify(e)}`); + hilog.error(0x000, 'progress', `videoPlay = ${JSON.stringify(e)}`); } } } @@ -212,7 +212,7 @@ export default class AvPlayManage { try { this.avPlayer.pause(); } catch (e) { - hilog.info(0x000, 'progress', `videoPause== ${JSON.stringify(e)}`); + hilog.info(0x000, 'progress', `videoPause== ${JSON.stringify(e)}`); } } } @@ -221,9 +221,9 @@ export default class AvPlayManage { if (this.avPlayer) { try { this.avPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_1_00_X); - hilog.info(0x000, 'progress', 'videoSpeed_1_00'); + hilog.info(0x000, 'progress', 'videoSpeed_1_00'); } catch (e) { - hilog.info(0x000, 'progress', `videoSpeed_1_00== ${JSON.stringify(e)}`); + hilog.info(0x000, 'progress', `videoSpeed_1_00== ${JSON.stringify(e)}`); } } } @@ -232,9 +232,9 @@ export default class AvPlayManage { if (this.avPlayer) { try { this.avPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_1_25_X); - hilog.info(0x000, 'progress', 'videoSpeed_1_25'); + hilog.info(0x000, 'progress', 'videoSpeed_1_25'); } catch (e) { - hilog.info(0x000, 'progress', `videoSpeed_1_25== ${JSON.stringify(e)}`); + hilog.info(0x000, 'progress', `videoSpeed_1_25== ${JSON.stringify(e)}`); } } } @@ -243,9 +243,9 @@ export default class AvPlayManage { if (this.avPlayer) { try { this.avPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_1_75_X); - hilog.info(0x000, 'progress', 'videoSpeed_1_75'); + hilog.info(0x000, 'progress', 'videoSpeed_1_75'); } catch (e) { - hilog.info(0x000, 'progress', 'videoSpeed_1_75==' + JSON.stringify(e)); + hilog.info(0x000, 'progress', 'videoSpeed_1_75==' + JSON.stringify(e)); } } } @@ -254,20 +254,21 @@ export default class AvPlayManage { if (this.avPlayer) { try { this.avPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_2_00_X); - hilog.info(0x000, 'progress', `videoSpeed_2_0`); + hilog.info(0x000, 'progress', `videoSpeed_2_0`); } catch (e) { - hilog.info(0x000, 'progress', `videoSpeed_2_0== ${JSON.stringify(e)}`); + hilog.info(0x000, 'progress', `videoSpeed_2_0== ${JSON.stringify(e)}`); } } } videoSeek(seekTime: number): void { - if ( this.state === 'playing' || this.state === 'paused' || this.state ==='prepared' || this.state ==='completed') { + if (this.state === 'playing' || this.state === 'paused' || this.state === 'prepared' || + this.state === 'completed') { try { this.avPlayer!.seek(seekTime, media.SeekMode.SEEK_CLOSEST); - hilog.info(0x000, 'progress', `videoSeek== ${seekTime}`); + hilog.info(0x000, 'progress', `videoSeek== ${seekTime}`); } catch (e) { - hilog.info(0x000, 'progress', `videoSeek== ${JSON.stringify(e)}`); + hilog.info(0x000, 'progress', `videoSeek== ${JSON.stringify(e)}`); } } } @@ -285,7 +286,7 @@ export default class AvPlayManage { } this.avPlayer.release((err) => { if (err === null) { - hilog.info(0x000, 'progress', 'videoRelease release success'); + hilog.info(0x000, 'progress', 'videoRelease release success'); } }); } @@ -295,10 +296,10 @@ export default class AvPlayManage { this.videoSrc = videoSrc; let timeInterval = AppStorage.get('timeInterval') as number; clearInterval(timeInterval); - hilog.info(0x000, 'progress', `videoChoose this.videoSrc = ${this.videoSrc}`); + hilog.info(0x000, 'progress', `videoChoose this.videoSrc = ${this.videoSrc}`); this.videoReset(); } catch (e) { - hilog.info(0x000, 'progress', `videoChoose== ${JSON.stringify(e)}`); + hilog.info(0x000, 'progress', `videoChoose== ${JSON.stringify(e)}`); } }