小程序银行卡提现页面(做记录用)

ui设计-1
ui设计-2.png
<template>

    <view class="layout">
        <view class="withdrawal-title container">
            <text>提现</text>
        </view>
        <!-- 扣除手续费提示 -->
        <view class="service-fee container">
            <text>每笔扣除{{serviceFee}}元手续费</text>
        </view>
        <view class="withdrawal container">
            <!-- 提现金额 -->
            <view class="withdrawal-money flex ">
                <text>¥</text>
                <input v-model="moneyInput" class="u-margin-left-32" placeholder="请输入提现金额" type="digit" placeholder-style="color:#E2E4EA;"
                 @input="checkPrice" />
            </view>
            <!-- 剩余金额 -->
            <view class="balance">
                <text>剩余金额{{balance}}元</text>
            </view>
        </view>
        <view class="withdrawal-bank flex container" @click="openPopupBank">
            <image src="../../../static/images/bank_logo@3x.png" mode=""></image>
            <view class="card-info flex u-margin-left-32">
                <text class="bank-name">{{bankName}}(尾号{{lastFourNum}})</text>
                <text class="quota">单笔限额10000元,单日限额10000元</text>
            </view>
            <u-icon name="arrow-right"></u-icon>
        </view>
        <view class="container submit">
            <u-button type="primary" @click="inputPwd" :disabled="moneyInput ==0 ||  checked == false || defaultBank.length ==0 ">确定</u-button>
        </view>
        <!-- 需要阅读的提示 -->
        <view class="tips flex container">
            <u-checkbox-group>
                <u-checkbox @change="!checkboxChange" v-model="checked" shape="circle">
                    <text>我已阅读并同意签署</text>
                    <u-link>《平台协议》《借款协议》《委托协议》</u-link>
                </u-checkbox>
            </u-checkbox-group>
        </view>

        <!-- 底部弹出的选择银行卡选项 -->
        <uni-popup ref="popup" type="bottom">
            <view class="choose-card">
                <view class="choose-title flex choose-card-padding">
                    <text>选择支付类型</text>
                    <u-icon name="close" size="28" @click="bankClose"></u-icon>
                </view>
                <view class="choose-bank-card flex choose-card-padding" v-for="(item,index) in bankList" :key="index" @click="chooseBank(item,index)">
                    <image src="../../../static/images/bank_logo@3x.png" mode=""></image>
                    <view class="card-info flex u-margin-left-32">
                        <text class="bank-name">{{item.bank_name}}(尾号{{item.bank_number.substr(item.bank_number.length-4, item.bank_number.length)}})</text>
                        <text class="quota">单笔限额10000元,单日限额10000元</text>
                    </view>
                    <u-icon v-if="currentIndex == index" name="checkmark" color="#007AFF"></u-icon>
                    <view class="border-bottom">
                    </view>
                </view>
                <view class="choose-bank-card flex choose-card-padding" @click="addNewCard">
                    <image src="../../../static/images/defualt-bank.png" mode=""></image>
                    <view class="card-info flex u-margin-left-32">
                        <text class="bank-name">使用新卡支付</text>
                    </view>
                </view>
                <view class="other">
                </view>
            </view>
        </uni-popup>
        <!-- 点击确定提现输入密码弹窗 -->
 
        <view class="pwdpopup">
            <u-keyboard :mask="true" ref="uKeyboard" :random="random" :dotEnable="false" mode="number" :tooltip="tooltip"
             v-model="show" @change="change" :mask-close-able="false" @backspace="backspace" :dot-enabled="false">
             <u-popup v-model="show" mode="center" closeable close-icon="close" close-icon-pos="top-right" length="80%" @close="close"
              :mask="false" :mask-close-able="false" border-radius="4" class="pwd-popup" negative-top="300" z-index="1000">
                <view class="popuppwd-style" style="height: 395upx">
                    <view class="flex flex-column-center">
                        <text class="withdrawal-input-money">提现{{withdrawal}}元</text>
                        <text class="withdrawal-input-pwd">输入提现密码</text>
                    </view>
                    <view class="input-password u-margin-top-60">
                        <u-toast ref="uToast"></u-toast>
                        <u-message-input :maxlength="6" :value="pwdvalue" mode="bottomLine" :breathe="true" :focus="true" @finish="finish"></u-message-input>
                    </view>
                </view>
             </u-popup>
            </u-keyboard>
        </view>
    </view>



</template>

<script>
    import Https from '../../../api/http.js'
    export default {

        data() {
            return {
                checked: false,
                keyshow: false,
                show: false,
                pwdvalue: '',
                showKeyboard: false,
                maskinput: false,
                // mask: true,
                moneyInput: '',
                // 默认选中银行信息
                defaultBank: {},
                balance: '',
                bankName: '',
                lastFourNum: '',
                serviceFee: '',
                bankList: [],
                currentIndex: '',
                userInfo: {},
                withdrawal: ''
            }
        },
        onLoad() {
            this.withDrawInfo()
        },
        onShow() {
            this.userInfo = this.$store.state.userInfo
        },
        methods: {
            async withDrawInfo() {
                let res = await Https.withDrawInfo()
                this.defaultBank = res.data.one_bank
                this.balance = res.data.money
                this.serviceFee = res.data.withDrawFee
                this.bankName = this.defaultBank.bank_name
                this.lastFourNum = this.defaultBank.bank_number.substr(this.defaultBank.bank_number.length - 4, this.defaultBank.bank_number
                    .length)
            },
            // 输入完密码验证
            finish() {
                Https.userWithdraw({
                    user_id: this.userInfo.id,
                    password: this.pwdvalue,
                    bank_card_id: this.defaultBank.ids,
                    amount: this.moneyInput,
                    vv_time: parseInt(new Date().getTime() / 1000)
                }).then(res2 => {
                    console.log(res2)
                    if (res2.flag == 1) {
                        uni.showToast({
                            title: '银行卡提现成功',
                            icon: 'success',
                            duration: 2000
                        })
                        this.show = false
                        uni.navigateTo({
                            url: '../submit/index?withdrawMoney=' + this.moneyInput + '&serviceFee=' + this.serviceFee + '&bankName=' +
                                this.bankName + '&lastFourNum=' + this.lastFourNum
                        })
                    } else {
                        uni.showToast({
                            icon: 'none',
                            title: res2.msg,
                            duration: 2000
                        })
                        this.pwdvalue = ''
                        this.show = false
                    }
                })
            },
            // 键盘输入
            change(input) {
                if (this.pwdvalue.length < 6) {
                    this.pwdvalue += input;
                }
                if (this.pwdvalue.length == 6) {
                    this.finish();
                }
            },
            //验证input价格输入框输入内容

            checkPrice: function(e) {
                let that = this;
                let price = e.detail.value
                if (price.indexOf(".") < 0 && price != "") {
                    price = parseFloat(price);

                } else if (price.indexOf(".") == 0) {
                    //'首位小数点情况'
                    price = price.replace(/[^$#$]/g, "0.");
                    price = price.replace(/\.{2,}/g, ".");
                } else if (!(/^(\d?)+(\.\d{0,2})?$/.test(price))) {
                    //去掉最后一位
                    price = price.substring(0, price.length - 1)
                }
                that.$nextTick(function() {
                    that.moneyInput = price
                })
            },
            // 点击键盘回退
            backspace() {
                if (this.pwdvalue.length) this.pwdvalue = this.pwdvalue.substr(0, this.pwdvalue.length - 1);
            },
            backspaceInput() {
                if (this.moneyInput.length) this.moneyInput = this.moneyInput.substr(0, this.moneyInput.length - 1);
            },
            checkboxChange() {
                this.checked = true
            },
            async openPopupBank() {
                this.$refs.popup.open()
                let res1 = await Https.myBankList()
                if (res1.flag == 1) {
                    this.bankList = res1.data.list
                }
            },
            chooseBank(item, index) {
                this.currentIndex = index
                this.defaultBank = item
                this.$refs.popup.close()
                this.bankName = this.defaultBank.bank_name
                this.lastFourNum = this.defaultBank.bank_number.substr(this.defaultBank.bank_number.length - 4, this.defaultBank
                    .bank_number
                    .length)
            },
            bankClose() {
                this.$refs.popup.close()
            },
            // 点击确定提取money
            inputPwd() {
                console.log(this.moneyInput)
                console.log(this.balance)
                if (parseInt(this.moneyInput) > parseInt(this.balance)) {
                    uni.showToast({
                        icon: 'none',
                        title: '超出提现余额,不能提现'
                    })
                    return
                } else {
                    this.withdrawal = this.moneyInput
                    this.show = true
                    this.pwdvalue = ''
                    // this.$refs.popuppwd.open()
                }

            },
            close() {
                this.show = false
            },
            addNewCard() {
                uni.navigateTo({
                    url: '../addCards/index'
                })
            }
            // tap(){
            //  console.log(111)
            //  this.show = true
            // }
        }




    };
</script>

<style lang="scss" scoped>
    @import "../../../assets/css/common.scss";

    .container {
        padding: 0 40upx;
    }

    .layout {
        background-color: $theme-bg-color;
        height: 1536upx;

        .withdrawal-title {
            height: 120upx;
            line-height: 120upx;
            background-color: $theme-words-color;

            text {
                font-size: $theme-f52;
                font-weight: 600;
                color: $theme-title-color;
            }
        }

        .service-fee {

            height: 76upx;
            line-height: 76upx;

            text {
                font-size: $theme-f24;
                color: $theme-info-color;
            }
        }

        .withdrawal {
            background: $theme-words-color;

            .withdrawal-money {
                height: 160upx;
                font-size: $theme-f44;
                align-items: center;
            }

            .balance {
                height: 76upx;
                font-size: $theme-f24;
                color: $theme-text-color;
                line-height: 76upx;
                border-top: 1px solid $theme-border-color;
            }
        }

        .withdrawal-bank {
            height: 140upx;
            margin-top: 20upx;
            background: $theme-words-color;
            align-items: center;

            image {
                width: 60upx;
                height: 60upx;
            }

            .card-info {
                flex-direction: column;

                .bank-name {
                    font-size: $theme-f32;
                    color: $theme-title-color;
                    margin-bottom: 4upx;
                }

                .quota {
                    font-size: $theme-f24;
                    color: $theme-text-color;
                }
            }

            u-icon {
                position: absolute;
                right: 40upx;
                color: $theme-tip-color;
            }
        }

        .submit {
            margin: 40upx 0;
        }

        .tips {
            .u-checkbox__icon.u-checkbox__icon--circle {
                margin-right: 20upx;
            }

            text {
                color: $theme-text-color;

            }
        }

        .choose-card-padding {
            padding: 0 32upx;
            height: 140upx;
        }

        .choose-card {

            background-color: $theme-bg-color;
            color: #333333;

            .choose-title {
                line-height: 140upx;
                font-size: $theme-f36;
                justify-content: center;


                u-icon {
                    position: absolute;
                    right: 32upx;
                    top: 52upx;
                }
            }

            .choose-bank-card {
                position: relative;
                background: $theme-words-color;
                align-items: center;

                .border-bottom:after {
                    content: '';
                    position: absolute;
                    left: 124upx;
                    top: auto;
                    bottom: 0;
                    right: auto;
                    height: 2upx;
                    width: 100%;
                    background-color: $theme-border-color;
                }

                image {
                    width: 60upx;
                    height: 60upx;
                }

                .card-info {
                    flex-direction: column;

                    .bank-name {
                        font-size: $theme-f32;
                        color: $theme-title-color;
                        margin-bottom: 4upx;
                    }

                    .quota {
                        font-size: $theme-f24;
                        color: $theme-text-color;
                    }
                }

                u-icon {
                    position: absolute;
                    right: 40upx;

                }
            }


            .other {
                height: 250upx;
            }
        }

        .popuppwd-style {
            padding-top: 30upx;

            .withdrawal-input-money {
                font-size: $theme-f40;
                color: $theme-title-color;
            }

            .withdrawal-input-pwd {
                margin-top: 20upx;
                font-size: $theme-f28;
                color: $theme-text-color;
            }
        }
    }
</style>

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 211,561评论 6 492
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,218评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 157,162评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,470评论 1 283
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,550评论 6 385
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,806评论 1 290
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,951评论 3 407
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,712评论 0 266
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,166评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,510评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,643评论 1 340
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,306评论 4 330
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,930评论 3 313
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,745评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,983评论 1 266
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,351评论 2 360
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,509评论 2 348

推荐阅读更多精彩内容