增加友链功能
This commit is contained in:
parent
e46a4100c7
commit
1f8d876cef
280
app/admin/controller/Cms/Friendlink/FriendlinkController.php
Normal file
280
app/admin/controller/Cms/Friendlink/FriendlinkController.php
Normal file
@ -0,0 +1,280 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace app\admin\controller\Cms\Friendlink;
|
||||||
|
|
||||||
|
use app\admin\BaseController;
|
||||||
|
use think\response\Json;
|
||||||
|
use app\model\Cms\Friendlink;
|
||||||
|
use think\exception\ValidateException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 友情链接管理控制器
|
||||||
|
*/
|
||||||
|
class FriendlinkController extends BaseController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 获取友情链接列表
|
||||||
|
* @return Json
|
||||||
|
*/
|
||||||
|
public function getList(): Json
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$page = (int)$this->request->param('page', 1);
|
||||||
|
$limit = (int)$this->request->param('limit', 10);
|
||||||
|
$keyword = $this->request->param('keyword', '');
|
||||||
|
$status = $this->request->param('status', '');
|
||||||
|
|
||||||
|
$query = Friendlink::where('delete_time', null)
|
||||||
|
->where('tid', $this->getTenantId());
|
||||||
|
|
||||||
|
// 关键词搜索
|
||||||
|
if (!empty($keyword)) {
|
||||||
|
$query->where('link_name', 'like', '%' . $keyword . '%');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 状态筛选
|
||||||
|
if ($status !== '') {
|
||||||
|
$query->where('status', (int)$status);
|
||||||
|
}
|
||||||
|
|
||||||
|
$total = $query->count();
|
||||||
|
$list = $query->order('sort', 'asc')
|
||||||
|
->order('id', 'desc')
|
||||||
|
->page($page, $limit)
|
||||||
|
->select()
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
return json([
|
||||||
|
'code' => 200,
|
||||||
|
'msg' => 'success',
|
||||||
|
'data' => [
|
||||||
|
'list' => $list,
|
||||||
|
'total' => $total
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return json([
|
||||||
|
'code' => 500,
|
||||||
|
'msg' => '获取失败:' . $e->getMessage(),
|
||||||
|
'data' => []
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有友情链接(用于下拉选择)
|
||||||
|
* @return Json
|
||||||
|
*/
|
||||||
|
public function getAll(): Json
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$list = Friendlink::where('delete_time', null)
|
||||||
|
->where('tid', $this->getTenantId())
|
||||||
|
->where('status', 1)
|
||||||
|
->order('sort', 'asc')
|
||||||
|
->field('id,link_name')
|
||||||
|
->select()
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
return json([
|
||||||
|
'code' => 200,
|
||||||
|
'msg' => 'success',
|
||||||
|
'data' => $list
|
||||||
|
]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return json([
|
||||||
|
'code' => 500,
|
||||||
|
'msg' => '获取失败:' . $e->getMessage(),
|
||||||
|
'data' => []
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加友情链接
|
||||||
|
* @return Json
|
||||||
|
*/
|
||||||
|
public function add(): Json
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$data = $this->request->param();
|
||||||
|
|
||||||
|
// 验证参数
|
||||||
|
$this->validate($data, [
|
||||||
|
'link_name|链接名称' => 'require|max:100',
|
||||||
|
'link_url|链接地址' => 'require|url|max:255',
|
||||||
|
'sort|排序' => 'integer',
|
||||||
|
'status|状态' => 'in:0,1'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$friendlink = new Friendlink();
|
||||||
|
$friendlink->tid = $this->getTenantId();
|
||||||
|
$friendlink->link_name = $data['link_name'];
|
||||||
|
$friendlink->link_url = $data['link_url'];
|
||||||
|
$friendlink->link_logo = $data['link_logo'] ?? '';
|
||||||
|
$friendlink->description = $data['description'] ?? '';
|
||||||
|
$friendlink->sort = $data['sort'] ?? 0;
|
||||||
|
$friendlink->status = $data['status'] ?? 1;
|
||||||
|
$friendlink->create_time = date('Y-m-d H:i:s');
|
||||||
|
$friendlink->save();
|
||||||
|
|
||||||
|
$this->logSuccess('友情链接', '添加链接', ['id' => $friendlink->id]);
|
||||||
|
|
||||||
|
return json([
|
||||||
|
'code' => 200,
|
||||||
|
'msg' => '添加成功',
|
||||||
|
'data' => $friendlink->toArray()
|
||||||
|
]);
|
||||||
|
} catch (ValidateException $e) {
|
||||||
|
return json([
|
||||||
|
'code' => 400,
|
||||||
|
'msg' => $e->getError()
|
||||||
|
]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->logFail('友情链接', '添加链接', $e->getMessage());
|
||||||
|
return json([
|
||||||
|
'code' => 500,
|
||||||
|
'msg' => '添加失败:' . $e->getMessage()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新友情链接
|
||||||
|
* @param int $id
|
||||||
|
* @return Json
|
||||||
|
*/
|
||||||
|
public function update(int $id): Json
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$data = $this->request->param();
|
||||||
|
|
||||||
|
$friendlink = Friendlink::where('id', $id)
|
||||||
|
->where('tid', $this->getTenantId())
|
||||||
|
->where('delete_time', null)
|
||||||
|
->find();
|
||||||
|
|
||||||
|
if (!$friendlink) {
|
||||||
|
return json([
|
||||||
|
'code' => 404,
|
||||||
|
'msg' => '链接不存在'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证参数
|
||||||
|
if (isset($data['link_name'])) {
|
||||||
|
$this->validate($data, [
|
||||||
|
'link_name|链接名称' => 'require|max:100'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
if (isset($data['link_url'])) {
|
||||||
|
$this->validate($data, [
|
||||||
|
'link_url|链接地址' => 'require|url|max:255'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($data['link_name'])) $friendlink->link_name = $data['link_name'];
|
||||||
|
if (isset($data['link_url'])) $friendlink->link_url = $data['link_url'];
|
||||||
|
if (isset($data['link_logo'])) $friendlink->link_logo = $data['link_logo'];
|
||||||
|
if (isset($data['description'])) $friendlink->description = $data['description'];
|
||||||
|
if (isset($data['sort'])) $friendlink->sort = $data['sort'];
|
||||||
|
if (isset($data['status'])) $friendlink->status = $data['status'];
|
||||||
|
$friendlink->update_time = date('Y-m-d H:i:s');
|
||||||
|
$friendlink->save();
|
||||||
|
|
||||||
|
$this->logSuccess('友情链接', '更新链接', ['id' => $id]);
|
||||||
|
|
||||||
|
return json([
|
||||||
|
'code' => 200,
|
||||||
|
'msg' => '更新成功',
|
||||||
|
'data' => $friendlink->toArray()
|
||||||
|
]);
|
||||||
|
} catch (ValidateException $e) {
|
||||||
|
return json([
|
||||||
|
'code' => 400,
|
||||||
|
'msg' => $e->getError()
|
||||||
|
]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->logFail('友情链接', '更新链接', $e->getMessage());
|
||||||
|
return json([
|
||||||
|
'code' => 500,
|
||||||
|
'msg' => '更新失败:' . $e->getMessage()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除友情链接
|
||||||
|
* @param int $id
|
||||||
|
* @return Json
|
||||||
|
*/
|
||||||
|
public function delete(int $id): Json
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$friendlink = Friendlink::where('id', $id)
|
||||||
|
->where('tid', $this->getTenantId())
|
||||||
|
->where('delete_time', null)
|
||||||
|
->find();
|
||||||
|
|
||||||
|
if (!$friendlink) {
|
||||||
|
return json([
|
||||||
|
'code' => 404,
|
||||||
|
'msg' => '链接不存在'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$friendlink->delete();
|
||||||
|
|
||||||
|
$this->logSuccess('友情链接', '删除链接', ['id' => $id]);
|
||||||
|
|
||||||
|
return json([
|
||||||
|
'code' => 200,
|
||||||
|
'msg' => '删除成功'
|
||||||
|
]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->logFail('友情链接', '删除链接', $e->getMessage());
|
||||||
|
return json([
|
||||||
|
'code' => 500,
|
||||||
|
'msg' => '删除失败:' . $e->getMessage()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除友情链接
|
||||||
|
* @return Json
|
||||||
|
*/
|
||||||
|
public function batchDelete(): Json
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$ids = $this->request->param('ids', []);
|
||||||
|
|
||||||
|
if (empty($ids)) {
|
||||||
|
return json([
|
||||||
|
'code' => 400,
|
||||||
|
'msg' => '请选择要删除的链接'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Friendlink::whereIn('id', $ids)
|
||||||
|
->where('tid', $this->getTenantId())
|
||||||
|
->where('delete_time', null)
|
||||||
|
->update(['delete_time' => date('Y-m-d H:i:s')]);
|
||||||
|
|
||||||
|
$this->logSuccess('友情链接', '批量删除链接', ['ids' => $ids]);
|
||||||
|
|
||||||
|
return json([
|
||||||
|
'code' => 200,
|
||||||
|
'msg' => '批量删除成功'
|
||||||
|
]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->logFail('友情链接', '批量删除链接', $e->getMessage());
|
||||||
|
return json([
|
||||||
|
'code' => 500,
|
||||||
|
'msg' => '批量删除失败:' . $e->getMessage()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
10
app/admin/route/routes/friendlink.php
Normal file
10
app/admin/route/routes/friendlink.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
use think\facade\Route;
|
||||||
|
|
||||||
|
// 友情链接路由
|
||||||
|
Route::get('friendlinks', 'app\admin\controller\Cms\Friendlink\FriendlinkController@getList');
|
||||||
|
Route::get('friendlinks/all', 'app\admin\controller\Cms\Friendlink\FriendlinkController@getAll');
|
||||||
|
Route::post('friendlinks', 'app\admin\controller\Cms\Friendlink\FriendlinkController@add');
|
||||||
|
Route::put('friendlinks/:id', 'app\admin\controller\Cms\Friendlink\FriendlinkController@update');
|
||||||
|
Route::delete('friendlinks/:id', 'app\admin\controller\Cms\Friendlink\FriendlinkController@delete');
|
||||||
|
Route::post('friendlinks/batchdelete', 'app\admin\controller\Cms\Friendlink\FriendlinkController@batchDelete');
|
||||||
@ -109,6 +109,33 @@ abstract class BaseController
|
|||||||
return $this->tenantId;
|
return $this->tenantId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据域名获取租户ID(静态方法,方便全局调用)
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function getTenantIdByDomain(): int
|
||||||
|
{
|
||||||
|
$request = request();
|
||||||
|
|
||||||
|
// 优先从 Referer 获取来源域名(跨域调用场景)
|
||||||
|
$referer = $request->header('Referer');
|
||||||
|
if ($referer) {
|
||||||
|
$host = parse_url($referer, PHP_URL_HOST);
|
||||||
|
} else {
|
||||||
|
// 否则使用当前访问域名
|
||||||
|
$host = $request->host(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询域名对应的租户ID
|
||||||
|
$tenantDomain = Db::name('mete_tenant_domain')
|
||||||
|
->where('full_domain', $host)
|
||||||
|
->where('status', 1)
|
||||||
|
->whereNull('delete_time')
|
||||||
|
->find();
|
||||||
|
|
||||||
|
return $tenantDomain ? (int)$tenantDomain['tid'] : 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证数据
|
* 验证数据
|
||||||
* @access protected
|
* @access protected
|
||||||
|
|||||||
@ -14,8 +14,7 @@ use think\db\exception\DbException;
|
|||||||
use think\facade\Env;
|
use think\facade\Env;
|
||||||
use think\facade\Request;
|
use think\facade\Request;
|
||||||
use app\model\Cms\TemplateSiteConfig;
|
use app\model\Cms\TemplateSiteConfig;
|
||||||
use app\model\Tenant\Tenant;
|
use app\model\Cms\Friendlink;
|
||||||
use app\model\Cms\Demand;
|
|
||||||
|
|
||||||
class Index extends BaseController
|
class Index extends BaseController
|
||||||
{
|
{
|
||||||
@ -351,24 +350,35 @@ class Index extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取企业信息
|
* 获取友情链接列表
|
||||||
* @return \think\response\Json
|
* @return \think\response\Json
|
||||||
*/
|
*/
|
||||||
public function getCompanyInfos()
|
public function getFriendlinkList()
|
||||||
{
|
{
|
||||||
// 从基类获取租户ID
|
|
||||||
$tid = $this->tenantId;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$companyInfo = Tenant::where('delete_time', null)
|
// 通过域名获取租户ID
|
||||||
->where('id', $tid)
|
$tid = BaseController::getTenantIdByDomain();
|
||||||
->field('contact_phone, contact_email, address, worktime')
|
|
||||||
->find();
|
if (empty($tid)) {
|
||||||
|
return json([
|
||||||
|
'code' => 400,
|
||||||
|
'msg' => '无法识别租户信息',
|
||||||
|
'data' => []
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$friendlinkList = Friendlink::where('delete_time', null)
|
||||||
|
->where('tid', $tid)
|
||||||
|
->where('status', 1)
|
||||||
|
->order('sort', 'asc')
|
||||||
|
->field('id,link_name,link_url,link_logo,description')
|
||||||
|
->select()
|
||||||
|
->toArray();
|
||||||
|
|
||||||
return json([
|
return json([
|
||||||
'code' => 200,
|
'code' => 200,
|
||||||
'msg' => 'success',
|
'msg' => 'success',
|
||||||
'data' => $companyInfo ?: null
|
'data' => $friendlinkList
|
||||||
]);
|
]);
|
||||||
} catch (DbException $e) {
|
} catch (DbException $e) {
|
||||||
return json([
|
return json([
|
||||||
@ -378,66 +388,4 @@ class Index extends BaseController
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
|
||||||
* 客户需求接口
|
|
||||||
* 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
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -12,6 +12,7 @@ Route::get('init', 'app\index\controller\Index@init');
|
|||||||
Route::get('footerdata', 'app\index\controller\Index@getFooterData');
|
Route::get('footerdata', 'app\index\controller\Index@getFooterData');
|
||||||
Route::get('companyInfos', 'app\index\controller\Index@getCompanyInfos');
|
Route::get('companyInfos', 'app\index\controller\Index@getCompanyInfos');
|
||||||
Route::post('requirement', 'app\index\controller\Index@requirement');
|
Route::post('requirement', 'app\index\controller\Index@requirement');
|
||||||
|
Route::get('friendlinks', 'app\index\controller\Index@getFriendlinkList');
|
||||||
|
|
||||||
// --- 客户需求路由 ---
|
// --- 客户需求路由 ---
|
||||||
|
|
||||||
|
|||||||
44
app/model/Cms/Friendlink.php
Normal file
44
app/model/Cms/Friendlink.php
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2006-2018 http://thinkphp.cn All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: Liu21st <liu21st@gmail.com>
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace app\model\Cms;
|
||||||
|
|
||||||
|
use think\Model;
|
||||||
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文章分类模型
|
||||||
|
*/
|
||||||
|
class Friendlink extends Model
|
||||||
|
{
|
||||||
|
// 启用软删除
|
||||||
|
use SoftDelete;
|
||||||
|
|
||||||
|
// 数据库表名
|
||||||
|
protected $name = 'mete_apps_cms_friendlink';
|
||||||
|
|
||||||
|
// 字段类型转换
|
||||||
|
protected $type = [
|
||||||
|
'id' => 'integer',
|
||||||
|
'tid' => 'integer',
|
||||||
|
'link_name' => 'string',
|
||||||
|
'link_url' => 'string',
|
||||||
|
'link_logo' => 'string',
|
||||||
|
'description' => 'string',
|
||||||
|
'sort' => 'integer',
|
||||||
|
'status' => 'integer',
|
||||||
|
'create_time' => 'datetime',
|
||||||
|
'update_time' => 'datetime',
|
||||||
|
'delete_time' => 'datetime',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
13
public/themes/default/assets/css/swiper-bundle.min.css
vendored
Normal file
13
public/themes/default/assets/css/swiper-bundle.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
14
public/themes/default/assets/js/swiper-bundle.min.js
vendored
Normal file
14
public/themes/default/assets/js/swiper-bundle.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -122,7 +122,7 @@ function stripHtml($html) {
|
|||||||
<link rel="stylesheet" href="assets/css/lindy-uikit.css" />
|
<link rel="stylesheet" href="assets/css/lindy-uikit.css" />
|
||||||
<link rel="stylesheet" href="assets/css/all.min.css" />
|
<link rel="stylesheet" href="assets/css/all.min.css" />
|
||||||
<!-- Swiper CSS -->
|
<!-- Swiper CSS -->
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css" />
|
<link rel="stylesheet" href="assets/css/swiper-bundle.min.css" />
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
@ -172,7 +172,7 @@ function stripHtml($html) {
|
|||||||
<a class="page-scroll active" href="#home">主页</a>
|
<a class="page-scroll active" href="#home">主页</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="page-scroll" href="#feature">文章中心</a>
|
<a class="page-scroll" href="#feature">新闻中心</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="page-scroll" href="#about">关于我们</a>
|
<a class="page-scroll" href="#about">关于我们</a>
|
||||||
@ -207,7 +207,7 @@ function stripHtml($html) {
|
|||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
<div class="col-xxl-5 col-xl-5 col-lg-7 col-md-8">
|
<div class="col-xxl-5 col-xl-5 col-lg-7 col-md-8">
|
||||||
<div class="section-title text-center mb-60">
|
<div class="section-title text-center mb-60">
|
||||||
<h3 class="mb-15 wow fadeInUp" data-wow-delay=".2s">文章中心</h3>
|
<h3 class="mb-15 wow fadeInUp" data-wow-delay=".2s">新闻中心</h3>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -257,8 +257,8 @@ function stripHtml($html) {
|
|||||||
<div class="row align-items-center">
|
<div class="row align-items-center">
|
||||||
<div class="col-xl-5 col-lg-6">
|
<div class="col-xl-5 col-lg-6">
|
||||||
<div class="section-title mb-60">
|
<div class="section-title mb-60">
|
||||||
<h3 class="mb-15 wow fadeInUp" data-wow-delay=".2s">Pricing Plan</h3>
|
<h3 class="mb-15 wow fadeInUp" data-wow-delay=".2s">特色业务</h3>
|
||||||
<p class="wow fadeInUp" data-wow-delay=".4s">Stop wasting time and money designing and managing a website that doesn’t get results. Happiness guaranteed!Stop wasting time and money designing and managing a website that doesn’t get results. Happiness guaranteed!</p>
|
<p class="wow fadeInUp" data-wow-delay=".4s">我们始终以专业、高效、创新为核心,深耕行业多年,形成了独具优势的特色业务体系。凭借成熟的服务流程、过硬的技术实力与丰富的实战经验,为客户提供一站式、定制化解决方案。</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xl-7 col-lg-6">
|
<div class="col-xl-7 col-lg-6">
|
||||||
@ -470,15 +470,19 @@ function stripHtml($html) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
<!-- 友情链接 -->
|
||||||
<section class="clients-logo-section pt-100 pb-100">
|
<section class="clients-logo-section pt-100 pb-100">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<div class="client-logo wow fadeInUp" data-wow-delay=".2s">
|
<div class="section-title text-center mb-50">
|
||||||
<img src="assets/img/clients/brands.svg" alt="" class="w-100">
|
<h3 class="wow fadeInUp" data-wow-delay=".2s">友情链接</h3>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row" id="friendlink-container">
|
||||||
|
<!-- 友情链接将通过 JavaScript 动态加载 -->
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<footer class="footer footer-style-4">
|
<footer class="footer footer-style-4">
|
||||||
@ -554,7 +558,7 @@ function stripHtml($html) {
|
|||||||
<script src="assets/js/main.js"></script>
|
<script src="assets/js/main.js"></script>
|
||||||
<script src="assets/js/all.min.js"></script>
|
<script src="assets/js/all.min.js"></script>
|
||||||
<!-- Swiper JS -->
|
<!-- Swiper JS -->
|
||||||
<script src="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js"></script>
|
<script src="assets/js/swiper-bundle.min.js"></script>
|
||||||
|
|
||||||
<!-- 加载新闻数据 -->
|
<!-- 加载新闻数据 -->
|
||||||
<script>
|
<script>
|
||||||
@ -656,11 +660,51 @@ function stripHtml($html) {
|
|||||||
return API_BASE_URL + (imagePath.startsWith('/') ? imagePath : '/' + imagePath);
|
return API_BASE_URL + (imagePath.startsWith('/') ? imagePath : '/' + imagePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 加载友情链接
|
||||||
|
function loadFriendlinks() {
|
||||||
|
const container = document.getElementById('friendlink-container');
|
||||||
|
if (!container) return;
|
||||||
|
|
||||||
|
fetch(API_BASE_URL + '/friendlinks')
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(result => {
|
||||||
|
if (result.code !== 200 || !result.data || result.data.length === 0) {
|
||||||
|
container.innerHTML = '<div class="col-12 text-center"><p>暂无友情链接</p></div>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let html = '';
|
||||||
|
result.data.forEach((item) => {
|
||||||
|
const logoUrl = item.link_logo ? (item.link_logo.startsWith('http') ? item.link_logo : API_BASE_URL + item.link_logo) : '';
|
||||||
|
const linkName = item.link_name || '';
|
||||||
|
const linkUrl = item.link_url || '#';
|
||||||
|
const description = item.description || '';
|
||||||
|
|
||||||
|
html += '<div class="col-lg-3 col-md-4 col-sm-6 mb-4">' +
|
||||||
|
'<a href="' + linkUrl + '" target="_blank" class="friendlink-item" title="' + description + '">' +
|
||||||
|
'<div class="friendlink-card">' +
|
||||||
|
(logoUrl ? '<img src="' + logoUrl + '" alt="' + linkName + '" class="friendlink-logo">' : '<div class="friendlink-name">' + linkName + '</div>') +
|
||||||
|
'</div>' +
|
||||||
|
'</a>' +
|
||||||
|
'</div>';
|
||||||
|
});
|
||||||
|
|
||||||
|
container.innerHTML = html;
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error('加载友情链接失败:', err);
|
||||||
|
container.innerHTML = '<div class="col-12 text-center"><p>加载失败</p></div>';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 页面加载完成后执行
|
// 页面加载完成后执行
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
// 加载 Banner 轮播图
|
// 加载 Banner 轮播图
|
||||||
loadBanners();
|
loadBanners();
|
||||||
|
|
||||||
|
// 加载友情链接
|
||||||
|
loadFriendlinks();
|
||||||
|
|
||||||
// 加载新闻数据
|
// 加载新闻数据
|
||||||
const container = document.getElementById('news-container');
|
const container = document.getElementById('news-container');
|
||||||
if (!container) return;
|
if (!container) return;
|
||||||
@ -764,6 +808,45 @@ function stripHtml($html) {
|
|||||||
background: #fff;
|
background: #fff;
|
||||||
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
|
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 友情链接样式 */
|
||||||
|
.friendlink-item {
|
||||||
|
display: block;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.friendlink-card {
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 15px;
|
||||||
|
height: 150px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.friendlink-card:hover {
|
||||||
|
border-color: #5864FF;
|
||||||
|
box-shadow: 0 4px 12px rgba(88, 100, 255, 0.15);
|
||||||
|
transform: translateY(-2px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.friendlink-logo {
|
||||||
|
max-width: 100%;
|
||||||
|
max-height: 120px;
|
||||||
|
width: auto;
|
||||||
|
height: auto;
|
||||||
|
object-fit: contain;
|
||||||
|
}
|
||||||
|
|
||||||
|
.friendlink-name {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #333;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<!-- 新闻卡片样式 -->
|
<!-- 新闻卡片样式 -->
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user