第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

《仿盒馬》app開(kāi)發(fā)技術(shù)分享-- 優(yōu)惠券展示頁(yè)(57)

標(biāo)簽:
鴻蒙 HarmonyOS

技术栈

Appgallery connect

开发准备

上一节我们实现了优惠券的领取功能,并且在云端已经成功查询出优惠券信息,那么我们需要来实现一个优惠券展示的页面来向用户展示当前账号下的优惠券信息,辅助用户更好的去购买需要的商品,因为优惠券会有多种状态,在展示时也要注意不同状态的区分如何处理

功能分析

要实现优惠券的展示我们首先要获取当前登录的用户,因为我们在领取优惠券的时候插入了领券用户的userid,所以在查询的时候也要根据userid进行查询,在进入页面时就要查询出云端对应的优惠券内容展示到list列表中。

代码实现

首先我们需要在新建的优惠券展示页面新增topbar

      CommonTopBar({ title: "优惠券", alpha: 0, titleAlignment: TextAlign.Center ,backButton:true})

我们获取当前已存储的用户信息

 @State user: User|null=null
 const value = await StorageUtils.getAll('user');
    if (value != "") {
      this.user=JSON.parse(value)
    }

根据当前用户id去查询对应的优惠券列表

  @State couponList:CouponMall[]=[]

let databaseZone = cloudDatabase.zone('default');
    let condition = new cloudDatabase.DatabaseQuery(coupon_mall);
    condition.equalTo("user_id",this.user?.user_id)
    let listData = await databaseZone.query(condition);
    let json = JSON.stringify(listData)
    let data:CouponMall[]= JSON.parse(json)
    this.couponList=data

查询到数据之后,添加list组件

List({space:10}){
        ForEach(this.couponList,(item:CouponMall,index:number)=>{
          ListItem(){
         
          }
        })
      }
      .padding(10)

然后我们使用 @Builder 来实现条目的布局

  @Builder
  Item(item:CouponMall){
    Column({space:10}){
      Row({space:10}){
        Column(){
          Text("¥"+item.price)
            .fontSize(30)
            .fontColor(Color.Red)
            .fontWeight(FontWeight.Bold)
          Text("满"+item.limit_amount+"元可用")
            .fontColor(Color.Red)
            .fontWeight(FontWeight.Bold)
            .fontSize(12)
        }

        Column({space:10}){
          Text(item.type_str)
            .fontColor(Color.Black)
            .fontWeight(FontWeight.Bold)
            .fontSize(16)

          Text(item.txt)
            .fontColor(Color.Grey)
            .fontSize(12)

        }
        Blank()
        Text("待使用")
          .width(80)
          .height(80)
          .borderRadius(40)
          .fontSize(14)
          .textAlign(TextAlign.Center)
          .fontColor(Color.White)
          .backgroundColor(Color.Red)
      }
      .width('100%')
      .justifyContent(FlexAlign.SpaceBetween)
      Divider().width('100%').height(0.8)
        .color("#e6e6e6")
      Text("有效期至"+item.start_time+"至"+item.end_time)
        .fontSize(12)
        .fontColor(Color.Grey)
    }.padding(10)
    .backgroundColor(Color.White)
    .borderRadius(10)
  }

然后把条目布局引用到listitem中

 List({space:10}){
        ForEach(this.couponList,(item:CouponMall,index:number)=>{
          ListItem(){
            this.Item(item)
          }
        })
      }
      .padding(10)

执行代码查看当前优惠券列表的展示效果

點(diǎn)擊查看更多內(nèi)容
TA 點(diǎn)贊

若覺(jué)得本文不錯(cuò),就分享一下吧!

評(píng)論

作者其他優(yōu)質(zhì)文章

正在加載中
  • 推薦
  • 評(píng)論
  • 收藏
  • 共同學(xué)習(xí),寫下你的評(píng)論
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說(shuō)多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開(kāi)微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊(cè)有機(jī)會(huì)得

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會(huì)
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)

舉報(bào)

0/150
提交
取消