鸿蒙界面开发(四):支付宝首页开发实战

利用了层叠布局和一个scroll滚动组件。

包括底部导航、顶部导航、主体的滚动窗口。

主体的滚动窗口又包括一个快捷导航栏和一个导航窗口、以及主体部分

javascript 复制代码
import text from '@ohos.graphics.text';

@Entry
@Component
struct Index {
  @State message: string = 'Hello World';
  //支付宝首页·
  build() {
    Stack({alignContent:Alignment.Bottom}){
      //顶部导航
      Stack({alignContent:Alignment.Top}){
        Row(){
          Column(){
            Text('北京')
              .fontSize(18)
              .fontColor('#fff')
            Text('晴 37C')//摄氏度的符号怎么打
              .fontSize(12)
              .fontColor('#fff')
            Image($r('app.media.zfb_head_down'))
              .width(12)
              .fillColor('#fff')
              .position({
                x:40,
                y:0
              })

          }

          Row(){
            Image($r('app.media.zfb_head_search'))
              .width(20)
              .fillColor('#666')
              .margin({left:5, right:5})
            Text('北京交通一卡通')
              .layoutWeight(1)
            Text('搜索')
              .width(55)
              .fontColor('#5b73de')
              .fontWeight(700)
              .textAlign(TextAlign.Center)
              .border({
                width:{left:1},
                color:'#ccc'
              })
          }.height(32)
          .layoutWeight(1)//自适应屏幕
          .backgroundColor('#fff')
          .borderRadius(5)
          .margin({left:25, right:12})

          Image($r('app.media.zfb_head_plus'))
            .width(30)
            .fillColor('#fff')
        }.width('100%')
        .height(60)
        .backgroundColor('#5b7fde')
        .zIndex(666)
        .padding({left:10,right:10})
        //Column和Row默认都没有滚动的效果
        // Column(){
        //
        // }
        //利用Scroll实现主体滚动部分
        Scroll(){
          Column(){
            //top快捷按钮
            Row(){
              Column(){
                Image($r('app.media.zfb_top_scan'))
                  .width(36)
                  .fillColor('#fff')
                Text('扫一扫')
                  .fontColor('#fff')
              }.layoutWeight(1)
              Column(){
                Image($r('app.media.zfb_top_pay'))
                  .width(36)
                  .fillColor('#fff')
                Text('收付款')
                  .fontColor('#fff')
              }.layoutWeight(1)
              Column(){
                Image($r('app.media.zfb_top_travel'))
                  .width(36)
                  .fillColor('#fff')
                Text('出行')
                  .fontColor('#fff')
              }.layoutWeight(1)
              Column(){
                Image($r('app.media.zfb_top_card'))
                  .width(36)
                  .fillColor('#fff')
                Text('卡包')
                  .fontColor('#fff')
              }.layoutWeight(1)
            }.width('100%')
              .padding({top:5,bottom:15})
              .backgroundColor('#5b7fde')

            //主体导航区
            Column({space:10}){
              Row(){
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
              }.width('100%')
              Row(){
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
              }.width('100%')
              Row(){
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
                Column(){
                  Image($r('app.media.zfb_nav1'))
                    .width(28)
                    .margin({bottom:8})
                  Text('滴滴出行')
                    .fontSize(12)
                    .fontColor('#666')
                }.layoutWeight(1)
              }.width('100%')
            }
              .width('100%')
              .borderRadius({
                topLeft:20,
                topRight:20
              })
              .padding(10)
              .backgroundColor(Color.White)

            //产品区
            Row({space:5}){
              Image($r('app.media.zfb_pro_pic1'))
                .layoutWeight(1)
              Image($r('app.media.zfb_pro_pic2'))
                .layoutWeight(1)
              Image($r('app.media.zfb_pro_pic3'))
                .layoutWeight(1)
            }.backgroundColor(Color.White)
            Column(){
              Image($r('app.media.zfb_pro_list1'))
                .width('100%')
              Image($r('app.media.zfb_pro_list2'))
                .width('100%')
            }.backgroundColor(Color.White)
          }.width('100%')
          .backgroundColor('#5b73de')

        }.width('100%')
        .padding({top:60,bottom:60})
      }.width('100%')
      .height('100%')//占用全部空间

      //底部导航栏
      Row(){
        Column(){
          Image($r('app.media.zfb_tab_home'))
            .width(35)

          // Text('首页')
          // .fontSize(12)
        }.layoutWeight(1)
        Column(){
          Image($r('app.media.zfb_tab_money'))
            .width(28)

          Text('理财')
            .fontSize(12)
        }.layoutWeight(1)
        Column(){
          Image($r('app.media.zfb_tab_life'))
            .width(28)

          Text('生活')
            .fontSize(12)
        }.layoutWeight(1)
        Column(){
          Image($r('app.media.zfb_tab_chat'))
            .width(28)

          Text('消息')
            .fontSize(12)
        }.layoutWeight(1)
        Column(){
          Image($r('app.media.zfb_tab_me'))
            .width(28)

            .margin({bottom:2})
          Text('我的')
            .fontSize(12)
        }.layoutWeight(1)
      }
      .width('100%')
      .height(60)
      .backgroundColor(Color.White)
    }.width('100%')
    .height('100%')
  }
}
相关推荐
B.-1 分钟前
Remix 学习 - @remix-run/react 中主要的 hooks
前端·javascript·学习·react.js·web
HarmonyOS_SDK4 分钟前
免弹窗、预授权,默认界面扫码能力打造系统级扫码体验
harmonyos
小刘|17 分钟前
《实现 HTML 图片轮播效果》
前端·html
罗_三金1 小时前
微信小程序读写NFC标签(实现NFC标签快速拉起小程序)实战
前端·javascript·微信小程序·小程序
大大。2 小时前
el-input 只能输入数字和一个小数点,或者只能输入正整数
前端·javascript·vue.js
盼盼盼2 小时前
如何避免在使用 Context API 时出现状态管理的常见问题?
前端·javascript·react.js
Amd7942 小时前
Nuxt Kit 中的布局管理
前端·web开发·nuxt.js·布局管理·代码示例·addlayout·页面结构
超雄代码狂2 小时前
JavaScript web API完结篇---多案例
开发语言·前端·javascript
追风小老头折腾程序2 小时前
实战06-LazyForEach
harmonyos
让开,我要吃人了3 小时前
OpenHarmony鸿蒙( Beta5.0)摄像头实践开发详解
驱动开发·华为·移动开发·harmonyos·鸿蒙·鸿蒙系统·openharmony