<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta content="telephone=no" name="format-detection">
    <meta name="wap-font-scale" content="no">
    <title>小券提现</title>
    <link rel="stylesheet" href="css/base.css">
    <link rel="stylesheet" href="css/layer.css">
    <link rel="stylesheet" href="css/index.css?v=2021051401">
    <script src="lib/fsize.js"></script>
    <style>
        .layui-layer-ico {
            display: none !important;
        }
        .layui-layer{
            box-shadow: none !important;
        }
        .yourclass{
            background: rgba(0,0,0,0) !important;
            border-radius: 0.4rem !important;
        }
        .layui-layer-page .layui-layer-content{
            border-radius: 0.4rem !important;
        }
        .yourclass2{
            border-radius: 0rem !important;
            background: rgba(0,0,0,0) !important;
        }
        .yourclass2 .layui-layer-content{
            border-radius: 0rem !important;
        }
    </style>

</head>
<body>
<div style="background: rgb(245,245,245);height: 0.15rem;"></div>
<div style="display: block" class="withdraw-bg">
    <div class="withdraw-div"><span style="width: 2.25rem;display: inline-block;">到账银行卡</span> <span class="withdraw-bank"></span><span class="r-arrow">></span></div>
    <div><span style="width: 2.25rem;display: inline-block;">提现金额</span>¥ <input oninput="value=value.replace(/[^\d]/g,'')" placeholder="请输入提现金额" class="withdraw-money" type="text"></div>
    <p class="withdraw-p">可提现小券:<span>--</span></p>
    <p class="withdraw-tips"><span>温馨提示 : </span>提现金额最低为100且必须为100的倍数,10000小券=100元</p>
    <p style="text-align: center"><button class="with-btn">提现</button></p>
    <p class="withdraw-bottom-tips">绑定的银行卡持有人必须与您实名认证的身份证姓名相符</p>
</div>
<div class="layer-msgBox">
    <p>点击授权即同意</p>
    <p>授权果冻直播代为缴纳相关税款</p>
    <div class="msgBox-bottom">
        <div class="msgBox-btn-no">取消</div>
        <div class="msgBox-btn-yes">授权</div>
    </div>
</div>
<div class="shadow"></div>
<div class="more-layer">
    <div>收款账户</div>
    <div>取消</div>
</div>
</body>
<script src="lib/jquery-3.1.1.min.js"></script>
<script src="layer-v3.1.0/layer/layer.js"></script>
<script>
//     $ip = 'http://test.api.lvdou66.com/';
    $ip = 'https://zhibo.lvdou66.com/';
//    $ip = 'https://zhibo.lvdou66.com/87server/'
    //    $ip = 'https://zhibo.lvdou66.com/';
    cdn = 'http://zhibocdn.ishuaji.cn/comm';
    var bbb = location.href;
    var data = url_get_params(bbb)
    function url_get_params(url_path) {
        var url = url_path;
        var theRequest = new Object();
        if (url.indexOf("?") != -1) {
            var str = url.substr(url.indexOf("?") + 1);
            strs = str.split("&");
            for (var i = 0; i < strs.length; i++) {
                theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
            }
        }
        return theRequest;
    }
    //ajax设置默认参数
    $.ajaxSetup({
        global: false,
        type: 'post',
        data: {
            uid:localStorage.uid,
            token:localStorage.token
        },
        dataType:"JSON"
    })
    var obj = {
        "cid": 11,
        "reqCode": new Date().getTime(),
        "data": {
            msg:"修改导航栏",
            titleName:"小券提现",
            color:'#000000',
            background:'#ffffff'
        }
    }
    var obj2 = JSON.stringify(obj);
    appCollaboration(obj2)
    var rightTopObj = {
        "cid": 13,
        "reqCode": new Date().getTime(),
        "data": {
            'msg':'添加右上角图标',
            'function':'more()',
            show:0
        }
    }
    var rightTop = JSON.stringify(rightTopObj);
    appCollaboration(rightTop)
    $(".withdraw-money").val(100)
    $(".withdraw-p span").text(sessionStorage.activebonds)
    $.ajax({
        url:$ip+'account/client/withdraw/bankmanage.html',
        success: function (data) {
            console.log(data);
            $(".withdraw-bank").text(data.bank+" ("+data.cardnum+") ")
            sessionStorage.firstwithdraw=data.firstwithdraw;
        }
    })
    $(".r-arrow").on("click",function(){
        more()
    })
    $(".more-layer div").eq(1).on("click", function () {
        $(".shadow").fadeOut(350)
        $(".more-layer").css("bottom","-3.2rem")
    })
    $(".more-layer div").eq(0).on("click", function () {
        $(".shadow").fadeOut(350)
        $(".more-layer").css("bottom","-3.2rem")
        setTimeout(function () {
            window.location.href='card.html';
        },300)
    })
    $(".withdraw-money").on("input", function () {
        if($(".withdraw-money").val()>($(".withdraw-p span").text()-$(".withdraw-p span").text()%10000)/100){
            $(".withdraw-money").val(($(".withdraw-p span").text()-$(".withdraw-p span").text()%10000)/100)
            layer.msg("金额超出可提现金额");
        }
        if($(".withdraw-money").val().length==0){
            $(".with-btn").unbind("click")
            $(".with-btn").addClass("with-btn-no")
        }else{
            $(".with-btn").unbind("click")
            $(".with-btn").removeClass("with-btn-no")
            $(".with-btn").on("click", function () {
                if(sessionStorage.firstwithdraw==1){
                    layer.open({
                        type: 1,
                        title: false,
                        shadeClose: false,
                        skin: "yourclass",
                        area: ["7.22rem", "4rem"],
                        content: $(".layer-msgBox")
                    })
                    return
                }
                if($(".withdraw-p span").text()<10000){
                    layer.msg('可提现小券数不足10000');
                    return
                }
                if($(".withdraw-money").val()<100){
                    layer.msg('提现金额最低为100');
                    return
                }
                if($(".withdraw-money").val()>20000){
                    layer.msg('单笔提现金额不能超过20000');
                    return;
                }
                if($(".withdraw-money").val()%100!=0){
                    layer.msg('提现金额必须为100的倍数');
                    return;
                }
                if(withBtn){
                    withBtn=false
                    $.ajax({
                        url:$ip+'account/client/withdraw/apply.html',
                        data:{
                            money:$(".withdraw-money").val()
                        },
                        success: function (data) {
                            console.log(data);
                            if(data.code==1){
                                sessionStorage.review=1
                                sessionStorage.title='小券提现'
                                window.location.href='review.html';
                            }else{
                                setTimeout(function () {
                                    layer.msg(data.msg)
                                    withBtn=true
                                },300)

                            }
                        }
                    })
                }
            })
        }
    })
    var withBtn=true
    $(".with-btn").on("click", function () {
        if(sessionStorage.firstwithdraw==1){
            layer.open({
                type: 1,
                title: false,
                shadeClose: false,
                skin: "yourclass",
                area: ["7.22rem", "4rem"],
                content: $(".layer-msgBox")
            })

            return
        }
        if($(".withdraw-p span").text()<10000){
            layer.msg('可提现小券数不足10000');
            return
        }
        if($(".withdraw-money").val()<100){
            layer.msg('提现金额最低为100');
            return
        }
        if($(".withdraw-money").val()>20000){
            layer.msg('单笔提现金额不能超过20000');
            return;
        }
        if($(".withdraw-money").val()%100!=0){
            layer.msg('提现金额必须为100的倍数');
            return;
        }
        if(withBtn){
            withBtn=false
            $.ajax({
                url:$ip+'account/client/withdraw/apply.html',
                data:{
                    money:$(".withdraw-money").val()
                },
                success: function (data) {
                    console.log(data);
                    if(data.code==1){
                        sessionStorage.review=1
                        sessionStorage.title='小券提现'
                        window.location.href='review.html';
                    }else{
                        setTimeout(function () {
                            layer.msg(data.msg)
                            withBtn=true
                        },300)

                    }
                }
            })
        }
    })

    $(".msgBox-btn-no").on("click", function () {
        layer.closeAll();
    })
    $(".msgBox-btn-yes").on("click", function () {
        if($(".withdraw-p span").text()<10000){
            layer.closeAll()
            layer.msg('可提现小券数不足10000');
            return
        }
        if($(".withdraw-money").val()<100){
            layer.closeAll()
            layer.msg('提现金额最低为100');
            return
        }
        if($(".withdraw-money").val()>20000){
            layer.closeAll()
            layer.msg('单笔提现金额不能超过20000');
            return;
        }
        if($(".withdraw-money").val()%100!=0){
            layer.closeAll()
            layer.msg('提现金额必须为100的倍数');
            return;
        }
        if(withBtn){
            withBtn=false
            $.ajax({
                url:$ip+'account/client/withdraw/apply.html',
                data:{
                    money:$(".withdraw-money").val()
                },
                success: function (data) {
                    console.log(data);
                    if(data.code==1){
                        sessionStorage.review=1
                        sessionStorage.title='小券提现'
                        window.location.href='review.html';
                    }else{
                        setTimeout(function () {
                            layer.msg(data.msg)
                            withBtn=true
                        },300)

                    }
                }
            })
        }
    })
    function more(){
        $('.more-layer').css("bottom","0.2rem");
        $(".shadow").show()
    }
    function appCollaboration(msg) {
        var ua = window.navigator.userAgent.toLowerCase();
        try{
            if (/iphone|ipad|ipod/.test(ua)) {
                window.webkit.messageHandlers.appCollaboration.postMessage(msg);
            }else if(/android/.test(ua)){
                window.yazhai.appCollaboration(msg);
            }
        }catch (e){}
    }
    //客户端回调结果
    function appCallback(msg) {
        console.log(msg);
    }
</script>
</html>