鸿蒙应用步伐开辟项目 美食杰app (提供源代码以及图片资源) ...

海哥  金牌会员 | 2024-12-12 13:41:33 | 显示全部楼层 | 阅读模式
打印 上一主题 下一主题

主题 993|帖子 993|积分 2979

本项目基于鸿蒙开辟工具DevEco Studio 实现,利用ArkTS开辟语言完成设计。
导言

鸿蒙应用开辟是基于华为的鸿蒙操作体系(HarmonyOS)进行的应用步伐开辟。鸿蒙体系旨在提供跨装备的统一体验,支持智能手机、平板、电视、物联网装备等多种终端。
一、开辟工具下载链接

DevEco Studio下载链接
点击下载,一直默认操作就行
二、项目展示

项目效果演示
三、源代码

接待页

代码

  1. import { router } from '@kit.ArkUI'
  2. @Entry
  3. @Component
  4. struct welcome{
  5.   build(){
  6.     Row() {
  7.       Image($r('app.media.welcome')).width('100%').height('100%')
  8.     }
  9.   }
  10.   onPageShow(): void {
  11.     setTimeout(()=>{
  12.       router.replaceUrl({
  13.         url:'pages/register'
  14.       })
  15.     },2000) //实现定时跳转,当进入app首先加载welcome pages,2秒后进入注册页
  16.   }
  17. }
复制代码
demo


注册页

代码

  1. import { font, Prompt, router } from '@kit.ArkUI';
  2. import { text } from '@kit.ArkGraphics2D';
  3. export class user_account{
  4.   username:string
  5.   password:string
  6.   constructor(pname:string,pwd:string) {
  7.     this.username = pname
  8.     this.password = pwd
  9.   }
  10. }
  11. @Entry
  12. @Component
  13. struct register{
  14.   @State username:string = "";
  15.   @State password:string = "";
  16.   @State conf_psd:string = "";
  17.   build() {
  18.     Column({space:15}){
  19.       //顶部应用图标
  20.       Text().width(150).height(150).borderRadius(90).margin({top:80})
  21.         .backgroundImage($r('app.media.icon')).backgroundImageSize(ImageSize.FILL)
  22.       //三个输入框及注册按钮
  23.       Flex({direction:FlexDirection.Column,justifyContent:FlexAlign.SpaceEvenly,alignItems:ItemAlign.Center}) {
  24.         TextInput({ placeholder: '输入用户名' }).width(300).type(InputType.USER_NAME).onChange(() => {
  25.         }).onChange((value: string) => {
  26.           this.username = value
  27.         }).maxLength(15)
  28.         TextInput({ placeholder: '输入密码' }).width(300).type(InputType.Password).onChange((value: string) => {
  29.           this.password = value
  30.         }).maxLength(15)
  31.         TextInput({ placeholder: '确认密码' }).width(300).type(InputType.Password).onChange((value: string) => {
  32.           this.conf_psd = value
  33.         }).maxLength(15)
  34.         Button('注册', { type: ButtonType.Normal, stateEffect: true }).width(150)
  35.           .onClick(() => {
  36.             if (this.username === "") {
  37.               //用户名为空,弹窗提示
  38.               Prompt.showToast({
  39.                 message: "用户名不能为空",
  40.                 duration: 1000
  41.               })
  42.             } else {
  43.               //密码为空,弹窗提示
  44.               if (this.password === "")
  45.                 Prompt.showToast({
  46.                   message: "密码不能为空",
  47.                   duration: 1000
  48.                 })
  49.               else {
  50.                 //确认密码为空,弹窗提示
  51.                 if (this.conf_psd === "")
  52.                   Prompt.showToast({
  53.                     message: "未确认密码",
  54.                     duration: 1000
  55.                   })
  56.                 else if (this.conf_psd != this.password) {
  57.                   //密码不一致,弹窗提示
  58.                   Prompt.showToast({
  59.                     message: "密码不一致",
  60.                     duration: 1000
  61.                   })
  62.                 } else {
  63.                   //成功注册,弹窗显示用户名及密码
  64.                   Prompt.showToast({
  65.                     message: "注册成功\n" + "用户名: " + this.username + '\n' + "密码: " + this.password,
  66.                     duration: 1000
  67.                   })
  68.                   let user: user_account = new user_account("", "")
  69.                   user.username = this.username
  70.                   user.password = this.password
  71.                   router.pushUrl({
  72.                     url: 'pages/login',
  73.                     params: user,
  74.                   })
  75.                 }
  76.               }
  77.             }
  78.           })
  79.       }.height('40%').width('95%').backgroundColor(Color.White)
  80.       .borderRadius(20)
  81.       .margin({top:40})
  82.     }.height('100%')
  83.     .width('100%')
  84.     .alignItems(HorizontalAlign.Center)
  85.     .backgroundImage($r('app.media.welcome_back')) //插入背景图片
  86.     .backgroundImageSize(ImageSize.FILL)
  87.   }
  88. }
复制代码
demo



登入页面

代码

  1. import { font, Prompt, router } from '@kit.ArkUI';
  2. import { text } from '@kit.ArkGraphics2D';
  3. import { user_account } from './register';
  4. @Entry
  5. @Component
  6. struct login{
  7.   private  user:user_account=  router.getParams() as user_account;
  8.   @State username:string = ""
  9.   @State password:string = "";
  10.   build() {
  11.     Column({space:15}){
  12.       Text().width(150).height(150).borderRadius(90).margin({top:80})
  13.         .backgroundImage($r('app.media.icon')).backgroundImageSize(ImageSize.FILL)
  14.       Flex({direction:FlexDirection.Column,justifyContent:FlexAlign.SpaceEvenly,alignItems:ItemAlign.Center}) {
  15.         TextInput({ placeholder: '输入用户名' }).width(300).type(InputType.Normal).onChange(() => {
  16.         }).onChange((value: string) => {
  17.           this.username = value
  18.         }).maxLength(15)
  19.         TextInput({ placeholder: '输入密码' }).width(300).type(InputType.Password).onChange((value: string) => {
  20.           this.password = value
  21.         })
  22.           .maxLength(15)
  23.         Button('登入', { type: ButtonType.Normal, stateEffect: true }).width(150)
  24.           .onClick(() => {
  25.             if (this.username === "") {
  26.               Prompt.showToast({
  27.                 message: "用户名为空",
  28.                 duration: 1000
  29.               })
  30.             }
  31.             else {
  32.               if (this.password === "")
  33.                 Prompt.showToast({
  34.                   message: "密码为空",
  35.                   duration: 1000
  36.                 })
  37.               else {
  38.                 if (this.username === this.user.username) {
  39.                   if (this.password === this.user.password)
  40.                     router.pushUrl({
  41.                       url: 'pages/Index'
  42.                     })
  43.                   else {
  44.                     Prompt.showToast({
  45.                       message: "密码错误",
  46.                       duration: 1000
  47.                     })
  48.                   }
  49.                 } else {
  50.                   Prompt.showToast({
  51.                     message: "账号不存在",
  52.                     duration: 1000
  53.                   })
  54.                 }
  55.               }
  56.             }
  57.           })
  58.       }.height('30%').width('95%').backgroundColor(Color.White).margin({top:50}).borderRadius(20)
  59.     }.height('100%')
  60.     .width('100%')
  61.     .backgroundImage($r('app.media.signin_back'))
  62.     .backgroundImageSize(ImageSize.FILL)
  63.     .alignItems(HorizontalAlign.Center)
  64.    // .justifyContent(FlexAlign.Center)
  65.   }
  66. }
复制代码
demo



应用页面

代码

由于采用Tabs()组件,故所有页面代码写都在一个文件里
  1. import { LengthMetrics, router } from '@kit.ArkUI';
  2. import sendableColorSpaceManager from '@ohos.graphics.sendableColorSpaceManager';
  3. @Entry
  4. @Component
  5. struct Index {
  6.   @State message: string = 'Hello World';
  7.   myscr: Scroller = new Scroller();
  8.   myscrhor:Scroller = new Scroller();
  9.   @State currentIndex:number = 0;
  10.   @State cur:number = 0;
  11.   @State expwidth:string = "60%"
  12.   @State dewidth:string = "30%"
  13.   @State button1width:string = this.expwidth
  14.   @State button2width:string = this.dewidth
  15.   myindic:DotIndicator = new DotIndicator();
  16.   myswiscr:SwiperController = new SwiperController()
  17.   @Styles myfun(){
  18.     .width('95%').height('22%')
  19.      .borderRadius(10).backgroundImageSize(ImageSize.FILL)
  20.   }
  21.   @Styles mystl(){
  22.     .width('100%').height('20%')
  23.   }
  24.   @Styles stlfull(){
  25.     .width('100%').height('50%')
  26.   }
  27.   @Styles dished(){
  28.     .height('100%').width('40%').borderRadius(10)
  29.     .margin({left:10}).backgroundImageSize(ImageSize.FILL)
  30.   }
  31.   @Builder mytabbar(title:string,Index:number,selectedimg:Resource,defimg:Resource){
  32.        Column(){
  33.          Text().height(45).width(45)
  34.            .backgroundImage(Index===this.currentIndex?selectedimg:defimg).backgroundImageSize(ImageSize.FILL)
  35.          Text(title).fontSize(14).textAlign(TextAlign.Center).fontColor(Index===this.currentIndex?Color.Red:Color.Black)
  36.            .height(20).width(60)
  37.        }
  38.   }
  39.   build() {
  40.     Tabs(){
  41.       //推荐页面
  42.       TabContent(){
  43.         Column() {
  44.           //顶部搜索框
  45.           Row({ space: 10 }) {
  46.             Text().width(30).height('50%').backgroundImage($r('app.media.ic_public_add_norm'))
  47.               .backgroundImageSize(ImageSize.Contain).margin({right:10})
  48.             Search({ placeholder: '搜索菜谱、食材' }).backgroundColor('#efefef').width(240).height('60%')
  49.             Text().width(30).height('50%').backgroundImage($r('app.media.ic_public_view_grid'))
  50.               .backgroundImageSize(ImageSize.Contain).margin({left:10})//.backgroundColor(Color.Red)
  51.           }
  52.           .height('8%')
  53.           .width('100%')
  54.           .margin({ top: 5 })
  55.           .justifyContent(FlexAlign.Center)
  56.           //滚动页面
  57.           Column() {
  58.             Scroll(this.myscr) {
  59.               Column() {
  60.                 Stack({alignContent: Alignment.Top}) {
  61.                   Swiper(this.myswiscr) {
  62.                     Column() {
  63.                       Text('今日早餐 ')
  64.                         .fontWeight(FontWeight.Bold)
  65.                         .width('100%')
  66.                         .height('9%')
  67.                         .padding({ left: 10 })
  68.                         .fontSize(25)
  69.                       Text().height('53%').width('95%')
  70.                         .backgroundImage($r('app.media.img_4')).backgroundImageSize(ImageSize.Contain)
  71.                     }
  72.                     Column() {
  73.                       Text('今日午餐 ')
  74.                         .fontWeight(FontWeight.Bold)
  75.                         .width('100%')
  76.                         .height('9%')
  77.                         .padding({ left: 10 })
  78.                         .fontSize(25)
  79.                       Text().height('53%').width('95%')
  80.                         .backgroundImage($r('app.media.img1')).backgroundImageSize(ImageSize.Contain)
  81.                     }
  82.                     Column() {
  83.                       Text('今日下午茶')
  84.                         .fontWeight(FontWeight.Bold)
  85.                         .width('100%')
  86.                         .height('9%')
  87.                         .padding({ left: 10 })
  88.                         .fontSize(25)
  89.                       Text().height('53%').width('95%')
  90.                         .backgroundImage($r('app.media.img_1')).backgroundImageSize(ImageSize.Contain)
  91.                     }
  92.                     Column() {
  93.                       Text('今日晚餐 ')
  94.                         .fontWeight(FontWeight.Bold)
  95.                         .width('100%')
  96.                         .height('9%')
  97.                         .padding({ left: 10 })
  98.                         .fontSize(25)
  99.                       Text().height('53%').width('95%')
  100.                         .backgroundImage($r('app.media.img_3')).backgroundImageSize(ImageSize.Contain)
  101.                     }
  102.                     Column() {
  103.                       Text('今日夜宵 ')
  104.                         .fontWeight(FontWeight.Bold)
  105.                         .width('100%')
  106.                         .height('9%')
  107.                         .padding({ left: 10 })
  108.                         .fontSize(25)
  109.                       Text().height('53%').width('95%')
  110.                         .backgroundImage($r('app.media.img_2')).backgroundImageSize(ImageSize.Contain)
  111.                     }
  112.                   }.autoPlay(true).indicator(this.myindic.selectedColor(Color.Red))
  113.                   .indicator(this.myindic.selectedItemWidth(10))
  114.                   .indicator(this.myindic.selectedItemWidth(10))
  115.                   .indicator(this.myindic.itemWidth(10))
  116.                   .indicator(this.myindic.itemHeight(10))
  117.                   Flex({direction:FlexDirection.Row,justifyContent:FlexAlign.End,alignItems:ItemAlign.Center}) {
  118.                     Text('更多三餐推荐 >')
  119.                       .fontWeight(FontWeight.Bold)
  120.                       .width('40%')
  121.                       .height('75%')
  122.                       .backgroundColor('#ffe854')
  123.                       .textAlign(TextAlign.Center)
  124.                       .margin({right:15})
  125.                       .fontSize(16)
  126.                       .borderRadius(40)
  127.                   }.width('100%').height('8%')
  128.                 }
  129.                 Column() {
  130.                   Text('二十四节气养生食谱')
  131.                     .backgroundColor(Color.Green)
  132.                     .fontSize(15)
  133.                     .fontColor(Color.White)
  134.                     .height('10%')
  135.                     .width(150)
  136.                     .textAlign(TextAlign.Center)
  137.                     .alignSelf(ItemAlign.Start)
  138.                     .borderRadius({ topLeft: 15, bottomRight: 15 })
  139.                   Text('夏至').fontWeight(FontWeight.Bold).fontSize(30).height('15%')
  140.                   Text('6月21日-7月6日').height('8%').fontSize(12).fontColor('#b0b0b0')
  141.                   Row({ space: 10 }) {
  142.                     Text("面条")
  143.                       .width('12%')
  144.                       .height(25)
  145.                       .textAlign(TextAlign.Center)
  146.                       .borderRadius(20)
  147.                       .fontColor('#6a9c5e')
  148.                       .backgroundColor('#eff3ee')
  149.                     Text("鸡蛋")
  150.                       .width('12%')
  151.                       .height(25)
  152.                       .textAlign(TextAlign.Center)
  153.                       .borderRadius(20)
  154.                       .fontColor('#6a9c5e')
  155.                       .backgroundColor('#eff3ee')
  156.                     Text("苦瓜")
  157.                       .width('12%')
  158.                       .height(25)
  159.                       .textAlign(TextAlign.Center)
  160.                       .borderRadius(20)
  161.                       .fontColor('#6a9c5e')
  162.                       .backgroundColor('#eff3ee')
  163.                     Text("苦菊")
  164.                       .width('12%')
  165.                       .height(25)
  166.                       .textAlign(TextAlign.Center)
  167.                       .borderRadius(20)
  168.                       .fontColor('#6a9c5e')
  169.                       .backgroundColor('#eff3ee')
  170.                     Text("丝瓜")
  171.                       .width('12%')
  172.                       .height(25)
  173.                       .textAlign(TextAlign.Center)
  174.                       .borderRadius(20)
  175.                       .fontColor('#6a9c5e')
  176.                       .backgroundColor('#eff3ee')
  177.                   }.height('10%').margin({ top: '2%' })
  178.                   Row({ space: 10 }) {
  179.                     Row() {
  180.                       Text('健脾养胃,来碗夏至面。')
  181.                         .width('90%')
  182.                         .height('100%')
  183.                         .fontSize(18)
  184.                         .fontColor('#6f6564')
  185.                       Text('>')
  186.                         .width('10%')
  187.                         .height('100%')
  188.                         .fontSize(18)
  189.                         .fontColor('#6f6564')
  190.                     }
  191.                     .width('48%')
  192.                     .height('97%')
  193.                     .borderRadius(10)
  194.                     .backgroundColor('#ffedeb')
  195.                     Row() {
  196.                       Text('养心安神,吃棵夏至蛋。')
  197.                         .width('90%')
  198.                         .height('100%')
  199.                         .fontSize(18)
  200.                         .fontColor('#6f6564')
  201.                       Text('>')
  202.                         .width('10%')
  203.                         .height('100%')
  204.                         .fontSize(18)
  205.                         .fontColor('#6f6564')
  206.                     }
  207.                     .width('48%')
  208.                     .height('97%')
  209.                     .borderRadius(10)
  210.                     .backgroundColor('#fef4ea')
  211.                   }.height('25%').width('100%')//.backgroundColor(Color.Orange)
  212.                   .justifyContent(FlexAlign.Center)
  213.                   .margin({top:5})
  214.                   Row({ space: 10 }) {
  215.                     Row() {
  216.                       Text('清热解暑,多吃“苦”味食物。')
  217.                         .width('90%')
  218.                         .height('100%')
  219.                         .fontSize(18)
  220.                         .fontColor('#6f6564')
  221.                       Text('>')
  222.                         .width('10%')
  223.                         .height('100%')
  224.                         .fontSize(18)
  225.                         .fontColor('#6f6564')
  226.                     }
  227.                     .width('48%')
  228.                     .height('97%')
  229.                     .borderRadius(10)
  230.                     .backgroundColor('#f6f3fe')
  231.                     Row() {
  232.                       Text('补充水分,多喝汤粥多喝水。')
  233.                         .width('90%')
  234.                         .height('100%')
  235.                         .fontSize(18)
  236.                         .fontColor('#6f6564')
  237.                       Text('>')
  238.                         .width('10%')
  239.                         .height('100%')
  240.                         .fontSize(18)
  241.                         .fontColor('#6f6564')
  242.                     }
  243.                     .width('48%')
  244.                     .height('97%')
  245.                     .borderRadius(10)
  246.                     .backgroundColor('#edf3ff')
  247.                   }.height('25%').width('100%')//.backgroundColor(Color.Orange)
  248.                   .justifyContent(FlexAlign.Center).margin({top:5})
  249.                 }.backgroundColor('#fdfdfd').height('41%').width('95%').borderRadius(15).margin({top:10})
  250.                 Column() {
  251.                   Button({type:ButtonType.Normal}).height('23%').width('95%').margin({top:5})
  252.                     .backgroundImage($r('app.media.img2')).backgroundImageSize(ImageSize.FILL).onClick(()=>{
  253.                       router.pushUrl({
  254.                         url:'pages/why_to_eat_noodles'
  255.                       })
  256.                   })
  257.                   Row({space:10}){
  258.                     Text().width('48%').height('80%').borderRadius(10)
  259.                       .backgroundImage($r('app.media.img3')).backgroundImageSize(ImageSize.Contain)
  260.                     Text().width('48%').height('80%').borderRadius(10)
  261.                       .backgroundImage($r('app.media.img4')).backgroundImageSize(ImageSize.Contain)
  262.                   }.height('16%').width('95%').justifyContent(FlexAlign.Center)
  263.                   Text('每日热门菜谱').height('7%').width('50%').fontSize(20).fontWeight(FontWeight.Bold)
  264.                     .backgroundColor(Color.White).alignSelf(ItemAlign.Start).padding({left:10})
  265.                   Scroll(this.myscrhor) {
  266.                     Row({space:10}) {
  267.                       Text().height('100%').width('40%')
  268.                         .margin({left:10}).backgroundImage($r('app.media.img5')).backgroundImageSize(ImageSize.Contain)
  269.                       Text().height('100%').width('40%')
  270.                         .backgroundImage($r('app.media.img6')).backgroundImageSize(ImageSize.Contain)
  271.                       Text().height('100%').width('40%')
  272.                         .backgroundImage($r('app.media.img7')).backgroundImageSize(ImageSize.Contain)
  273.                       Text().height('100%').width('40%')
  274.                         .margin({right:10})
  275.                         .backgroundImage($r('app.media.img8')).backgroundImageSize(ImageSize.Contain)
  276.                     }.height("33%")//.backgroundColor(Color.Red)
  277.                     .justifyContent(FlexAlign.Center)
  278.                   }.scrollable(ScrollDirection.Horizontal).scrollBar(BarState.Off)
  279.                   Row() {
  280.                     Text().height('100%').width('40%')
  281.                       .margin({left:10}).backgroundImage($r('app.media.img9')).backgroundImageSize(ImageSize.Contain)
  282.                     Column() {
  283.                       Text('饺子皮版水煎包').height('20%').width('100%').fontSize(20)
  284.                       Row({space:10}){
  285.                         Text('饺子皮').height('100%').width('30%').fontSize(13)
  286.                           .backgroundColor('#fdf1c7').textAlign(TextAlign.Center)
  287.                           .borderRadius(10)
  288.                         Text('粉丝').height('100%').width('18%').fontSize(13)
  289.                           .backgroundColor('#fdf1c7').textAlign(TextAlign.Center)
  290.                           .borderRadius(10)
  291.                         Text('胡萝卜').height('100%').width('25%').fontSize(13)
  292.                           .backgroundColor('#fdf1c7').textAlign(TextAlign.Center)
  293.                           .borderRadius(10)
  294.                       }.height('15%').width('100%')
  295.                     }.height('100%').width('50%')//.backgroundColor(Color.Green)
  296.                     .margin({ left: 10})
  297.                   }.height('24%').width('100%').margin({ top: 10})
  298.                   Row() {
  299.                     Text().height('100%').width('40%')
  300.                       .margin({left:10}).backgroundImage($r('app.media.img10')).backgroundImageSize(ImageSize.Contain)
  301.                     Column() {
  302.                       Text('椒盐蘑菇').height('20%').width('100%').fontSize(20)
  303.                       Row({space:10}){
  304.                         Text('平菇').height('100%').width('25%').fontSize(13)
  305.                           .backgroundColor('#fdf1c7').textAlign(TextAlign.Center)
  306.                           .borderRadius(10)
  307.                       }.height('15%').width('100%').backgroundColor(Color.White)
  308.                     }.height('100%').width('50%')
  309.                     .margin({ left: 10 })
  310.                   }.height('24%').width('100%').margin({ top: 7})
  311.                 }.width('100%')
  312.               }.width('100%')
  313.             }.scrollable(ScrollDirection.Vertical).scrollBar(BarState.Off)
  314.           }.height('92%').width('100%')//.backgroundColor(Color.Orange)
  315.         }
  316.         .width('100%')
  317.       }.tabBar(this.mytabbar('推荐',0,$r('app.media.home_filled'),$r('app.media.home')))
  318.       // 排行榜
  319.       TabContent(){
  320.         Scroll(){
  321.           Column(){
  322.             Text().width('100%').height('25%').backgroundImage($r('app.media.img2_1')).backgroundImageSize(ImageSize.FILL)
  323.             Row() {
  324.               Text().backgroundImage($r('app.media.img2_2')).dished()
  325.               Column() {
  326.                 Text('土豆炖牛肉').height('20%').width('100%').fontSize(20).fontWeight(FontWeight.Bold)
  327.                 Row({space:10}){
  328.                   Text('土豆').height('100%').width('18%').fontSize(13)
  329.                     .backgroundColor('#fdf1c7').textAlign(TextAlign.Center)
  330.                     .borderRadius(10)
  331.                   Text('牛肉').height('100%').width('18%').fontSize(13)
  332.                     .backgroundColor('#fdf1c7').textAlign(TextAlign.Center)
  333.                     .borderRadius(10)
  334.                 }.height('15%').width('100%')
  335.               }.height('100%').width('50%')//.backgroundColor(Color.Green)
  336.               .margin({ left: 10})
  337.             }.mystl()
  338.             Row() {
  339.               Text().backgroundImage($r('app.media.img2_3')).dished()
  340.               Column() {
  341.                 Text('红烧排骨').height('20%').width('100%').fontSize(20)
  342.                   .fontWeight(FontWeight.Bold)
  343.                 Text('蛋白质会促进男士精子质量,生个宝宝健康又漂亮').fontSize(14).width('100%')
  344.                 Row({space:10}){
  345.                   Text('猪小排').height('100%').width('30%').fontSize(13)
  346.                     .backgroundColor('#fdf1c7').textAlign(TextAlign.Center)
  347.                     .borderRadius(10)
  348.                 }.height('15%').width('100%').margin({top:8})
  349.               }.height('100%').width('50%')//.backgroundColor(Color.Green)
  350.               .margin({ left: 10})
  351.             }.mystl().margin({ top: 20})
  352.             Row() {
  353.               Text().backgroundImage($r('app.media.img2_4')).dished()
  354.               Column() {
  355.                 Text('素烧茄子').height('20%').width('100%').fontSize(20).fontWeight(FontWeight.Bold)
  356.                 Row(){
  357.                   Text('茄子(紫皮,长)').height('100%').width('60%').fontSize(13)
  358.                     .backgroundColor('#fdf1c7').textAlign(TextAlign.Center)
  359.                     .borderRadius(10)
  360.                 }.height('15%').width('100%')
  361.               }.height('100%').width('50%')//.backgroundColor(Color.Green)
  362.               .margin({ left: 10})
  363.             }.mystl().margin({ top: 20})
  364.             Row() {
  365.               Text().backgroundImage($r('app.media.img2_5')).dished()
  366.               Column() {
  367.                 Text('鲜虾丸子').height('20%').width('100%').fontSize(20).fontWeight(FontWeight.Bold)
  368.                 Row({space:10}){
  369.                   Text('虾肉').height('100%').width('18%').fontSize(13)
  370.                     .backgroundColor('#fdf1c7').textAlign(TextAlign.Center)
  371.                     .borderRadius(10)
  372.                 }.height('15%').width('100%')
  373.               }.height('100%').width('50%')//.backgroundColor(Color.Green)
  374.               .margin({ left: 10})
  375.             }.mystl().margin({ top: 20})
  376.             Row() {
  377.               Text().backgroundImage($r('app.media.img2_6')).dished()
  378.               Column() {
  379.                 Text('麻婆豆腐').height('20%').width('100%').fontSize(20).fontWeight(FontWeight.Bold)
  380.                 Text('维E对改善血夜循环,加速烧伤冻伤的愈合有作用').fontSize(14).width('100%')
  381.                 Row({space:10}){
  382.                   Text('豆腐').height('100%').width('18%').fontSize(13)
  383.                     .backgroundColor('#fdf1c7').textAlign(TextAlign.Center)
  384.                     .borderRadius(10)
  385.                   Text('肉末').height('100%').width('18%').fontSize(13)
  386.                     .backgroundColor('#fdf1c7').textAlign(TextAlign.Center)
  387.                     .borderRadius(10)
  388.                   Text('小葱').height('100%').width('18%').fontSize(13)
  389.                     .backgroundColor('#fdf1c7').textAlign(TextAlign.Center)
  390.                     .borderRadius(10)
  391.                   Text('大蒜').height('100%').width('18%').fontSize(13)
  392.                     .backgroundColor('#fdf1c7').textAlign(TextAlign.Center)
  393.                     .borderRadius(10)
  394.                 }.height('15%').width('100%').margin({top:8})
  395.                 Row({space:10}){
  396.                   Text('郫县豆瓣酱').height('100%').width('45%').fontSize(13)
  397.                     .backgroundColor('#fdf1c7').textAlign(TextAlign.Center)
  398.                     .borderRadius(10)
  399.                 }.height('15%').width('100%').margin({top:8})
  400.               }.height('100%').width('50%')//.backgroundColor(Color.Green)
  401.               .margin({ left: 10})
  402.             }.mystl().margin({ top: 20})
  403.             Row() {
  404.               Text().backgroundImage($r('app.media.img2_7')).dished()
  405.               Column() {
  406.                 Text('疙瘩汤').height('20%').width('100%').fontSize(20).fontWeight(FontWeight.Bold)
  407.                 Row({space:10}){
  408.                   Text('面粉').height('100%').width('18%').fontSize(13)
  409.                     .backgroundColor('#fdf1c7').textAlign(TextAlign.Center)
  410.                     .borderRadius(10)
  411.                 }.height('15%').width('100%')
  412.               }.height('100%').width('50%')//.backgroundColor(Color.Green)
  413.               .margin({ left: 10})
  414.             }.mystl().margin({ top: 20})
  415.             Row() {
  416.               Text().backgroundImage($r('app.media.img2_8')).dished()
  417.               Column() {
  418.                 Text('辣子鸡').height('20%').width('100%').fontSize(20).fontWeight(FontWeight.Bold)
  419.                 Row({space:10}){
  420.                   Text('黑脚土鸡').height('100%').width('35%').fontSize(13)
  421.                     .backgroundColor('#fdf1c7').textAlign(TextAlign.Center)
  422.                     .borderRadius(10)
  423.                 }.height('15%').width('100%')
  424.               }.height('100%').width('50%')//.backgroundColor(Color.Green)
  425.               .margin({ left: 10})
  426.             }.mystl().margin({ top: 20})
  427.           }.width('100%')
  428.         }
  429.       }.tabBar(this.mytabbar('排行榜',1,$r('app.media.rank_filled'),$r('app.media.rank')))
  430.       //吃什么
  431.       TabContent(){
  432.         Scroll() {
  433.           Column() {
  434.             Text().width('100%').height('22%').backgroundImage($r('app.media.img3_0')).backgroundImageSize(ImageSize.FILL)
  435.             Column({space:18}) {
  436.               Text().myfun().backgroundImage($r('app.media.img3_1'))
  437.               Text().myfun().backgroundImage($r('app.media.img3_2'))
  438.               Text().myfun().backgroundImage($r('app.media.img3_3'))
  439.               Text().myfun().height('45%').backgroundImage($r('app.media.img3_4'))
  440.               Row({space:10}){
  441.                  Column(){
  442.                     Text('减肥吃什么?').height('42%').fontSize(22).fontColor('#a38ba5')
  443.                       .margin({top:5})
  444.                     Text('精选食谱1238篇').height('40%').fontSize(18).borderRadius(20)
  445.                       .fontColor(Color.White).backgroundColor('#a889a8').width('95%').textAlign(TextAlign.Center)
  446.                  }.myfun().height('100%').width('48%').backgroundColor('#f5f0f4')
  447.                   Column(){
  448.                   Text('贫血吃什么?').height('42%').fontSize(22).fontColor('#f5b475')
  449.                     .margin({top:5})
  450.                   Text('精选食谱2732篇').height('40%').fontSize(18).borderRadius(20)
  451.                     .fontColor(Color.White).backgroundColor('#f7b470').width('95%').textAlign(TextAlign.Center)
  452.                 }.myfun().height('100%').width('48%').backgroundColor('#fff5ec')
  453.               }.width('95%').height('15%')
  454.             }
  455.           }.width('100%')
  456.         }
  457.       }.tabBar(this.mytabbar('吃什么',2,$r('app.media.whattoeat_filled'),$r('app.media.what_to_eat')))
  458.       //我的
  459.       TabContent(){
  460.        Column(){
  461.          Column(){
  462.            Row({space:10}){
  463.               Text().height(35).width(35).backgroundImage($r('app.media.ic_public_email')).backgroundImageSize(ImageSize.FILL)
  464.               Text().height(35).width(35).margin({right:10}).backgroundImage($r('app.media.ic_public_settings')).backgroundImageSize(ImageSize.FILL)
  465.             }.height('12%').width('100%').justifyContent(FlexAlign.End)
  466.            Row(){
  467.               Text("Hi,\n冲228").fontSize(30).fontWeight(FontWeight.Bold).margin({left:10})
  468.               Button().height(80).width(80).borderRadius(90).backgroundColor(Color.Green).margin({left:'49%'})
  469.                 .backgroundImage($r('app.media.headimg')).backgroundImageSize(ImageSize.FILL)
  470.                 .onClick(()=>{
  471.                   router.pushUrl({
  472.                     url: 'pages/edit_info'
  473.                   })
  474.                 })
  475.            }.height('20%').width('100%').margin({top:10})
  476.            Row(){
  477.              Column() {
  478.                Text("0").fontWeight(FontWeight.Bold).fontSize(25).width('23%').textAlign(TextAlign.Center)
  479.                  .height('50%')
  480.                Text("访客").fontSize(15).width('23%').textAlign(TextAlign.Center)
  481.                  .height('30%')
  482.              }.height('100%')
  483.              Column() {
  484.                Text("0").fontWeight(FontWeight.Bold).fontSize(25).width('23%').textAlign(TextAlign.Center)
  485.                  .height('50%')
  486.                Text("粉丝").fontSize(15).width('23%').textAlign(TextAlign.Center)
  487.                  .height('30%')
  488.              }.height('100%')
  489.              Column() {
  490.                Text("0").fontWeight(FontWeight.Bold).fontSize(25).width('23%').textAlign(TextAlign.Center)
  491.                  .height('50%')
  492.                Text("关注").fontSize(15).width('23%').textAlign(TextAlign.Center)
  493.                  .height('30%')
  494.              }.height('100%')
  495.              Column() {
  496.                Text("0").fontWeight(FontWeight.Bold).fontSize(25).width('23%').textAlign(TextAlign.Center)
  497.                  .height('50%')
  498.                Text("发布").fontSize(15).width('23%').textAlign(TextAlign.Center)
  499.                  .height('30%')
  500.              }.height('100%')
  501.            }.height('18%').width('100%').justifyContent(FlexAlign.Center)
  502.            .margin({top:'45%'})
  503.          }.backgroundColor(Color.Orange).stlfull().backgroundImage($r('app.media.img4_1')).backgroundImageSize(ImageSize.FILL)
  504.          Flex({direction:FlexDirection.Row,justifyContent:FlexAlign.SpaceBetween,alignItems:ItemAlign.Center}){
  505.            Button({type:ButtonType.Normal}){
  506.              Text('我的收藏').fontWeight(this.cur===0?FontWeight.Bold:FontWeight.Normal).fontSize(20)
  507.            }.onClick(()=>{
  508.              this.cur=0;
  509.              this.button1width = this.expwidth;
  510.              this.button2width = this.dewidth;
  511.            }).width(this.button1width).height('95%').margin({left:10})
  512.            .backgroundColor(this.cur===0? '#ffe854':'#eef2f1').borderRadius(10)
  513.            .animation({
  514.              duration: 100,
  515.              curve:Curve.Linear,
  516.              iterations: 1,
  517.            })
  518.            Button({type:ButtonType.Normal}){
  519.              Text('浏览历史').fontWeight(this.cur===1?FontWeight.Bold:FontWeight.Normal).fontSize(20)
  520.            }.onClick(()=>{
  521.              this.cur=1;
  522.              this.button1width = this.dewidth;
  523.              this.button2width = this.expwidth;
  524.            }).width(this.button2width).height('95%').margin({right:10})
  525.            .backgroundColor(this.cur===1? '#ffe854':'#eef2f1').borderRadius(10)
  526.            .animation({
  527.              duration: 100,
  528.              curve:Curve.Linear,
  529.              iterations: 1,
  530.            })
  531.          }
  532.          .margin({top:10}).height('7%')
  533.          Tabs({index:this.cur}){
  534.            TabContent(){
  535.              Column() {
  536.                Text().width(170).height(170).backgroundImage($r('app.media.ic_public_favor')).backgroundImageSize(ImageSize.FILL)
  537.                Text('暂无收藏').margin({top:10}).fontColor('#9a9a9a')
  538.              }
  539.            }
  540.            TabContent(){}
  541.          }.height('40%').barHeight(0).animationDuration(1)
  542.          .margin({top:10}).scrollable(false)
  543.         }
  544.       }.tabBar(this.mytabbar('我的',3,$r('app.media.mine_filled'),$r('app.media.mine')))
  545.     }.onChange((index:number)=>{
  546.         this.currentIndex = index
  547.     }).barPosition(BarPosition.End).barHeight('8%').scrollable(false).animationDuration(1)
  548.   }
  549. }
复制代码
demo

保举页



排行榜


吃什么​​​​​​​


我的


其他跳转页面

你知道夏至为什么要吃面吗

代码

  1. import { LengthMetrics, router } from '@kit.ArkUI'
  2. @Styles function myfun(){
  3.   .height('95%').width('48%')
  4. }
  5. @Entry
  6. @Component
  7. struct noodles{
  8.   myscr:Scroller = new Scroller()
  9.   build() {
  10.     Column() {
  11.       Row() {
  12.         Button({type:ButtonType.Circle}).backgroundImage($r('app.media.ic_public_arrow_left')).size({width:20})
  13.           .backgroundColor(Color.White).backgroundImageSize(ImageSize.FILL).onClick(() => {
  14.           router.back()
  15.         })
  16.         Text("夏至除了吃面,你知道还要吃什么吗?").fontSize(18)
  17.       }.height('5%').width('100%').margin({ top: 2 })
  18.       Scroll(this.myscr) {
  19.         Column() {
  20.           Text()
  21.             .width('100%')
  22.             .height('50%')
  23.             .backgroundColor(Color.Green)
  24.             .backgroundImage($r('app.media.img5_1'))
  25.             .backgroundImageSize(ImageSize.FILL)
  26.           Text("夏至除了吃面,你知道还要吃什么吗?")
  27.             .fontSize(20)
  28.             .fontWeight(FontWeight.Bold)
  29.             .width('95%')
  30.             .padding({ left: 5 })
  31.             .margin({ top: 4 })
  32.             .height('5%')
  33.             .textAlign(TextAlign.Start)
  34.           Text("古语有云:“至者,极也”。夏至,是北半球一年中白昼最长的一天。过了夏至,气温将会日渐升高," +
  35.             "一年中最热的时候随即到来,适时养生是非常重要的。下面大家一起了解下夏至吃什么养生," +
  36.             "夏至的饮食习俗有哪些吧!").maxLines(5).lineSpacing(LengthMetrics.vp(10)).width('95%')
  37.           Column() {
  38.             Text('一、夏至有哪些饮食习俗?').height('5%')
  39.               .fontColor(Color.Red).fontSize(20)
  40.             Text('/夏至面/').fontWeight(FontWeight.Bold).fontSize(18)
  41.             Text('俗话说,“吃过夏至面,一天短一线”。按照习惯夏至这一天要吃面,夏至吃面不仅有以面食敬神、' +
  42.               '庆祝丰收的喜悦,而且也是尝新之意。夏至前新麦收获,新麦面粉也随之上市,新麦面粉不论是口感' +
  43.               '还是营养都是最佳的,人们便纷纷使用新麦面粉做成面条汲取营养,以达到尝新目的。夏至面多以凉面' +
  44.               '为主,此时高温酷暑、天气炎热,吃一些冷的面条可以开胃降火,而又不会因为寒凉损害身体健康。')
  45.               .lineSpacing(LengthMetrics.vp(10)).margin({ top: 4 })
  46.             Row({ space: 10 }) {
  47.               Text().myfun().backgroundImage($r('app.media.img5_2'))
  48.                 .backgroundImageSize(ImageSize.FILL)
  49.               Text().myfun().backgroundImage($r('app.media.img5_3')).backgroundImageSize(ImageSize.FILL)
  50.             }.height('30%').justifyContent(FlexAlign.Center).margin({ top: 8 })
  51.             Row({ space: 10 }) {
  52.               Text().myfun().backgroundImage($r('app.media.img5_4')).backgroundImageSize(ImageSize.FILL)
  53.               Text().myfun().backgroundImage($r('app.media.img5_5')).backgroundImageSize(ImageSize.FILL)
  54.             }.height('30%').justifyContent(FlexAlign.Center).margin({ top: 5 })
  55.           }.width('95%')
  56.           Column() {
  57.             Text('二、夏至养生有哪些要点?').height('5%')
  58.               .fontColor(Color.Red).fontSize(20)
  59.             Column() {
  60.               Text('1、清淡饮食,多吃“苦”').fontWeight(FontWeight.Bold).fontSize(18).width('100%')
  61.                 .textAlign(TextAlign.Start)
  62.               Text('夏至饮食宜清淡,可以多吃些苦菜类蔬菜,如苦瓜、苦菊、苦菜等。' +
  63.                 '因苦味食物具有除燥祛湿、清凉解暑的作用,夏天吃能帮助体内毒素排除,缓解夏季炎热天气带来的不适。')
  64.                 .lineSpacing(LengthMetrics.vp(10)).margin({ top: 4 })
  65.               Row({ space: 10 }) {
  66.                 Text()
  67.                   .myfun()
  68.                   .backgroundColor(Color.Gray)
  69.                   .backgroundImage($r('app.media.img5_6'))
  70.                   .backgroundImageSize(ImageSize.FILL)
  71.                 Text()
  72.                   .myfun()
  73.                   .backgroundColor(Color.Green)
  74.                   .backgroundImage($r('app.media.img5_7'))
  75.                   .backgroundImageSize(ImageSize.FILL)
  76.               }.height('30%').justifyContent(FlexAlign.Center).margin({ top: 8 })
  77.               Row({ space: 10 }) {
  78.                 Text()
  79.                   .myfun()
  80.                   .backgroundColor(Color.Gray)
  81.                   .backgroundImage($r('app.media.img5_8'))
  82.                   .backgroundImageSize(ImageSize.FILL)
  83.                 Text()
  84.                   .myfun()
  85.                   .backgroundColor(Color.Green)
  86.                   .backgroundImage($r('app.media.img5_9'))
  87.                   .backgroundImageSize(ImageSize.FILL)
  88.               }.height('30%').justifyContent(FlexAlign.Center).margin({ top: 5 })
  89.             }
  90.             Column() {
  91.               Text('2、晚餐忌食生冷食物。').fontWeight(FontWeight.Bold).fontSize(18).width('100%')
  92.                 .textAlign(TextAlign.Start)
  93.               Text('夏季夜短,晚餐最好不要吃生冷、粘腻之物,否则容易引起腹胀、吐泻等肠胃不适症状。将食物做成全熟' +
  94.                 ',可以杀死潜藏的细菌和病毒,吃起来也更加安全、放心')
  95.                 .lineSpacing(LengthMetrics.vp(10)).margin({ top: 4 })
  96.               Row({ space: 10 }) {
  97.                 Text()
  98.                   .myfun()
  99.                   .backgroundColor(Color.Gray)
  100.                   .backgroundImage($r('app.media.img5_10'))
  101.                   .backgroundImageSize(ImageSize.FILL)
  102.                 Text()
  103.                   .myfun()
  104.                   .backgroundColor(Color.Green)
  105.                   .backgroundImage($r('app.media.img5_11'))
  106.                   .backgroundImageSize(ImageSize.FILL)
  107.               }.height('30%').justifyContent(FlexAlign.Center).margin({ top: 8 })
  108.               Row({ space: 10 }) {
  109.                 Text()
  110.                   .myfun()
  111.                   .backgroundColor(Color.Gray)
  112.                   .backgroundImage($r('app.media.img5_12'))
  113.                   .backgroundImageSize(ImageSize.FILL)
  114.                 Text()
  115.                   .myfun()
  116.                   .backgroundColor(Color.Green)
  117.                   .backgroundImage($r('app.media.img5_13'))
  118.                   .backgroundImageSize(ImageSize.FILL)
  119.               }.height('30%').justifyContent(FlexAlign.Center).margin({ top: 5 })
  120.             }
  121.             Column() {
  122.               Text('3、多喝汤、多饮水').fontWeight(FontWeight.Bold).fontSize(18).width('100%')
  123.                 .textAlign(TextAlign.Start)
  124.               Text('夏至时节气温高,人体每天的排汗量会明显增加,如果不能及时补充,很容易造成身体缺水状态。多喝汤' +
  125.                 '、多饮水,能够缓解疲劳,促进新陈代谢,使人身体强健')
  126.                 .lineSpacing(LengthMetrics.vp(10)).margin({ top: 4 })
  127.               Row({ space: 10 }) {
  128.                 Text()
  129.                   .myfun()
  130.                   .backgroundColor(Color.Gray)
  131.                   .backgroundImage($r('app.media.img5_14'))
  132.                   .backgroundImageSize(ImageSize.FILL)
  133.                 Text()
  134.                   .myfun()
  135.                   .backgroundColor(Color.Green)
  136.                   .backgroundImage($r('app.media.img5_15'))
  137.                   .backgroundImageSize(ImageSize.FILL)
  138.               }.height('30%').justifyContent(FlexAlign.Center).margin({ top: 8 })
  139.               Row({ space: 10 }) {
  140.                 Text()
  141.                   .myfun()
  142.                   .backgroundColor(Color.Gray)
  143.                   .backgroundImage($r('app.media.img5_16'))
  144.                   .backgroundImageSize(ImageSize.FILL)
  145.                 Text()
  146.                   .myfun()
  147.                   .backgroundColor(Color.Green)
  148.                   .backgroundImage($r('app.media.img5_17'))
  149.                   .backgroundImageSize(ImageSize.FILL)
  150.               }.height('30%').justifyContent(FlexAlign.Center).margin({ top: 5 })
  151.             }
  152.             Column() {
  153.               Text('4、适量锻炼。').fontWeight(FontWeight.Bold).fontSize(18).width('100%')
  154.                 .textAlign(TextAlign.Start)
  155.               Text("到了夏至,天气炎热,想要身体更加强健,可以适当进行锻炼。锻炼的时间,最好选择在清晨" +
  156.                 "或傍晚天气较为凉爽的时进行,场地可选择在河湖水边、" +
  157.                 "公园庭院等空气清新的地方,锻炼的项目以散步、打太极拳、做广播体操为好,不宜做剧烈运动。")
  158.                 .lineSpacing(LengthMetrics.vp(10)).margin({ top: 4 })
  159.               Text("好啦,今天的美食分享就到这里啦,你夏至的时候打算吃什么呢?欢迎大家留言分享哦~")
  160.                 .lineSpacing(LengthMetrics.vp(10)).margin({ top: 4 }).margin({ bottom: 8 })
  161.             }.height('38%')
  162.           }.width('95%')
  163.         }.width('100%')
  164.       }.scrollable(ScrollDirection.Vertical)
  165.     }
  166.   }
  167. }
复制代码
demo


个人信息编辑页

代码

  1. import { Prompt, router } from '@kit.ArkUI'
  2. @Entry
  3. @Component
  4. struct edit{
  5.   build() {
  6.    Column(){
  7.      Row() {
  8.        Button().height(30).width(30).margin({left:10}).backgroundImage($r('app.media.ic_public_arrow_left'))
  9.          .backgroundColor(Color.White).backgroundImageSize(ImageSize.FILL)
  10.          .onClick(()=>{
  11.            router.back()
  12.          })
  13.        Text('编辑个人信息').fontSize(18).margin({left:80})
  14.      }.height(40).width('100%').margin({top:5})
  15.      Button().width(150).height(150).borderRadius(90).backgroundColor(Color.Gray).margin({top:20})
  16.        .onClick(()=>{
  17.          AlertDialog.show({
  18.            title: '未授权',
  19.            message: '需允许摄像头权限和访问相册权限才能发布图片,请开启后重试',
  20.            autoCancel: false,
  21.            alignment: DialogAlignment.Center,
  22.            offset: { dx: 0, dy: 0 },
  23.            gridCount: 5,
  24.            primaryButton: {
  25.              value: '去开启',
  26.              fontColor: Color.Blue,
  27.              action: () => {
  28.                console.info('Button-clicking callback')
  29.              },
  30.            },
  31.            secondaryButton: {
  32.              value: '取消',
  33.              fontColor: Color.Blue,
  34.              action: () => {
  35.                console.info('Button-cancel callback')
  36.              },
  37.            },
  38.          })
  39.        }).backgroundImage($r('app.media.headimg')).backgroundImageSize(ImageSize.FILL)
  40.      Text('冲228').fontWeight(FontWeight.Bold).height(50).fontSize(25)
  41.      TextInput({placeholder:'点击添加签名'}).backgroundColor(Color.White).textAlign(TextAlign.Center)
  42.        .width('40%')
  43.      Text('如果修改头像时遇到点对勾没有反应的情况\n可以尝试退出本页重试').margin({top:140})
  44.        .textAlign(TextAlign.Center)
  45.    }.height('100%').width('100%')
  46.   }
  47. }
复制代码
demo


四、总结

在项目编写中,我感受到了鸿蒙开辟工具的强大,现在鸿蒙体系还处于测试阶段,其开辟远景广泛。


项目中用到的    图片资源​​​​​​​



免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

海哥

金牌会员
这个人很懒什么都没写!
快速回复 返回顶部 返回列表