<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">

<head>
    <th:block th:include="include :: header('gago')"/>
</head>
<style>
    td {
        horiz-align: center;
        text-align: left;
        padding: 10px;
    }

</style>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="userMobile-form">
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">用户手机号码：</label>
            <div class="col-sm-8">
                <input type="number" id="userMobile" name="userMobile" class="form-control">
                <input id="userId" name="userId" class="form-control" type="hidden" readonly>
            </div>
            <button type="button" class="btn btn-w-m btn-success" onclick="getMobileIsAudit()">
                验证手机号
            </button>
        </div>
    </form>

    <form class="form-horizontal m" id="nft-form">
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">数字藏品名称：</label>
            <div class="col-sm-8">
                <input id="skuId" name="skuId" th:value="*{skuId}" type="hidden">
                <div class="remote_wrapper" style="position: relative;">
                    <input name="ids" type="hidden">
                    <input type="text" id="remoteSearch">
                </div>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">生成序号：</label>
            <div class="col-sm-8">
                <input type="number" id="nftNum" name="nftNum" class="form-control">
            </div>
        </div>
    </form>

    <button type="button" class="btn btn-w-m btn-success" onclick="ce()">
        生成订单
    </button>

</div>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: bootstrap-suggest-js"/>
<script th:src="@{/js/remote-search-nft.js}"></script>
<script th:inline="javascript">
    var prefix = ctx + "goblin/gago";

    function getMobileIsAudit() {
        var mobile = $("#userMobile").val();
        $("#userId").val('');
        $.operate.get(prefix + "/nftAccount?userMobile=" + mobile, function (res) {
            uid = res.uid;
            $("#userId").val(uid);
        });
    }

    $('#remoteSearch').remoteSearchPerformance({
        ajax: {
            url: "/goblin/common/sku?type=1",
            type: "get"
        },
        chose: function (text, val) {
            $("#skuId").val(val);
        },
        success: function () {
        }
    })

    function ce() {
        var skuId = $("#skuId").val();
        var nftNum = $("#nftNum").val();
        var uid = $("#userId").val();
        if (uid == "" || nftNum == "" || uid == "") {
            alert("请完整填写信息")
        } else {
            var param = {
                skuId: skuId,
                nftNum: nftNum,
                uid: uid
            };
            $.operate.post(prefix + "/exchangeNumNftOrder", param, function (res) {
            });

            // alert("uid =" + uid + " skuId=" + skuId + " nftNum=" + nftNum)
        }
    }

</script>
</body>
</html>
