var exhibitId = getUrlParam("id");
$(function () {
    $.ajax({
        type: "POST",
        url: "/manage_exhibitions/orders",
        data: JSON.stringify({
            id: Number(exhibitId)
        }),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (data) {
            let content = '';
            // 总数
            content = 
            `<h1>订单列表 (订单总数: ${data.orders.length})</h1>
            <input class="back-btn" type="button" value="返回" onclick="back()">`
            $('#top-panel').html(content)
            content = 
            `<tr>
                <td>姓名</td>
                <td>电话</td>
                <td>出价</td>
            </tr>`
            for (let i = 0; i < data.orders.length; i++) {
                let order = data.orders[i]
                content +=
                    `<tr>
                        <td>${order.UserName}</td>
                        <td>${order.Phone}</td>
                        <td>${order.Price}</td>
                    </tr>`
            }
            $('table').html(content)
        },
        error: function (xhr, textStatus, error) {
            var msg = JSON.parse(xhr.responseText);
            alert(msg.error);
        }
    });
})

function back() {
    history.back();
}