liujian1_wd

添加楼层

@@ -7,10 +7,10 @@ @@ -7,10 +7,10 @@
7 "main": "", 7 "main": "",
8 "version": "1.0.0", 8 "version": "1.0.0",
9 "dependencies": { 9 "dependencies": {
10 - "wdBean": "file:../wdBean",  
11 "wdComponent": "file:../wdComponent", 10 "wdComponent": "file:../wdComponent",
12 "wdConstant": "file:../wdConstant", 11 "wdConstant": "file:../wdConstant",
13 "wdKit": "file:../wdKit", 12 "wdKit": "file:../wdKit",
  13 + "wdBean": "file:../wdBean",
14 "wdNetwork": "file:../wdNetwork" 14 "wdNetwork": "file:../wdNetwork"
15 } 15 }
16 -}  
  16 +}
1 import { CompDTO, CompStyle, GroupDTO, ItemBean, ItemDTO, ViewType } from 'wdBean'; 1 import { CompDTO, CompStyle, GroupDTO, ItemBean, ItemDTO, ViewType } from 'wdBean';
2 -import { CompUtils, EmptyComponent, ErrorComponent, LabelComponent, LoadingComponent, } from 'wdComponent'; 2 +import { CompUtils, EmptyComponent, ErrorComponent,
  3 + GridLayout01Component,
  4 + LabelComponent, LoadingComponent,
  5 + SingleRow03Component, } from 'wdComponent';
3 import { CommonConstants } from 'wdConstant'; 6 import { CommonConstants } from 'wdConstant';
4 import { LazyDataSource, Logger, StringUtils } from 'wdKit'; 7 import { LazyDataSource, Logger, StringUtils } from 'wdKit';
5 8
@@ -54,6 +57,10 @@ export struct PageComponent { @@ -54,6 +57,10 @@ export struct PageComponent {
54 componentBuilder(compDTO: CompDTO, groupIndex: number, compIndex: number) { 57 componentBuilder(compDTO: CompDTO, groupIndex: number, compIndex: number) {
55 if (compDTO.compStyle === CompStyle.Label_03) { 58 if (compDTO.compStyle === CompStyle.Label_03) {
56 LabelComponent({ label: CompUtils.getLabelTitle(compDTO.extraData) }) 59 LabelComponent({ label: CompUtils.getLabelTitle(compDTO.extraData) })
  60 + } else if(compDTO.compStyle === CompStyle.Single_Row_03){
  61 + SingleRow03Component({dataList: compDTO.operDataList})
  62 + } else if(compDTO.compStyle === CompStyle.Grid_Layout_01){
  63 + GridLayout01Component({dataList: compDTO.operDataList})
57 } else { 64 } else {
58 // todo:组件未实现 / Component Not Implemented 65 // todo:组件未实现 / Component Not Implemented
59 Text(compDTO.compStyle) 66 Text(compDTO.compStyle)
@@ -33,6 +33,11 @@ @@ -33,6 +33,11 @@
33 } 33 }
34 ] 34 ]
35 } 35 }
  36 + ],
  37 + "requestPermissions": [
  38 + {
  39 + "name": "ohos.permission.INTERNET"
  40 + }
36 ] 41 ]
37 } 42 }
38 } 43 }
@@ -5,5 +5,5 @@ @@ -5,5 +5,5 @@
5 # as it contains information specific to your local configuration. 5 # as it contains information specific to your local configuration.
6 # 6 #
7 # For customization when using a Version Control System, please read the header note. 7 # For customization when using a Version Control System, please read the header note.
8 -hwsdk.dir=D:/Harmony/HarmonyOS_SDK- 4.0.3.700-SP1  
9 -nodejs.dir=D:/nodejs-16.20.1 8 +nodejs.dir=D:/node
  9 +hwsdk.dir=D:/huawei/Sdk-4.0.700
1 { 1 {
  2 + "license": "Apache-2.0",
  3 + "devDependencies": {},
  4 + "author": "",
2 "name": "wdbean", 5 "name": "wdbean",
3 - "version": "1.0.0",  
4 "description": "Please describe the basic information.", 6 "description": "Please describe the basic information.",
5 "main": "Index.ets", 7 "main": "Index.ets",
6 - "author": "",  
7 - "license": "Apache-2.0",  
8 - "dependencies": {  
9 - }  
10 -}  
  8 + "version": "1.0.0",
  9 + "dependencies": {}
  10 +}
@@ -6,4 +6,8 @@ export { ErrorComponent } from "./src/main/ets/components/ErrorComponent" @@ -6,4 +6,8 @@ export { ErrorComponent } from "./src/main/ets/components/ErrorComponent"
6 6
7 export { LoadingComponent } from "./src/main/ets/components/LoadingComponent" 7 export { LoadingComponent } from "./src/main/ets/components/LoadingComponent"
8 8
9 -export { LabelComponent } from "./src/main/ets/components/LabelComponent"  
  9 +export { LabelComponent } from "./src/main/ets/components/LabelComponent"
  10 +
  11 +export {SingleRow03Component} from "./src/main/ets/components/SingleRow03Component"
  12 +
  13 +export {GridLayout01Component} from "./src/main/ets/components/GridLayout01Component"
1 { 1 {
  2 + "license": "Apache-2.0",
  3 + "devDependencies": {},
  4 + "author": "",
2 "name": "wdcomponent", 5 "name": "wdcomponent",
3 - "version": "1.0.0",  
4 "description": "Please describe the basic information.", 6 "description": "Please describe the basic information.",
5 "main": "Index.ets", 7 "main": "Index.ets",
6 - "author": "",  
7 - "license": "Apache-2.0", 8 + "version": "1.0.0",
8 "dependencies": { 9 "dependencies": {
9 - "wdBean": "file:../wdBean",  
10 "wdConstant": "file:../wdConstant", 10 "wdConstant": "file:../wdConstant",
11 - "wdKit": "file:../wdKit" 11 + "wdKit": "file:../wdKit",
  12 + "wdBean": "file:../wdBean"
12 } 13 }
13 -}  
  14 +}
  1 +import { ContentDTO } from 'wdBean';
  2 +import { CommonConstants } from 'wdConstant';
  3 +
  4 +
  5 +const TAG = 'GridLayout01Component';
  6 +
  7 +/**
  8 + * 热点视频推荐
  9 + * Grid_Layout-03
  10 + * 支持添加视频、直播内容
  11 + */
  12 +@Component
  13 +export struct GridLayout01Component {
  14 + @StorageLink('currentBreakpoint') currentBreakpoint: string = 'xs';
  15 + @State dataList?: ContentDTO[] = undefined
  16 + @State adapterBeanList?:ContentDTO[] = []
  17 +
  18 + aboutToAppear() {
  19 + this.buildAdapterBeanList(this.currentBreakpoint)
  20 + }
  21 +
  22 + aboutToDisappear() {
  23 + }
  24 +
  25 + build() {
  26 + GridRow({
  27 + columns: 12,
  28 + gutter: { x: vp2px(2.5), y: vp2px(2.5) },
  29 + }) {
  30 + ForEach(this.dataList, (programmeBean: ContentDTO, index: number) => {
  31 + GridCol({ span: { xs: 6, sm: 6, md: 3, lg: 3 } }) {
  32 + this.buildItemTopImgBottomTxt01(programmeBean, index)
  33 + }
  34 + })
  35 + }
  36 + .margin({ left: $r('app.float.main_margin'), right: $r('app.float.main_margin') })
  37 + .onBreakpointChange((currentBreakpoint: string) => {
  38 + this.currentBreakpoint = currentBreakpoint
  39 + this.buildAdapterBeanList(currentBreakpoint)
  40 + })
  41 + }
  42 +
  43 + // 只从list最后添加/补充数据item,不截断list
  44 + buildAdapterBeanList(currentBreakpoint: string): void {
  45 + if (!this.dataList || this.dataList.length == 0) {
  46 + return
  47 + }
  48 + let divisor: number = 1; // 除数
  49 + switch (currentBreakpoint) {
  50 + case 'xs': // break; // pass through
  51 + case 'sm':
  52 + divisor = 2;
  53 + break;
  54 + case 'md': // break; // pass through
  55 + case 'lg': // break; // pass through
  56 + default:
  57 + divisor = 4;
  58 + break;
  59 + }
  60 + this.adapterBeanList = [] // 重置
  61 + this.adapterBeanList.push(...this.dataList.reverse());
  62 + let mod = this.dataList.length % divisor // 余数
  63 + if (mod == 0) {
  64 + return
  65 + }
  66 + // 在尾部补全数据
  67 + let complementIndex = 0
  68 + while (complementIndex < mod) {
  69 + // 从原有数据前(循环)依次取数据,补充到列表尾部,
  70 + this.adapterBeanList.push(this.dataList[complementIndex])
  71 + complementIndex++
  72 + }
  73 + return
  74 + }
  75 +
  76 + @Builder
  77 + buildItemTopImgBottomTxt01(item: ContentDTO, index: number){
  78 + Column(){
  79 + RelativeContainer() {
  80 + Image(item.hImageUrl)
  81 + .width('100%')
  82 + .aspectRatio(16 / 9)
  83 + .borderRadius($r("app.float.image_border_radius"))
  84 + .objectFit(ImageFit.Cover)
  85 + .alignRules({
  86 + top: { anchor: '__container__', align: VerticalAlign.Top },
  87 + left: { anchor: '__container__', align: HorizontalAlign.Start }
  88 + })
  89 + .id('img_cover')
  90 +
  91 + Text(item.title)
  92 + .width('100%')
  93 + .margin({ top: 4, left: 6, right: 6 })
  94 + .fontWeight(FontWeight.Normal)
  95 + .textAlign(TextAlign.Start)
  96 + .fontSize($r('app.float.font_size_14'))
  97 + .fontColor($r('app.color.color_333333'))
  98 + .maxLines(2)
  99 + .textOverflow({ overflow: TextOverflow.Ellipsis })
  100 + .alignRules({
  101 + top: {anchor:'img_cover', align: VerticalAlign.Bottom},
  102 + left: {anchor: 'img_cover', align: HorizontalAlign.Start},
  103 + right:{anchor: 'img_cover', align: HorizontalAlign.End}
  104 + })
  105 + .id("tv_title")
  106 +
  107 + }
  108 + .width('100%')
  109 + .height($r('app.float.single_row_03_item_height'))
  110 + }
  111 + .backgroundColor(Color.White)
  112 + .hoverEffect(HoverEffect.Scale)
  113 + .alignItems(HorizontalAlign.Start)
  114 +
  115 +
  116 + }
  117 +}
  1 +import { ContentDTO } from 'wdBean';
  2 +
  3 +
  4 +const TAG = 'SingleRow03Component';
  5 +
  6 +/**
  7 + * 直播横划卡
  8 + * Single_Row-03
  9 + * 支持添加直播内容
  10 + */
  11 +@Component
  12 +export struct SingleRow03Component {
  13 + @State dataList?: ContentDTO[] = undefined
  14 +
  15 + build() {
  16 + List( {space: 2.5}){
  17 + ForEach(this.dataList, (item : ContentDTO, index?: number) =>{
  18 + ListItem(){
  19 + this.contentItem(item)
  20 + }
  21 +
  22 + } , (item: ContentDTO) => JSON.stringify(item))
  23 +
  24 + }
  25 + .listDirection(Axis.Horizontal)
  26 + .lanes(1)
  27 + .scrollBar(BarState.Off)
  28 + }
  29 +
  30 + @Builder
  31 + contentItem(item: ContentDTO){
  32 + Column(){
  33 + RelativeContainer() {
  34 + Image(item.coverUrl)
  35 + .width('100%')
  36 + .height($r('app.float.single_row_03_img_height'))
  37 + .borderRadius($r("app.float.image_border_radius"))
  38 + .objectFit(ImageFit.Cover)
  39 + .alignRules({
  40 + top: { anchor: '__container__', align: VerticalAlign.Top },
  41 + left: { anchor: '__container__', align: HorizontalAlign.Start }
  42 + })
  43 + .id('img_cover')
  44 +
  45 + Text(item.title)
  46 + .width('100%')
  47 + .margin({ top: 4, left: 6, right: 6 })
  48 + .fontWeight(FontWeight.Normal)
  49 + .textAlign(TextAlign.Start)
  50 + .fontSize($r('app.float.font_size_14'))
  51 + .fontColor($r('app.color.color_333333'))
  52 + .maxLines(2)
  53 + .textOverflow({ overflow: TextOverflow.Ellipsis })
  54 + .alignRules({
  55 + top: {anchor:'img_cover', align: VerticalAlign.Bottom},
  56 + left: {anchor: 'img_cover', align: HorizontalAlign.Start},
  57 + right:{anchor: 'img_cover', align: HorizontalAlign.End}
  58 + })
  59 + .id("tv_title")
  60 +
  61 + Button('预约')
  62 + .width(58)
  63 + .height(24)
  64 + .margin({bottom: 6})
  65 + .backgroundColor(0xF55A42)
  66 + .id('button')
  67 + .alignRules({
  68 + bottom: {anchor:'__container__', align: VerticalAlign.Bottom},
  69 + right:{anchor: '__container__', align: HorizontalAlign.End}
  70 + })
  71 + .onClick((event: ClickEvent) => {
  72 +
  73 + })
  74 +
  75 + Text(item.startTime)
  76 + .fontWeight(FontWeight.Normal)
  77 + .textAlign(TextAlign.Start)
  78 + .margin({ left: 6})
  79 + .fontSize($r('app.float.font_size_10'))
  80 + .fontColor($r('app.color.color_999999'))
  81 + .maxLines(1)
  82 + .textOverflow({ overflow: TextOverflow.Ellipsis })
  83 + .alignRules({
  84 + center: {anchor:'button', align:VerticalAlign.Center},
  85 + left: {anchor: 'tv_title', align: HorizontalAlign.Start},
  86 + })
  87 + .id("tv_start_time")
  88 +
  89 +
  90 +
  91 + }
  92 + .width('100%')
  93 + .height('100%')
  94 + }
  95 + .width($r('app.float.single_row_03_item_width'))
  96 + .height($r('app.float.single_row_03_item_height'))
  97 + .backgroundColor(Color.White)
  98 + .alignItems(HorizontalAlign.Start)
  99 +
  100 +
  101 + }
  102 +}
@@ -8,6 +8,11 @@ @@ -8,6 +8,11 @@
8 "tablet", 8 "tablet",
9 "2in1" 9 "2in1"
10 ], 10 ],
11 - "deliveryWithInstall": true 11 + "deliveryWithInstall": true,
  12 + "requestPermissions": [
  13 + {
  14 + "name": "ohos.permission.INTERNET"
  15 + }
  16 + ]
12 } 17 }
13 } 18 }
@@ -3,6 +3,14 @@ @@ -3,6 +3,14 @@
3 { 3 {
4 "name": "white", 4 "name": "white",
5 "value": "#FFFFFF" 5 "value": "#FFFFFF"
  6 + },
  7 + {
  8 + "name": "color_333333",
  9 + "value": "#333333"
  10 + },
  11 + {
  12 + "name": "color_999999",
  13 + "value": "#999999"
6 } 14 }
7 ] 15 ]
8 } 16 }
@@ -15,6 +15,30 @@ @@ -15,6 +15,30 @@
15 { 15 {
16 "name": "label_margin_bottom", 16 "name": "label_margin_bottom",
17 "value": "8vp" 17 "value": "8vp"
  18 + },
  19 + {
  20 + "name": "single_row_03_item_width",
  21 + "value": "158vp"
  22 + },
  23 + {
  24 + "name": "single_row_03_item_height",
  25 + "value": "160vp"
  26 + },
  27 + {
  28 + "name": "single_row_03_img_height",
  29 + "value": "88vp"
  30 + },
  31 + {
  32 + "name": "font_size_14",
  33 + "value": "14fp"
  34 + },
  35 + {
  36 + "name": "font_size_10",
  37 + "value": "10fp"
  38 + },
  39 + {
  40 + "name": "image_border_radius",
  41 + "value": "8vp"
18 } 42 }
19 ] 43 ]
20 } 44 }
1 { 1 {
  2 + "license": "Apache-2.0",
  3 + "devDependencies": {},
  4 + "author": "",
2 "name": "wdconstant", 5 "name": "wdconstant",
3 - "version": "1.0.0",  
4 "description": "Please describe the basic information.", 6 "description": "Please describe the basic information.",
5 "main": "Index.ets", 7 "main": "Index.ets",
6 - "author": "",  
7 - "license": "Apache-2.0",  
8 - "dependencies": {  
9 - }  
10 -}  
  8 + "version": "1.0.0",
  9 + "dependencies": {}
  10 +}
1 { 1 {
  2 + "license": "Apache-2.0",
  3 + "devDependencies": {},
  4 + "author": "",
2 "name": "wdkit", 5 "name": "wdkit",
3 - "version": "1.0.0",  
4 "description": "Please describe the basic information.", 6 "description": "Please describe the basic information.",
5 "main": "Index.ets", 7 "main": "Index.ets",
6 - "author": "",  
7 - "license": "Apache-2.0",  
8 - "dependencies": {  
9 - }  
10 -}  
  8 + "version": "1.0.0",
  9 + "dependencies": {}
  10 +}
1 { 1 {
  2 + "license": "Apache-2.0",
  3 + "devDependencies": {},
  4 + "author": "",
2 "name": "wdnetwork", 5 "name": "wdnetwork",
3 - "version": "1.0.0",  
4 "description": "Please describe the basic information.", 6 "description": "Please describe the basic information.",
5 "main": "Index.ets", 7 "main": "Index.ets",
6 - "author": "",  
7 - "license": "Apache-2.0", 8 + "version": "1.0.0",
8 "dependencies": { 9 "dependencies": {
9 "@ohos/axios": "^2.1.1" 10 "@ohos/axios": "^2.1.1"
10 } 11 }
11 -}  
  12 +}