10 changed files with 563 additions and 19 deletions
@ -0,0 +1,107 @@ |
|||||
|
<?php |
||||
|
/** |
||||
|
* |
||||
|
*/ |
||||
|
include_once(SERVER_ROOT . "/model/mBase.php"); |
||||
|
|
||||
|
class mEs extends mBase { |
||||
|
public $es_host = '127.0.0.1'; |
||||
|
public $es_port = 9200; |
||||
|
public $es_index = ''; |
||||
|
|
||||
|
public function __construct($index) { |
||||
|
$this->es_index = $index; |
||||
|
} |
||||
|
|
||||
|
public function search($body) { |
||||
|
$es_url = "http://" . $this->es_host . ":" . $this->es_port . "/{$this->es_index}/_search"; |
||||
|
return $this->postCUrl($es_url, $body, 10, false, true); |
||||
|
} |
||||
|
|
||||
|
public function searchWeibo($keywords) { |
||||
|
if(empty($keywords)) return false; |
||||
|
|
||||
|
$from = 0; |
||||
|
$size = 50; |
||||
|
|
||||
|
$body = [ |
||||
|
'query' => [ |
||||
|
'bool' => [ |
||||
|
'should' => [ |
||||
|
[ |
||||
|
'match' => [ |
||||
|
'content' => [ |
||||
|
'query' => $keywords, |
||||
|
'boost' => 4, |
||||
|
] |
||||
|
] |
||||
|
], |
||||
|
], |
||||
|
], |
||||
|
], |
||||
|
'highlight' => [ |
||||
|
'fields' => [ |
||||
|
'content' => [ |
||||
|
'fragment_size' => 2, |
||||
|
'number_of_fragments' => 20, |
||||
|
'pre_tags' => [''], |
||||
|
'post_tags' => [''] |
||||
|
] |
||||
|
] |
||||
|
], |
||||
|
'from' => $from, |
||||
|
'size' => $size |
||||
|
]; |
||||
|
|
||||
|
$res = $this->search(json_encode($body)); |
||||
|
$list = json_decode($res, true); |
||||
|
if(empty($res) || empty($list['hits'])) { |
||||
|
$this->setError('获取失败'); |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
$rdata['total'] = $list['hits']['total']+0; |
||||
|
$data['list'] = $list['hits']['hits']; |
||||
|
if($rdata['total'] <= 0) { |
||||
|
$rdata['list'] = array(); |
||||
|
return $rdata; |
||||
|
} |
||||
|
|
||||
|
$rdata['total'] = $size; |
||||
|
$weibo_ids = array_column($data['list'], '_id'); |
||||
|
|
||||
|
$obj = new mWeibo(); |
||||
|
$list = $obj->getWeiboByIds($weibo_ids); |
||||
|
|
||||
|
$rlist = array(); |
||||
|
foreach($data['list'] as $v) { |
||||
|
$weibo_id = $v['_id']; |
||||
|
$weibo = $list[$weibo_id]; |
||||
|
if(empty($weibo)) continue; |
||||
|
|
||||
|
$highlights = $v['highlight']["content"]; |
||||
|
if(!empty($highlights)) { |
||||
|
foreach($highlights as $k=>$val) { |
||||
|
$weibo['text'] = str_replace($val, '<em class="highlight" style="color:green;">'.$val.'</em>', $weibo['text']); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
$weibo['name'] = '张宝旬'; |
||||
|
$pic_ids = json_decode($weibo['pic_ids'], 1); |
||||
|
$pic_arr = array(); |
||||
|
if ($pic_ids) { |
||||
|
foreach ($pic_ids as $pic_id) { |
||||
|
$pic_arr[] = $obj->getPicOssUrl($pic_id, $weibo['created_at']); |
||||
|
} |
||||
|
} |
||||
|
$weibo['pic_arr'] = $pic_arr; |
||||
|
|
||||
|
if ($weibo['video_url']) $weibo['video_url'] = $obj->getVideoOssUrl($weibo['wid'], $weibo['created_at']); |
||||
|
if ($weibo['video_cover']) $weibo['video_cover'] = $obj->getPicOssUrl($weibo['video_cover'], $weibo['created_at']); |
||||
|
|
||||
|
$rdata['list'][] = $weibo; |
||||
|
} |
||||
|
|
||||
|
return $rdata; |
||||
|
} |
||||
|
} |
@ -0,0 +1,211 @@ |
|||||
|
<!DOCTYPE html> |
||||
|
<html lang="en"> |
||||
|
|
||||
|
<head> |
||||
|
<meta charset="UTF-8"> |
||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
||||
|
<title>知识库</title> |
||||
|
<link rel="stylesheet" href="{$smarty.const.CSS_URL}/css/common.css?v={$smarty.const.CSS_JS_VERSION}"> |
||||
|
<link rel="stylesheet" href="{$smarty.const.CSS_URL}/css/index.css?v={$smarty.const.CSS_JS_VERSION}"> |
||||
|
<script src="{$smarty.const.CSS_URL}/js/jquery-3.6.0.min.js"></script> |
||||
|
{literal} |
||||
|
<style> |
||||
|
.search-wrapper{ |
||||
|
column-gap: 12px; |
||||
|
width: 100%; |
||||
|
} |
||||
|
.search-wrapper input{ |
||||
|
width: 200px; |
||||
|
padding-left: 8px; |
||||
|
} |
||||
|
.addNewBtn2 { |
||||
|
width: 121px; |
||||
|
display: flex; |
||||
|
flex-direction: row; |
||||
|
justify-content: center; |
||||
|
align-items: center; |
||||
|
height: 32px; |
||||
|
border-radius: 3px; |
||||
|
opacity: 1; |
||||
|
height: 32px; |
||||
|
border:none; |
||||
|
background: #006AFF; |
||||
|
font-weight: normal; |
||||
|
line-height: normal; |
||||
|
letter-spacing: 0.08em; |
||||
|
color: #FFFFFF; |
||||
|
} |
||||
|
</style> |
||||
|
{/literal} |
||||
|
</head> |
||||
|
|
||||
|
<body> |
||||
|
<div class="home-page"> |
||||
|
{include file="include/header.html"} |
||||
|
|
||||
|
<div class="home-main-content"> |
||||
|
<div class="home-main"> |
||||
|
<div class="tab-list index-nav-wrap flex"> |
||||
|
<div class="search-wrapper flex"> |
||||
|
<input type="text" placeholder="输入症状进行查询" id="search-input" value="{$keyword}"> |
||||
|
<button class="addNewBtn2" id="searchWeibo"> |
||||
|
搜索 |
||||
|
</button> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
|
||||
|
<div class="list_all" id="data-list"> |
||||
|
</div> |
||||
|
|
||||
|
|
||||
|
<!-- 数据列表 --> |
||||
|
<!-- <ul id="data-list"></ul> --> |
||||
|
|
||||
|
<!-- 分页控件 --> |
||||
|
<div class="pagination hide"> |
||||
|
<img id="prev-page" src="{$smarty.const.CSS_URL}/images/prev.svg" alt=""> |
||||
|
<ul id="page-numbers"></ul> |
||||
|
<img id="next-page" src="{$smarty.const.CSS_URL}/images/next.svg" alt=""> |
||||
|
<div class="input-page"> |
||||
|
<span>前往</span> |
||||
|
<input type="number" id="jump-to-page" min="1" placeholder="页码"> |
||||
|
<span>页</span> |
||||
|
</div> |
||||
|
<button id="go-to-page">跳转</button> |
||||
|
</div> |
||||
|
|
||||
|
<!-- 放大后的图片容器 --> |
||||
|
<div id="large-image-container"> |
||||
|
<h2>预览</h2> |
||||
|
<img id="large-image" src="{$smarty.const.CSS_URL}/images/viewimg1.png" alt="Large Image"> |
||||
|
<span id="close-btn2">×</span> |
||||
|
</div> |
||||
|
|
||||
|
<!-- 放大后的视频容器 --> |
||||
|
<div id="large-video-container"> |
||||
|
<video id="large-video" controls> |
||||
|
<source id="large-viedo-url" src="" type="video/mp4"> |
||||
|
Your browser does not support the video tag. |
||||
|
</video> |
||||
|
<button id="close-btn">×</button> |
||||
|
</div> |
||||
|
|
||||
|
<!-- 弹框 --> |
||||
|
<div class="modal-overlay"></div> |
||||
|
<div class="modal"> |
||||
|
<div class="modal_top"> |
||||
|
<b id="header_title">编辑</b> |
||||
|
<img src="{$smarty.const.CSS_URL}/images/close_modal.svg" id="close_modal" alt=""> |
||||
|
</div> |
||||
|
|
||||
|
<div class="add-form"> |
||||
|
<div class="form-item radio-form"> |
||||
|
<input type="hidden" id="id" value=""> |
||||
|
<div class="form-left"> |
||||
|
录入形式 |
||||
|
</div> |
||||
|
<div class="form-right radio-wrap flex"> |
||||
|
<div class="radio_box radio_box_active"> |
||||
|
<input value="1" type="radio"id="edu1"> |
||||
|
<div></div> |
||||
|
<label >信息段录入</label> |
||||
|
</div> |
||||
|
<div class="radio_box"> |
||||
|
<input value="2" type="radio"id="edu2"> |
||||
|
<div></div> |
||||
|
<label >问答式录入</label> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="form-item normal-form" style="display: none;"> |
||||
|
<div class="form-left"> |
||||
|
提问信息 |
||||
|
</div> |
||||
|
<div class="form-right"> |
||||
|
<div class="text-area-container"> |
||||
|
<textarea class="edit-input normal-input" ></textarea> |
||||
|
<div class="char-count wordNum">0/200</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<div class="form-item"> |
||||
|
<div class="form-left common-input"> |
||||
|
回答信息 |
||||
|
</div> |
||||
|
<div class="form-right"> |
||||
|
<div class="text-area-container"> |
||||
|
<textarea class="edit-input answer-input" ></textarea> |
||||
|
<div class="char-count1 wordNum">0/200</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
{literal} |
||||
|
<script> |
||||
|
const maxLength = 100; // 设置最大字数限制 |
||||
|
$('.normal-input').on('input', function () { |
||||
|
var currentLength = $(this).val().length; |
||||
|
$('.char-count').text(currentLength + '/' + maxLength); |
||||
|
if (currentLength > maxLength) { |
||||
|
$('.normal-input').val($('.normal-input').val().slice(0, maxLength)) |
||||
|
$('.char-count').text(maxLength + '/' + maxLength); |
||||
|
} |
||||
|
}); |
||||
|
$('.answer-input').on('input', function () { |
||||
|
var currentLength = $(this).val().length; |
||||
|
$('.char-count1').text(currentLength + '/' + maxLength); |
||||
|
if (currentLength > maxLength) { |
||||
|
$('.answer-input').val($('.answer-input').val().slice(0, maxLength)) |
||||
|
$('.char-count1').text(maxLength + '/' + maxLength); |
||||
|
} |
||||
|
}); |
||||
|
</script> |
||||
|
{/literal} |
||||
|
<div class="img_list2" style="display: none;"></div> |
||||
|
<div class="preview"></div> |
||||
|
|
||||
|
<div class="modal_upload_btn flex hide"> |
||||
|
<div class="flex modal_btns"> |
||||
|
<button id="upload-image-btn" class="button upload_btn"> |
||||
|
<img src="{$smarty.const.CSS_URL}/images/img_upload.svg" alt="">上传图片 |
||||
|
</button> |
||||
|
<button id="upload-video-btn" class="button upload_btn"> |
||||
|
<img src="{$smarty.const.CSS_URL}/images/vedio_upload.svg" alt="">上传视频 |
||||
|
</button> |
||||
|
</div> |
||||
|
<p>支持 jpg、png、mp4 格式,单个文件不超过 10MB</p> |
||||
|
</div> |
||||
|
<input type="file" id="upload-image" accept="image/*" style="display: none;" multiple> |
||||
|
<input type="file" id="upload-video" accept="video/*" style="display: none;" multiple> |
||||
|
<div class="buttons flex"> |
||||
|
<button id="submit" class="button ">仅保存</button> |
||||
|
<button id="savePass" class="button button-primary">保存并通过审批</button> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
{include file="include/footer.html"} |
||||
|
</div> |
||||
|
|
||||
|
<div id="hidecomments" style="display: none;"></div> |
||||
|
<div id="hidesearch" style="display: none;"></div> |
||||
|
<div id="hidekeyword" style="display: none;">{$keyword}</div> |
||||
|
|
||||
|
</body> |
||||
|
<script src="{$smarty.const.CSS_URL}/js/index.js?v={$smarty.const.CSS_JS_VERSION}589"></script> |
||||
|
|
||||
|
{literal} |
||||
|
<script> |
||||
|
$('#searchWeibo').click(function () { |
||||
|
var keyword = $('#search-input').val() |
||||
|
if (keyword) { |
||||
|
window.location.href = '/weibo/search?keyword=' + keyword |
||||
|
} else { |
||||
|
window.location.href = '/weibo/search' |
||||
|
} |
||||
|
}) |
||||
|
</script> |
||||
|
{/literal} |
||||
|
</html> |
@ -0,0 +1,170 @@ |
|||||
|
<!DOCTYPE html> |
||||
|
<html lang="en"> |
||||
|
|
||||
|
<head> |
||||
|
<meta charset="UTF-8"> |
||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
||||
|
<title>知识库</title> |
||||
|
<link rel="stylesheet" href="{$smarty.const.CSS_URL}/css/common.css?v={$smarty.const.CSS_JS_VERSION}"> |
||||
|
<link rel="stylesheet" href="{$smarty.const.CSS_URL}/css/index.css?v={$smarty.const.CSS_JS_VERSION}"> |
||||
|
<script src="{$smarty.const.CSS_URL}/js/jquery-3.6.0.min.js"></script> |
||||
|
</head> |
||||
|
|
||||
|
<body> |
||||
|
<div class="home-page"> |
||||
|
{include file="include/header.html"} |
||||
|
|
||||
|
<div class="home-main-content"> |
||||
|
<div class="home-main"> |
||||
|
<div class="tab-list index-nav-wrap flex"> |
||||
|
<ul class="tab-wrap" style="display: none;"> |
||||
|
<li class="index-nav-wrap-li" type="1"><span class="active">待审批</span></li> |
||||
|
<li class="index-nav-wrap-li" type="2"><span>已审批</span></li> |
||||
|
<li class="index-nav-wrap-li" type="3"><span>已删除</span></li> |
||||
|
</ul> |
||||
|
<button class="addNewBtn" style="display: none;"> |
||||
|
<img src="{$smarty.const.CSS_URL}/images/add.svg" alt="">新增自录入 |
||||
|
</button> |
||||
|
</div> |
||||
|
|
||||
|
|
||||
|
<div class="list_all" id="data-list"> |
||||
|
</div> |
||||
|
|
||||
|
|
||||
|
<!-- 数据列表 --> |
||||
|
<!-- <ul id="data-list"></ul> --> |
||||
|
|
||||
|
<!-- 分页控件 --> |
||||
|
<div class="pagination hide"> |
||||
|
<img id="prev-page" src="{$smarty.const.CSS_URL}/images/prev.svg" alt=""> |
||||
|
<ul id="page-numbers"></ul> |
||||
|
<img id="next-page" src="{$smarty.const.CSS_URL}/images/next.svg" alt=""> |
||||
|
<div class="input-page"> |
||||
|
<span>前往</span> |
||||
|
<input type="number" id="jump-to-page" min="1" placeholder="页码"> |
||||
|
<span>页</span> |
||||
|
</div> |
||||
|
<button id="go-to-page">跳转</button> |
||||
|
</div> |
||||
|
|
||||
|
<!-- 放大后的图片容器 --> |
||||
|
<div id="large-image-container"> |
||||
|
<h2>预览</h2> |
||||
|
<img id="large-image" src="{$smarty.const.CSS_URL}/images/viewimg1.png" alt="Large Image"> |
||||
|
<span id="close-btn2">×</span> |
||||
|
</div> |
||||
|
|
||||
|
<!-- 放大后的视频容器 --> |
||||
|
<div id="large-video-container"> |
||||
|
<video id="large-video" controls> |
||||
|
<source id="large-viedo-url" src="" type="video/mp4"> |
||||
|
Your browser does not support the video tag. |
||||
|
</video> |
||||
|
<button id="close-btn">×</button> |
||||
|
</div> |
||||
|
|
||||
|
<!-- 弹框 --> |
||||
|
<div class="modal-overlay"></div> |
||||
|
<div class="modal"> |
||||
|
<div class="modal_top"> |
||||
|
<b id="header_title">编辑</b> |
||||
|
<img src="{$smarty.const.CSS_URL}/images/close_modal.svg" id="close_modal" alt=""> |
||||
|
</div> |
||||
|
|
||||
|
<div class="add-form"> |
||||
|
<div class="form-item radio-form"> |
||||
|
<input type="hidden" id="id" value=""> |
||||
|
<div class="form-left"> |
||||
|
录入形式 |
||||
|
</div> |
||||
|
<div class="form-right radio-wrap flex"> |
||||
|
<div class="radio_box radio_box_active"> |
||||
|
<input value="1" type="radio"id="edu1"> |
||||
|
<div></div> |
||||
|
<label >信息段录入</label> |
||||
|
</div> |
||||
|
<div class="radio_box"> |
||||
|
<input value="2" type="radio"id="edu2"> |
||||
|
<div></div> |
||||
|
<label >问答式录入</label> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="form-item normal-form" style="display: none;"> |
||||
|
<div class="form-left"> |
||||
|
提问信息 |
||||
|
</div> |
||||
|
<div class="form-right"> |
||||
|
<div class="text-area-container"> |
||||
|
<textarea class="edit-input normal-input" ></textarea> |
||||
|
<div class="char-count wordNum">0/200</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<div class="form-item"> |
||||
|
<div class="form-left common-input"> |
||||
|
回答信息 |
||||
|
</div> |
||||
|
<div class="form-right"> |
||||
|
<div class="text-area-container"> |
||||
|
<textarea class="edit-input answer-input" ></textarea> |
||||
|
<div class="char-count1 wordNum">0/200</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
{literal} |
||||
|
<script> |
||||
|
const maxLength = 100; // 设置最大字数限制 |
||||
|
$('.normal-input').on('input', function () { |
||||
|
var currentLength = $(this).val().length; |
||||
|
$('.char-count').text(currentLength + '/' + maxLength); |
||||
|
if (currentLength > maxLength) { |
||||
|
$('.normal-input').val($('.normal-input').val().slice(0, maxLength)) |
||||
|
$('.char-count').text(maxLength + '/' + maxLength); |
||||
|
} |
||||
|
}); |
||||
|
$('.answer-input').on('input', function () { |
||||
|
var currentLength = $(this).val().length; |
||||
|
$('.char-count1').text(currentLength + '/' + maxLength); |
||||
|
if (currentLength > maxLength) { |
||||
|
$('.answer-input').val($('.answer-input').val().slice(0, maxLength)) |
||||
|
$('.char-count1').text(maxLength + '/' + maxLength); |
||||
|
} |
||||
|
}); |
||||
|
</script> |
||||
|
{/literal} |
||||
|
<div class="img_list2" style="display: none;"></div> |
||||
|
<div class="preview"></div> |
||||
|
|
||||
|
<div class="modal_upload_btn flex hide"> |
||||
|
<div class="flex modal_btns"> |
||||
|
<button id="upload-image-btn" class="button upload_btn"> |
||||
|
<img src="{$smarty.const.CSS_URL}/images/img_upload.svg" alt="">上传图片 |
||||
|
</button> |
||||
|
<button id="upload-video-btn" class="button upload_btn"> |
||||
|
<img src="{$smarty.const.CSS_URL}/images/vedio_upload.svg" alt="">上传视频 |
||||
|
</button> |
||||
|
</div> |
||||
|
<p>支持 jpg、png、mp4 格式,单个文件不超过 10MB</p> |
||||
|
</div> |
||||
|
<input type="file" id="upload-image" accept="image/*" style="display: none;" multiple> |
||||
|
<input type="file" id="upload-video" accept="video/*" style="display: none;" multiple> |
||||
|
<div class="buttons flex"> |
||||
|
<button id="submit" class="button ">仅保存</button> |
||||
|
<button id="savePass" class="button button-primary">保存并通过审批</button> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
{include file="include/footer.html"} |
||||
|
</div> |
||||
|
|
||||
|
<div id="hidecomments" style="display: none;"></div> |
||||
|
|
||||
|
</body> |
||||
|
<script src="{$smarty.const.CSS_URL}/js/index.js?v={$smarty.const.CSS_JS_VERSION}589"></script> |
||||
|
|
||||
|
</html> |
Loading…
Reference in new issue