Browse Source

交易及市场日历(calendar) 相关文章

master
xiaodong 2 weeks ago
parent
commit
cac43f4140
  1. 64
      app/controller/frontend/SearchController.php
  2. 4
      public/themes/hc_original/dongya-web/index.html
  3. 4
      public/themes/static_new/index.html
  4. 4
      public/themes/website/1/zh/dongya-web/index.html
  5. 3
      route/1_zh_frontend.php

64
app/controller/frontend/SearchController.php

@ -8,6 +8,8 @@ use app\exception\ModelEmptyException;
use app\model\Category;
use app\model\CategorySubContent;
use app\model\SubContent;
use think\facade\Cache;
use think\facade\Db;
use think\Request;
use think\response\Json;
@ -95,13 +97,75 @@ class SearchController extends BaseController
return $this->fetch(config('view.view_search_page_name'));
}
// 交易及市场日历(calendar) 相关文章列表
public function searchCalendar(Request $request) :Json
{
$reqParam = $request->param();
$resData = [
'code'=>200,
'msg'=>'ok',
'data'=>[],
];
$reqDate = $reqParam['date'] ?? ''; // 2026-7-16
if(empty($reqDate)){
return json($resData);
}
$cacheKey = 'searchCalendar-'.$reqDate;
$cacheTmp = Cache::get($cacheKey);
if(!empty($cacheTmp)){
$cacheTmp['msg'] = 'ok-cache';
return json($cacheTmp);
}
// 将时间转为传入时间的那一天的开始时间和结束时间(时间戳)
$timestamp = strtotime($reqDate);
if ($timestamp === false) {
return json($resData);
}
$start = strtotime(date('Y-m-d', $timestamp) . ' 00:00:00');
$end = strtotime(date('Y-m-d', $timestamp) . ' 23:59:59');
// 查询时间段文章列表
$articleList = Db::table('hc_sub_content')
->field('id,title,create_time')
->where('category_id','=',215) // 交易及市场日历(calendar)
->where('create_time','>=',$start)
->where('create_time','<=',$end)
->select();
$resData['data'] = $articleList;
Cache::set($cacheKey,$resData,30);
return json($resData);
}
// 交易及市场日历(calendar) 相关文章详情
public function searchOneArticle(Request $request) :Json
{
$reqParam = $request->param();
$resData = [
'code'=>200,
'msg'=>'ok',
'data'=>'',
];
$reqID = $reqParam['id'] ?? 0; // hc_sub_content.id
if(empty($reqID)){
return json($resData);
}
$cacheKey = 'searchOneArticle-'.$reqID;
$cacheTmp = Cache::get($cacheKey);
if(!empty($cacheTmp)){
$cacheTmp['msg'] = 'ok-cache';
return json($cacheTmp);
}
// 查询时间段文章列表
$oneArticle = Db::table('hc_sub_content')
->field('id,title,create_time,content')
->where('category_id','=',215) // 交易及市场日历(calendar)
->where('id','=',$reqID)
->findOrEmpty();
$resData['data'] = $oneArticle;
Cache::set($cacheKey,$resData,30);
return json($resData);
}
}

4
public/themes/hc_original/dongya-web/index.html

@ -497,7 +497,7 @@
function timeclick(e) {
$("#date-show").html(e);
$(".event_ul").empty();
$.getJSON("/calendar/date-article-list", { date: e }, function (result) {
$.getJSON("/calendar-article-list", { date: e }, function (result) {
for (var i = 0; i < result.data.length; i++) {
$(".event_ul").append('<li data-id="' + result.data[i].id + '" href="javascript:void(0);"> ' + result.data[i].title + ' </li>');
}
@ -516,7 +516,7 @@
})
$(".event_ul").on("click", "li", function () {
$.getJSON("/calendar/article-detail", { id: $(this).data("id") }, function (result) {
$.getJSON("/calendar-article-list", { id: $(this).data("id") }, function (result) {
$(".apprais").html(result.data.title);
$(".apprais_cont").html(result.data.content);
$(".calendar_pop").show();

4
public/themes/static_new/index.html

@ -973,7 +973,7 @@
function timeclick(e) {
$("#date-show").html(e);
$(".event_ul").empty();
$.getJSON("/calendar/date-article-list", { date: e }, function (result) {
$.getJSON("/calendar-article-list", { date: e }, function (result) {
for (var i = 0; i < result.data.length; i++) {
$(".event_ul").append('<li data-id="' + result.data[i].id + '" href="javascript:void(0);"> ' + result.data[i].title + ' </li>');
}
@ -992,7 +992,7 @@
})
$(".event_ul").on("click", "li", function () {
$.getJSON("/calendar/article-detail", { id: $(this).data("id") }, function (result) {
$.getJSON("/calendar-article-list", { id: $(this).data("id") }, function (result) {
$(".apprais").html(result.data.title);
$(".apprais_cont").html(result.data.content);
$(".calendar_pop").show();

4
public/themes/website/1/zh/dongya-web/index.html

@ -497,7 +497,7 @@
function timeclick(e) {
$("#date-show").html(e);
$(".event_ul").empty();
$.getJSON("/calendar/date-article-list", { date: e }, function (result) {
$.getJSON("/calendar-article-list", { date: e }, function (result) {
for (var i = 0; i < result.data.length; i++) {
$(".event_ul").append('<li data-id="' + result.data[i].id + '" href="javascript:void(0);"> ' + result.data[i].title + ' </li>');
}
@ -516,7 +516,7 @@
})
$(".event_ul").on("click", "li", function () {
$.getJSON("/calendar/article-detail", { id: $(this).data("id") }, function (result) {
$.getJSON("/calendar-article-detail", { id: $(this).data("id") }, function (result) {
$(".apprais").html(result.data.title);
$(".apprais_cont").html(result.data.content);
$(".calendar_pop").show();

3
route/1_zh_frontend.php

@ -318,7 +318,8 @@ Route::get('/tagList/:id', 'List/tag')->name('List/tag')
Route::get('/search', 'Search/index');
// 交易及市场日历(calendar)
Route::get('/calendar/article-detail', 'Search/searchCalendar');
Route::get('/calendar-article-list', 'Search/searchCalendar');
Route::get('/calendar-article-detail', 'Search/searchOneArticle');

Loading…
Cancel
Save