<template>
    <view title="提现" ref="pageRef">
        <view class="paddingX12 paddingT16">
            <view class="cu-form-group">
                <view class="title">真实姓名：</view>
                <input placeholder="请输入真实姓名" v-model="form.idName" name="input" />
            </view>
            <view class="cu-form-group">
                <view class="title">身份证号：</view>
                <input placeholder="请输入身份证号" v-model="form.idNum" name="input" />
            </view>
            <view class="cu-form-group">
                <view class="title">银行账户：</view>
                <input placeholder="请输入银行账户" v-model="form.bankNum" name="input" />
            </view>
            <view class="cu-form-group">
                <view class="title">所属银行：</view>
                <input placeholder="请输入所属银行" v-model="form.bankName" name="input" />
            </view>
            <view class="cu-form-group">
                <view class="title">所属支行：</view>
                <input placeholder="请输入所属支行" v-model="form.bankNameBranch" name="input" />
            </view>
            <view class="cu-form-group">
                <view class="title">预留手机：</view>
                <input placeholder="请输入预留手机" v-model="form.bankPhone" name="input" />
            </view>
            <view class="tip paddingT15" style="color: #ff0000;">
              * 请您务必保证输入的账号和姓名匹配，且该账号已实名认证。若因您输入信息错误，导致提现到他人账号，因此造成的后果，平台不承担任何责任，
            </view>
        </view>
        <view class="paddingX26 paddingT15 marginT15 radius2" style="background-color: #f6f6f6">
            <cm-button :height="37" @click="apply">保存</cm-button>
        </view>
    </view>
</template>

<script>
    import { throttle } from '@/utils/utils.js'

    export default {
        data() {
            return {
                pre: null,
                balance: null,
                desc: '',
                type: 'ALIPAY',
                money: '',
                form: {
                    idName: '', //真实姓名
                    idNum: '', //身份证号
                    bankNum: '', //银行卡号
                    bankName: '', //所属银行
                    bankNameBranch: '', //所属支行
                    bankPhone: '' //银行预留手机号
                },
                idName: null,
                idNum: null,
                accountNo: ''
            }
        },
        onLoad(option) {
            this.type = option.type || 'ALIPAY'
        },
        onShow() {
            this.getWithdraw()
        },
        methods: {
          async getWithdraw() {
                const res = await this.$service.wallet.getWithdraw()
                this.form = res
            },
            async getPre() {
                // const res = await this.$service.wallet.withdrawPre(this.type, 'MAGIC_PROMOTION')
                // if (res) {
                //     if (res.account && res.account.idName) {
                //         this.idName = res.account.idName
                //         this.idNum = res.account.idNum
                //         this.accountNo = res.account.accountNo
                //     }
                //     this.balance = res.avaliableWithdraw.amount
                //     this.desc = res.avaliableWithdraw.desc
                // }
            },
            apply() {
                if (!this.form.idName) {
                    this.$message.warn('请输入真实姓名')
                    return
                }
                if (!this.form.idNum) {
                    this.$message.warn('请输入身份证号')
                    return
                }
                if (!this.form.bankNum) {
                    this.$message.warn('请输入银行账户')
                    return
                }
                if (!this.form.bankName) {
                    this.$message.warn('请输入所属银行')
                    return
                }
                if (!this.form.bankNameBranch) {
                    this.$message.warn('请输入所属支行')
                    return
                }
                if (!this.form.bankPhone) {
                    this.$message.warn('请输入预留手机')
                    return
                }
                    this.realApply()

            },
            async realApply() {
                const res = await this.$service.wallet.saveBank(this.form)
                if (res) {
                    this.$router.back()
                }
            }
        }
    }
</script>
<style>
    page {
        background: #fff;
    }
</style>
<style lang="scss" scoped>
    .input-wrapper {
        width: 100%;
        height: 104rpx;
        border-radius: 16rpx;
        padding: 0 15rpx;
        .left {
            width: 160rpx;
        }
    }
    .un-check {
        width: 36rpx;
        height: 36rpx;
        border: 2rpx solid $color-theme;
        border-radius: 4rpx;
    }
    .check {
        width: 36rpx;
        height: 36rpx;
    }
    .cu-form-group{
      border-top: none;
    }
</style>
