更新若干bug
This commit is contained in:
parent
f134b0e759
commit
e46a4100c7
@ -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保存成功']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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');
|
||||
|
||||
@ -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
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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');
|
||||
|
||||
@ -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',
|
||||
|
||||
@ -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',
|
||||
|
||||
BIN
public/storage/uploads/2026/03/11/69b12bf9ac509.png
Normal file
BIN
public/storage/uploads/2026/03/11/69b12bf9ac509.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 120 KiB |
BIN
public/storage/uploads/2026/03/11/69b12c0515188.png
Normal file
BIN
public/storage/uploads/2026/03/11/69b12c0515188.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.7 KiB |
@ -1,5 +1,110 @@
|
||||
<?php
|
||||
// 引入 ThinkPHP 应用
|
||||
require_once __DIR__ . '/../../../vendor/autoload.php';
|
||||
|
||||
use think\facade\Db;
|
||||
use think\App;
|
||||
use app\model\Tenant\TenantDomain;
|
||||
use app\model\Tenant\Tenant;
|
||||
use app\model\Cms\Banner;
|
||||
use app\model\Cms\Articles;
|
||||
use app\model\Cms\ArticlesCategory;
|
||||
|
||||
// 初始化应用
|
||||
$app = new App(__DIR__ . '/../../../');
|
||||
$app->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);
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html class="no-js" lang="">
|
||||
@ -221,11 +326,11 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-8">
|
||||
<div class="contact-form-wrapper">
|
||||
<form action="" method="">
|
||||
<form id="requirementForm" action="" method="">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="single-input">
|
||||
<input type="text" id="name" name="name" class="form-input" placeholder="姓名">
|
||||
<input type="text" id="applicant" name="applicant" class="form-input" placeholder="姓名">
|
||||
<i class="lni lni-user"></i>
|
||||
</div>
|
||||
</div>
|
||||
@ -237,67 +342,127 @@
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="single-input">
|
||||
<input type="text" id="number" name="number" class="form-input" placeholder="手机号">
|
||||
<input type="text" id="phone" name="phone" class="form-input" placeholder="手机号">
|
||||
<i class="lni lni-phone"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="single-input">
|
||||
<input type="text" id="subject" name="subject" class="form-input" placeholder="您的标题">
|
||||
<input type="text" id="title" name="title" class="form-input" placeholder="您的标题" required>
|
||||
<i class="lni lni-text-format"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<div class="single-input">
|
||||
<textarea name="message" id="message" class="form-input" placeholder="您的需求" rows="6"></textarea>
|
||||
<textarea name="desc" id="desc" class="form-input" placeholder="您的需求" rows="6" required></textarea>
|
||||
<i class="lni lni-comments-alt"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<div class="form-button">
|
||||
<button type="submit" class="button"> <i class="lni lni-telegram-original"></i> 提交</button>
|
||||
<button type="submit" class="button" id="submitBtn"> <i class="lni lni-telegram-original"></i> 提交</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- 需求提交脚本 -->
|
||||
<script>
|
||||
document.getElementById('requirementForm').addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const submitBtn = document.getElementById('submitBtn');
|
||||
submitBtn.disabled = true;
|
||||
submitBtn.innerHTML = '<i class="lni lni-spinner"></i> 提交中...';
|
||||
|
||||
const data = {
|
||||
title: document.getElementById('title').value,
|
||||
desc: document.getElementById('desc').value,
|
||||
applicant: document.getElementById('applicant').value,
|
||||
phone: document.getElementById('phone').value
|
||||
};
|
||||
|
||||
fetch('/index/requirement', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(result => {
|
||||
if (result.code === 200) {
|
||||
alert('提交成功!我们会尽快与您联系。');
|
||||
document.getElementById('requirementForm').reset();
|
||||
} else {
|
||||
alert(result.msg || '提交失败,请稍后重试');
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('提交失败:', err);
|
||||
alert('提交失败,请稍后重试');
|
||||
})
|
||||
.finally(() => {
|
||||
submitBtn.disabled = false;
|
||||
submitBtn.innerHTML = '<i class="lni lni-telegram-original"></i> 提交';
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-lg-4">
|
||||
<div class="left-wrapper">
|
||||
<div class="row">
|
||||
<?php if (!empty($companyInfo['contact_phone'])): ?>
|
||||
<div class="col-lg-12 col-md-6">
|
||||
<div class="single-item">
|
||||
<div class="icon">
|
||||
<i class="lni lni-phone"></i>
|
||||
</div>
|
||||
<div class="text">
|
||||
<p>+86 19895983967</p>
|
||||
<p>+86 <?php echo htmlspecialchars($companyInfo['contact_phone']); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($companyInfo['contact_email'])): ?>
|
||||
<div class="col-lg-12 col-md-6">
|
||||
<div class="single-item">
|
||||
<div class="icon">
|
||||
<i class="lni lni-envelope"></i>
|
||||
</div>
|
||||
<div class="text">
|
||||
<p>lygyunze@gmail.com</p>
|
||||
<p>357099073@qq.com</p>
|
||||
<p><?php echo htmlspecialchars($companyInfo['contact_email']); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($companyInfo['address'])): ?>
|
||||
<div class="col-lg-12 col-md-6">
|
||||
<div class="single-item">
|
||||
<div class="icon">
|
||||
<i class="lni lni-map-marker"></i>
|
||||
</div>
|
||||
<div class="text">
|
||||
<p>江苏省连云港市海州区润潮国际大厦</p>
|
||||
<p><?php echo htmlspecialchars($companyInfo['address']); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($companyInfo['worktime'])): ?>
|
||||
<div class="col-lg-12 col-md-6">
|
||||
<div class="single-item">
|
||||
<div class="icon">
|
||||
<i class="lni lni-timer"></i>
|
||||
</div>
|
||||
<div class="text">
|
||||
<p><?php echo htmlspecialchars($companyInfo['worktime']); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user