my_withdraw.html 4.3 KB
<!DOCTYPE html>
<html lang="en">

{include file="public/head"/}
<link rel="stylesheet" href="__CDN__/assets/advertising/css/record.css">
<style>
    .btn {
        margin: 0.3rem 0;
    }
</style>

<body>
    <div class="my_wallet">
        <!-- 钱包余额 -->
        <div class="wallet_money layout align_center justify_center flex_diection">
            <div class="wallet_tips">我的钱包金额</div>
            <div class="wallet_coupon">{$user.exp}</div>
            <div class="wallet_num">约¥{$user.rmb}</div>
        </div>
        <!-- 提现金额 -->
        <div class="with_drawal_money">
            <div class="width_drawal_box">
                <div class="width_drawal_tips">提现金额</div>
                <div class="choice_with_drawal layout align_center justify flex_row flex_wrap">
                    {foreach name="$data" item="vo"}
                    <div class="choice_single layout align_center justify_center flex_diection" data-exp="{$vo}" data-rmb="{$key}">
                        <div class="choice_money">{$key}元</div>
                        <div class="choice_coupon">消耗{$vo}红包券</div>
                    </div>
                    {/foreach}
                </div>
                <div class="btn">立即提现</div>
            </div>
        </div>
        <!-- 提现弹窗 -->
        <div class="with_drawal_modal"></div>
        <div class="with_drawal_dialog">
            <div class="with_drawal_dialog_box">
                <div class="layout justify flex_row with_dialog_title">
                    <div class="with_drawal_tips">提现账户</div>
                    <div class="with_drawal_account">微信余额</div>
                </div>
                <div class="layout justify flex_row with_dialog_msg">
                    <div>提现金额</div>
                    <div class="rmb">10元</div>
                </div>
                <div class="layout justify flex_row with_dialog_msg">
                    <div>消耗红包劵</div>
                    <div class="exp">-10000</div>
                </div>
                <div class="layout justify flex_row with_dialog_btns">
                    <div class="with_btn_l">取消</div>
                    <div class="with_btn_r">确认</div>
                </div>
            </div>
        </div>
    </div>
    {include file="public/js" /}
    <script>
        // 选择提现金额
        $(".choice_single").click(function() {
            $(this).addClass("choiced");
            $(this).siblings().removeClass("choiced");
        })

        // 提现
        $(".btn").click(function() {
            var user_exp = $('.wallet_coupon').text();
            var exp = $('.choiced').attr('data-exp');
            var rmb = $('.choiced').attr('data-rmb');
            if(exp == undefined){
                toast('请选择提现金额');
                return false;
            }else if(user_exp < exp){
                toast('提现金额过高');
                return false;
            }
            $(".rmb").text(rmb+"元");
            $(".exp").text("-"+exp);
            $(".with_drawal_modal").show();
            $(".with_drawal_dialog").show();
        })

        // 取消
        $(".with_btn_l").click(function() {
            $(".with_drawal_modal").hide();
            $(".with_drawal_dialog").hide();
        })

        // 确认提现
        $(".with_btn_r").click(function() {
            var user_id = "{$user.id}";
            var exp = $('.choiced').attr('data-exp');
            $.ajax({
                url:"{:url('withdraw')}",
                type:"POST",
                data:{'user_id':user_id,'exp':exp},
                success:function(res){
                    if(res.code == 1){
                        toast("请等待提现审核");
                        setTimeout(function(){
                            window.location.href = '';
                        },2000)
                    }else{
                        toast(res.msg);
                        if(res.url != ''){
                            setTimeout(function(){
                                window.location.href = res.url;
                            },2000)
                        }
                    }
                },
                error:function(res){
                    toast("与服务器断开连接");
                }
            })
        })
    </script>
</body>

</html>