1/* 2 * Copyright (c) 2022-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15import { Url } from '../../main/NavigationHomePage'; 16import { TITLE_BAR_DATA } from '../../mock/ProductsData'; 17import { TitleBarModel } from '../../model/GoodsModel'; 18import { GoodsList } from '../good/GoodsList'; 19import { SwiperComponent } from './Swiper'; 20 21@Component 22export struct HomePageContent { 23 @State tabsIndex: number = 0; 24 private url: string = ''; 25 private controller: TabsController = new TabsController(); 26 @StorageLink('listHeight') listHeight: number = 100; 27 @StorageLink('curBp') curBp: string = 'sm'; 28 29 build() { 30 Column() { 31 SwiperComponent() 32 .width('100%') 33 Row() { 34 ForEach(TITLE_BAR_DATA, (item: TitleBarModel) => { 35 Column({ 36 space: 6 37 }) { 38 Text(item.title) 39 .fontSize(16) 40 .fontWeight(400) 41 .fontColor(Color.Black) 42 Text(item.content) 43 .fontSize(12) 44 .fontWeight(400) 45 .opacity(this.tabsIndex === item.id ? 1 : 0.6) 46 .fontColor(this.tabsIndex === item.id ? $r('app.color.pink') : Color.Black) 47 } 48 .onClick(() => { 49 this.tabsIndex = item.id; 50 this.controller.changeIndex(item.id); 51 }) 52 }, (item: TitleBarModel) => item.id.toString()) 53 } 54 .width('100%') 55 .padding({ 56 top: 12, 57 bottom: 12, 58 left: 20, 59 right: 20 60 }) 61 .justifyContent(FlexAlign.SpaceBetween) 62 63 // 主页下半部分商品展示--全部、精选、新品、实惠 64 Tabs({ controller: this.controller }) { 65 TabContent() { 66 GoodsList(new Url(this.url)); 67 } 68 69 TabContent() { 70 GoodsList(new Url(this.url)); 71 } 72 73 TabContent() { 74 GoodsList(new Url(this.url)); 75 } 76 77 TabContent() { 78 GoodsList(new Url(this.url)); 79 } 80 } 81 .height(this.listHeight + 12) 82 .barWidth(0) 83 .barHeight(0) 84 .scrollable(false) 85 } 86 } 87}