<template>
    <view class="wbtBind">
        
        <view class="input">
            <view class="title">文版通编号</view>
            <input type="number" maxlength="13" v-model="account" placeholder-class="placeholderClass" placeholder="请输入13位数字的文版通账号" />
        </view>
        
        <view class="input">
            <view class="title">文版通姓名</view>
            <input type="text" v-model="name" placeholder-class="placeholderClass" placeholder="请输入您的文版通姓名" />
        </view>
        
        <view class="group">
            <u-radio-group>
                <u-radio :checked='true' activeColor="#34ce98" labelColor="#999" labelSize="13" label="我有文版通账号" />
            </u-radio-group>
            <view class="created" >创建账号</view>
        </view>

        <view class="sure" @click="wbtBind"> 确认绑定文版通 </view>
        
        <navigator hover-class="none" url="/pages/vip/agreement?id=9">
            <view class="agree"> 同意
                <span>《文版通使用协议》</span>
            </view>
        </navigator>

        <view class="help">
            <view class="title"> 温馨提示 </view>
            <view class="help_1" v-for="item in 4" :key='item'>
                {{item}}.文版通使用注意事项，文版通使用注意事项，文版通使用注意事项，文版通使用注意事项，文版通使用注意事项，文版通使用注意事项。
            </view>
        </view>
    </view>
</template>

<script>
    import { wbtBind } from '@/apis/interfaces/account'
    export default {
        data() {
            return {
                account: '',
                name: ''
            };
        },
        methods:{
            wbtBind(){
                let data = {
                    account: this.account,
                    name: this.name
                }
                if(data.account === '' && data.account.length !== 13){
                    uni.showToast({
                        title:'请核对账号',
                        icon:"none",
                        mask:true
                    })
                    return ;
                }
                if(data.name === ''){
                    uni.showToast({
                        title:'请核对姓名',
                        icon:"none",
                        mask:true
                    })
                    return ;
                }
                uni.showModal({
                    title:'温馨提示',
                    content:'确认绑定该文版通账号,绑定后无法撤回！',
                    success:(res)=> {
                        if(res.confirm){
                            wbtBind(data).then(res=>{
                                uni.showToast({
                                    title:'文版通账号绑定成功',
                                    icon:"none",
                                    mask:true,
                                    duration:1500
                                })
                                setTimeout(()=>{
                                    uni.navigateBack({})
                                },2000)
                            }).catch(err=>{
                                uni.showToast({
                                    title:err.message,
                                    icon:"none",
                                    mask:true
                                })
                            })
                        }
                    }
                })
            }
        }
    }
</script>

<style lang="scss">
    .wbtBind {
        min-height: 100vh;
        background-color: #f9f9f9;
        width: 100%;
        box-sizing: border-box;
        padding-top: 20rpx;

        .input {
            display: flex;
            flex-direction: row;
            align-items: center;
            justify-content: space-between;
            box-sizing: border-box;
            padding: $padding + 20 $padding;
            background-color: #fff;
            border-bottom: solid 1rpx #f9f9f9;

            input {
                flex: 1;
                text-align: left;
                font-size: 30rpx;
            }

            .title {
                font-size: 32rpx;
                color: #333;
                width: 200rpx;
                margin-right: $margin;
                font-weight: 600;
            }

            .placeholderClass {
                color: #cacaca;
                font-size: 30rpx;
            }
        }

        .group {
            font-size: 28rpx;
            padding: $padding;
            display: flex;
            flex-direction: row;
            align-items: center;
            justify-content: space-between;
            box-sizing: border-box;
            margin-top: 10rpx;

            .created {
                color: #34CE98;
            }
        }

        .sure {
            background-color: $main-color;
            color: #FFFFFF;
            font-size: 34rpx;
            font-weight: bold;
            margin: 0 $margin $margin $margin;
            border-radius: 10rpx;
            text-align: center;
            padding: $padding;
            font-weight: bold;
        }

        .agree {
            display: flex;
            flex-direction: row;
            align-items: center;
            justify-content: flex-start;
            box-sizing: border-box;
            padding-left: $padding;
            font-size: 28rpx;
            color: #999;

            span {
                color: #1482D1;
                margin-left: 10rpx;
            }
        }

        .help {
            padding: $padding;
            color: #666;
            font-size: 30rpx;
            margin-top: $margin;

            .title {
                font-size: 34rpx;
                font-weight: bold;
                padding-bottom: 20rpx;
                padding-top: 20rpx;
                color: #333;
            }

            .help_1 {
                padding-top: 10rpx;
                line-height: 1.5;
            }
        }
    }
</style>
