作者 lyh

gx

... ... @@ -31,6 +31,17 @@ class DomainInfoController extends BaseController
$this->map['domain'] = ['like','%'.$this->map['domain'],'%'];
}
$lists = $domainModel->lists($this->map,$this->page,$this->row,$this->order);
if(!empty($lists)){
$project_model = new Project();
foreach ($lists['list'] as $k=>$v){
$company = '';
$pro_info = $project_model->read(['id'=>$v['project_id']],'company');
if($pro_info){
$company = $pro_info['company'];
}
$lists['list'][$k]['company'] = $company;
}
}
return $this->response('success', Code::SUCCESS, $lists);
}
... ...
... ... @@ -113,7 +113,7 @@ class ProjectLogic extends BaseLogic
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('error');
$this->fail('请填写完整后再提交');
}
return $this->success();
}
... ...
... ... @@ -12,6 +12,7 @@ namespace App\Http\Logic\Bside\BTemplate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Service\Service as ServiceSettingModel;
use App\Models\Template\BTemplate;
use App\Models\Template\BTemplateCommon;
use App\Models\Template\BTemplateLog;
class BTemplateLogLogic extends BaseLogic
... ... @@ -41,12 +42,17 @@ class BTemplateLogLogic extends BaseLogic
if(($this->user['project_id'] == 1) && (!in_array($this->user['mobile'],$bTemplateModel->mobile)) && ($info['source'] == 1)){
$this->fail('演示项目仅支持演示功能,无法更改首页');
}
try {
$data = $this->setParam($info);
$BTemplateModel = new BTemplate();
$rs = $BTemplateModel->edit($data,['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id']]);
if($rs === false){
$this->fail('error');
$BTemplateModel->edit($data,['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id']]);
$commonData = $this->setCommonParam($info);
$commonTemplateModel = new BTemplateCommon();
$commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
}catch (\Exception $e){
$this->fail('系统错误,请联系管理员');
}
//同步更新公共头和底
return $this->success();
}
... ... @@ -71,6 +77,23 @@ class BTemplateLogLogic extends BaseLogic
}
/**
* @remark :设置回滚公共参数参数
* @name :setParam
* @author :lyh
* @method :post
* @time :2023/8/23 14:18
*/
public function setCommonParam($info){
$data = [
'head_html'=>$info['head_html'],
'head_css'=>$info['head_css'],
'footer_html'=>$info['footer_html'],
'footer_css'=>$info['footer_css'],
];
return $this->success($data);
}
/**
* @remark :获取数据详情
* @name :templateLogInfo
* @author :lyh
... ...
... ... @@ -104,9 +104,14 @@ class BTemplateLogic extends BaseLogic
$ATemplateModel = new Template();
$TemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']]);
}else{
//渲染首页数据
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
if($commonInfo !== false){
$TemplateInfo['html'] = $commonInfo['head_css'].$TemplateInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
$commonInfo['head_html'].$TemplateInfo['main_html'].$commonInfo['footer_html'];
}
$ATemplateModel = new Template();
$ATemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']]);
$ATemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']],['name','image']);
$TemplateInfo['name'] = $ATemplateInfo['name'];
$TemplateInfo['image_link'] = getImageUrl($ATemplateInfo['image']);
}
... ... @@ -122,24 +127,35 @@ class BTemplateLogic extends BaseLogic
* @time :2023/7/25 16:40
*/
public function productHtml($info,$source,$source_id){
//查看当前模板是否已编辑保存web_template
$TemplateInfo = $this->webTemplateInfo($info['template_id'],$source,$source_id);
if($TemplateInfo === false){
//获取首页数据
$homeTemplateInfo = $this->webTemplateInfo($info['template_id'],1,0);
if($homeTemplateInfo === false){
$this->fail('请先装修首页');
}
//查看当前模板是否已编辑保存web_template
$TemplateInfo = $this->webTemplateInfo($info['template_id'],$source,$source_id);
if($TemplateInfo === false){
//兼容老数据
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
if($commonInfo !== false){
$html = $commonInfo['head_css']."<style id='globalsojs-styles'></style>".$commonInfo['footer_css'].$commonInfo['other'].
$commonInfo['head_html']."<main>{$this->getProductModule()}</main>".$commonInfo['footer_html'];
}else{
$html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', "<style id='globalsojs-styles'></style>", $homeTemplateInfo['html']);
$html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', "<main>{$this->getProductModule()}</main>", $html);
}else{
$homeTemplateInfo = $this->webTemplateInfo($info['template_id'],1,0);
if($homeTemplateInfo === false){
$this->fail('请先装修首页');
}
}else{
//兼容老数据
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
if($commonInfo !== false){
$html = $commonInfo['head_css'].$TemplateInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
$commonInfo['head_html'].$TemplateInfo['main_html'].$commonInfo['footer_html'];
}else{
$html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', $TemplateInfo['main_css'], $homeTemplateInfo['html']);
$html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s',$TemplateInfo['main_html'] , $html);
}
}
$TemplateInfo['html'] = $this->getHeadFooter($html);//组装数据
return $this->success($TemplateInfo);
}
... ... @@ -187,17 +203,19 @@ class BTemplateLogic extends BaseLogic
$info = $this->webTemplateInfo($this->param['template_id'],$this->param['source'],$this->param['source_id']);
//字符串截取
$this->param = $this->stringProcessing($this->param);
$this->param = $this->templateSaveParam($this->param);
$this->saveCommonTemplate($this->param);
$this->param = $this->templateSaveParam($this->param);//组装数据
if($info === false){
$this->model->add($this->param);
}else{
$this->model->edit($this->param,['id'=>$info['id']]);
}
//写入操作模版记录
$this->setTemplateLog($this->param);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('error');
$this->fail('系统错误,请联系管理员');
}
//通知更新
$this->homeOrProduct($this->param['source'],$this->param['source_id']);
... ... @@ -205,6 +223,34 @@ class BTemplateLogic extends BaseLogic
}
/**
* @remark :保存头部公共数据
* @name :saveCommonTemplate
* @author :lyh
* @method :post
* @time :2023/10/13 14:27
*/
public function saveCommonTemplate($param){
$templateCommonModel = new BTemplateCommon();
$info = $templateCommonModel->read(['template_id'=>$param['template_id'],'project_id'=>$this->user['project_id']]);
// @file_put_contents(storage_path('logs/lyh_error.log'), var_export($param['html'], true) . PHP_EOL, FILE_APPEND);
$data = [
'head_html'=>$param['head_html'],
'head_css'=>$param['head_css'],
'footer_html'=>$param['footer_html'],
'footer_css'=>$param['footer_css'],
'other'=>str_replace('<header','',characterTruncation($param['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s")),
];
if($info === false){
$data['template_id'] = $param['template_id'];
$data['project_id'] = $this->user['project_id'];
$templateCommonModel->add($data);
}else{
$templateCommonModel->edit($data,['id'=>$info['id']]);
}
return $this->success();
}
/**
* @remark :生成记录
* @name :setTemplateLog
* @author :lyh
... ...
... ... @@ -6,6 +6,7 @@ use App\Http\Logic\Bside\BaseLogic;
use App\Models\RouteMap\RouteMap;
use App\Models\Service\Service as ServiceSettingModel;
use App\Models\Template\BCustomTemplate;
use App\Models\Template\BTemplateCommon;
use App\Models\Template\Setting;
use App\Models\Template\BTemplate;
... ... @@ -179,26 +180,20 @@ class CustomTemplateLogic extends BaseLogic
* @time :2023/7/21 18:08
*/
public function getBodyHeaderFooter($preg_html,$html_style){
if(empty($preg_html)){
$preg_html = "<main></main>";
$html_style = "<style id='globalsojs-styles'></style>";
}
//获取设置的默认模版
$bSettingModel = new Setting();
$info = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
//获取模板详情
$bTemplateModel = new BTemplate();
$TemplateInfo = $bTemplateModel->read([
'template_id'=>$info['template_id'],
'project_id'=>$this->user['project_id'],
'source'=>1//首页
]);
//兼容老数据
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
$html = '';
if($TemplateInfo !== false){
if(empty($preg_html)){
$preg_html = "<main></main>";
$html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', "<style id='globalsojs-styles'></style>", $TemplateInfo['html']);
}else{
$html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s',$html_style , $TemplateInfo['html']);
}
//内容
$html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', $preg_html, $html);
if($commonInfo !== false){
$html = $commonInfo['head_css'].$html_style.$commonInfo['footer_css'].$commonInfo['other'].
$commonInfo['head_html'].$preg_html.$commonInfo['footer_html'];
}
return $html;
}
... ...
... ... @@ -13,7 +13,7 @@ use App\Models\Base;
class BTemplateCommon extends Base
{
protected $table = 'gl_template_common';
protected $table = 'gl_web_template_common';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...