作者 张关杰

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

... ... @@ -55,7 +55,7 @@ class UpdateRoute extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['is_upgrade'=>0,'delete_status'=>0,'id'=>['<',500]]);
$list = $projectModel->list(['id'=>645]);
$data = [];
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
... ...
... ... @@ -291,7 +291,7 @@ class WebTraffic extends Command
}else{
//大于9个月项目
$startTime = Carbon::now()->addMonths(-9)->startOfDay()->toDateTimeString();
$query->whereBetween('pdo.start_date', '<', $startTime);
$query->where('pdo.start_date', '<', $startTime);
}
})->select('pdo.project_id')->forPage($page, 500)->get();
//其他地方在引流的域名
... ...
... ... @@ -727,7 +727,7 @@ class Translate
* @return \Illuminate\Http\Client\Response
* @time 2022/3/30 15:58
*/
public static function translate($texts, $tls)
public static function translate($texts, $tls, $sl = 'auto')
{
$action = 'translates';
if (is_string($texts)) {
... ... @@ -738,7 +738,7 @@ class Translate
}
$data = [
'texts' => $texts,
'sl' => 'auto',
'sl' => $sl,
'tls' => $tls,
];
return http_post(self::$url.$action, json_encode($data),self::$header);
... ...
... ... @@ -213,7 +213,7 @@ class OptimizeController extends BaseController
if(isset($this->map['level']) && !empty($this->map['level'])){
$query = $query->whereRaw("FIND_IN_SET(?, gl_project.level) > 0", [$this->map['level']]);
}
if(isset($this->map['online_updated_at']) && !empty($this->map['online_updated_at'])){
if(isset($this->map['online_updated_at']) && !empty($this->map['online_updated_at']) && is_array($this->map['online_updated_at'])){
$query = $query->whereBetween('gl_project_deploy_optimize.updated_at', $this->map['online_updated_at']);
}
if(isset($this->map['special'])){
... ...
... ... @@ -300,4 +300,28 @@ class ComController extends BaseController
}
$this->response('success',Code::SUCCESS,['url'=>$url_link]);
}
/**
* @remark :根据手机号码,获取当前号码拥有的所有项目
* @name :getMobileProject
* @author :lyh
* @method :post
* @time :2024/2/22 9:32
*/
public function getMobileProject(){
$data = [];
$userModel = new User();
$list = $userModel->list(['mobile'=>$this->user['mobile'],'project_id'=>['!=',$this->user['project_id']]],'id',['id','project_id']);
if(!empty($list)){
$projectModel = new Project();
foreach ($list as $k => $v){
$projectInfo = $projectModel->read(['id'=>$v['project_id']],['id','company']);
//获取当前项目详情
$data[] = ['project_id'=>$projectInfo['id'],'company'=>$projectInfo['company']];
}
}
//登录选择项目的有效时间
Cache::add('login-project-'.$this->user['mobile'],1,300);
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -17,6 +17,7 @@ use App\Models\Product\ExtendInfo;
use App\Models\Product\Keyword;
use App\Models\Product\KeywordRelated;
use App\Models\Product\Product;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\Setting;
use App\Models\Template\BTemplate;
use App\Models\User\User;
... ... @@ -58,7 +59,7 @@ class ProductController extends BaseController
$template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL);//获取模版id
$userModel = new User();
foreach ($lists['list'] as $k=>$v){
$v['url'] = $this->user['domain'].$v['route'].'/';
$v['url'] = $this->user['domain'] . getRouteMap(RouteMap::SOURCE_PRODUCT,$v['id']);;
$v['category_id_text'] = $this->categoryName($v['category_id'],$cate_data);
$v['keyword_id_text'] = $this->keywordName($v['keyword_id'],$key_data);
$v['created_uid_text'] = $userModel->getName($v['created_uid']);
... ...
<?php
/**
* @remark :
* @name :UpdateHtml.php
* @author :lyh
* @method :post
* @time :2024/2/2 10:11
*/
namespace App\Http\Controllers\Html;
use App\Http\Controllers\Controller;
use App\Models\Com\NoticeLog;
use App\Models\CustomModule\CustomModule;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
use App\Models\Service\Service as ServiceSettingModel;
use App\Models\Template\BTemplate;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\DB;
class UpdateHtml extends Controller
{
protected $param;
protected $project_id;
public function __construct($data){
$this->param = $data;//Todo::传递的参数
$this->project_id = $data['project_id'];
}
/**
* @remark :更新界面
* @name :updateHtml
* @author :lyh
* @method :post
* @time :2024/2/2 10:12
*/
public function updateHtml(){
ProjectServer::useProject($this->project_id);
if(isset($this->param['route']) && $this->param['route'] == 'all'){
//TODO::更新所有界面
}else{
//TODO::更新单页
$routeMapModel = new RouteMap();
}
DB::disconnect('custom_mysql');
}
/**
* @remark :获取页面是否为 定制/非定制 页面
* @name :getPageHtmlIsCustomized
* @param :source:类型;is_list:是否为列表页 1:列表页面
* @author :lyh
* @method :post
* @time :2024/2/2 11:03
*/
public function getPageHtmlIsCustomized($source,$is_list,$is_custom){
if($is_custom == BTemplate::IS_CUSTOM){
$customModuleModel = new CustomModule();
$info = $customModuleModel->read(['id'=>$source]);
if($info === false){
$this->fail('当前扩展模块不存在或已被删除');
}
//扩展模块定制
if($is_list == BTemplate::IS_LIST && $info['list_customized'] == BTemplate::IS_VISUALIZATION){
return BTemplate::IS_VISUALIZATION;
}
if($is_list == BTemplate::IS_DETAIL && $info['detail_customized'] == BTemplate::IS_VISUALIZATION){
return BTemplate::IS_VISUALIZATION;
}
}else{
$type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
//查看当前页面是否定制,是否开启可视化
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
if (in_array($type, $page_array)) {//是定制界面
return BTemplate::IS_VISUALIZATION;
}
}
return BTemplate::IS_NO_VISUALIZATION;
}
/**
* @remark :获取头部底部公共部分代码
* @name :getTemplateCommon
* @author :lyh
* @method :post
* @time :2024/2/2 11:02
*/
public function getTemplateCommon(){
}
/**
* @remark :获取装修中间内容
* @name :getTemplateMainHtml
* @author :lyh
* @method :post
* @time :2024/2/2 11:01
*/
public function getTemplateMainHtml(){
}
/**
* @remark :获取项目详情
* @name :getProjectInfo
* @author :lyh
* @method :post
* @time :2024/2/2 10:50
*/
public function getProjectInfo($project_id){
$projectModel = new Project();
$info = $projectModel->read(['id'=>$project_id],['id','is_customized']);
return $info;
}
/**
* @remark :拼接获取公共头部底部
* @name :getHeadFooter
* @author :lyh
* @method :post
* @time :2023/7/21 17:22
*/
public function getHeadFooter($html){
//获取公共主题头部底部
$serviceSettingModel = new ServiceSettingModel();
$list = $serviceSettingModel->list(['type'=>2],'created_at');
//拼接html
foreach ($list as $v){
if($v['key'] == 'head'){
$html = $v['values'].$html;
}
if($v['key'] == 'footer'){
$html = $html.$v['values'];
}
}
return $html;
}
/**
* @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;
}
}
... ... @@ -173,7 +173,7 @@ class BaseLogic extends Logic
$data['project_id'] = $this->user['project_id'];
$str = http_build_query($data);
$url = $this->user['domain'].'api/delHtml/?'.$str;
$rs = shell_exec('curl -k '.$url);
shell_exec('curl -k '.$url);
// curlGet($url);
return $this->success();
}
... ...
... ... @@ -88,7 +88,7 @@ class CountLogic extends BaseLogic
* @time :2023/5/24 14:03
*/
public function keyword_data_count(){
$yesterday = date('Y-m-d');
$yesterday = Carbon::yesterday()->toDateString();
$rankDataModel = new RankDataModel();
$param = [
'updated_date' => $yesterday,
... ...
... ... @@ -42,16 +42,19 @@ class WebSettingServiceLogic extends BaseLogic
$this->param['data'] = Common::uniqueMultiArray($this->param['data']);
//删除以前的数据
$this->model->del(['project_id'=>$this->user['project_id']]);
$data = [];
foreach ($this->param['data'] as $k => $v){
if(!isset($v['values']) || empty($v['values'])){
$v['values'] = '';
if(isset($v['values']) && empty($v['values'])){
$v['project_id'] = $this->user['project_id'];
$v['created_at'] = date('Y-m-d H:i:s');
$v['updated_at'] = date('Y-m-d H:i:s');
$data[] = $v;
}
$v['project_id'] = $this->user['project_id'];
$v['created_at'] = date('Y-m-d H:i:s');
$v['updated_at'] = date('Y-m-d H:i:s');
$this->param['data'][$k] = $v;
}
$this->model->insert($this->param['data']);
if(!empty($data)){
$this->model->insert($data);
}
DB::commit();
}catch (\Exception $e){
DB::rollBack();
... ...
... ... @@ -386,4 +386,5 @@ class UserLoginLogic
throw new AsideGlobalException($code, $message);
}
}
... ...
... ... @@ -55,6 +55,8 @@ class RouteMap extends Base
public static function generateRoute($title, $source, $source_id, $project_id){
if(preg_match('/[\x{4e00}-\x{9fa5}]/u', $title)){
$title = Translate::tran($title, 'en');
}elseif (preg_match('/[а-яА-Я]/u', $title)) {
$title = Translate::tran($title, 'en');
}
$i=1;
$sign = generateRoute($title);
... ...
<?php
/**
* Created by PhpStorm.
* User: zhl
* Date: 2024/2/19
* Time: 15:46
*/
namespace App\Services;
class CreateHtmlService
{
public function __construct(){}
/**
* 返回最终需要的HTML
* @return string
*/
public function getHtml($project, $route, $lang = [], $page = 0)
{
// 获取页面信息
$page_info = $this->getInfoByRoute($route);
// 根据项目和路由信息返回的结果确定当前页面使用5.0还是6.0的页面;
if ($project && $page_info) {
$html = $this->getHtmlV6($page_info['master_lang'], $lang = [], $page = 0);
} else {
$html = $this->getHtmlV5();
}
return $html;
}
/**
* 返回5.0页面最终HTML
* @return string
*/
public function getHtmlV5()
{
$html = '';
return $html;
}
/**
* 返回6.0页面最终HTML
* @return mixed
*/
public function getHtmlV6($master_lang, $lang = [], $page = 0)
{
// 初始化后续需要渲染页面需要的数据 路由、主语种、tdk、嵌入等信息
$origin_html = $this->originHtml();
$html = $this->renderData($origin_html, $page);
$html = $this->plugHead($html);
$html = $this->processFinal($html);
/** ... 调用其他方法, 直至返回完整的正确的HTML */
return $html;
}
/**
* 根据路由信息 返回 路由属性及详细信息
* @param string $route
* @return array
*/
public function getInfoByRoute($route)
{
// TODO 获取详情需要通过路由查下路由信息, 以及数据信息, 要处理特殊几个路由: top-search、products、news、blog, 这几个如果存在就用查下的信息, 如果不存在要初始化信息
return [];
}
/**
* 获取可视化HTML
* @return string
*/
public function originHtml()
{
$html = '根据路由查询数据库,并拼装HTML';
return $html;
}
/**
* 补充其他信息
* TDK mate信息等
* @param $html
* @return mixed
*/
public function plugHead($html)
{
/** 渲染tdk信息、 mate信息、 嵌入信息、 图标信息*/
return $html;
}
/**
* 处理最终信息
* 处理标签、最后代码标识、特殊规则或者字符等
* @param string $html
* @return string
*/
public function processFinal($html)
{
return $html;
}
/**
* 渲染页面数据
* @param string $html
* @return string
*/
public function renderData($html, $page)
{
/**
* 根据可视化HTML中关键词渲染数据
* 这个方法还需要进行拆分, 这个功能内容应该会比较多
* 并且还会根据路由信息和分页信息不同, 渲染不同数据, 只要针对列表页面
*/
return $html;
}
}
\ No newline at end of file
... ...
<?php
/**
* @remark :
* @name :GeneratePageService.php
* @author :lyh
* @method :post
* @time :2024/2/19 15:54
*/
namespace App\Services;
use App\Models\CustomModule\CustomModule;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\CustomModule\CustomModuleContent;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BTemplate;
use App\Models\Template\BTemplateCommon;
use App\Models\Template\BTemplateMain;
use App\Models\Template\Setting;
use App\Models\Template\Template;
use App\Models\Template\TemplateTypeMain;
use Illuminate\Support\Facades\DB;
class GeneratePageService
{
protected $route;
protected $param;
protected $project_id = 0;
public function __construct(){
$this->param = request()->all();
$this->route = $this->param['route'];
$this->project_id = $this->param['project_id'];
}
/**
* @remark :生成单页数据
* @name :generateHtml
* @author :lyh
* @method :post
* @time :2024/2/19 16:57
*/
public function generateHtml(){
ProjectServer::useProject($this->project_id);
$routeMapModel = new RouteMap();
$routeInfo = $routeMapModel->read(['route'=>$this->param['route']]);
if($this->param['route'] != RouteMap::SOURCE_INDEX && $routeInfo['source'] == RouteMap::SOURCE_PAGE){
//页面管理单独处理
}else{
$this->handleParam($routeInfo);
$this->getTemplateHtml();
}
DB::disconnect('custom_mysql');
return true;
}
/**
* @remark :生成页面参数处理
* @name :generateHtml
* @author :lyh
* @method :post
* @time :2024/2/19 16:36
*/
public function handleParam($routeInfo){
switch ($routeInfo['source']){
case RouteMap::SOURCE_PRODUCT:
$this->param['source'] = BTemplate::SOURCE_PRODUCT;
$this->param['is_list'] = BTemplate::IS_DETAIL;
break;
case RouteMap::SOURCE_PRODUCT_CATE:
$this->param['source'] = BTemplate::SOURCE_PRODUCT;
$this->param['is_list'] = BTemplate::IS_LIST;
break;
case RouteMap::SOURCE_BLOG:
$this->param['source'] = BTemplate::SOURCE_BLOG;
$this->param['is_list'] = BTemplate::IS_DETAIL;
break;
case RouteMap::SOURCE_BLOG_CATE:
$this->param['source'] = BTemplate::SOURCE_BLOG;
$this->param['is_list'] = BTemplate::IS_LIST;
break;
case RouteMap::SOURCE_NEWS:
$this->param['source'] = BTemplate::SOURCE_NEWS;
$this->param['is_list'] = BTemplate::IS_DETAIL;
break;
case RouteMap::SOURCE_NEWS_CATE:
$this->param['source'] = BTemplate::SOURCE_NEWS;
$this->param['is_list'] = BTemplate::IS_LIST;
break;
case RouteMap::SOURCE_MODULE:
$this->param['is_custom'] = BTemplate::IS_CUSTOM;
//TODO::获取对应模块数据
$moduleModel = new CustomModuleContent();
$moduleInfo = $moduleModel->read(['id'=>$routeInfo['source_id']],['module_id']);
$this->param['source'] = $moduleInfo['id'] ?? 0;
$this->param['is_list'] = BTemplate::IS_DETAIL;
break;
case RouteMap::SOURCE_MODULE_CATE:
$this->param['is_custom'] = BTemplate::IS_CUSTOM;
//TODO::获取对应模块数据
$moduleModel = new CustomModuleCategory();
$moduleInfo = $moduleModel->read(['id'=>$routeInfo['source_id']],['module_id']);
$this->param['source'] = $moduleInfo['id'] ?? 0;
$this->param['is_list'] = BTemplate::IS_LIST;
break;
default:
$this->param['source'] = BTemplate::SOURCE_HOME;
$this->param['is_list'] = BTemplate::IS_DETAIL;
break;
return true;
}
}
/**
* @notes: 请简要描述方法功能
* @param array $data
* @return array
*/
public function success($data = [])
{
return $data;
}
/**
* @remark :获取html
* @name :getTemplateHtml
* @author :lyh
* @method :post
*/
public function getTemplateHtml(){
$is_custom = $this->param['is_custom'] ?? 0;//是否为扩展模块
$is_list = $this->param['is_list'] ?? 0;//是否为列表页
$template_id = $this->getSettingTemplate($this->param['source'],$is_list,$is_custom);//设置的模版id
$templateInfo = $this->webTemplateInfo($this->param['source'],$this->param['source_id'],$template_id,$is_custom,$is_list);
if($templateInfo === false){
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//处理定制页面初始数据
$html = $this->customizedReturnHtml($this->param['source'],$template_id,$is_custom,$is_list);
if($html !== false){
return $this->success($html);
}
}
//非定制初始中间部分
$mainInfo = $this->getMAinHtml($this->param['source'],$is_custom,$is_list);//获取中间部分代码
}else{
if($templateInfo['type'] == BTemplate::ALL_HTML){//返回整个html代码
return $this->getCustomizeAllHtml($templateInfo,$template_id,$is_custom,$is_list);
}
$mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']];
}
$commonInfo = $this->getCommonHtml($this->param['source'],$is_list,$template_id,$is_custom);//获取非定制头部
$html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html'];
$html = $this->getHeadFooter($html);
$result = ['html'=>$html,'template_id'=>$template_id];
return $this->success($result);
}
/**
* @remark :获取整个html代码
* @name :getCustomizeAllHtml
* @author :lyh
* @method :post
* @time :2024/1/10 14:15
*/
public function getCustomizeAllHtml($templateInfo,$template_id,$is_custom,$is_list){
if($is_custom == BTemplate::IS_CUSTOM){
$commonInfo = $this->getCustomizedCommonHtml($this->param['source'],$is_custom,$is_list);//获取定制头部
$html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
}else{
$type = $this->getCustomizedType($this->param['source'],$is_list);
$commonInfo = $this->getCustomizedCommonHtml($type,$is_custom,$is_list);//获取定制头部
$html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
}
return $this->success(['html'=>$html,'template_id'=>$template_id]);
}
/**
* @remark :获取装修详情
* @name :webTemplateInfo
* @author :lyh
* @method :post
* @time :2024/1/10 13:43
*/
public function webTemplateInfo($source,$source_id,$template_id,$is_custom,$is_list){
$templateInfo = $this->model->read([
'template_id'=>$template_id, 'source'=>$source,
'project_id'=>$this->user['project_id'], 'source_id'=>$source_id,
'is_custom'=>$is_custom, 'is_list'=>$is_list
]);
return $this->success($templateInfo);
}
/**
* @remark :定制页面获取html
* @name :customizedReturnHtml
* @author :lyh
* @method :post
* @time :2024/1/10 13:46
*/
public function customizedReturnHtml($source,$template_id,$is_custom,$is_list){
//TODO::扩展模块定制单独处理
if($is_custom == BTemplate::IS_CUSTOM){
$customModuleModel = new CustomModule();
$info = $customModuleModel->read(['id'=>$source]);
if($info === false){
$this->fail('当前扩展模块不存在或已被删除');
}
//扩展模块定制
if($is_list == BTemplate::IS_LIST && $info['list_customized'] == BTemplate::IS_VISUALIZATION){
$html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom);
return $this->success(['html'=>$html,'template_id'=>$template_id]);
}
if($is_list == BTemplate::IS_DETAIL && $info['detail_customized'] == BTemplate::IS_VISUALIZATION){
$html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom);
return $this->success(['html'=>$html,'template_id'=>$template_id]);
}
return false;
}
//TODO::默认模块定制
$html = $this->isCustomizedPage($source,$is_list,$is_custom);//获取定制页面的html
if(!empty($html)){
return $this->success(['html'=>$html,'template_id'=>$template_id]);
}
return false;
}
/**
* @remark :扩展模块定制html
* @name :customModuleInfo
* @author :lyh
* @method :post
* @time :2024/1/10 9:20
*/
public function customModuleCustomizeHtml($source,$is_list,$is_custom){
$bTemplateMainModel = new BTemplateMain();
//TODO::获取初始代码
$customHtmlInfo = $bTemplateMainModel->read(['type'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom]);
if($customHtmlInfo === false){
$this->fail('定制页面,请先上传代码块');
}
$commonInfo = $this->getCustomizedCommonHtml($source,$is_custom,$is_list);//获取定制头部
if($commonInfo !== false){
$customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']);
}
return $customHtmlInfo['main_html'];
}
/**
* @remark :获取中间部分的html
* @name :getMAinHtml
* @author :lyh
* @method :post
* @time :2023/12/27 15:00
*/
public function getMAinHtml($type,$is_custom,$is_list){
//获取设置的默认中间部分
$bTemplateMainModel = new BTemplateMain();
$mainInfo = $bTemplateMainModel->read(['type'=>$type,'is_list'=>$is_list,'is_custom'=>$is_custom]);
if($mainInfo === false){
$main_html = $this->getInitModule($type,$is_custom,$is_list);
$main_css = "<style id='globalsojs-styles'></style>";
}else{
$main_html = $mainInfo['main_html'];
$main_css = $mainInfo['main_css'];
}
return ['main_html'=>$main_html,'main_css'=>$main_css];
}
/**
* @remark :默认复合页数据
* @name :getProductModule
* @author :lyh
* @method :post
* @time :2023/7/27 15:08
*/
public function getInitModule($type,$is_custom,$is_list){
if($is_custom == BTemplate::IS_CUSTOM) {
$type = BTemplate::SOURCE_CUSTOM;
}
$mainModel = new TemplateTypeMain();
$info = $mainModel->read(['type'=>$type,'is_list'=>$is_list]);
return $info['main_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 :页面是否为定制页面获取初始代码
* @name :watchProjectIsCustomized
* @author :lyh
* @method :post
* @time :2023/12/13 10:55
*/
public function isCustomizedPage($source,$is_list,$is_custom)
{
$type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
//查看当前页面是否定制,是否开启可视化
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
if (in_array($type, $page_array)) {//是定制界面
//TODO::获取初始代码
$bTemplateMainModel = new BTemplateMain();
$customHtmlInfo = $bTemplateMainModel->read(['type'=>$source,'is_custom'=>$is_custom,'is_list'=>$is_list]);
if($customHtmlInfo === false){
$this->fail('定制页面,请先上传代码块');
}
$commonInfo = $this->getCustomizedCommonHtml($type,$is_custom,$is_list);//获取定制头部
if($commonInfo !== false){
$customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']);
}
return $customHtmlInfo['main_html'];
}
return false;
}
/**
* @remark :定制项目获取头部底部
* @name :getCustomizedCommonHtml
* @author :lyh
* @method :post
* @time :2023/12/29 13:13
*/
public function getCustomizedCommonHtml($type,$is_custom = 0,$is_list = 0){
$data = [
'template_id' => 0,
'project_id' => $this->user['project_id'],
'type'=>$type,
'is_custom'=>$is_custom,
'is_list'=>$is_list
];
$commonTemplateModel = new BTemplateCommon();
return $commonTemplateModel->read($data);
}
/**
* @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 :getSettingTemplate
* @author :lyh
* @method :post
* @time :2023/12/13 10:48
*/
public function getSettingTemplate($source,$is_list,$is_custom){
$template_id = 0;
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION) {//定制项目
if($is_custom == BTemplate::IS_CUSTOM){
$customModuleModel = new CustomModule();
$info = $customModuleModel->read(['id'=>$source]);
if($info === false){
return false;
}
if($info['list_customized'] == BTemplate::IS_VISUALIZATION && $is_list == BTemplate::IS_LIST){
return $this->success($template_id);
}
if($info['detail_customized'] == BTemplate::IS_VISUALIZATION && $is_list == BTemplate::IS_DETAIL){
return $this->success($template_id);
}
}else{
$type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
//查看当前页面是否定制,是否开启可视化
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
if (in_array($type, $page_array)) {//是定制界面
return $this->success($template_id);
}
}
}
$bSettingModel = new Setting();
$info = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
if($info === false){
$this->fail('请先选择模版');
}
$template_id = $info['template_id'];
return $this->success($template_id);
}
/**
* @remark :根据类型获取公共头和底
* @name :getCommonPage
* @author :lyh
* @method :post
* @time :2023/10/21 16:55
*/
public function getCommonHtml($source,$is_list,$template_id,$is_custom = 0){
$type = $this->getType($source,$is_list,$is_custom);
$data = [
'template_id' => $template_id,
'project_id' => $this->user['project_id'],
'type'=>$type,
'is_custom'=>0,
];
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read($data);
if($commonInfo === false){
$data['type'] = BTemplate::SOURCE_HOME;
$commonInfo = $commonTemplateModel->read($data);
}
return $this->success($commonInfo);
}
}
... ...
... ... @@ -19,6 +19,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/get_project', [\App\Http\Controllers\Bside\BCom\ComController::class, 'get_project'])->name('get_project');
Route::any('/generateToken', [\App\Http\Controllers\Bside\BCom\ComController::class, 'generateToken'])->name('generateToken');
Route::any('/getLink', [\App\Http\Controllers\Bside\BCom\ComController::class, 'getLink'])->name('getLink');
Route::any('/getMobileProject', [\App\Http\Controllers\Bside\BCom\ComController::class, 'getMobileProject'])->name('getMobileProject');
//用户相关路由
Route::prefix('user')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\User\UserController::class, 'lists'])->name('user_lists');
... ...