<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('顶部banner')" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
    <style>
        .home_page {
            display: flex;
            justify-content: center;
            padding: 20px;
        }
        .right_content {
            font-size: 16px;
            font-weight: 600;
            display: flex;
            flex-direction: column;
            align-items: center;
            width: 50%;
        }
        .left_content {
            flex: 1;
        }
        .left_title, .right_title {
            margin-bottom: 12px;
        }
        .function_btn, .first_content {
            display: flex;
            align-items: center;
            margin-bottom: 12px;
        }
        .function_btn .hot_title {
            font-size: 16px;
            font-weight: 600;
        }
        .function_btn .tags {
            display: flex;
            align-items: center;
        }
        .function_btn .tags_content {
            display: flex;
            flex-direction: column;
        }
        label {
            margin: 0;
            display: flex;
            align-items: center;
        }
        .function_btn .tags label input {
            margin: 0 4px 0 12px;
        }
        .function_btn .tags .tag {
            padding: 6px 12px 4px;
            border: 1px solid #ccc;
            border-radius: 5px;
            position: relative;
            margin-right: 12px;
        }
        .function_btn .tags .tag span {
            display: inline-block;
            position: absolute;
            top: -8px;
            right: -8px;
            width: 18px;
            height: 18px;
            line-height: 16px;
            border: 1px solid #aaa;
            border-radius: 50%;
            background: #fff;
            text-align: center;
            cursor: pointer;
        }
        .banner_list {
            display: flex;
            flex-direction: column;
            width: 100%;
        }
        .banner_item, .items {
            border: 1px dashed #ccc;
            border-radius: 10px;
            padding: 12px;
            margin-bottom: 20px;
        }
        .img_show, .set_method, .set_function {
            display: flex;
        }
        .title {
            font-size: 16px;
            font-weight: 600;
            width: 80px;
            text-align: right;
        }
        .kv-upload-progress {
            display: none !important;
        }
        .ibox-content .imgBox {
            width: 350px;
            max-height: 180px;
        }
        .jump, .ticket_name, .set_function_time {
            display: flex;
            flex-grow: 1;
            align-items: center;
        }
        .iptOrSelect {
            flex: 1;
        }
        .img_box {
            display: flex;
            flex-direction: column;
        }
    </style>
</head>
<body>
    <div class="home_page">
        <div class="left_content">
            <div class="left_title">
                
            </div>
            <div class="function_btn">
                <div class="hot_title">
                    展示形式：
                </div>
                <div class="tags">
                    <label>
                        <input type="radio" checked value="1" id="optionsRadios1" name="optionsRadios"><span>一行一个</span></label>
                    <label>
                        <input type="radio" value="2" id="optionsRadios1" name="optionsRadios"><span>一行两个</span></label>
                    <label>
                        <input type="radio" value="3" id="optionsRadios1" name="optionsRadios"><span>一行三个</span></label>
                    <label>
                        <input type="radio" value="4" id="optionsRadios1" name="optionsRadios"><span>上一下三</span></label>
                </div>
            </div>
            <div class="function_btn">
                <div id="bannerList" class="banner_list">
                    
                </div>
            </div>
            <div class="footer_btn">
                <button type="button" class="btn btn-success" onclick="save()">保存</button>
            </div>
        </div>
        <div class="right_content">
            <div class="right_title">
                
            </div>
            <div class="function_area">
                <iframe src="http://172.16.2.214:8080/#/goods/home?place=admin" width="375" height="896" frameborder="0"></iframe>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer"/>
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <th:block th:include="include :: bootstrap-suggest-js" />
    <script th:inline="javascript">
        var prefix2 = ctx + "local";
        var platformUrl = [[${platformUrl}]];
        let num = 1;
        $(function() {
            addItem (1);
        })
        $("input[name=optionsRadios]").change(function(e){
            $("#bannerList").empty();
            let num = e.target.value;
            addItem (num);
        })
        function addItem (num) {
            console.log(num, '221212')
            let str = '';
            for (var i = 0; i < num; i++) {
                str = `<div class="items">
                        <div class="first_content">
                            <div class="hot_title">
                                页面属性：
                            </div>
                            <div class="tags">
                                <label>
                                    <input type="radio" checked value="1" id="pageAttribute${i}" name="pageAttribute${i}"><span>单商品</span></label>
                                <label>
                                    <input type="radio" value="2" id="pageAttribute${i}" name="pageAttribute${i}"><span>合集</span></label>
                            </div>
                        </div>
                        <div class="first_content" style="align-items: flex-start;">
                            <div class="hot_title">
                                选择商品：
                            </div>
                            <div class="tags_content" style="width: 553px;">
                                <div class="input-group">
                                    <input id="goodsName${i}" type="text" class="form-control storeList" placeholder="搜索商品名称">
                                    <div class="input-group-btn">
                                        <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                        </ul>
                                    </div>
                                </div>
                                <div class="img_box">
                                    <img id="goodsImg${i}" src="https://img.zhengzai.tv/banner/2022/01/06/d4e7ef3aeabb4151a3a8dd9ab7a272a8.png" alt="" style="max-height: 180px;max-width:180px;margin: 12px 0;">
                                    <p id="goodsTitle${i}" style="width:180px;">2021草莓音乐节主页（RE）连帽卫衣</p>
                                    <p id="goodsPrice${i}">￥99</p>
                                </div>
                                <button id="del${i}" type="button" class="btn btn-danger" style="width: 60px;" onclick="del('${i}')">删除</button>
                            </div>
                        </div>
                        <div class="first_content" style="align-items: flex-start;">
                            <div class="hot_title">
                                推荐文案：
                            </div>
                            <div class="tags">
                                <textarea id="text${i}" class="form-control" name="" id="" style="width: 553px;height: 150px;"></textarea>
                            </div>
                        </div>
                    </div>`
                $("#bannerList").append(str);
                common(i)
            }
        }
        function save () {
            refreshItem()
        }
        function del (num) {
            console.log(num)
            $('#goodsImg'+num+'').attr('src', '');
            $('#goodsTitle'+num+'').html('');
            $('#goodsPrice'+num+'').html('');
            $('#del'+num+'').hide();
            console.log(11)
        }
        function common (num) {
            $(".storeList").bsSuggest({
                allowNoKeyword: false, //是否允许无关键字时请求数据
                showBtn:false,
                multiWord: true, //以分隔符号分割的多关键字支持
                hideOnSelect: true,
                getDataMethod: "url", //获取数据的方式，总是从 URL 获取
                url: ctx+'kylin/base/performance/status?status=(3,6)&title=',
                /*如果从 url 获取数据，并且需要跨域，则该参数必须设置*/
                processData: function (json) { // url 获取数据时，对数据的处理，作为 getData 的回调函数
                    //字符串转化为 js 对象
                    return json;
                }
            }).on('onDataRequestSuccess', function (e, result) {
	            console.log('onDataRequestSuccess: ',e, result);
            }).on('onSetSelectValue', function (e, selectedData,selectedRawData ) { // 当前行的所有值都能拿到
                console.log('211: ',  e.target.value, selectedData, selectedRawData);
            }).on('onUnsetSelectValue', function (e) {
                console.log("onUnsetSelectValue", e);
            });;
        }
    </script>
</body>
</html>