《仿盒马》app开发技术分享-- 回收金提现准备页(50)

鸿蒙小林
• 阅读 7

技术栈

Appgallery connect

开发准备

上一节我们实现了回收金的收入、支出记录查询,并且在订单完成后成功创建对应的收支记录,但是我们暂时只有收入记录,并没有支出记录,这一节我们将要实现账号的回收金提现功能,从商业角度实现app应用的正向循环

功能分析

要实现提现功能,首先我们需要有对应银行卡信息的绑定,提现的金额,以及当前账号下的回收金总额,从商业角度考虑,我们还要限制一天内回收金额的提取总数,避免在某些情况下造成不必要的损失,首先我们需要判断当前账号是否绑定有对应的信息,然后我们通过对input组件进行条件判断来限制用户一些不正确的操作,然后在添加确认提现和提现记录按钮

代码实现

首先我们创建对应的绑定信息表

{
  "objectTypeName": "bind_bank",
  "fields": [
    {"fieldName": "id", "fieldType": "Integer", "notNull": true, "belongPrimaryKey": true},
    {"fieldName": "user_id", "fieldType": "Integer"},
    {"fieldName": "bank_name", "fieldType": "String"},
    {"fieldName": "bank_card", "fieldType": "String"},
    {"fieldName": "bank_people", "fieldType": "String"},
    {"fieldName": "is_verify", "fieldType": "Boolean"},
    {"fieldName": "verify_id", "fieldType": "Integer"}
  ],
  "indexes": [
    {"indexName": "field1Index", "indexList": [{"fieldName":"id","sortType":"ASC"}]}
  ],
  "permissions": [
    {"role": "World", "rights": ["Read", "Upsert", "Delete"]},
    {"role": "Authenticated", "rights": ["Read", "Upsert", "Delete"]},
    {"role": "Creator", "rights": ["Read", "Upsert", "Delete"]},
    {"role": "Administrator", "rights": ["Read", "Upsert", "Delete"]}
  ]
}

然后我们实现银行卡绑定模块,我们用组件引入的方式来实现,处理好绑定以及未绑定的展示逻辑

import { BindBank } from "../../entity/BindBank"

@Component
export struct BindAlipay {
  @Link bankList:BindBank[]
  public callback:()=>void=():void=>{}
  public postCallback:()=>void=():void=>{}


  @Builder
  notAlipay(){
    Row(){
      Image($r('app.media.tv_card'))
        .height(17)
        .width(17)
        .margin({left:14})

      Text("您还未绑定银行卡账号,点击绑定")
        .fontColor("#FF4242")
        .fontSize(16)
    }
    .backgroundColor(Color.White)
    .padding(10)
    .margin({bottom:50})
    .onClick(e=>{
      this.callback()
    })
    .height(48)
    .width('100%')
  }




  @Builder bindAlipay(){
    Row(){
      Column(){
        Row(){
          Image($r('app.media.tv_card'))
            .height(17)
            .width(17)
            .margin({left:14})
          Text("12212")
            .fontColor("#333333")
            .fontSize(16)
        }
        Text("预计2小时内到账(以实际到账时间为准)")
          .fontColor("#999999")
          .fontSize(15)
      }
      Image($r('app.media.back_right_recycle'))
        .height(30)
        .width(30)
    }
  }
  build() {
    Column() {
      if (this.bankList.length>0){
        this.bindAlipay()

      }else {
        this.notAlipay()
      }

    }
  }

}

然后我们实现提现金额输入的模块


@Component
export struct InputItem {
  @Consume
  moneyNum:number
  @State text: string = ''
  controller: TextInputController = new TextInputController()
  @Consume
  isPost:boolean

  build() {
    Column() {
      Row() {
        Text("提现金额")
          .fontSize(16)
          .fontColor("#333333")
        Text("单笔提现至少1元")
          .fontSize(14)
          .fontColor("#FF4242")
      }
      .width('100%')
      .justifyContent(FlexAlign.SpaceBetween)
      Row() {
        Text("¥")
          .fontSize(28)
          .fontColor("#333333")
        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) {
              this.isPost=true
            }else {
              this.isPost=false
            }
          })
      }
      Divider().width('100%').height(1)
      Text("可提现金额¥1500.00 (单日最大提现额度:300)")
        .fontSize(15)
        .fontColor("#333333")
    }
    .padding(10)
    .backgroundColor(Color.White)
    .alignItems(HorizontalAlign.Start)
  }
}

通过定义的@Provide @Consume可以帮助我们跨组件获取值,来更好的进行逻辑判断

Column({space:15}){
              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(()=>{
                  if (this.isPost) {
                    //拉起弹窗
                  }else {
                    if (this.moneyNum==0){
                      showToast("提现金额单笔至少1元")
                    }
                    if (this.moneyNum>300) {
                      showToast('单日限额300元,请重新输入')
                    }
                  }
                })

              Text("查看提现记录")
                .width('100%')
                .fontColor(Color.Black)
                .textAlign(TextAlign.Center)
                .backgroundColor("#ffffff")
                .padding(10)
                .borderRadius(15)
            }
            .margin({top:50})

然后我们在住页面调用组件

import { BindBank } from "../../entity/BindBank"
import showToast from "../../utils/ToastUtils"
import { CommonTopBar } from "../../widget/CommonTopBar"
import { BindAlipay } from "./BindAlipay"
import { InputItem } from "./InputItem"

@Entry
@Component
export default struct WithdrawMoneyPage {
  @State fontColor: string = '#182431'
  @State selectedFontColor: string = '#007DFF'
  @State currentIndex: number = 0
  @State alipayAcc:string=''
  @State bindAlipayName:string=''
  @State phoneCode:string=''

  @Provide
  isPost:boolean=false

  @Provide
  moneyNum:number=0

  @State bankList:BindBank[]=[]


  @Builder TabBuilder(index: number, name: string) {
    Row() {
      Image($r('app.media.tv_card'))
        .height(17)
        .width(17)
        .margin({left:15})
      Text(name)
        .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor)
        .fontSize(16)
        .fontWeight(this.currentIndex === index ? 500 : 400)
        .lineHeight(22)
    }
    .height(55)
    .width('100%')
    .alignItems(VerticalAlign.Center)
  }







  build() {
    Column() {
      CommonTopBar({ title: "提现", alpha: 0, titleAlignment: TextAlign.Center ,backButton:true})
          Column(){
            BindAlipay({bankList:this.bankList,
              callback:()=>{},
              postCallback:()=>{}})
            InputItem()

            Column({space:15}){
              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(()=>{
                  if (this.isPost) {
                    //拉起弹窗
                  }else {
                    if (this.moneyNum==0){
                      showToast("提现金额单笔至少1元")
                    }
                    if (this.moneyNum>300) {
                      showToast('单日限额300元,请重新输入')
                    }
                  }
                })

              Text("查看提现记录")
                .width('100%')
                .fontColor(Color.Black)
                .textAlign(TextAlign.Center)
                .backgroundColor("#ffffff")
                .padding(10)
                .borderRadius(15)
            }
            .margin({top:50})
          }
          .backgroundColor('#F1F3F5')
          .height('100%')
          .justifyContent(FlexAlign.Start)
          .padding(10)
    }
  }


}

点赞
收藏
评论区
推荐文章
鸿蒙小林 鸿蒙小林
16小时前
《仿盒马》app开发技术分享-- 旧物回收页(静态)(40)
技术栈Appgalleryconnect开发准备上一节我们进行了购物车业务逻辑的优化,使我们的程序变得更加健壮,这一节我们将要开始电商业务以外的内容,旧物回收,这是一个全新的业务模块,我们将要在这里实现对应的,回收金,积分,回收业务相关内容功能分析要想实现
鸿蒙小林 鸿蒙小林
16小时前
《仿盒马》app开发技术分享-- 旧物回收订单列表(43)
技术栈Appgalleryconnect开发准备上一节我们实现了订单的创建,并且成功吧数据提交到云数据库中,这一节我们实现的内容是展示我们提交的订单列表功能分析要实现订单列表的展示,首先我们要查询对应用户下的订单列表,查询出对应的订单列表后,展示出对应的数
鸿蒙小林 鸿蒙小林
16小时前
《仿盒马》app开发技术分享-- 回收记录页(47)
技术栈Appgalleryconnect开发准备上一节我们实现了在订单列表中查看订单详情,但是我们的回收相关的营收就必须要进入到商品详情页才能够进行查看,如果我们在订单较多的情况下,一个一个的查看订单的详情就会变得非常的麻烦了,现在我们需要实现一个订单记录
鸿蒙小林 鸿蒙小林
16小时前
《仿盒马》app开发技术分享-- 回收金收支查询(49)
技术栈Appgalleryconnect开发准备上一节我们实现了回收金页面的部分布局填充和内容展示,并且实现了当前订单收益总金额的展示,以及金额的隐藏,这一节我们来实现当前用户收支列表的展示,在这之前,我们先要修改一下我们recycleinfo表,我们把规
鸿蒙小林 鸿蒙小林
16小时前
《仿盒马》app开发技术分享-- 绑定银行卡回显(52)
技术栈Appgalleryconnect开发准备上一节我们实现了安全锁的绑定,这一切都是为了帮助用户在提现流程上能有更好更安全的体验,现在我们开始正式着手提现相关的流程,我们先进行提现银行卡的绑定,绑定成功后我们关闭页面把数据回显到提现页功能分析首先我们要
鸿蒙小林 鸿蒙小林
16小时前
《仿盒马》app开发技术分享-- 回收金提现记录查询(54)
技术栈Appgalleryconnect开发准备上一节我们实现了回收金提现的功能,并且成功展示了当前账户的支出列表,但是我们的提现相关的记录并没有很好的给用户做出展示,用户只知道当前账户提现扣款,并不知道回收金的去向,这一节我们就要实现回收金记录的查询添加
鸿蒙小林 鸿蒙小林
16小时前
《仿盒马》app开发技术分享-- 回收金提现安全锁校验(55)
技术栈Appgalleryconnect开发准备上一节我们实现了回收金提现记录的展示功能,我们回收金相关的内容更加的丰富了,在之前的业务逻辑中我们添加了一个设置安全锁的功能,虽然我们成功设置了安全锁,也把对应的表信息提交到云端,但是我们并没有在提现的流程中
鸿蒙小林 鸿蒙小林
16小时前
《仿盒马》app开发技术分享-- 我的积分页(63)
技术栈Appgalleryconnect开发准备上一节我们实现了个人中心页面的业务逻辑优化,成功的在用户登陆退出状态下展示对应的组件内容,这一节我们来实现app中另外一个比较重要的模块积分模块。功能分析因为我们的回收订单是跟回收金积分是绑定的,我们在完成回
鸿蒙小林 鸿蒙小林
16小时前
《仿盒马》app开发技术分享-- 兑换商品数据插入(67)
技术栈Appgalleryconnect开发准备上一节我们实现了积分列表的展示,我们可以更直观的查看当前用户积分的收支情况,但是现在我们只有积分收入并没有消费的地方,所以现在我们开始着手积分兑换相关的内容。这一节我们来实现积分兑换商品的内容功能分析首先我们
鸿蒙小林 鸿蒙小林
16小时前
《仿盒马》app开发技术分享-- 兑换订单列表框架(75)
技术栈Appgalleryconnect开发准备上一节我们针对订单兑换的业务逻辑进行了完善,成功的在兑换物品之后修改了用户信息的修改,新增了积分消费的记录。这一节我们实现订单创建之后进入的列表展示页框架。功能分析兑换商品的订单列表框架我们选择使用tabs,