更新:联系我们-留言管理

virtual
zwesy 2020-12-04 18:22:07 +08:00
parent 9501199759
commit adc9c78394
15 changed files with 341 additions and 30 deletions

View File

@ -123,7 +123,7 @@ class Article extends Base
$cateList = [];
$newsChildrenFlip = array_flip(Category::$CIdList['news_children']);
foreach ($categoryChildren as $cate) {
$cate['items'] = MArticle::getLatestByCategory($cate['id'], 4);
$cate['items'] = MArticle::getLatestByCategory($cate['id'], 4, 1);
$cateList[$newsChildrenFlip[$cate['id']]] = $cate;
}
$this->data['cateList'] = $cateList;

View File

@ -21,14 +21,14 @@ class Index extends Base
// 关联产品中心
$this->data['products'] = [
'category' => Category::getById(Category::$CIdList['products']),
'items' => Article::getLatestByCategory(Category::$CIdList['products'], 4)
'items' => Article::getLatestByCategory(Category::$CIdList['products'], 4, 1)
];
// 关联新闻
$this->data['newsCenter'] = Category::getById(Category::$CIdList['news']);
$newsCIdList = [Category::$CIdList['news_children']['enterprise'], Category::$CIdList['news_children']['industry']];
$newsList = Category::getListByIds($newsCIdList);
foreach ($newsList as &$cate) {
$cate['items'] = Article::getLatestByCategory($cate['id'], 4);
$cate['items'] = Article::getLatestByCategory($cate['id'], 4, 1);
}
unset($cate);
$this->data['newsList'] = $newsList;

View File

@ -0,0 +1,42 @@
<?php
namespace app\controller;
use app\model\Message as MMessage;
use app\validate\Message as VMessage;
use think\exception\ValidateException;
/**
* 留言
* Class Message
* @package app\controller
*/
class Message extends Base
{
// 新增留言
public function add()
{
if(request()->isPost()) {
$msgData = [
'company_name' => trim(input('post.company_name', '')),
'name' => trim(input('post.name', '')),
'phone' => trim(input('post.phone', '')),
'email' => trim(input('post.email', '')),
'content' => trim(input('post.content', '')),
];
// 安全过滤
$msgData = array_map('strip_tags', $msgData);
try {
validate(VMessage::class)->check($msgData);
$msgData['ip'] = request()->ip();
$msgData['create_time'] = time();
MMessage::create($msgData);
return $this->json();
} catch (ValidateException $e) {
return $this->json(2, $e->getError());
}
} else {
return $this->json(1, '非法请求');
}
}
}

View File

@ -47,7 +47,11 @@ class Page extends Base
case 'marketing' :
$this->assignMarketing($childCategory);
break;
case 'contact' :
$this->assignContact($childCategory);
break;
default :
$this->data['blocks'] = Block::getByCategoryId($category['id']);
}
}
@ -117,9 +121,25 @@ class Page extends Base
$achievementCate = Category::getById(Category::$CIdList['achievement_manage']);
$achievementList = [];
if ($achievementCate) {
$achievementList = Article::getLatestByCategory($achievementCate['id'], $achievementCate['number'] ? $achievementCate['number'] : 10);
$achievementList = Article::getLatestByCategory($achievementCate['id'], $achievementCate['number'] ? $achievementCate['number'] : 10, 1);
}
$this->data['blocks'] = $blocks;
$this->data['achievementList'] = $achievementList;
}
// 联系我们
private function assignContact($childCategory)
{
$blocks = [];
$blockCateIds = $this->getBlockCateIds($childCategory);
$blockList = Block::getByCategoryIds($blockCateIds);
$contactChildrenFlip = array_flip(Category::$CIdList['contact_children']);
foreach ($childCategory as $cate) {
$blocks[$contactChildrenFlip[$cate['id']]] = $blockList[$cate['id']] ?? [];
}
$jobsCate = Category::getById(Category::$CIdList['jobs_manage']);
$jobList = Article::getLatestByCategory($jobsCate['id'], $jobsCate['number'] ? $jobsCate['number'] : 10, 1);
$this->data['blocks'] = $blocks;
$this->data['jobList'] = $jobList;
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace app\controller\manager;
use app\model\Message as MMessage;
/**
* 留言
* Class Message
* @package app\controller\manager
*/
class Message extends Base
{
// 留言消息
public function index()
{
$keyword = trim(input('param.keyword', ''));
$this->data['list'] = MMessage::getPaginateList(20, $keyword, false);
$this->data['keyword'] = $keyword;
return $this->view();
}
public function del()
{
$id = input('param.id/d', 0);
$msg = MMessage::getById($id);
if(count($msg) == 0) {
return $this->json(1, '该消息不存在');
}
MMessage::destroy($id);
return $this->json();
}
}

View File

@ -15,18 +15,23 @@ class Article extends Base
->toArray();
}
//获取栏目下最新记录
public static function getLatestByCategory($categoryId, $limit = 5, $order = [])
public static function getLatestByCategory($categoryId, $limit = 5, $status = -1, $order = [])
{
if(empty($categoryId)){
return [];
}
$whereMap = [];
if($limit <= 0){
$limit = 5;
}
if(is_numeric($status) && $status != -1){
$whereMap[] = ['status', '=', $status];
}
if(empty($order)) {
$order = ['create_time' => 'desc'];
}
return self::where('category_id', $categoryId)
->where($whereMap)
->order($order)
->limit($limit)
->select()
@ -166,6 +171,10 @@ class Article extends Base
}
}
}
if(is_numeric($status) && $status != -1){
$whereMap[] = ['status', '=', $status];
$pageParam['status'] = $status;
}
$paginate = [
'list_rows' => $per,
'query' => $pageParam

View File

@ -33,6 +33,13 @@ class Category extends Base
'industry' => 21, // 行业资讯
'dynamics' => 22, // 最新动态
],
'contact' => 19, // 联系我们
'contact_children' => [
'information' => 23, // 联系方式
'jobs' => 24, // 行业资讯
'message' => 25, // 在线留言
],
'jobs_manage' => 33, // 招聘管理
];
//获取首页栏目ID

View File

@ -3,12 +3,25 @@ namespace app\model;
class Message extends Base
{
/**
* 获取留言列表
*/
public static function getList($per = 20)
// 获取留言列表
public static function getPaginateList($per = 20, $keyword = '', $isSimple = false)
{
return self::order("create_time desc")
->paginate($per);
$paginate = [
'list_rows' => $per,
'query' => [
'keyword' => $keyword,
]
];
return self::when(!empty($keyword), function ($query) use ($keyword) {
$map = [
['company_name', 'like', '%'.$keyword.'%'],
['name', 'like', '%'.$keyword.'%'],
['phone', 'like', '%'.$keyword.'%'],
['email', 'like', '%'.$keyword.'%'],
];
$query->whereOr($map);
})
->order('create_time', 'desc')
->paginate($paginate, $isSimple);
}
}

27
app/validate/Message.php Normal file
View File

@ -0,0 +1,27 @@
<?php
namespace app\validate;
use think\Validate;
class Message extends Validate
{
protected $rule = [
'company_name' => 'requireWithout:name|length:2,100',
'name' => 'requireWithout:company_name|length:2,50',
'content' => 'require|length:4,500',
'phone' => 'requireWithout:email|mobile',
'email' => 'requireWithout:phone|email',
];
protected $message = [
'company_name.requireWithout' => '公司名称和联系人署名至少需要填写一个',
'company_name.length' => '公司名称长度限制为2~100个字符',
'name.requireWithout' => '公司名称和联系人署名至少需要填写一个',
'name.length' => '联系人署名长度限制为2~50个字符',
'phone.requireWithout' => '联系电话和邮箱至少需要填写一个',
'phone.mobile' => '请输入正确的联系电话',
'email.requireWithout' => '联系电话和邮箱至少需要填写一个',
'email.email' => '请输入正确的邮箱',
'content.require' => '咨询事项不能为空',
'content.length' => '咨询事项长度限制为4~500个字符',
];
}

View File

@ -334,7 +334,7 @@ input,select,textarea{outline:medium none; resize: none;}
.contact-box3 .center-block .text:nth-child(2n){ float: right;}
.contact-box3 .center-block textarea{ width: 100%; float: left; height: 110px; border: none; border-bottom: 1px solid #c2c2c2; background: none; font-size: 0.875rem; margin-top: 1.25rem;}
.contact-box3 .center-block .btns{ width: 100%; float: left; text-align: center;}
.contact-box3 .center-block .btns input{ width: 10rem; line-height: 2.25rem; background: #00418f; border:none; color: #fff; font-size: 1rem; margin-top: 1.875rem;}
.contact-box3 .center-block .btns button{ width: 10rem; line-height: 2.25rem; background: #00418f; border:none; color: #fff; font-size: 1rem; margin-top: 1.875rem;}
.product-box{ padding: 8rem 0 5rem;}
.product-box .center-block ul{ margin: 0 -1.25rem;}

View File

@ -5,6 +5,10 @@ function wah() {
}
layui.use(['layer', 'form', 'element'], function(){
var layer = layui.layer,form = layui.form,element = layui.element;
});
$(window).scroll(function(event) {
// if ($(window).scrollTop() > 0) {
// $('.head-box').addClass('active');
@ -104,10 +108,63 @@ $(function() {
scrollAnh = 0;
scrollNum = 0;
});
});
layui.use(['layer', 'form', 'element'], function(){
var layer = layui.layer,form = layui.form,element = layui.element;
});
// 留言提交
$('#message-submit').click(function () {
var companyName = $("#message-form input[name='company_name']").val();
var name = $("#message-form input[name='name']").val();
var phone = $("#message-form input[name='phone']").val();
var email = $("#message-form input[name='email']").val();
var content = $("#message-form textarea[name='content']").val();
var url = $("#message-form").data('action');
var token = $('#token').attr('content');
if(companyName.length == 0 && name.length == 0) {
layer.msg('公司名称和联系人署名至少需要填写一个');
return;
}
if(companyName.length > 0 && (companyName.length < 2 || companyName.length > 100)) {
layer.msg('司名称长度限制为2~100个字符');
return;
}
if(name.length > 0 && (name.length < 2 || name.length > 100)) {
layer.msg('联系人署名长度限制为2~100个字符');
return;
}
if(phone.length == 0 && email.length == 0) {
layer.msg('联系电话和邮箱至少需要填写一个');
return;
}
if(content.length == 0 || (content.length < 6 || content.length > 500)) {
layer.msg('请输入4 ~ 500字符的咨询事项内容');
return;
}
$.ajax({
dataType: "json",
type: "post",
async:true,
url: url,
data: {
'company_name':companyName,
'name':name,
'phone':phone,
'email':email,
'content':content,
'_token':token,
},
success: function(data) {
if(data.code == 0) {
layer.msg('提交成功, 感谢您的反馈!');
$("#message-form input").val('');
$("#message-form textarea").val('');
} else {
layer.msg(data.msg);
}
},
error: function (data) {
layer.msg('提交失败,请稍后再试');
}
});
});
});

View File

@ -16,6 +16,9 @@ Route::get('page/:category_id', "page/index");
Route::rule('products', 'article/index')->name('products.search'); // 产品查询
Route::rule('news', 'article/index')->name('news.search'); // 新闻查询
Route::post('message/add', 'message/add');

View File

@ -3,19 +3,21 @@
<div class="layui-card-body">
<table class="layui-table" id="check_box">
<colgroup>
<col width="150px" />
<col width="120px" />
<col width="200px" />
<col width="150px" />
<col width="200px" />
<col />
<col width="120px" />
<col width="150px" />
<col width="150px" />
<col width="50px" />
</colgroup>
<thead>
<td>姓名</td>
<td>电话</td>
<td>联系人署名</td>
<td>公司名称</td>
<td>联系电话</td>
<td>邮箱</td>
<td>内容</td>
<td>咨询事项</td>
<td>IP</td>
<td>时间</td>
<td>操作</td>
@ -23,6 +25,7 @@
{foreach $list as $item}
<tr class="select_box">
<td>{$item.name}</td>
<td>{$item.company_name}</td>
<td>{$item.phone}</td>
<td>{$item.email}</td>
<td>{$item.content}</td>

View File

@ -82,18 +82,26 @@
</div>
</div>
<div class="layui-form-itemBox1 between-center">
<div class="layui-form-item">
<label class="layui-form-label">版权信息</label>
<div class="layui-input-block">
<input class="layui-input" type="text" name="item[company_copyright]" value="{$item['company_copyright']?$item['company_copyright']:''}" />
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">域名备案号</label>
<div class="layui-input-block">
<input class="layui-input" type="text" name="item[company_copy]" value="{$item['company_copy']?$item['company_copy']:''}"/>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">公司传真</label>
<div class="layui-input-block">
<input class="layui-input" type="text" name="item[company_fax]" value="{$item['company_fax']?$item['company_fax']:''}" />
</div>
</div>
</div>
<div class="layui-form-itemBox1 between-center">
<div class="layui-form-item">
<label class="layui-form-label">版权信息</label>
<div class="layui-input-block">
<input class="layui-input" type="text" name="item[company_copyright]" value="{$item['company_copyright']?$item['company_copyright']:''}" />
</div>
</div>
</div>
<div class="system_title">SEO信息</div>
<div class="layui-form-itemBox2 between">

View File

@ -1 +1,91 @@
{layout name="layout"}
{layout name="layout"}
<!-- banner -->
<div class="page-banner w-100" style="background-image: url({:getImgSrc($topCategory, '__IMG__/page_ban1.jpg')});">
<div class="info">
<div class="w-1200">
<strong>{$topCategory.title}</strong>
<p>{:nl2br($topCategory.description ?? '')}</p>
</div>
</div>
</div>
<!-- -->
<div class="all-center-box">
<div class="contact-box1 w-100" id="contact1">
<div class="w-1200">
<div class="between-top">
<div class="column-between">
<div class="all-title-box2 w-100"><span>{$blocks['information']['title']['value'] ?? ''}</span><p>{$blocks['information']['subtitle']['value'] ?? ''}</p></div>
{if isset($blocks['information']['logo']) && !empty($blocks['information']['logo']['value'])}
<img src="{$blocks['information']['logo']['value'] ?? ''}" >
{/if}
</div>
<div class="box-info column-between">
<p><span>电话/Tel</span>{$system['company_tel'] ?? ''}</p>
<p><span>传真/Fax</span>{$system['company_fax'] ?? ''}</p>
<p><span>邮箱/E-mail</span>{$system['company_email'] ?? ''}</p>
<p>
{$system['company_addr'] ?? ''}
<br>{$system['company_addr_detail_en'] ?? ''}
<br>{$system['company_addr_en'] ?? ''}
</p>
<p>
{$system['company_name'] ?? ''}
<br>{$system['company_name_en'] ?? ''}
<br>{$system['company_type_en'] ?? ''}
</p>
</div>
{if isset($blocks['information']['wechat']) && !empty($blocks['information']['wechat'])}
<div class="column-between">
<p>&nbsp;</p>
<div class="ewm">
<img src="{$blocks['information']['wechat']['value'] ?? ''}" >
<p>微信二维码/Wechant</p>
</div>
</div>
{/if}
</div>
<div class="w-100 text-center"><img src="__IMG__/lx1_bg.png" ></div>
</div>
</div>
<div class="contact-box2 w-100" id="contact2">
<div class="w-1200">
<div class="all-title-box2 w-100"><span>{$blocks['jobs']['title']['value'] ?? ''}</span><p>{$blocks['jobs']['subtitle']['value'] ?? ''}</p></div>
<div class="marketing-box2 w-100">
<div class="center-block w-100">
<ul>
{if isset($jobList) && count($jobList) > 0}
{foreach $jobList as $job}
<li>
<div class="top-box w-100">
<div class="pull-left"><i>{$job.summary ?? ''}</i><span>{$job.title ?? ''}</span></div>
<div class="pull-right">展开</div>
</div>
<div class="lower-box w-100">
<div class="pull-left">{$job.create_time|date="Y.m.d"}</div>
<div class="pull-right">{$job.content|raw}</div>
</div>
</li>
{/foreach}
{/if}
</ul>
</div>
</div>
</div>
</div>
<div class="contact-box3 w-100" id="contact3">
<div class="w-1200">
<div class="all-title-box2 w-100"><span>{$blocks['message']['title']['value'] ?? ''}</span><p>{$blocks['message']['subtitle']['value'] ?? ''}</p></div>
<div class="box-info w-100">{:nl2br($blocks['message']['description']['value'] ?? '')}</div>
<form data-action="{:url('message/add')}" class="center-block w-100" method="post" id="message-form">
<input type="text" class="text" name="company_name" placeholder="公司名称" />
<input type="text" class="text" name="email" placeholder="邮箱" />
<input type="text" class="text" name="name" placeholder="联系人署名" />
<input type="text" class="text" name="phone" placeholder="联系电话" />
<textarea placeholder="咨询事项, 4 ~ 500 字以内" name="content"></textarea>
<div class="btns"><button type="button" id="message-submit">提交</button></div>
</form>
</div>
</div>
</div>