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

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

技术栈

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)
    }
  }


}
相关文章
|
2月前
|
人工智能 自然语言处理 安全
阿里云通义千问大模型全解读:模型矩阵、核心竞争力、行业应用与定价策略一文讲透
通义千问的野心,不止于做一个"好用的聊天机器人"。从2023年8月首发到2026年衍生模型突破20万款、全球下载量破10亿次,它已构建起一座从底层架构到行业应用、从开源社区到商业闭环的完整AI生态。无论你是个人开发者想快速验证想法,还是大型企业要完成数字化转型的核心引擎——‌阿里云百炼大模型服务平台页面面**‌,都是你启程的第一站。 ‌记住:选对模型,就是选对了未来的起跑线。
767 1
|
3月前
|
缓存 NoSQL 测试技术
商品详情页高并发读:多级缓存与击穿、雪崩、穿透三件套防护实践
商品详情页是商城读流量最大的入口,大促时缓存一旦击穿、雪崩、穿透,会直接打垮数据库。本文讲清多级缓存架构(本地缓存+Redis+数据库)与三类故障的成因和防护:互斥重建、逻辑过期、布隆过滤器,并给出Java与Redis命令和五个生产踩坑。
|
4月前
|
人工智能 缓存 移动开发
秒悟官网Meoo.com零代码 AI 建站工具功能、积分计费、三版套餐及活动指南
秒悟(Meoo)是阿里云推出的国产AI零代码开发平台,支持自然语言一句话生成网页/H5/小程序/APP/PPT及数据看板,并自动完成前后端、数据库与云端部署。现Pro版限时9.9元/月,阿里云官网活动:https://t.aliyun.com/U/8CWzLR
|
4月前
|
人工智能 文字识别 前端开发
DeepSeek 终于能看图了!教你免费使用 + 8 大场景实测
DeepSeek V4 Flash Vision 视觉模型全方位测评 + 免费使用方法,8 轮硬核测试涵盖 OCR 识别、身份识别、ASCII 转换、报错截图修复、前端 UI 复刻、逻辑推理,全程对比 Claude Opus 5,看看国产视觉模型 DeepSeek 大肥鱼到底能不能打。
853 0
|
人工智能 自然语言处理 测试技术
基于Dify创建可复用测试用例工厂
本文介绍如何利用Dify平台搭建智能测试用例工厂,通过自然语言需求自动生成结构化测试用例。该方法将传统耗时数天的用例编写工作压缩至数小时,显著提升测试覆盖率和维护效率,实现测试开发的智能化转型。
|
7月前
|
人工智能 安全 机器人
我们来说说到底什么是 agent ?
我是小假 期待与你的下一次相遇 ~
1896 1
|
8月前
|
人工智能 安全 Windows
2026 最新版 OpenClaw,Windows10/11 专属一键汉化安装(包含新安装包)
专为 Windows10、Windows11 系统优化的 2026 最新版 OpenClaw 汉化安装包,完美适配新系统环境,解决旧版不兼容、启动闪退、界面错乱等问题,内置针对性配置脚本,一键自动安装、自动汉化,无需手动调整系统设置,不用输入任何命令,安装后运行流畅、界面清晰,充分适配新系统特性,满足新电脑用户需求。
|
6月前
|
运维 算法 安全
零基础个人跨境出海:零技术SaaS建站的轻量化落地逻辑
跨境电商公域内卷加剧,个人创业者生存艰难。轻量化SaaS云建站依托阿里云技术,零代码、低投入、私有资产、极简运维,助力零基础者快速搭建合规独立站,自主经营、沉淀客户、长效获客,是副业出海最优解。(239字)
374 0
|
8月前
|
存储 人工智能 供应链
客户案例 | 60天内完成中国部署,士卓曼做对了哪3件事?
士卓曼携手阿里云上的Salesforce,2个月完成部署,兼顾全球统一治理与本地合规(数据驻留、医疗监管)、敏捷迭代及微信/AI等本土化创新,打造跨国企业本土化落地标杆范本。
|
8月前
|
人工智能
AI洗稿就是“小偷”,自己不原创,就搞这些小动作
自媒体人须警醒:洗稿时代已终结!对标≠洗稿,用AI改写、提炼重写均属抄袭。
424 4