作者 lyh

Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6 into develop

... ... @@ -3,6 +3,7 @@
namespace App\Http\Controllers\Aside\Optimize;
use App\Enums\Common\Code;
use App\Helper\Arr;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Optimize\OptimizeLogic;
use App\Http\Logic\Aside\Project\ProjectLogic;
... ... @@ -47,6 +48,7 @@ class OptimizeController extends BaseController
$data = $rankDataModel->read(['project_id'=>$v['id'],'lang'=>''],['first_page_num','indexed_pages_num']);
$v['first_page_num'] = $data['first_page_num'] ?? 0;
$v['indexed_pages_num'] = $data['indexed_pages_num'] ?? 0;
$v['g'] = $this->getGNum($v['id']);
$v = $this->handleParam($v);
$lists['list'][$k] = $v;
}
... ... @@ -55,6 +57,27 @@ class OptimizeController extends BaseController
}
/**
* @remark :统计数量
* @name :getGNum
* @author :lyh
* @method :post
* @time :2024/1/6 11:12
*/
public function getGNum($project_id){
$num = 0;
$list = RankData::where('project_id', $project_id)->where('lang', '')->value('data') ?: [];
if(!empty($list)){
foreach ($list as $v) {
$last = Arr::last($v);
if(isset($last['g']) && ($last['g'] == 1)){
$num = $num+1;
}
}
}
return $num;
}
/**
* @remark :参数处理
* @name :handleParam
* @author :lyh
... ...
... ... @@ -176,9 +176,6 @@ class BTemplateLogic extends BaseLogic
$this->fail('定制页面,请先上传代码块');
}
$commonInfo = $this->getCustomizedCommonHtml($type);//获取定制头部
if($this->user['project_id'] == 655){
return $customHtmlInfo['main_html'];
}
if($commonInfo !== false){
$customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']);
}
... ...
... ... @@ -264,12 +264,36 @@ class InitHtmlLogic extends BaseLogic
if($info === false){
$html = '';
}else{
$type = $this->getCustomizedType($this->param['type'],$is_list);
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read(['template_id' => 0,'type'=>$type]);
if($commonInfo !== false){
$info['main_html'] = $this->handleAllHtml($commonInfo,$info['main_html']);
}
$html = $info['main_html'];
}
//更新头部底部
return $this->success(['html'=>$html]);
}
/**
* @remark :返回整个html截取代码
* @name :handleAllHtml
* @author :lyh
* @method :post
* @time :2023/12/13 15:39
*/
public function handleAllHtml($commonInfo,$html){
if(!empty($commonInfo)){
$html = preg_replace('/<header\b[^>]*>(.*?)<\/header>/s', $commonInfo['head_html'], $html);
$html = preg_replace('/<footer\b[^>]*>(.*?)<\/footer>/s', $commonInfo['footer_html'], $html);
$html = preg_replace('/<style id="globalsojs-header">(.*?)<\/style>/s', $commonInfo['head_css'], $html);
$html = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', $commonInfo['footer_css'], $html);
}
return $html;
}
/**
* @remark :保存定制html
* @name :saveHtml
* @author :lyh
... ... @@ -292,6 +316,8 @@ class InitHtmlLogic extends BaseLogic
}else{
$bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]);
}
//更新头部底部
$this->saveCustomizeCommon($this->param['html'],$this->param['type'],$is_list);
}catch (\Exception $exception){
$this->fail('保存失败,请联系开发人员');
}
... ... @@ -299,6 +325,68 @@ class InitHtmlLogic extends BaseLogic
}
/**
* @remark :定制代码更新头部信息
* @name :saveCustomizeCommon
* @author :lyh
* @method :post
* @time :2024/1/6 10:29
*/
public function saveCustomizeCommon($html,$source,$is_list){
$type = $this->getCustomizedType($source,$is_list);
$templateCommonModel = new BTemplateCommon();
$commonInfo = $templateCommonModel->read(['template_id'=>0,'type'=>$type]);//查看当前头部是否存在
$handleInfo = $this->handleCommonParam($html);
if($commonInfo === false){
$data = [
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
'type'=>$type,'template_id'=>0, 'project_id'=>$this->user['project_id'],
];
$templateCommonModel->add($data);
}else{
$data = [
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
];
$templateCommonModel->edit($data,['id'=>$commonInfo['id']]);
}
return $this->success();
}
/**
* @remark :定制页面头部类型---根据source获取type类型
* @name :getType
* @author :lyh
* @method :post
* @time :2023/11/16 11:20
*/
public function getCustomizedType($source,$is_list){
$type = BTemplate::TYPE_HOME;
if($source == BTemplate::SOURCE_PRODUCT){
if($is_list == BTemplate::IS_LIST){
$type = BTemplate::TYPE_PRODUCT_LIST;
}else{
$type = BTemplate::TYPE_PRODUCT_DETAIL;
}
}
if($source == BTemplate::SOURCE_BLOG){
if($is_list == BTemplate::IS_LIST){
$type = BTemplate::TYPE_BLOG_LIST;
}else{
$type = BTemplate::TYPE_BLOG_DETAIL;
}
}
if($source == BTemplate::SOURCE_NEWS){
if($is_list == BTemplate::IS_LIST){
$type = BTemplate::TYPE_NEWS_LIST;
}else{
$type = BTemplate::TYPE_NEWS_DETAIL;
}
}
return $type;
}
/**
* @remark :前端获取设置模块(侧边栏)
* @name :getInitModuleMain
* @author :lyh
... ...