@extends('layouts.advert.member')
@section('title','充值')

@section('content')
    <style>
        .pr{
            font-size: 22px;
            line-height: 22px;
            color: #f60!important;
        }
        .order li{
            padding:10px 0;
            
        }
        .order li span{
            float:left;
            font-size:16;
        }
        .lab{
            display:block;
            width:100px;
            margin-right: 20px;
            text-align:right;
        }
    </style>
    <h1 class="fz18 pb10 bb-e0e0e0">请用微信App扫码支付</h1>
    <ul class="order">
        <li class="clear"><span class="lab">商品名称:</span><span>会员充值，金额：{{$money}}</span></li>
        <li class="clear"><span class="lab">订单号:</span><span>{{$charge_no}}</span></li>
        <li class="clear"><span class="lab">交易金额:</span><span class="pr">{{$money}}</span>元</li>
    </ul>
    <div style="position:relative;height:480px">
        <canvas id="qr" class="position-middle-center"></canvas>
    </div>
@endsection
@section('script')
<script src="/js/qrious.js"></script>
    <!-- 弹框插件layer -->
    <script>
        function checkpay(){
            var param = {};
            param.theUrl = '/advert/wechart/check';
            param.theData = {charge_no:'{{$charge_no}}'};
            $.ajax({
                type : 'POST',
                url : param.theUrl,
                data : param.theData,
                cache : false,
                success : function(data){
                    if(data.code == 200){
                        setTimeout(function(){
                            window.location.href = '/advert/member/charge';
                        },1000)
                    }else{
                        console.log('-未支付-');
                    }
                }
            });
        }
        (function() {
                var qr = new QRious({
                    element: document.getElementById('qr'),
                    value: '{{$result['code_url']}}',
                     size: '260'
                });
                setInterval(function(){
                    checkpay();
                },1000);
            }
        )();
    </script>
@endsection