{include file="layout/header" /}
<style type="text/css">
</style>
<!-- banner -->

<section class="wthree-row" id="pricing">
    <div class="container" style="font-size: 18px; font-weight: 800; margin-top: 50px;">
        <img src="{$Think.HOME_SITE_ROOT}/images/shopping.png">
        订单支付
    </div>
    <div class="container" style="font-size: 16px; margin-top: 50px; color: #B7B7B7;">
        <div style="display: flex; justify-content: center">
            <div>
                <div class="shopping_step">1</div>
                <div>选购服务</div>
            </div>
            <div class="shopping_line"></div>
            <div>
                <div class="shopping_step" style="background: #0074FF; color: #fff; border: 0;">2</div>
                <div style="color: #0074FF">订单支付</div>
            </div>
            <div class="shopping_line"></div>
            <div>
                <div class="shopping_step">3</div>
                <div>支付成功</div>
            </div>
        </div>
    </div>
    <div class="container" style="margin-top: 50px; margin-bottom: 50px;">
        <table class="gridtable">
            <tr>
                <td style="width: 33%;background: #ccc !important;">服务名称</td>
                <td style="width: 33%;background: #ccc !important;">时长</td>
                <td style="width: 33%;background: #ccc !important;">价格</td>
            </tr>
        </table>
        <table class="gridtable" style="margin-top: 20px;">
            <tr style="height: 50px;">
                <td style="border-right: 0; width: 33%;">{$fatherProduct.product_name} ▪ {$product.product_name}</td>
                <td style="border-right: 0; border-left: 0; width: 33%;">{$renewal.renewal_name}</td>
                <td style="border-left: 0; width: 33%;color: #FF2929">￥
                    <?php
                        switch($renewal->renewal_identity){
                    case 1:
                    echo $product->product_TypeOne;
                    break;
                    case 2:
                    echo $product->product_TypeTwo;
                    break;
                    case 3:
                    echo $product->product_TypeThree;
                    break;
                    case 4:
                    echo $product->product_TypeFour;
                    break;
                    }
                    ?>
                </td>
            </tr>
        </table>
    </div>
    <div class="container" style="margin-top: 50px; margin-bottom: 50px; display: flex;">
        <div>
            <span>应付金额：￥
                <?php
                    $money = 0;
                    switch($renewal->renewal_identity){
                        case 1:
                        $money = $product->product_TypeOne;
                        break;
                        case 2:
                        $money = $product->product_TypeTwo;
                        break;
                        case 3:
                        $money =  $product->product_TypeThree;
                        break;
                        case 4:
                        $money =  $product->product_TypeFour;
                        break;
                       }
                       echo $money;
                ?>
            </span>
            <br/>
            {if $money <= $userInfo.userInfo_money}
            <span>账户余额：￥{$userInfo.userInfo_money}</span>
            {else}
            <span style="color: #FF2929">账户余额：￥{$userInfo.userInfo_money}</span>
            {/if}
        </div>
        <div style="flex: 1; text-align: right;">
            {if $money <= $userInfo.userInfo_money}
            <button onclick="shopping('{$product.product_id}','{$renewal.renewal_identity}')" style="background: #0074FF; border: 0;" type="button" class="btn btn-info btn-lg-block w3ls-btn px-4 text-uppercase font-weight-bold">
                确认支付
            </button>
            {else}
            <!--<span style="color: #FF2929; margin-right: 10px; font-size: 14px;">当前余额不足</span>-->
            <div style="background: #DDDDDD; border: 0; cursor: not-allowed" class="btn btn-info btn-lg-block w3ls-btn px-4 text-uppercase font-weight-bold">
                确认支付
            </div>
            {/if}
        </div>
    </div>
</section>
<script>
    const myHost = "http://" + window.location.host;
    function shopping(product_id, renewal_identity) {
        $.ajax({
            url: myHost + "/home/product/purchased.html",
            type: 'post',
            dataType: 'json',
            data: {product_id: product_id, renewal_identity: renewal_identity},
            success: function(res){
                if (res['success']) {
                    window.location.href = myHost + "/home/product/purchased.html?data=" + res['data'];
                } else {
                    console.log(res);
                }
            },
            error: function(){
                alert("服务器连接失败");
            }
        });
    }
</script>
{include file="layout/footer" /}
