This commit is contained in:
2025-09-19 14:13:56 +08:00
4 changed files with 28 additions and 8 deletions

View File

@@ -343,8 +343,18 @@ class TopicNas extends Common
->language($this->lang_id) ->language($this->lang_id)
->where('category_id', 'IN', array_column($categorys, 'id')) ->where('category_id', 'IN', array_column($categorys, 'id'))
->select(); ->select();
//查询上级id
$parent_two = ArticleCategoryModel::parentColumn(array_column($categorys, 'id'))->language($this->lang_id)->column('pid','id');//二级分类id
$articles_data = $articles->toArray();
foreach ($articles_data as &$v) {
$v['pid'] = 0;
if ( $parent_two[$v['category_id']] !== $parent ) {
$v['pid'] = $v['category_id'];
$v['category_id'] = $parent_two[$v['category_id']];
}
}
return success('success', $articles->toArray()); return success('success', $articles_data);
} }
/** /**

View File

@@ -56,6 +56,16 @@ class ArticleCategoryModel extends ArticleCategoryBaseModel
$query->where('pid', '=', $parent); $query->where('pid', '=', $parent);
} }
// 所属上级分类查询
public function scopeParentColumn($query, $parent)
{
if (is_array($parent)) {
$query->where('id', 'IN', $parent);
return;
}
$query->where('id', '=', $parent);
}
// 所属子分类范围查询 // 所属子分类范围查询
public function scopeChild($query, $id, $merge_self = false) public function scopeChild($query, $id, $merge_self = false)

View File

@@ -73,14 +73,14 @@
<li class="two-mues"> <li class="two-mues">
<a href="#" class="two-a"> <a href="#" class="two-a">
<div><img src="__IMAGES__/nars-jt.png" <div><img src="__IMAGES__/nars-jt.png"
class="arrow {if condition='$ad.id == $Request.get.cid'}rotate{/if}"> class="arrow {if condition='$ad.id == $Request.get.pid'}rotate{/if}">
</div> </div>
<span>{$ad.name}</span> <span>{$ad.name}</span>
</a> </a>
<ul class="thress-mues"> <ul class="thress-mues" {if condition='$ad.id == $Request.get.pid' }style="display: block;" {/if}>
{volist name="ad.article" id="ae"} {volist name="ad.article" id="ae"}
<li> <li>
<a href="{:url('/index/topic/nas/help_detail', ['cid' => $ad.id , 'id' => $ae.id])}" <a href="{:url('/index/topic/nas/help_detail', ['cid' => $ac.id ,'pid' => $ad.id, 'id' => $ae.id])}"
style="margin-left:18%;padding: 0.4rem;">{$ae.title}</a> style="margin-left:18%;padding: 0.4rem;">{$ae.title}</a>
</li> </li>
{/volist} {/volist}

View File

@@ -46,12 +46,12 @@
{volist name="ac.child" id="ad"} {volist name="ac.child" id="ad"}
<li class="two-mues"> <li class="two-mues">
<a href="#" class="two-a"> <a href="#" class="two-a">
<div class="arrow {if condition='$ad.id == $Request.get.cid'}rotate{/if}"><img src="__IMAGES__/nas-jt.png" class="arrow" /></div> <div class="arrow {if condition='$ad.id == $Request.get.pid'}rotate{/if}"><img src="__IMAGES__/nas-jt.png" class="arrow {if condition='$ad.id == $Request.get.pid'}rotate{/if}" /></div>
<span>{$ad.name}</span> <span>{$ad.name}</span>
</a> </a>
<ul class="thress-mues"> <ul class="thress-mues" {if condition='$ad.id == $Request.get.pid' }style="display: block;" {/if}>
{volist name="ad.article" id="ae"} {volist name="ad.article" id="ae"}
<li><a href="{:url('/index/topic/nas/help_detail', ['cid' => $ad.id, 'id' => $ae.id])}" style="padding-top: 6px;padding-left: 30px;" {eq <li><a href="{:url('/index/topic/nas/help_detail', ['cid' => $ac.id,'pid' => $ad.id, 'id' => $ae.id])}" style="padding-top: 6px;padding-left: 30px;" {eq
name="ae.id" value="$Request.get.id" }class="active" {/eq}>{$ae.title}</a></li> name="ae.id" value="$Request.get.id" }class="active" {/eq}>{$ae.title}</a></li>
{/volist} {/volist}
</ul> </ul>
@@ -135,7 +135,7 @@
html = '<ul>' html = '<ul>'
$.each(r.data, function (k, v) { $.each(r.data, function (k, v) {
html += html +=
'<li><a href="{:url(\'/index/topic/nas/help_detail\')}?cid=' + v.category_id + '&id=' + v.id + '">' + v.title + '</a></li>' '<li><a href="{:url(\'/index/topic/nas/help_detail\')}?cid=' + v.category_id + '&id=' + v.id + '&pid=' + v.pid + '">' + v.title + '</a></li>'
}) })
html += '</ul>' html += '</ul>'
} }