+86 19895983967
++86
diff --git a/app/admin/controller/SiteSettingsController.php b/app/admin/controller/SiteSettingsController.php index 31adab4..cb35e59 100644 --- a/app/admin/controller/SiteSettingsController.php +++ b/app/admin/controller/SiteSettingsController.php @@ -43,7 +43,7 @@ class SiteSettingsController extends BaseController $data = [ 'sitename' => $siteSetting->sitename ?? '', 'logo' => $siteSetting->logo ?? '', - 'logow' => $siteSetting->{'logo-w'} ?? '', + 'logow' => $siteSetting->logow ?? '', 'description' => $siteSetting->description ?? '', 'copyright' => $siteSetting->copyright ?? '', 'companyname' => $siteSetting->companyname ?? '', @@ -89,7 +89,7 @@ class SiteSettingsController extends BaseController $siteSetting->logo = (string)$rawData['logo']; } if (isset($rawData['logow'])) { - $siteSetting->{'logo-w'} = (string)$rawData['logow']; + $siteSetting->logow = (string)$rawData['logow']; } if (isset($rawData['description'])) { $siteSetting->description = (string)$rawData['description']; @@ -300,4 +300,77 @@ class SiteSettingsController extends BaseController return json(['code' => 200, 'msg' => '企业信息保存成功']); } + + /** + * 获取企业SEO + * @return Json + */ + public function getCompanySeo() + { + // 获取当前租户ID + $tid = $this->getTenantId(); + + // 直接根据 ID 查询租户记录 + $tenant = Tenant::where('delete_time', null) + ->where('id', $tid) + ->field('seoTitle, seoKeywords, seoDescription') + ->find(); + + // 如果没有数据,返回默认空值 + if (!$tenant) { + $data = [ + 'seoTitle' => '', + 'seoKeywords' => '', + 'seoDescription' => '' + ]; + } else { + // 直接读取模型对象的属性 + $data = [ + 'seoTitle' => $tenant->seoTitle ?? '', + 'seoKeywords' => $tenant->seoKeywords ?? '', + 'seoDescription' => $tenant->seoDescription ?? '' + ]; + } + + $this->logSuccess('站点设置管理', '查看企业SEO', ['tid' => $tid], $this->getAdminUserInfo()); + + return json([ + 'code' => 200, + 'msg' => '获取成功', + 'data' => $data + ]); + } + + /** + * 保存企业SEO + * @return Json + */ + public function saveCompanySeo() + { + $params = $this->request->param(); + + $id = $this->getTenantId(); + + $tenant = Tenant::where('delete_time', null) + ->where('id', $id) + ->find(); + + if (!$tenant) { + return json(['code' => 404, 'msg' => '租户不存在']); + } + + // 构建更新数据 + $updateData = []; + if (isset($params['seoTitle'])) $updateData['seoTitle'] = (string)$params['seoTitle']; + if (isset($params['seoKeywords'])) $updateData['seoKeywords'] = (string)$params['seoKeywords']; + if (isset($params['seoDescription'])) $updateData['seoDescription'] = (string)$params['seoDescription']; + + if (!empty($updateData)) { + $tenant->save($updateData); + } + + $this->logSuccess('站点设置管理', '保存企业SEO', ['tid' => $id], $this->getAdminUserInfo()); + + return json(['code' => 200, 'msg' => '企业SEO保存成功']); + } } diff --git a/app/admin/route/routes/siteSettings.php b/app/admin/route/routes/siteSettings.php index 0beff17..3a6201f 100644 --- a/app/admin/route/routes/siteSettings.php +++ b/app/admin/route/routes/siteSettings.php @@ -10,3 +10,5 @@ Route::get('legalInfos', 'app\\admin\\controller\\SiteSettingsController@getLega Route::post('saveLegalInfos', 'app\\admin\\controller\\SiteSettingsController@saveLegalInfos'); Route::get('companyInfos', 'app\\admin\\controller\\SiteSettingsController@getCompanyInfos'); Route::post('saveCompanyInfos', 'app\\admin\\controller\\SiteSettingsController@saveCompanyInfos'); +Route::get('companySeo', 'app\\admin\\controller\\SiteSettingsController@getCompanySeo'); +Route::post('saveCompanySeo', 'app\\admin\\controller\\SiteSettingsController@saveCompanySeo'); diff --git a/app/index/controller/Index.php b/app/index/controller/Index.php index 4c4eb1b..8ab2eea 100644 --- a/app/index/controller/Index.php +++ b/app/index/controller/Index.php @@ -14,6 +14,8 @@ use think\db\exception\DbException; use think\facade\Env; use think\facade\Request; use app\model\Cms\TemplateSiteConfig; +use app\model\Tenant\Tenant; +use app\model\Cms\Demand; class Index extends BaseController { @@ -347,4 +349,95 @@ class Index extends BaseController ]); } } -} + + /** + * 获取企业信息 + * @return \think\response\Json + */ + public function getCompanyInfos() + { + // 从基类获取租户ID + $tid = $this->tenantId; + + try { + $companyInfo = Tenant::where('delete_time', null) + ->where('id', $tid) + ->field('contact_phone, contact_email, address, worktime') + ->find(); + + return json([ + 'code' => 200, + 'msg' => 'success', + 'data' => $companyInfo ?: null + ]); + } catch (DbException $e) { + return json([ + 'code' => 500, + 'msg' => 'fail:' . $e->getMessage(), + 'data' => null + ]); + } + } + + /** + * 客户需求接口 + * post /index/requirement + * @param string $title 标题 + * @param string $desc 描述 + * @param string $applicant 申请人 + * @param string $phone 手机号 + * @return \think\response\Json + */ + public function requirement() + { + // 获取参数 + $title = Request::param('title', ''); + $desc = Request::param('desc', ''); + $applicant = Request::param('applicant', ''); + $phone = Request::param('phone', ''); + + // 验证必填字段 + if (empty($title)) { + return json([ + 'code' => 400, + 'msg' => '标题不能为空', + 'data' => null + ]); + } + if (empty($desc)) { + return json([ + 'code' => 400, + 'msg' => '描述不能为空', + 'data' => null + ]); + } + + // 从基类获取租户ID + $tid = $this->tenantId; + + try { + // 保存到需求表 + $id = Demand::insertGetId([ + 'tid' => $tid, + 'title' => $title, + 'desc' => $desc, + 'applicant' => $applicant, + 'phone' => $phone, + 'status' => 1, + 'create_time' => date('Y-m-d H:i:s') + ]); + + return json([ + 'code' => 200, + 'msg' => '提交成功', + 'data' => ['id' => $id] + ]); + } catch (DbException $e) { + return json([ + 'code' => 500, + 'msg' => '提交失败:' . $e->getMessage(), + 'data' => null + ]); + } + } +} \ No newline at end of file diff --git a/app/index/route/app.php b/app/index/route/app.php index 0d1c507..7cedd08 100644 --- a/app/index/route/app.php +++ b/app/index/route/app.php @@ -8,8 +8,12 @@ Route::get('index/index', 'app\index\controller\Index@index'); // --- 模板初始化接口 --- Route::get('init', 'app\index\controller\Index@init'); -// --- 前端底部数据路由 --- +// --- 前端其他数据路由 --- Route::get('footerdata', 'app\index\controller\Index@getFooterData'); +Route::get('companyInfos', 'app\index\controller\Index@getCompanyInfos'); +Route::post('requirement', 'app\index\controller\Index@requirement'); + +// --- 客户需求路由 --- // --- 文章列表路由 --- Route::get('getCenterNews', 'app\index\controller\Article\NewsCenterController@getCenterNews'); diff --git a/app/model/System/SystemSiteSetting.php b/app/model/System/SystemSiteSetting.php index a144724..bb93125 100644 --- a/app/model/System/SystemSiteSetting.php +++ b/app/model/System/SystemSiteSetting.php @@ -31,7 +31,7 @@ class SystemSiteSetting extends Model 'tid' => 'integer', 'sitename' => 'string', 'logo' => 'string', - 'logo-w' => 'string', + 'logow' => 'string', 'description' => 'string', 'copyright' => 'string', 'companyname' => 'string', diff --git a/app/model/Tenant/Tenant.php b/app/model/Tenant/Tenant.php index 8d4e2dd..8c57621 100644 --- a/app/model/Tenant/Tenant.php +++ b/app/model/Tenant/Tenant.php @@ -31,6 +31,9 @@ class Tenant extends Model 'contact_email' => 'string', 'address' => 'string', 'worktime' => 'string', + 'seoTitle' => 'string', + 'seoKeywords' => 'string', + 'seoDescription' => 'string', 'status' => 'integer', 'create_time' => 'datetime', 'update_time' => 'datetime', diff --git a/public/storage/uploads/2026/03/11/69b12bf9ac509.png b/public/storage/uploads/2026/03/11/69b12bf9ac509.png new file mode 100644 index 0000000..495c3bd Binary files /dev/null and b/public/storage/uploads/2026/03/11/69b12bf9ac509.png differ diff --git a/public/storage/uploads/2026/03/11/69b12c0515188.png b/public/storage/uploads/2026/03/11/69b12c0515188.png new file mode 100644 index 0000000..17619e0 Binary files /dev/null and b/public/storage/uploads/2026/03/11/69b12c0515188.png differ diff --git a/public/themes/default/index.php b/public/themes/default/index.php index c40b17e..4db1dab 100644 --- a/public/themes/default/index.php +++ b/public/themes/default/index.php @@ -1,5 +1,110 @@ initialize(); + +// 获取当前域名 +$host = $_SERVER['HTTP_HOST'] ?? ''; + +// 查询域名对应的租户ID +$tenantDomain = TenantDomain::where('full_domain', $host) + ->where('status', 1) + ->whereNull('delete_time') + ->find(); + +$tid = $tenantDomain ? (int)$tenantDomain['tid'] : 0; + +// 获取 Banner 数据 +$banners = []; +if ($tid > 0) { + $banners = Banner::where('tid', $tid) + ->whereNull('delete_time') + ->order('sort', 'asc') + ->order('id', 'desc') + ->select() + ->toArray(); + + // 处理图片路径 + foreach ($banners as &$banner) { + if (!empty($banner['image'])) { + if (!preg_match('/^https?:\/\//', $banner['image'])) { + $scheme = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http'; + $banner['image'] = $scheme . '://' . $host . + (strpos($banner['image'], '/') === 0 ? '' : '/') . $banner['image']; + } + } + } +} + +// 获取新闻数据 +$articles = []; +if ($tid > 0) { + $articles = Articles::where('tid', $tid) + ->where('delete_time', null) + ->where('status', 2) + ->order('publish_date', 'desc') + ->limit(8) + ->select() + ->toArray(); + + // 处理图片:如果文章image为空,则取分类的image + foreach ($articles as &$article) { + if (empty($article['image']) && !empty($article['cate'])) { + $category = ArticlesCategory::where('id', $article['cate']) + ->where('delete_time', null) + ->find(); + if ($category && !empty($category['image'])) { + $article['image'] = $category['image']; + } + } + // 处理图片路径 + if (!empty($article['image']) && !preg_match('/^https?:\/\//', $article['image'])) { + $scheme = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http'; + $article['image'] = $scheme . '://' . $host . + (strpos($article['image'], '/') === 0 ? '' : '/') . $article['image']; + } + if (!empty($article['thumb']) && !preg_match('/^https?:\/\//', $article['thumb'])) { + $scheme = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http'; + $article['thumb'] = $scheme . '://' . $host . + (strpos($article['thumb'], '/') === 0 ? '' : '/') . $article['thumb']; + } + } +} + +// 获取企业联系信息 +$companyInfo = []; +if ($tid > 0) { + $companyInfo = Tenant::where('id', $tid) + ->where('delete_time', null) + ->field('contact_phone, contact_email, address, worktime') + ->find(); +}else{ + $companyInfo = [ + 'contact_phone' => '-', + 'contact_email' => '-', + 'address' => '-', + 'worktime' => '-' + ]; +} + +// 辅助函数:去除 HTML 标签 +function stripHtml($html) { + if (empty($html)) return ''; + $text = preg_replace('/<[^>]+>/', ' ', $html); + $text = preg_replace('/\s+/', ' ', $text); + return trim($text); +} ?> @@ -221,11 +326,11 @@
+86 19895983967
++86
lygyunze@gmail.com
-357099073@qq.com
+江苏省连云港市海州区润潮国际大厦
+