<!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('首页排版')" />
    <style>
        .home_page {
            display: flex;
            justify-content: center;
            padding: 20px;
        }
        .left_content, .right_content {
            font-size: 16px;
            font-weight: 600;
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        .left_title, .right_title {
            margin-bottom: 12px;
        }
        .function_area {
            position: relative;
        }
        .function_area .banner {
            position: absolute;
            width: 373px;
            height: 244px;
            background: rgba(0,0,0,0);
            left: 1px;
            top: 104px;
            cursor: pointer;
        }
        
        .banner span, .searchAreaModeSp {
            /* display: inline-block; */
            position: relative;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            text-align: center;
            line-height: 18px;
            border: 2px solid yellowgreen;
            right: -358px;
            top: -10px;
            color: yellowgreen;
            cursor: pointer;
            display: none;
        }
        .huDongBanner {
            height: 160px;
            position: absolute;
            width: 373px;
            background: rgba(0,0,0,0);
            cursor: pointer;
        }
        .moFang span, .jinGangWei span, .huDongBanner span {
            /* display: inline-block; */
            position: relative;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            text-align: center;
            line-height: 18px;
            border: 2px solid yellowgreen;
            right: -358px;
            top: -10px;
            color: yellowgreen;
            cursor: pointer;
            display: none;
        }
        .function_area .moFang {
            position: absolute;
            width: 373px;
            height: 450px;
            background: rgba(0,0,0,0);
            left: 1px;
            cursor: pointer;
        }
        .function_area .jinGangWei {
            position: absolute;
            width: 373px;
            height: 250px;
            background: rgba(0,0,0,0);
            left: 1px;
            cursor: pointer;
        }
        .banner:hover,.searchAreaMode:hover,.moFang:hover,.jinGangWei:hover,.huDongBanner:hover {
            border-radius: 8px;
            border: 2px dashed yellowgreen;
        }
        .banner:hover .bannerSp,.searchAreaMode:hover .searchAreaModeSp, .moFang:hover .mofangSp, .jinGangWei:hover .jinGangWeiSp, .huDongBanner:hover .huDongBannerSp {
            display: inline-block;
        }
        .searchAreaMode {
            position: absolute;
            width: 373px;
            height: 46px;
            background: rgba(0,0,0,0);
            left: 1px;
            top: 56px;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div class="home_page">
        <div class="left_content">
            <div class="left_title">
                营销组件
            </div>
            <div class="function_btn">
                <button type="button" class="btn btn-primary" onclick="goArea(1)">金刚位</button>
                <button type="button" class="btn btn-warning" onclick="goArea(2)">活动banner</button>
                <button type="button" class="btn btn-info" onclick="goArea(3)">限时秒杀</button>
                <button type="button" class="btn btn-success" onclick="goArea(4)">魔方</button>
                <button type="button" class="btn" onclick="goArea(7)">精选商品</button>
            </div>
            <button type="button" class="btn" onclick="git()">上线</button>
        </div>
        <div class="right_content">
            <div class="right_title">
                选择区域
            </div>
            <div class="function_area" style="position: relative;">
                <div class="searchAreaMode" onclick="goArea(5)">
                    <!-- <span class="searchAreaModeSp" onclick="delSearchAreaModeSpp()">X</span> -->
                </div>
                <div class="banner" onclick="goArea(6)">
                    <!-- <span class="bannerSp" onclick="delbannerSp()">X</span> -->
                </div>
                <div class="moFang" onclick="goArea(4)">
                    <span class="mofangSp" onclick="delSp()">X</span>
                </div>
                <div class="jinGangWei" onclick="goArea(1)">
                    <span class="jinGangWeiSp" onclick="delSp(1)">X</span>
                </div>
                <div class="huDongBanner" onclick="goArea(2)">
                    <span class="huDongBannerSp" onclick="delSp(2)">X</span>
                </div>
                <iframe src="http://172.16.3.82:8080/#/goods/home?place=admin" width="375" height="1190" frameborder="0"></iframe>
            </div>
            
        </div>
    </div>
    <th:block th:include="include :: footer"/>
    <script th:inline="javascript">
        var prefix2 = ctx + "local";
        $(function() {
            modalPx()
        })
        function goArea (num) {
            switch(num) {
                case 1:
                    $.modal.openTab('金刚位', prefix2 + "/kingArea?id=" + 1212)
                    break;
                case 5:
                    $.modal.openTab('商品搜索', prefix2 + "/searchStore?id=" + 1212)
                    break;
                case 6:
                    $.modal.openTab('顶部banner', prefix2 + "/topBanner?id=" + num)
                    break;
                case 2:
                    $.modal.openTab('活动banner', prefix2 + "/topBanner?id=" + num)
                    break;
                case 4:
                    $.modal.openTab('魔方位', prefix2 + "/RubikArea?id=" + num)
                    break;
                case 7:
                    $.modal.openTab('精选商品', prefix2 + "/carefullyGoods?id=" + num)
                    break;
            }
        }
        function delSp (num) {
            console.log($('.goods-banner-props'), '有吗')
            let arr = [
                {"mid":2,"moudleIndexId":"708754120962334729770775","moudleName":"jinGangWei","indexs":2,"updateTime":"2022-01-11 17:40:03","createTime":"2022-01-06 13:53:45","delTag":0,"status":0},
                {"mid":1,"moudleIndexId":"708753099180072962244503","moudleName":"huDongBanner","indexs":1,"updateTime":"2022-01-06 13:52:22","createTime":"2022-01-06 13:52:19","delTag":0,"status":0},
                {"mid":3,"moudleIndexId":"708754120962334729770777","moudleName":"xianShiMiaoSha","indexs":3,"updateTime":"2022-01-06 13:55:04","createTime":"2022-01-06 13:55:07","delTag":0,"status":0},
                {"mid":4,"moudleIndexId":"708754120962334729772770","moudleName":"moFang","indexs":3,"updateTime":"2022-01-14 13:32:40","createTime":"2022-01-06 13:55:34","delTag":0,"status":0}
            ]
            arr[num-1].delTag = 1;
            $.ajax({
                type: 'post',
                url: '/front-index/update',
                data: JSON.stringify(arr[num-1]),
                success:function (res) {
                    console.log(res, 'res')
                }
            })
        }
        function git () {
            $.ajax({
                type: 'post',
                url: '/frontBanner/online',
                success:function(res) {
                    console.log(res)
                    if (res.code == 0) {
                        layer.msg('上线成功！')
                    }
                }
            })
        }
        function modalPx(params) {
            $.ajax({
                type: 'post',
                url: '/front-index/list',
                success: function (res) {
                    console.log(res, 'resp')
                    let {data} = res;
                    let firstHeight = '';
                    let secondHeight = '';
                    let datas = []
                    data.map(item => {
                        if (item.moudleIndexId != "708754120962334729770777") {
                            datas.push({...item})
                        }
                    })
                    console.log(datas, '??')
                    datas.forEach((item,index)=>{
                        if (item.delTag) {
                            $('.'+item.moudleName+'').hide()
                        }
                        if (index == 0) {
                            $('.'+item.moudleName+'').css('top', 341)
                            if (item.moudleName == "huDongBanner") {
                                firstHeight = 501;
                            } else if (item.moudleName == "jinGangWei") {
                                firstHeight = 591;
                            } else if (item.moudleName == "moFang") {
                                firstHeight = 791;
                            }
                        } else if (index == 1) {
                            $('.'+item.moudleName+'').css('top', firstHeight)
                            console.log($('.'+item.moudleName+''),firstHeight)
                            if (item.moudleName == "huDongBanner") {
                                secondHeight = firstHeight+160;
                            } else if (item.moudleName == "jinGangWei") {
                                secondHeight = firstHeight+250;
                            } else if (item.moudleName == "moFang") {
                                secondHeight = firstHeight+450;
                            }
                        } else {
                            $('.'+item.moudleName+'').css('top', secondHeight)
                        }
                    })
                }
            })
        }
    </script>
</body>
</html>