<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改演出')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-qrcode-add">
        <div class="form-group" style="display: none">
            <label class="col-sm-3 control-label is-required">mid：</label>
            <div class="col-sm-8">
                <input name="mid" class="form-control" type="text" required readonly>
            </div>
        </div>
        <div class="form-group" style="display: none">
            <label class="col-sm-3 control-label is-required">type：</label>
            <div class="col-sm-8">
                <input name="type" th:value="${type}" class="form-control" type="text" required readonly>
            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-8">
                <input id="fileinput10" type="file">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">图片地址：</label>
            <div class="col-sm-8">
                <input id="iptUrl" name="url" class="form-control" type="text" required readonly>
            </div>
        </div>
    </form>

    <div class="cover_pop" style="display: none">
        <div class="pop_inner">
            <div class="wrapper wrapper-content animated fadeInRight ibox-content">
                <div class="file-loading">
                    <input id="fileinput-demo-1" type="file" name="file" data-browse-on-zone-click="true"
                           data-msg-placeholder="Select {files} for upload...">
                    <input hidden id="coverImg" name="coverImg">
                </div>
            </div>
            <div class="pop_btns">
                <div class="confirm_btn" onclick="popBtn(1)">确认</div>
                <div class="confirm_btn confirm_cancel" onclick="popBtn(0)">取消</div>
            </div>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: bootstrap-fileinput-js"/>
<script th:inline="javascript">
    var prefix = ctx + "sweet/active";
    var platformUrl = [[${platformUrl}]];
    $("#form-roadShow-edit").validate({
        focusCleanup: true
    });

    $("#fileinput10").change((e) => {
        if (!e.target.files[0]) {
            return
        }
        var formData = new FormData();
        formData.append("file", e.target.files[0]);
        $.ajax({
            url: platformUrl + "/platform/basicServices/alOss/upload",//路径是你控制器中上传图片的方法，下面controller里面我会写到
            data: formData,
            cache: false,
            contentType: false,
            processData: false,
            type: 'POST',
            success: function (res) {
                console.log(res, 'res')
                let imgPath = 'https://img.zhengzai.tv/' + res.data.ossPath;
                $("#iptUrl").val(imgPath);
            }
        });
    })

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/addQrCode", $('#form-qrcode-add').serialize());
        }
    }
</script>
</body>
</html>