<style>
    .link-box{font-size:12px}
    .link-box .link-center{display:flex;height:480px}
    .link-box .link-left{overflow-y:auto;width:138px;height:100%;border-right:1px solid #f2f2f2}
    .link-box .link-left dt{position:relative;padding-left:15px;height:32px;line-height:32px;color:#333;cursor:pointer;transition:all .3s}
    .link-box .link-left dt.triangle:after{content:'';position:absolute;left:0;top:51%;transform:translateY(-50%);border:4px solid transparent;border-right-color:#333;border-bottom-color:#333;cursor:pointer}
    .link-box .link-left dt.active:after{transform:translateY(-50%) rotate(-45deg)}
    .link-box .link-left dd{margin-right:25px;padding-left:25px;height:32px;line-height:32px;color:#666;cursor:pointer}
    .link-box .link-left dd:hover{background-color:#f2f2f2}
    .link-box .link-right{overflow-y:auto;height:100%;flex:1;padding-left:20px}
    .link-box .link-right dl{overflow:hidden}
    .link-box .link-right dt{height:40px;line-height:40px}
    .link-box .link-right dd{float:left;margin:5px 5px 5px 0;padding:0 16px;border:1px solid #ededed;border-radius:3px;line-height:30px;color:#666;cursor:pointer}
    .link-box .link-right .layui-table-body{height:350px}
    .link-btn{margin-top:20px;padding-right:10px;height:45px;line-height:45px;text-align:right;border-top:1px solid #f2f2f2}
    .link-box .custom-link{width:420px;margin:50px}
    .link-box .ns-word-aux{width:250px}
    .link-box .other-applet{width:450px;margin:50px}
    .link-box .layui-form-label{width: 150px;padding: 0 10px 0 0;line-height: 34px;height: 34px;}
    .link-box .layui-table td, .layui-table th {position: relative;}
    .ns-title-pic img {
        width: 50px;
        height: 50px;
    }
    .ns-table-title {
        display: flex;
        align-items: center;
    }
    .ns-table-title .ns-title-pic {
        flex-shrink: 0;
        display: inline-block;
        width: 50px;
        height: 50px;
        text-align: center;
        line-height: 50px;
        margin-left: 5px;
    }
    .ns-table-title .ns-title-content {
        overflow: hidden;
        margin-left: 10px;
        flex: 1;
        line-height: 1.8;
    }
    .ns-multi-line-hiding {
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        white-space: normal;
        word-break: break-all;
        line-height: 22px !important;
        max-height: 42px !important;
    }
    .link-right .layui-table-view .layui-table[lay-size=lg] .layui-table-cell {
        height: 50px;
        line-height: 50px;
    }
</style>

<div class="link-box">
    <div class="link-center">
        <div class="link-left">
            <foreach name="list" item="item">
            <dl>
                <!-- style="<?php if($item['name']=='COMMODITY'){ echo 'display:none;'; } ?>" -->
                <dt data-ident="{$item.name}" <notempty name='item.child_list'>class="triangle"</notempty>>{$item.title}</dt>
                <foreach name="item.child_list" item="child_item" key="child_key">
                    <dd data-ident="{$child_item.name}" class="<?php if(!empty($link)&&isset($link['parents'])&&$child_item.name==$link['parents']){ ?>ns-text-color<?php } ?>">{$child_item.title}</dd>
                </foreach>
            </dl>
            </foreach>
        </div>
        <div class="link-right"></div>
    </div>
    <div class="link-btn">
        <button class="layui-btn link-eliminate layui-btn-primary">清空</button>
        <button class="layui-btn link-save ns-bg-color">确定</button>
    </div>
</div>

<script>
    var promotion,wap_url,goodsIdent,
        initMeun = $(".link-box .link-left dd:eq(0)").attr("data-ident"),
        customIdent = false, //自定义链接
        appletIdent = false, //外部小程序链接
        webviewIdent = false, //外部链接
        getLineData = {
            link : '{:html_entity_decode($link)}',
            support_diy_view : '',
        };

    var preoldlink = JSON.parse(getLineData.link);

    if(!preoldlink.parents){
        preoldlink = {};
        preoldlink.parents = initMeun;
    }

    initRequest();
    function initRequest(){
        if(preoldlink.parents == 'CUSTOM_LINK'){
            $(".link-left dl").eq(2).find('dt').addClass("ns-text-color");
            customLinkHtml();
            $(".link-box input[name='title']").val(preoldlink.title);
            $(".link-box input[name='wap_url']").val(preoldlink.wap_url);
            customIdent = true;
            return;
        }
        if(preoldlink.parents == 'OTHER_APPLET'){
            $(".link-left dl").eq(3).find('dt').addClass("ns-text-color");
            otherAppletHtml();
            $(".link-box input[name='appid']").val(preoldlink.appid);
            $(".link-box input[name='page']").val(preoldlink.page);
            appletIdent = true;
            return;
        }
        if(preoldlink.parents == 'WEBVIEW'){
            $(".link-left dl").eq(4).find('dt').addClass("ns-text-color");
            webviewHtml();
            $(".link-box input[name='wapurl']").val(preoldlink.wap_url);
            webviewIdent = true;
            return;
        }
        $categoryList = eval(<?php echo json_encode($list); ?>);
        var categoryList=$categoryList;
        for(var i=0;i<categoryList.length;i++){
            var arr=categoryList[i].child_list;
            for(var j=0;j<arr.length;j++){
                if(arr[j].name == preoldlink.parents){
                    let documentPage= $(".link-left dl dt");
                    for(let z=0;z<documentPage.length;z++){
                        documentPage.eq(z).addClass("active");
                        $(documentPage.eq(z)).parent("dl").find("dd").addClass("layui-hide");
                    }
                    documentPage.eq(i).removeClass("active");
                    $(documentPage.eq(i)).parent("dl").find("dd").removeClass("layui-hide");
                    $(documentPage.eq(i)).parent("dl").find("dd").eq(j).addClass("ns-text-color");
                    let title = $(documentPage.eq(i)).parent("dl").find("dd").eq(j).attr("data-ident");
                    getLinkInfo(title);
                }
            }
        }
    }

    function getLinkInfo(name){
        getLineData.name = name;
        var lurl = "{:U('Shopdiy/childLink')}";
        if(name=='MALL_LINK') lurl = "{:U('Util/diygeturl')}";
        $.ajax({
            url : lurl,
            data: getLineData,
            dataType: 'json',
            type: 'post',
            success : function(data) {
                var list = data.list;
                var data_link = data.link;
                var html = '';
                if (list.length > 0){
                    for (var i = 0; i < list.length; i++){
                        html += `<dl>`;
                        html += `<dt>${list[i].title}</dt>`;
                        if (list[i].child_list != undefined) {
                            for (var j = 0; j < list[i].child_list.length; j++){
                                if (list[i].child_list[j].name == preoldlink.name || list[i].child_list[j].name == data_link.name)
                                    html += `<dd data-value='${JSON.stringify(list[i].child_list[j])}' class="ns-border-color" data-old-value='${JSON.stringify(data_link)}'>${list[i].child_list[j].title}</dd>`;
                                else
                                    html += `<dd data-value='${JSON.stringify(list[i].child_list[j])}'>${list[i].child_list[j].title}</dd>`;
                            }
                        }
                        html += `</dl>`
                    }
                }else{
                    if (name.indexOf('_GOODS') != -1) {
                        html += `<table id="goods_list" lay-filter="goods_list"></table>`;
                    } else if (name.indexOf('_GAME') != -1) {
                        html += `<table id="game_list" lay-filter="game_list"></table>`;
                    } else if(name.indexOf('_CATEGORY') != -1){
                        html += `<div id="category_list" lay-filter="category_list"></div>`;
                    }

                }
                $(".link-right").html(html);
                if (!list.length){
                    if (name.indexOf('_GOODS') != -1) {
                        getGoodsInfo(name);
                    } else if(name.indexOf('_CATEGORY') != -1){
                        getCategory(name);
                    }
                }
            }
        });
    }

    function getGoodsInfo(name){
        var goodsCols,table;
        if (name == 'ALL_GOODS'){
            promotion = 'normal';
            wap_url = '/lionfish_comshop/pages/goods/goodsDetail?id=';

            goodsCols = [
                [
                    {
                        unresize: 'false',
                        width: '8%',
                        templet: '#checkbox'
                    },
                    {
                        title: '商品',
                        unresize: 'false',
                        width: '62%',
                        templet: '#goods_info'
                    },
                    {
                        field: 'productprice',
                        title: '价格',
                        unresize: 'false',
                        width: '15%'
                    },
                    {
                        field: 'total',
                        title: '库存',
                        unresize: 'false',
                        width: '15%'
                    }
                ]
            ];
        }else if(name == "PINTUAN_GOODS"){
            promotion = 'pintuan';
            wap_url = '/lionfish_comshop/moduleA/pin/goodsDetail?id=';

            goodsCols = [
                [{
                    unresize: 'false',
                    width: '8%',
                    templet: '#checkbox'
                },{
                    title: '拼团商品',
                    unresize: 'false',
                    width: '62%',
                    templet: function (data) {
                        var html = '';
                        html += `<div class="ns-table-title">`;
                            html += `<div class="ns-title-pic" id="goods_img_{{data.id}}">`;
                                html += `<img layer-src src="{{data.sku_image.split(',')[0]}}"/>`;
                            html += `</div>`;
                            html += `<div class="ns-title-content">`;
                                html += `<a href="javascript:;" class="ns-multi-line-hiding ns-text-color" title="${data.sku_name}">${data.sku_name}</a>`;
                            html += `</div>`;
                        html += `</div>`;

                        return html;
                    }
                },{
                    field: 'pintuan_price',
                    title: '价格',
                    unresize: 'false',
                    width: '15%'
                },{
                    field: 'goods_stock',
                    title: '库存',
                    unresize: 'false',
                    width: '15%'
                }]
            ];
        }else if(name == "PRESALE_GOODS"){
            promotion = 'presale';
            wap_url = '/lionfish_comshop/pages/goods/goodsDetail?type=presale&id=';

            goodsCols = [
                [{
                    unresize: 'false',
                    width: '8%',
                    templet: '#checkbox'
                },{
                    title: '预售商品',
                    unresize: 'false',
                    width: '62%',
                    templet: '#goods_info'
                },{
                    field: 'price',
                    title: '价格',
                    unresize: 'false',
                    width: '15%'
                },
                {
                    field: 'goods_stock',
                    title: '库存',
                    unresize: 'false',
                    width: '15%'
                }]
            ]
        }
        goodsIdent = name;
        initMeun = name;

        table = new Table({
            elem: '#goods_list',
            url: '{:U("Shopdiy/goodsselect")}',
            where: {promotion},
            cols: goodsCols
        });
    }

    function getCategory(name){
        var addon_url = '';
        wap_url = '/lionfish_comshop/pages/type/index?id=';
        initMeun = name;

        layui.use(['laytpl', 'form'], function(){
            var laytpl = layui.laytpl;
            var form = layui.form;
            laytpl($("#category_html").html()).render([], function(html) {
                $("#category_list").html(html);
                //展开收齐点击事件
                $(".js-switch").click(function () {
                    var category_id = $(this).attr("data-category-id");
                    console.log('category_id', category_id);
                    var level = $(this).attr("data-level");
                    var open = parseInt($(this).attr("data-open").toString());

                    if(open){
                        $(".goods-category-list .layui-table tr[data-category-id-"+ level+"='" + category_id + "']").hide();
                        $(this).text("+");
                    }else{
                        $(".goods-category-list .layui-table tr[data-category-id-"+ level+"='" + category_id + "']").show();
                        $(this).text("-");
                    }
                    $(this).attr("data-open", (open ? 0 : 1));
                });

                console.log($("input[name='category_select_id']:checked").length);
                if ($("input[name='category_select_id']:checked").length > 0){
                    var category_id_1 = $("input[name='category_select_id']:checked").parents('.category-line').attr('data-category-id-1');
                    var category_id_2 = $("input[name='category_select_id']:checked").parents('.category-line').attr('data-category-id-2');
                    console.log(category_id_1,category_id_2);
                    if(category_id_1 > 0){
                        $('tr[data-category-id-1='+category_id_1+']').show();
                    }
                    if(category_id_2 > 0){
                        $('tr[data-category-id-2='+category_id_2+']').show();
                    }
                }
                // 勾选分类
                form.on('checkbox(category_select_id)', function(data) {
                    if (data.elem.checked){
                        $("input[name='category_select_id']:checked").prop("checked",false);
                        $(data.elem).prop("checked",true);
                        form.render();
                    }
                });
                form.render();
            });
        });
    }

    //自定义链接
    $("dt[data-ident='CUSTOM_LINK']").click(function(){
        customLinkHtml();
        customIdent = true;
        appletIdent = false;
        webviewIdent = false;
        if (preoldlink.name == 'CUSTOM_LINK') {
            $(".link-box input[name='title']").val(preoldlink.title);
            $(".link-box input[name='wap_url']").val(preoldlink.wap_url);
        }
    });

    function customLinkHtml(){
        var html = '';
        html += '<div class="layui-form custom-link">';
        html += '<div class="layui-form-item">';
        html += '<label class="layui-form-label sm"><span class="required">*</span>链接名称</label>';
        html += '<div class="layui-input-inline">';
        html += '<input type="text" name="title" class="layui-input ns-len-mid" required>';
        html += '</div>';
        html += '</div>';
        html += '<div class="layui-form-item">';
        html += '<label class="layui-form-label sm"><span class="required">*</span>跳转路径</label>';
        html += '<div class="layui-input-block">';
        html += '<input type="text" name="wap_url" class="layui-input ns-len-mid">';
        html += '</div>';
        html += '<div class="ns-word-aux mid">路径必须以“/”开头，例：“/lionfish_comshop/pages/index/index”</div>';
        html += '</div>';
        html += '</div>';
        $(".link-right").html(html);
    }

    // 跳转小程序
    $("dt[data-ident='OTHER_APPLET']").click(function(){
        otherAppletHtml();
        customIdent = false;
        webviewIdent = false;
        appletIdent = true;
        if (preoldlink.name == 'OTHER_APPLET') {
            $(".link-box input[name='appid']").val(preoldlink.appid);
            $(".link-box input[name='page']").val(preoldlink.page);
        }
    });

    function otherAppletHtml(){
        var html = '';
        html += '<div class="layui-form other-applet">';
        html += '<div class="layui-form-item">';
        html += '<label class="layui-form-label mid"><span class="required">*</span>小程序AppID</label>';
        html += '<div class="layui-input-inline">';
        html += '<input type="text" name="appid" class="layui-input ns-len-mid" required placeholder="请输入要打开的小程序的appid">';
        html += '</div>';
        html += '</div>';
        html += '<div class="layui-form-item">';
        html += '<label class="layui-form-label mid">小程序路径</label>';
        html += '<div class="layui-input-block" style="margin-left: 150px;">';
        html += '<input type="text" name="page" class="layui-input ns-len-mid" placeholder="请输入要打开的小程序路径">';
        html += '</div>';
        html += '<div class="ns-word-aux mid" style="width: auto">仅支持小程序之间的跳转，不支持从其他渠道跳转小程序</div>';
        html += '<div class="ns-word-aux mid" style="width: auto">小程序路径如果为空则跳转到小程序首页</div>';
        html += '<div class="ns-word-aux mid" style="width: auto">小程序路径格式如：page/index/index/index</div>';
        html += '</div>';
        html += '</div>';
        $(".link-right").html(html);
    }

    // 跳转外部链接
    $("dt[data-ident='WEBVIEW']").click(function(){
        webviewHtml();
        customIdent = false;
        appletIdent = false;
        webviewIdent = true;
        if (preoldlink.name == 'WEBVIEW') {
            $(".link-box input[name='wapurl']").val(preoldlink.wapurl);
        }
    });

    function webviewHtml(){
        var html = '';
        html += '<div class="layui-form webview">';
        html += '<div class="layui-form-item">';
        html += '<label class="layui-form-label mid"><span class="required">*</span>外部链接</label>';
        html += '<div class="layui-input-block" style="margin-left: 150px;">';
        html += '<input type="text" name="wapurl" class="layui-input ns-len-mid" required placeholder="请输入要打开的外部链接">';
        html += '</div>';
        html += '<div class="ns-word-aux mid" style="width: auto">请使用http或https链接</div>';
        html += '<div class="ns-word-aux mid" style="width: auto">在<a href="https://mp.weixin.qq.com" class="ns-text-color" target="_blank">mp.weixin.qq.com</a>开发-开发设置-业务域名添加此域名</div>';
        html += '</div>';
        html += '</div>';
        $(".link-right").html(html);
    }

    $("body").off('click').on("click", ".link-box .link-left dd", function () {
        customIdent = false;
        appletIdent = false;
        webviewIdent = false;
        if (!$(this).hasClass("ns-text-color")){
            $(".link-box .link-left dd,.link-box .link-left dt").removeClass("ns-text-color");
            $(this).addClass("ns-text-color");
        }
        initMeun = $(this).attr("data-ident");
        getLinkInfo(initMeun);
    });

    $(".link-box .link-left dt").click(function () {
        if (!$(this).hasClass("active")){
            $(this).addClass("active");
            $(this).parent("dl").find("dd").addClass("layui-hide");
        }else{
            $(this).removeClass("active");
            $(this).parent("dl").find("dd").removeClass("layui-hide");
        }

        if ($(this).parent("dl").find("dd").length == 0) {
            $(".link-box .link-left dd,.link-box .link-left dt").removeClass("ns-text-color");
            $(this).addClass("ns-text-color");
        }
    });

    // 选择链接
    $("body").on("click", ".link-box .link-right dd", function () {
        $(".link-box .link-right dd").removeClass("ns-border-color");
        if (!$(this).hasClass("ns-border-color")) $(this).addClass("ns-border-color");
    });

    //清空
    $(".link-btn .link-eliminate").click(function () {
        $(".link-box input[name='title']").val('');
        $(".link-box input[name='wap_url']").val('');

        $(".link-box .link-right dd").removeClass("ns-border-color");

        $(".link-box input[type='checkbox']:checked").prop('checked',false);
        $(".link-box .layui-unselect.layui-form-checkbox").removeClass("layui-form-checked");

        var obj = {"title":"","wap_url":'',"name":''};
        window.linkData = obj;
        window.linkData.parents = '';

        layer.close(window.linkIndex);
    });

    // 保存
    $(".link-box .link-save").click(function(){
        var value,old_value;
        var dd = $(".link-box .link-right dd.ns-border-color").eq(0);

        /* 商城页面链接保存 */
        if(dd.length){
            value = dd.attr("data-value");
            old_value = dd.attr("data-old-value");

            if(old_value) value = old_value;
            initMeun = $(".link-box .link-left dd.ns-text-color").attr('data-ident');
        }

        /* 商品链接保存 */
        if ($("input[name='goods_checkbox']:checked").length){
            var goodsId = $("input[name='goods_checkbox']:checked").eq(0).attr("data-goods-id");
            value = $("input[name='goods_json'][data-goods-id = "+ goodsId +"]").val();
            old_value = $("input[name='old_goods_json'][data-goods-id = "+ goodsId +"]").val();

            console.log(value)
            if(old_value) value = old_value.toString();
            value = JSON.parse(value);
            if (!value.wap_url){
                var nn =value.id;
                value.wap_url = wap_url + value.id;
                value.title = value.title;
                value.name = "";
            }
            value = JSON.stringify(value);
        }

        // 商品分类
        if ($("input[name='category_select_id']:checked").length){
            var category_select_id = $("input[name='category_select_id']:checked").attr('data-category_select_id');
            value = $("input[name='category_select_id']:checked").val();
            value = JSON.parse(value);

            if (!value.wap_url){
                value.wap_url = wap_url+value.id;
                value.title = value.name;
                value.selected = true;
                value.name = "";
            }
            value = JSON.stringify(value);
        }

        //自定义链接
        if(customIdent){
            value = {};
            if (!$(".custom-link input[name='title']").val()){
                layer.msg("链接名称不能为空");
                return false;
            }

            if (!$(".custom-link input[name='wap_url']").val()){
                layer.msg("跳转路径不能为空");
                return false;
            }

            value.title = $(".custom-link input[name='title']").val();
            value.wap_url = $(".custom-link input[name='wap_url']").val();
            value.id = -999;
            value.addon_icon = "";
            value.addon_name = "CustomLink";
            value.addon_title = "自定义链接";
            value.icon = "";
            value.name = "CUSTOM_LINK";
            value.type = 0;

            window.linkData = value;
            window.linkData.parents = 'CUSTOM_LINK';
        }

        if(appletIdent){
            value = {};
            if (!$(".other-applet input[name='appid']").val()){
                layer.msg("跳转小程序appid不能为空");
                return false;
            }

            value.wap_url = '';
            value.appid = $(".other-applet input[name='appid']").val();
            value.page = $(".other-applet input[name='page']").val();
            value.title = '小程序-' + value.appid;
            value.id = -999;
            value.addon_icon = "";
            value.addon_name = "ToApplet";
            value.addon_title = "跳转小程序";
            value.icon = "";
            value.name = "OTHER_APPLET";
            value.type = 0;

            window.linkData = value;
            window.linkData.parents = 'OTHER_APPLET';
        }

        if(webviewIdent){
            value = {};
            if (!$(".webview input[name='wapurl']").val()){
                layer.msg("跳转链接不能为空");
                return false;
            }

            value.wap_url = $(".webview input[name='wapurl']").val();
            value.appid = '';
            value.page = '';
            value.title = '外链-' + value.wap_url;
            value.id = -999;
            value.addon_icon = "";
            value.addon_name = "Webview";
            value.addon_title = "webview跳转";
            value.icon = "";
            value.name = "WEBVIEW";
            value.type = 0;

            window.linkData = value;
            window.linkData.parents = 'WEBVIEW';
        }

        if(value && !customIdent && !appletIdent && !webviewIdent) {
            value = JSON.parse(value);
            window.linkData = value;
            window.linkData.parents = initMeun;
        }

        layer.close(window.linkIndex);
    });
</script>


<!-- 分类列表 -->
<style>
    .goods-category-list .layui-table td {
        border-left: 0;
        border-right: 0;
    }
    .goods-category-list .layui-table .switchBtn {
        font-size: 16px;
        cursor: pointer;
        width: 12px;
        line-height: 1;
        display: inline-block;
        text-align: center;
        vertical-align: middle;
    }
    .goods-category-list .layui-table img {width: 40px;}
</style>

<script type="text/html" id="category_html">
    <div class="goods-category-list layui-form">
        <table class="layui-table ns-pithy-table">
            <colgroup>
                <col width="5%">
                <col width="6%">
                <col width="59%">
                <col width="30%">
            </colgroup>
            <thead>
            <tr>
                <th></th>
                <th></th>
                <th>分类名称</th>
                <th>图片</th>
            </tr>
            </thead>
            <tbody>
            <if condition="category_list">
                <foreach name="category_list" item="vo">
                    <tr class='category-line'>
                        <td>
                            <input type="checkbox" name="category_select_id" data-category_select_id="{$vo['id']}" lay-skin="primary" value='{:json_encode($vo)}' lay-filter="category_select_id" <?php if(!empty($link_array['id']) && $link_array['id'] == $vo['id']){ ?>checked<?php } ?>>
                        </td>
                        <td>
                            <notempty name="vo.child_list">
                            <span class="switchBtn ns-text-color js-switch" data-category-id="{$vo['id']}" data-level="{$vo['level']}" data-open="0">+</span>
                            </notempty>
                        </td>
                        <td>{$vo['name']}</td>
                        <td>
                            <notempty name="vo.logo">
                            <div class="ns-img-box">
                                <img layer-src src="{$vo['logo']}"/>
                            </div>
                            </notempty>
                        </td>
                    </tr>

                    <notempty name="vo.child_list">
                        <foreach name="vo.child_list" item="second">
                            <tr class='category-line' data-category-id-1="{$second['category_id_1']}" style="display:none;">
                                <td><input type="checkbox" name="category_select_id" lay-skin="primary"data-category_select_id="{$second['id']}" value='{:json_encode($second)}' lay-filter="category_select_id" <?php if(!empty($link_array['id'])&&$link_array['id']==$second['id']) { ?>checked<?php } ?>></td>
                                <td></td>
                                <td style="padding-left: 20px;">
                                    <span class="switchBtn ns-text-color js-switch" data-category-id="{$second['id']}" data-level="{$second['level']}" data-open="1" style="padding-right: 20px;">-</span>
                                    <span>{$second['name']}</span>
                                </td>
                                <td>
                                    <notempty name="second.logo">
                                    <img layer-src src="{$second.logo)}"/>
                                    </notempty>
                                </td>
                            </tr>

                            <notempty name="second.child_list">
                                <foreach name="second.child_list" item="third">
                                    <tr class='category-line'data-category-id-1="{$vo['category_id_1']}" data-category-id-2="{$third['category_id_2']}" style="display:none;">
                                        <td><input type="checkbox" name="category_select_id" lay-skin="primary" value='{:json_encode($third)}' data-category_select_id='{$third.id}' lay-filter="category_select_id" <?php if(!empty($link_array['id'])&&$link_array['id'] == $third['id']) { ?>checked<?php } ?>></td>
                                        <td></td>
                                        <td style="padding-left: 80px;">
                                            <span>{$third['name']}</span>
                                        </td>
                                        <td>
                                            <notempty name="third.logo">
                                            <img layer-src src="{$third['logo']}"/>
                                            </notempty>
                                        </td>
                                    </tr>
                                </foreach>
                            </notempty>
                        </foreach>
                    </notempty>
                </foreach>
            <else/>
                <tr>
                    <td colspan="9" style="text-align: center">无数据</td>
                </tr>
            </if>
            </tbody>
        </table>
    </div>
</script>

<script type="text/html" id="checkbox">
    {{# if(d.selected){ }}
    <input type="checkbox" data-goods-id="{{d.id}}" name="goods_checkbox" lay-skin="primary" lay-filter="goods_checkbox" checked>
    <input type="hidden" data-goods-id="{{d.id}}" name="old_goods_json" value='{:html_entity_decode($link)}' />
    {{# }else{ }}
    <input type="checkbox" data-goods-id="{{d.id}}" name="goods_checkbox" lay-skin="primary" lay-filter="goods_checkbox">
    {{# } }}
    <input type="hidden" data-goods-id="{{d.id}}" name="goods_json" value='{{ JSON.stringify(d) }}' />
</script>

<!-- 商品信息 -->
<script type="text/html" id="goods_info">
    <div class="ns-table-title">
        <div class="ns-title-pic" id="goods_img_{{d.id}}">
            <img layer-src src="{{d.image}}"/>
        </div>
        <div class="ns-title-content">
            <a href="javascript:;" class="ns-multi-line-hiding ns-text-color" title="{{d.title}}">{{d.title}}</a>
        </div>
    </div>
</script>