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

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定

《仿盒馬》app開發(fā)技術(shù)分享-- 回收金提現(xiàn)(53)

標(biāo)簽:
鴻蒙 HarmonyOS

技术栈

Appgallery connect

开发准备

上一节我们实现了银行卡的绑定跟回显,这一节我们要真正的实现银行卡提现的功能了,在这之前我们还需要对提现页的业务逻辑进行更进一步的优化,同时为了方便我们去进行数据间的交互,我们在个人信息模块新增了金额和积分的字段,方便我们其他页面的展示和隐藏

功能分析

要实现这些功能首先我们要获取当前账号下的回收金总额,这样我们在金额输入的时候才能根据他们两个实现用户多填写金额的判断,这样就会少对云数据库少进行一次请求,避免对资源浪费,同时我们提现的时候也要生成对应的记录,我们还需要操作moneyinfo表,因为我们在userinfo中新增了字段,同时还要操作userinfo表

代码实现

首先在提现页面先获取当前用户信息表userinfo下的账户总额

  let condition1=new cloudDatabase.DatabaseQuery(user_info)
    condition1.equalTo("user_id", this.user?.user_id)
    let listData1 = await databaseZone.query(condition1)
    let json1=JSON.stringify(listData1)
    let data1:UserInfo[] = JSON.parse(json1)
    this.userInfo=data1[0]

拿到之后我们传递给金额填写的自定义组件

//先在组件中定义
@Link userInfo:UserInfo|null

//传入数据
  InputItem({userInfo:this.userInfo})

修改对应的校验逻辑,展示当前账号回收金总额

 TextInput({ text: this.text, placeholder: '输入提现金额', controller: this.controller })
          .placeholderColor("#999999")
          .placeholderFont({ size: 28, weight: 400 })
          .caretColor("#FCDB29")
          .width(400)
          .height(50)
          .backgroundColor(null)
          .type(InputType.Number)
          .margin(20)
          .fontSize(14)
          .fontColor(Color.Black)
          .onChange((value: string) => {

            this.moneyNum=Number(value)
            this.text = value
            if (this.moneyNum>0&&this.moneyNum<=300) {
              if (this.moneyNum>this.userInfo!.money) {
                this.isPost=false
              }else {
                this.isPost=true
              }
            }else {
              this.isPost=false
            }
          })
      }
      Divider().width('100%').height(1)
      Text("可提现金额¥"+this.userInfo?.money+" (单笔最大提现额度:300)")
        .fontSize(15)
        .fontColor("#333333")

在提交按钮处新增提醒用户

 if (this.moneyNum>this.userInfo!.money) {
                    showToast('超过最大可提现金额,请重新输入')

                  }

这样我们就先处理好了逻辑,然后在确认提现的按钮处操作我们的两张表,分别把已经获取到的数据和填写的提现金额输入进去,我们需要拿账号总额去减去当前提现的额度,并且生成记录

   Text("确认提现")
              .width('100%')
              .fontColor(Color.White)
              .borderRadius(15)
              .padding(10)
              .textAlign(TextAlign.Center)
              .fontColor(this.isPost?Color.Black:Color.White)
              .backgroundColor(this.isPost?"#ffff6363":$r('app.color.color_999'))
              .onClick(async ()=>{
                if (this.isPost) {
                  let money=new money_info()
                  money.id=Math.floor(Math.random() * 1000000)
                  money.user_id=this.user!.user_id
                  money.money=String(this.moneyNum)
                  money.all_money=''
                  money.money_type='1'
                  money.address='银行卡提现'
                  money.year=this.year
                  money.month=this.month
                  money.day=this.day
                  money.time=this.time
                  money.create_time=this.year+"-"+this.month+"-"+this.day+" "+this.time
                  let nums =  await databaseZone.upsert(money);



                  let userData=new user_info()
                  userData.id=this.userInfo!.id
                  userData.user_id=this.userInfo!.user_id
                  userData.sex=this.userInfo!.sex
                  userData.bind_phone=this.userInfo!.bind_phone
                  userData.create_time=this.userInfo!.create_time
                  userData.nickname=this.userInfo!.nickname
                  userData.head_img=this.userInfo!.head_img
                  if (this.userInfo?.money!=null) {
                    userData.money=this.userInfo!.money-this.moneyNum
                  }else {
                    userData.money=0
                  }
                  if (this.userInfo?.points!=null) {
                    userData.points=this.userInfo!.points
                  }else {
                    userData.points=0
                  }
                  let s= await databaseZone.upsert(userData);

                  if (s>0) {
                    router.pushUrl({url:'pages/recycle/money/SuccessPage'})
                  }
                }else {
                  if (this.moneyNum==0){
                    showToast("提现金额单笔至少1元")
                  }
                  if (this.moneyNum>300) {
                    showToast('单日限额300元,请重新输入')
                  }
                  if (this.moneyNum>this.userInfo!.money) {
                    showToast('超过最大可提现金额,请重新输入')

                  }
                }
              })

在提现成功后,我们需要给用户一个反馈,这时候我们就新增一个简单的页面展示状态即可

import { CommonTopBar } from '../../widget/CommonTopBar';
import { router } from '@kit.ArkUI';

@Entry
@Component
struct SuccessPage {
  @State message: string = 'Hello World';

  build() {
    Column() {
      CommonTopBar({ title: "提现状态", alpha: 0, titleAlignment: TextAlign.Center ,backButton:true})
      Text("提现成功")
        .textAlign(TextAlign.Center)
        .fontColor(Color.Black)
        .fontSize(20)
        .fontWeight(FontWeight.Bold)
        .margin({top:100})

      Image($r('app.media.success_money'))
        .height(100)
        .width(100)
        .margin({top:20})



      Text("确认")
        .textAlign(TextAlign.Center)
        .width('95%')
        .padding(10)
        .fontColor(Color.White)
        .borderRadius(10)
        .backgroundColor("#fffa4444")
        .margin({top:100})
        .onClick(()=>{
          router.back()
        })
    }
    .backgroundColor(Color.White)
    .height('100%')
    .width('100%')
  }
}
點(diǎn)擊查看更多內(nèi)容
TA 點(diǎn)贊

若覺得本文不錯,就分享一下吧!

評論

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

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

100積分直接送

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

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

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

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

幫助反饋 APP下載

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

公眾號

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

舉報

0/150
提交
取消