Browse Source

首页修改

master
loucongjun 2 weeks ago
parent
commit
9cd31d2bc9
  1. 58
      app/common.php
  2. 1178
      public/themes/website/1/zh/demo/single_index.html

58
app/common.php

@ -1637,3 +1637,61 @@ if (!function_exists('isHcListEmpty')) {
return false; return false;
} }
} }
/**
* 获取指定栏目下所有子栏目及其内容
* @param int $parentId 父栏目ID
* @param int $sellerId 商户ID
* @param int $limit 每个子栏目返回的内容条数
* @param string $sort 排序方式
* @return array
*/
if (!function_exists('getChildCategoriesContent')) {
function getChildCategoriesContent(int $parentId, int $sellerId, int $limit = 6, string $sort = 'publish_time desc'): array
{
if (empty($parentId)) {
return [];
}
try {
$categoryModel = new \app\model\Category();
// 1. 查询所有子栏目
$childCates = $categoryModel->where('parent_id', $parentId)
->where('seller_id', $sellerId)
->order('sort asc')
->select()
->toArray();
if (empty($childCates)) {
return [];
}
// 2. 获取所有子栏目ID
$childCateIds = array_column($childCates, 'id');
// 3. 查询这些子栏目下的文章
$contents = \app\model\SubContent::where('category_id', 'in', $childCateIds)
->where('seller_id', $sellerId)
->where('is_del', 1)
->field('id,main_id,title,category_id,description,thumbnail,publish_time')
->order($sort)
->limit($limit)
->select()
->toArray();
// 4. 批量查询附件URL
$thumbIds = array_unique(array_filter(array_column($contents, 'thumbnail')));
if (!empty($thumbIds)) {
$attachments = \app\model\Attachment::whereIn('id', $thumbIds)->column('url', 'id');
foreach ($contents as &$content) {
$content['thumbnail_url'] = $attachments[$content['thumbnail']] ?? '';
}
unset($content);
}
return $contents;
} catch (\Exception $e) {
return [];
}
}
}

1178
public/themes/website/1/zh/demo/single_index.html
File diff suppressed because it is too large
View File

Loading…
Cancel
Save