《仿盒马》app开发技术分享-- 兑换页地址商品展示(71)

鸿蒙小林
• 阅读 3

技术栈

Appgallery connect

开发准备

上一节我们实现了商品兑换的校验功能,这能很好的帮助用户节省更多的时间,同时也能减小服务器的开销,同时我们的业务逻辑也会更加的完善功能也更加的丰富了,这一节我们实现校验通过后的内容,实现地址的选择和兑换商品信息的展示

功能分析

地址的选择我们通过获取地址管理页的地址来实现,商品兑换信息的展示我们通过传递详情页的商品id来这个页面继续进行查询。保证数据的实时性。

代码实现

首先我们实现地址的选择

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

然后我们通过传递过来的id查询对应的商品

@State pointsProduct:PointsProduct|null=null

  async aboutToAppear(): Promise<void> {
    let databaseZone = cloudDatabase.zone('default');
    let product = await router.getParams() as ProductDetailModel;
    let condition1 = new cloudDatabase.DatabaseQuery(points_product);
    condition1.equalTo("id",product.id)
    let productDetail = await databaseZone.query(condition1);
    let json = JSON.stringify(productDetail)
    let list:PointsProduct[]= JSON.parse(json)
    this.pointsProduct=list[0]
  }

把获取到的地址信息展示到页面上


        if (this.addressInfo!=null){
          Column({space:10}){
            Row({space:20}){
              Image($r('app.media.order_location'))
                .height(20)
                .width(20)
              Column(){
                Row(){
                  Text(this.addressInfo.nikeName)
                    .fontColor(Color.Black)
                    .fontSize(16)
                    .fontWeight(FontWeight.Bold)
                  Text(this.addressInfo.phone)
                    .fontColor(Color.Black)
                    .fontSize(16)
                    .fontWeight(FontWeight.Bold)
                    .margin({left:20})
                }

                Text(this.addressInfo.administrativeArea+this.addressInfo.locality+this.addressInfo.subLocality+this.addressInfo.placeName+this.addressInfo.address)
                  .fontColor(Color.Black)
                  .fontSize(16)
                  .margin({top:10})
                  .width('80%')
              }
              .alignItems(HorizontalAlign.Start)
              .width('100%')

            }
          }
          .alignItems(HorizontalAlign.Start)
          .justifyContent(FlexAlign.Center)
          .padding(15)
          .width('100%')
          .justifyContent(FlexAlign.SpaceBetween)
          .onClick(()=>{
            let  status:AddressPointsStatusModel={
              status:true
            }
            router.pushUrl({url:'pages/view/AddressListPage',params:status})
          })

        }else {
          Row({space:20}){
            Image($r('app.media.order_location'))
              .height(20)
              .width(20)
            Text("请选择收货地址")
              .fontColor(Color.Black)
              .fontSize(16)
            Blank()
            Image($r('app.media.right'))
              .height(20)
              .width(20)
          }
          .padding(10)
          .width('100%')
          .justifyContent(FlexAlign.SpaceBetween)
          .height(40)
          .alignItems(VerticalAlign.Center)
          .onClick(()=>{
            let  status:AddressPointsStatusModel={
              status:true
            }
            router.pushUrl({url:'pages/view/AddressListPage',params:status})
          })
        }

然后我们把查询出的兑换商品展示到页面上

  Column(){
          Row() {
            Row({ space: 10 }) {
              Image(this.pointsProduct?.url)
                .height(70)
                .width(70)
                .margin({ left: 10 })
                .borderRadius(10)
              Column({ space: 5 }) {
                Text(this.pointsProduct?.name)
                  .fontColor(Color.Black)
                  .fontSize(14)

                Text(this.pointsProduct?.spec_str)
                  .fontColor(Color.Grey)
                  .fontSize(14)

                Row() {
                  Text() {
                    Span("$ ")
                      .fontSize(14)
                      .fontColor(Color.Red)
                    Span(this.pointsProduct?.points + "")
                      .fontSize(16)
                      .fontColor(Color.Red)
                  }
                }
                .alignItems(VerticalAlign.Bottom)


                Text("数量:" + this.pointsProduct?.amount)
                  .fontColor(Color.Black)
                  .fontColor(Color.Gray)
                  .fontSize(12)
              }
              .alignItems(HorizontalAlign.Start)

            }

            .justifyContent(FlexAlign.Start)
            .alignItems(VerticalAlign.Top)


            Blank()

            Text("$ " + this.pointsProduct!.points*this.pointsProduct!.amount)
              .fontColor(Color.Black)
              .fontSize(14)
          }
          .padding(10)
          .width('100%')
          .alignItems(VerticalAlign.Top)
          .justifyContent(FlexAlign.SpaceBetween)


          Divider()
            .width('100%')
            .height(1)
            .backgroundColor("#f7f7f7")

        }

现在我们就实现了兑换页地址和商品的展示逻辑

点赞
收藏
评论区
推荐文章
鸿蒙小林 鸿蒙小林
4小时前
《仿盒马》app开发技术分享-- 确认订单页(业务逻辑)(30)
技术栈Appgalleryconnect开发准备上一节我们实现了确认订单页的页面绘制和价格计算优惠计算,订单列表展示等功能,这一节我们来实现确认订单页的整个业务逻辑。首先我们要实现的就是地址的选择,然后把我们计算的价格,商品列表等数据保存起来,然后我们开始
鸿蒙小林 鸿蒙小林
4小时前
《仿盒马》app开发技术分享-- 兑换商品数据插入(67)
技术栈Appgalleryconnect开发准备上一节我们实现了积分列表的展示,我们可以更直观的查看当前用户积分的收支情况,但是现在我们只有积分收入并没有消费的地方,所以现在我们开始着手积分兑换相关的内容。这一节我们来实现积分兑换商品的内容功能分析首先我们
鸿蒙小林 鸿蒙小林
4小时前
《仿盒马》app开发技术分享-- 兑换商品详情(69)
技术栈Appgalleryconnect开发准备上一节我们实现了兑换商品列表的展示,用户可以在回收之后通过积分页面进入兑换列表页查看当前能够兑换的商品了,我们距离一个完整的app又更近了一步,现在我们要实现的就是当用户点击列表条目的时候能够查看数据详情。功
鸿蒙小林 鸿蒙小林
4小时前
《仿盒马》app开发技术分享-- 商品兑换校验(70)
技术栈Appgalleryconnect开发准备上一节我们实现了可兑换商品的详情,我们能够查看到商品更多的信息,这一节我们来实现商品兑换相关的功能,在进行商品兑换之前,我们在兑换详情页面,点击立即兑换按钮之后我们需要跳转到兑换详情页,但是用户的积分可能达不
鸿蒙小林 鸿蒙小林
4小时前
《仿盒马》app开发技术分享-- 兑换提交准备(72)
技术栈Appgalleryconnect开发准备上一节我们实现了地址的选择,商品数据的展示,我们页面中需要的提交的内容还有所欠缺,我们还需要新增一些展示兑换细节的组件,同时在提交之前还需要实现备注功能,我们还要在页面中展示一些积分相关的内容,告知用户积分的
鸿蒙小林 鸿蒙小林
4小时前
《仿盒马》app开发技术分享-- 兑换订单提交(73)
技术栈Appgalleryconnect开发准备上一节我们实现了兑换提交前的准备页面,向用户展示了兑换相关的所有信息,这一节我们就可以实现兑换订单的提交了功能分析订单提交我们需要创建对应的兑换商品订单提交信息表,我们需要把地址,商品信息,积分,备注,订单状
鸿蒙小林 鸿蒙小林
4小时前
《仿盒马》app开发技术分享-- 兑换订单列表框架(75)
技术栈Appgalleryconnect开发准备上一节我们针对订单兑换的业务逻辑进行了完善,成功的在兑换物品之后修改了用户信息的修改,新增了积分消费的记录。这一节我们实现订单创建之后进入的列表展示页框架。功能分析兑换商品的订单列表框架我们选择使用tabs,
鸿蒙小林 鸿蒙小林
4小时前
《仿盒马》app开发技术分享-- 待发货兑换订单列表(76)
技术栈Appgalleryconnect开发准备上一节我们实现了兑换订单展示页面的框架,这一节我们要进行兑换订单的展示,在兑换订单提交后,默认的状态是待发货状态,我们用列表的方式展示出来功能分析进入页面时我们就要通过用户的userid去查询对应的订单,获取
鸿蒙小林 鸿蒙小林
4小时前
《仿盒马》app开发技术分享-- 兑换商品收货确认&已完成列表展示(79)
技术栈Appgalleryconnect开发准备上一节我们实现了兑换商品订单的确认揽收功能,实现了tabs切换时的数据刷新,实现了待收货订单的列表展示。这一节我们要实现确认收货功能,并且实现待收货的列表展示功能功能分析当我们点击确认揽收的时候,修改订单状态
鸿蒙小林 鸿蒙小林
4小时前
《仿盒马》app开发技术分享-- 逻辑优化第一弹(81)
技术栈Appgalleryconnect开发准备随着上一节我们兑换商品订单相关逻辑的实现,我们的app功能已经更加的完善了,接下来我们开始对整个app缺失的小功能以及对已有的功能bug进行优化和逻辑的新增,这一节我们新增的功能是,商城订单的揽收功能,兑换订