《仿盒马》app开发技术分享-- 旧物回收页(业务逻辑)(41)

鸿蒙小林
• 阅读 3

技术栈

Appgallery connect

开发准备

上一节我们实现了旧物回收页的静态展示页,现在我们开始添加对应的模块逻辑,我们要实现的内容有,地址选择、留言、取件时间、重量选择这些模块

功能分析

1.地址选择 要实现地址选择,我们首先要在跳转到地址列表选择页,传递过去一个标记,证明我们是从回收首页跳转过来的,选择地址后的地址信息传递要传递到对应的页面。 2.留言 这里我们实现一个添加留言的弹窗,拿到内容展示到留言板块即可 3.取件时间 我们只需要在模块中展示当前的下单时间即可 4.重量选择 可以点击切换,切换时修改对应的背景色,获取到对应的数据。

代码实现

地址选择,点击事件跳转对应的页面

 .onClick(()=>{
                let  status:AddressRecycleStatusModel={
                  status:true
                }
                router.pushUrl({url:'pages/view/AddressListPage',params:status})
              })

在地址选择页面拿到对应的状态标记

export class AddressRecycleStatusModel {
  status: boolean = false;
}
  @State recycleStatus:boolean=false

 let recycleStatus = router.getParams() as AddressRecycleStatusModel
       if (recycleStatus&&recycleStatus!=undefined){
         this.recycleStatus=recycleStatus.status
       }

传递对应的地址数据过去,然后接收

 if (this.recycleStatus) {
                        router.back({url:'pages/recycle/home/RecycleHomePage',params:paramsInfo})
                      }

 onPageShow(): void {
    let params1 = router.getParams() as AddressModel
    if (params1!=null&&params1.address!=undefined){
      this.addressInfo=JSON.parse(params1.address)
    }
  }

  Row(){
                Image($r('app.media.weizhi'))
                  .width($r('app.float.size_17'))
                  .height($r('app.float.size_17'))
                  .objectFit(ImageFit.Contain)

                Flex({direction:FlexDirection.Column,alignItems:ItemAlign.Start}){
                  Text(this.addressInfo!=null?this.addressInfo.nikeName+" "+this.addressInfo.phone:"地址:")
                    .fontSize(16)
                    .fontWeight(FontWeight.Bold)
                    .fontColor($r('app.color.color_ff333'))
                  Text(this.addressInfo!=null?this.addressInfo.administrativeArea+" "+this.addressInfo.locality+""+this.addressInfo.subLocality+" "+this.addressInfo.placeName:"点击选择地址:")
                    .fontSize(14)
                    .fontColor($r('app.color.color_999'))
                    .margin({top:$r('app.float.size_4')})
                }
                .margin({left:10})

                Blank()
                Image($r('app.media.back_right_recycle'))
                  .width($r('app.float.size_16'))
                  .height($r('app.float.size_16'))
                  .objectFit(ImageFit.Contain)
              }
              .alignItems(VerticalAlign.Top)
              .padding({top:$r('app.float.size_16'),left:$r('app.float.size_10'),right:$r('app.float.size_10'),bottom:$r('app.float.size_10')})
              .width('100%')
              .height($r('app.float.size_80'))
              .backgroundColor(Color.White)
              .borderRadius($r('app.float.size_10'))
              .onClick(()=>{
                let  status:AddressRecycleStatusModel={
                  status:true
                }
                router.pushUrl({url:'pages/view/AddressListPage',params:status})
              })

留言实现,我们先创建弹窗然后引用

import showToast from "../utils/ToastUtils";
import { cloudDatabase } from "@kit.CloudFoundationKit";
import { user_info } from "../clouddb/user_info";
import { UserInfo } from "../entity/UserInfo";
import { hilog } from "@kit.PerformanceAnalysisKit";

@Preview
@CustomDialog
export struct RecycleRemarkDialog {
  controller: CustomDialogController;
  @Link str: string ;
  build() {
    Column({space:20}) {

      Text("备注")
        .fontSize($r('app.float.size_20'))
        .fontWeight(FontWeight.Bold)
        .fontColor(Color.Black)
        .margin({top:20})

      TextArea({text:this.str})
        .backgroundColor("#f6f6f6")
        .placeholderColor("#ff999595")
        .fontColor("#333333")
        .height(150)
        .maxLength(50)
        .onChange((value: String) => {
          if (value.length>50) {
            showToast("最多50个字呦~")
            return
          }else {
            this.str = value.toString()
          }
        })
        .margin(20)
      Row(){
        Text("取消")
          .width('30%')
          .textAlign(TextAlign.Center)
          .height(40)
          .fontSize(18)
          .fontColor(Color.White)
          .backgroundColor(0xff0000)
          .borderRadius(30)
          .margin({top:30})
          .onClick(()=>{
            this.str=''
              this.controller.close()
          })

        Text("确认")
          .width('30%')
          .textAlign(TextAlign.Center)
          .height(40)
          .fontSize(18)
          .fontColor(Color.White)
          .backgroundColor(0xff0000)
          .borderRadius(30)
          .margin({top:30})
          .onClick(async ()=>{
            if (this.str!='') {
             this.controller.close()
            }else {
              this.str=''
              this.controller.close()

            }
          })
      }
      .width('100%')
      .justifyContent(FlexAlign.SpaceAround)


    }
    .borderRadius({topLeft:20,topRight:20})
    .justifyContent(FlexAlign.Start)
    .backgroundColor(Color.White)
    .height(400)
    .width('100%')
  }
}


recycleController: CustomDialogController| null = new CustomDialogController({
    builder: RecycleRemarkDialog({
      str:this.remark

    }),
    alignment: DialogAlignment.Bottom,
    customStyle:true
  });


  Row(){
                Image($r('app.media.liuyan'))
                  .width($r('app.float.size_17'))
                  .height($r('app.float.size_17'))
                  .objectFit(ImageFit.Contain)

                Flex({direction:FlexDirection.Column,alignItems:ItemAlign.Start}){
                  Text("留言:")
                    .fontSize(16)
                    .fontWeight(FontWeight.Bold)
                    .fontColor($r('app.color.color_ff333'))
                  Text(this.remark!=""?this.remark:"点击留言")
                    .fontSize(14)
                    .fontColor($r('app.color.color_999'))
                    .margin({top:$r('app.float.size_4')})
                }
                .margin({left:10})

                Blank()
                Image($r('app.media.back_right_recycle'))
                  .width($r('app.float.size_16'))
                  .height($r('app.float.size_16'))
                  .objectFit(ImageFit.Contain)
              }
              .alignItems(VerticalAlign.Top)
              .padding({top:$r('app.float.size_16'),left:$r('app.float.size_10'),right:$r('app.float.size_10'),bottom:$r('app.float.size_10')})
              .width('100%')
              .height($r('app.float.size_80'))
              .backgroundColor(Color.White)
              .borderRadius($r('app.float.size_10'))
              .onClick(()=>{
                this.recycleController?.open()
              })

取件时间,直接获取当前日期

    Row(){
                Image($r('app.media.shijian'))
                  .width($r('app.float.size_17'))
                  .height($r('app.float.size_17'))
                  .objectFit(ImageFit.Contain)

                Flex({direction:FlexDirection.Column,alignItems:ItemAlign.Start}){
                  Text("取件时间:")
                    .fontSize(16)
                    .fontWeight(FontWeight.Bold)
                    .fontColor($r('app.color.color_ff333'))
                  Text(this.formatCurrentDate()+"(下单后一小时内上门)")
                    .fontSize(14)
                    .fontColor($r('app.color.color_999'))
                    .margin({top:$r('app.float.size_4')})
                }
                .margin({left:10})

                Blank()
                Image($r('app.media.back_right_recycle'))
                  .width($r('app.float.size_16'))
                  .height($r('app.float.size_16'))
                  .objectFit(ImageFit.Contain)
              }
              .alignItems(VerticalAlign.Top)
              .padding({top:$r('app.float.size_16'),left:$r('app.float.size_10'),right:$r('app.float.size_10'),bottom:$r('app.float.size_10')})
              .width('100%')
              .height($r('app.float.size_80'))
              .backgroundColor(Color.White)
              .borderRadius($r('app.float.size_10'))

预估重量选择实现

 Flex({direction:FlexDirection.Column,alignItems:ItemAlign.Start}){
                Text("预估重量:")
                  .fontSize(16)
                  .fontWeight(FontWeight.Bold)
                  .fontColor($r('app.color.color_ff333'))
                Grid(this.scroller) {
                  ForEach(this.weightList, (item: ESObject,index:number) => {
                    GridItem() {
                      Column({space:5}){
                        Text(item.left+"-"+item.right+"kg")
                          .fontSize(16)
                          .width('100%')
                          .textAlign(TextAlign.Center)
                          .onClick(()=>{
                            this.checkPosition = index
                            showToast(item.left)
                          })
                          .fontColor(this.checkPosition == index ? "#000000" : "#ffffff")


                        Text(item.txt)
                          .fontSize(12)
                          .fontColor(Color.Black)
                          .fontColor(this.checkPosition == index ? "#000000" : "#ffffff")

                      }
                      .padding({top:5,bottom:5})
                      .borderRadius(10)
                      .backgroundColor(this.checkPosition == index ? "#fffa3e3e" : "#fff1a3a3")

                    }
                  })
                }
                .columnsTemplate('1fr 1fr 1fr 1fr ')
                .columnsGap(10)
                .rowsGap(10)
                .friction(0.6)
                .enableScrollInteraction(true)
                .supportAnimation(false)
                .multiSelectable(false)
                .edgeEffect(EdgeEffect.Spring)
                .scrollBar(BarState.Off)
                .scrollBarColor(Color.Grey)
                .scrollBarWidth(4)
                .width('90%')
                .backgroundColor("#FFFFFF")
                .height(100)
                .margin({top:10})
              }
              .margin({left:10})

到这我们把订单创建之前的业务都实现了

点赞
收藏
评论区
推荐文章
鸿蒙小林 鸿蒙小林
6小时前
《仿盒马》app开发技术分享-- 分类右侧商品列表(18)
技术栈Appgalleryconnect开发准备上一节我们实现了分类页左侧二级分类列表功能,并实现了顶部列表&弹窗跟左侧列表的联动,这一节我们需要在它们联动的基础上继续添加右侧列表的联动效果功能分析1.列表展示当我们选择顶部一级分类列表时,左侧列表展示二级
鸿蒙小林 鸿蒙小林
6小时前
《仿盒马》app开发技术分享-- 地址管理页(24)
技术栈Appgalleryconnect开发准备上一节我们实现了个人信息页面的信息展示和页面修改,并且实现了数据的同步修改,这一节我们来实现电商应用里比较重要的模块,地址模块。首先我们来实现地址的展示。功能分析地址列表的展示相对来说是比较简单的,首先我们要
鸿蒙小林 鸿蒙小林
6小时前
《仿盒马》app开发技术分享-- 地图选点(27)
技术栈Appgalleryconnect开发准备上一节我们实现了地图的简单展示,这一节我们要实现的内容是,根据展示的地图,实现当前定位功能,当前位置的poi地址功能,以及列表的展示,给地图添加标记,展示自己的当前定位功能分析要想实现这些功能,首先我们需要在
鸿蒙小林 鸿蒙小林
6小时前
《仿盒马》app开发技术分享-- 确认订单页(业务逻辑)(30)
技术栈Appgalleryconnect开发准备上一节我们实现了确认订单页的页面绘制和价格计算优惠计算,订单列表展示等功能,这一节我们来实现确认订单页的整个业务逻辑。首先我们要实现的就是地址的选择,然后把我们计算的价格,商品列表等数据保存起来,然后我们开始
鸿蒙小林 鸿蒙小林
6小时前
《仿盒马》app开发技术分享-- 旧物回收页(静态)(40)
技术栈Appgalleryconnect开发准备上一节我们进行了购物车业务逻辑的优化,使我们的程序变得更加健壮,这一节我们将要开始电商业务以外的内容,旧物回收,这是一个全新的业务模块,我们将要在这里实现对应的,回收金,积分,回收业务相关内容功能分析要想实现
鸿蒙小林 鸿蒙小林
6小时前
《仿盒马》app开发技术分享-- 旧物回收页(提交云端)(42)
技术栈Appgalleryconnect开发准备上一节我们已经实现了地址,留言,取件时间的选择,以及静态的预估重量。现在我们需要把预估重量创建出来,从云端去获取,以应对后续的其他业务逻辑,以及回收订单的创建功能分析预估重量列表的实现首先需要创建对应的表和数
鸿蒙小林 鸿蒙小林
6小时前
《仿盒马》app开发技术分享--确认订单选择优惠券(59)
技术栈Appgalleryconnect开发准备在上一节我们实现了在确认订单页查询优惠券,但是我们并没有其他优惠券相关的逻辑,我们的目的还是在订单结算的时候去使用我们对应的优惠券,现在我们要在确认订单页去进行优惠券的选择,为了方便用户操作,我们以弹窗的形式
鸿蒙小林 鸿蒙小林
6小时前
《仿盒马》app开发技术分享-- 我的积分页(63)
技术栈Appgalleryconnect开发准备上一节我们实现了个人中心页面的业务逻辑优化,成功的在用户登陆退出状态下展示对应的组件内容,这一节我们来实现app中另外一个比较重要的模块积分模块。功能分析因为我们的回收订单是跟回收金积分是绑定的,我们在完成回
鸿蒙小林 鸿蒙小林
6小时前
《仿盒马》app开发技术分享-- 兑换订单列表框架(75)
技术栈Appgalleryconnect开发准备上一节我们针对订单兑换的业务逻辑进行了完善,成功的在兑换物品之后修改了用户信息的修改,新增了积分消费的记录。这一节我们实现订单创建之后进入的列表展示页框架。功能分析兑换商品的订单列表框架我们选择使用tabs,
鸿蒙小林 鸿蒙小林
4小时前
《伴时匣》app开发技术分享--表单提交页(5)
技术栈Appgalleryconnect开发准备上一节我们已经实现了表单信息的创建,完成了首页跳转表单提交页的内容,这一节我们就要实现表单创建前的数据填充的页面。功能分析在表单提交前,我们要实现的静态内容有很多,分别有输入框,开关,时间选择器,表类型,是否