feat: 联系我们
This commit is contained in:
99
app/index/controller/ContactUs.php
Normal file
99
app/index/controller/ContactUs.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\controller;
|
||||
|
||||
use app\index\model\LeaveMessageModel;
|
||||
use app\index\model\SysBannerModel;
|
||||
use app\index\validate\ContactUsValidate;
|
||||
use think\facade\View;
|
||||
|
||||
/**
|
||||
* 联系我们控制器
|
||||
*/
|
||||
class ContactUs extends Common
|
||||
{
|
||||
/**
|
||||
* 联系我们
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return View::fetch('index');
|
||||
}
|
||||
|
||||
/**
|
||||
* 留言联系我们
|
||||
*/
|
||||
public function message()
|
||||
{
|
||||
if (request()->isPost()) {
|
||||
// 提交留言处理
|
||||
$form_data = request()->post([
|
||||
'name',
|
||||
'email',
|
||||
'content'
|
||||
]);
|
||||
|
||||
// 数据校验
|
||||
$validate = new ContactUsValidate;
|
||||
if (!$validate->check($form_data)) {
|
||||
return error($validate->getError());
|
||||
}
|
||||
|
||||
// 保存留言
|
||||
$msg = LeaveMessageModel::create([
|
||||
'language_id' => $this->lang_id,
|
||||
'name' => $form_data['name'],
|
||||
'email' => $form_data['email'],
|
||||
'content' => $form_data['content'],
|
||||
'ip' => request()->ip(),
|
||||
'user_agent' => request()->header('user-agent'),
|
||||
]);
|
||||
if ($msg->isEmpty()) {
|
||||
return error(lang('contact_message.send_fail'));
|
||||
}
|
||||
|
||||
return success(lang('contact_message.send_success'));
|
||||
}
|
||||
|
||||
$focus_image = [];
|
||||
$our_information = [];
|
||||
// 获取我的信息banner
|
||||
$banner = SysBannerModel::with(['items' => function($query) {
|
||||
$query->withoutField(['status', 'created_at', 'updated_at', 'deleted_at'])
|
||||
->where('status', '=', 1)
|
||||
->order(['sort' => 'asc', 'id' => 'desc']);
|
||||
}])
|
||||
->uniqueLabel([
|
||||
'BANNER_6801be1e7d686',
|
||||
'BANNER_6801c053ce12e',
|
||||
])
|
||||
->language($this->lang_id)
|
||||
->enabled(true)
|
||||
->select();
|
||||
if (!$banner->isEmpty()) {
|
||||
$banner_map = [];
|
||||
foreach ($banner as $v) {
|
||||
$banner_map[$v->unique_label] = $v;
|
||||
}
|
||||
$focus_image = data_get($banner_map, 'BANNER_6801be1e7d686')?->items->first()?->toArray();
|
||||
$our_information = data_get($banner_map, 'BANNER_6801c053ce12e')?->items->toArray();
|
||||
}
|
||||
View::assign('focus_image', $focus_image);
|
||||
View::assign('our_information', $our_information);
|
||||
|
||||
return View::fetch('message');
|
||||
}
|
||||
|
||||
/**
|
||||
* 留言成为分销商
|
||||
*/
|
||||
public function distributor()
|
||||
{
|
||||
if (request()->isPost()) {
|
||||
// 提交留言处理
|
||||
}
|
||||
|
||||
return View::fetch('distributor');
|
||||
}
|
||||
}
|
||||
@@ -46,4 +46,28 @@ return [
|
||||
'events' => 'Brand Events',
|
||||
'development' => 'Tech Development',
|
||||
],
|
||||
'contact_message' => [
|
||||
'title' => 'contact us',
|
||||
'our_information' => 'Our Information',
|
||||
'send_question' => 'Send Us Your Question',
|
||||
'form_name' => 'Yuor Name',
|
||||
'form_name_placeholder' => 'This is your placeholder text',
|
||||
'form_email' => 'Your Email',
|
||||
'form_email_placeholder' => 'This is your placeholder text',
|
||||
'form_question' => 'Your Message',
|
||||
'form_question_placeholder' => 'This is your placeholder text',
|
||||
'form_submit' => 'SEND',
|
||||
'become_a_distributor' => 'Become a Distributor',
|
||||
// 验证器中文本
|
||||
'validate_name_required' => 'Name is required',
|
||||
'validate_name_max' => 'Name cannot exceed 64 characters',
|
||||
'validate_email_required' => 'Email is required',
|
||||
'validate_email_email' => 'Email format is incorrect',
|
||||
'validate_email_max' => 'Email cannot exceed 128 characters',
|
||||
'validate_content_required' => 'Message is required',
|
||||
'validate_content_max' => 'Message cannot exceed 1024 characters',
|
||||
// 返回文本
|
||||
'send_success' => 'success',
|
||||
'send_fail' => 'fail',
|
||||
],
|
||||
];
|
||||
@@ -46,4 +46,28 @@ return [
|
||||
'events' => '品牌里程',
|
||||
'development' => '品牌活动',
|
||||
],
|
||||
'contact_message' => [
|
||||
'title' => '联系我们',
|
||||
'our_information' => '我们的信息',
|
||||
'send_question' => '提交您的问题',
|
||||
'form_name' => '姓名',
|
||||
'form_name_placeholder' => '请输入你的姓名',
|
||||
'form_email' => '电子邮箱',
|
||||
'form_email_placeholder' => '请输入你的邮箱',
|
||||
'form_question' => '您的问题',
|
||||
'form_question_placeholder' => '请输入你的问题',
|
||||
'form_submit' => '发送',
|
||||
'become_a_distributor' => '成为经销商',
|
||||
// 验证器中文本
|
||||
'validate_name_required' => '姓名不能为空',
|
||||
'validate_name_max' => '姓名不能超过64个字符',
|
||||
'validate_email_required' => '邮箱不能为空',
|
||||
'validate_email_email' => '邮箱格式不正确',
|
||||
'validate_email_max' => '邮箱不能超过128个字符',
|
||||
'validate_content_required' => '问题不能为空',
|
||||
'validate_content_max' => '问题不能超过1024个字符',
|
||||
// 返回文本
|
||||
'send_success' => '提交成功',
|
||||
'send_fail' => '提交失败',
|
||||
],
|
||||
];
|
||||
15
app/index/model/LeaveMessageModel.php
Normal file
15
app/index/model/LeaveMessageModel.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
use app\common\model\LeaveMessageBaseModel;
|
||||
|
||||
/**
|
||||
* 联系我们留言模型
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class LeaveMessageModel extends LeaveMessageBaseModel
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -56,5 +56,18 @@ Route::group('aboutus', function() {
|
||||
Route::get('mileage', 'AboutUs/mileage');
|
||||
});
|
||||
|
||||
// 联系我们
|
||||
Route::group('contactus', function() {
|
||||
// 联系我们
|
||||
Route::get('index', 'ContactUs/index');
|
||||
// 留言联系我们
|
||||
Route::get('message', 'ContactUs/message');
|
||||
// 提交留言联系我们
|
||||
Route::post('message', 'ContactUs/message');
|
||||
// 留言成为分销商
|
||||
Route::get('distributor', 'ContactUs/distributor');
|
||||
// 提交留言成为分销商
|
||||
Route::post('distributor', 'ContactUs/distributor');
|
||||
});
|
||||
// 数据迁移
|
||||
Route::get('/data/migration', 'DataMigration/index');
|
||||
|
||||
37
app/index/validate/ContactUsValidate.php
Normal file
37
app/index/validate/ContactUsValidate.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class ContactUsValidate extends Validate
|
||||
{
|
||||
/**
|
||||
* 定义验证规则
|
||||
* 格式:'字段名' => ['规则1','规则2'...]
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $rule = [
|
||||
'name' => 'require|max:64',
|
||||
'email' => 'require|email|max:128',
|
||||
'content' => 'require|max:1024'
|
||||
];
|
||||
|
||||
/**
|
||||
* 定义错误信息
|
||||
* 格式:'字段名.规则名' => '错误信息'
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $message = [
|
||||
'name.require' => 'contact_message.validate_name_required',
|
||||
'name.max' => 'contact_message.validate_name_max',
|
||||
'email.require' => 'contact_message.validate_email_required',
|
||||
'email.email' => 'contact_message.validate_email_email',
|
||||
'email.max' => 'contact_message.validate_email_max',
|
||||
'content.require' => 'contact_message.validate_content_required',
|
||||
'content.max' => 'contact_message.validate_content_max'
|
||||
];
|
||||
}
|
||||
0
app/index/view/contact_us/distributor.html
Normal file
0
app/index/view/contact_us/distributor.html
Normal file
0
app/index/view/contact_us/index.html
Normal file
0
app/index/view/contact_us/index.html
Normal file
108
app/index/view/contact_us/message.html
Normal file
108
app/index/view/contact_us/message.html
Normal file
@@ -0,0 +1,108 @@
|
||||
{extend name="public/base" /}
|
||||
{block name="title"}<title>{:lang('contact_message.title')}</title>{/block}
|
||||
{block name="style"}
|
||||
<link rel="stylesheet" href="__CSS__/contact.css" />
|
||||
{/block}
|
||||
{block name="main"}
|
||||
<div class="orico_Page_contact">
|
||||
<!-- 内容 -->
|
||||
<div class="contactMain">
|
||||
{notempty name="focus_image"}
|
||||
<a href="{notempty name='focus_image.link'}{$focus_image.link}{else/}javascript:void(0);{/notempty}">
|
||||
<img src="{$focus_image.image}" class="contactImg" />
|
||||
</a>
|
||||
{/notempty}
|
||||
<div class="contact_c">
|
||||
<div class="all_contact">
|
||||
<div class="info">
|
||||
<div class="title"> {:lang('contact_message.our_information')} </div>
|
||||
{notempty name="our_information[0]"}
|
||||
<div class="info_all">
|
||||
{assign name="first_info" value="$our_information|array_shift" /}
|
||||
{notempty name="first_info"}
|
||||
<div class="list">
|
||||
{notempty name="first_info.image"}
|
||||
<div class="list_img"><img src="{$first_info.image}" /></div>
|
||||
{/notempty}
|
||||
<div class="list_right">
|
||||
<div class="title">{$first_info.title}:</div>
|
||||
<div class="des">{$first_info.desc|raw}</div>
|
||||
</div>
|
||||
</div>
|
||||
{/notempty}
|
||||
{volist name="our_information|array_chunk=2" id="infos"}
|
||||
<div class="list">
|
||||
{volist name="infos" id="inf"}
|
||||
{notempty name="inf.image"}
|
||||
<div class="list_img"><img src="{$inf.image}" alt=""></div>
|
||||
{/notempty}
|
||||
<div class="sub_list">
|
||||
<div class="title">{$inf.title}:</div>
|
||||
<div class="des">{$inf.desc|raw}</div>
|
||||
</div>
|
||||
{/volist}
|
||||
</div>
|
||||
{/volist}
|
||||
</div>
|
||||
{/notempty}
|
||||
</div>
|
||||
<div class="question">
|
||||
<div class="title">{:lang('contact_message.send_question')}</div>
|
||||
<div class="question_form">
|
||||
<form action="" method="post" autocomplete="off">
|
||||
<div class="list">
|
||||
<div class="title">{:lang('contact_message.form_name')}<span class="f_red">*</span></div>
|
||||
<div class="form_input">
|
||||
<input name="name" class="form-control itinp" placeholder="{:lang('contact_message.form_name_placeholder')}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="list">
|
||||
<div class="title">{:lang('contact_message.form_email')} <span class="f_red">*</span></div>
|
||||
<div class="form_input">
|
||||
<input name="email" class="form-control itinp" placeholder="{:lang('contact_message.form_email_placeholder')}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="list">
|
||||
<div class="title">{:lang('contact_message.form_question')} <span class="f_red">*</span></div>
|
||||
<div class="form_input">
|
||||
<textarea rows="6" name="content" class="ittextarea" placeholder="{:lang('contact_message.form_question_placeholder')}"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list">
|
||||
<div class="contact_button" id="send">{:lang('contact_message.form_submit')}</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="become_dis">
|
||||
<a href="{:url('contactus/distributor')}" class="text_blue">{:lang('contact_message.become_a_distributor')}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
||||
{block name="script"}
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
$("#send").click(function () {
|
||||
var form = $(this).parents("form");
|
||||
$.ajax({
|
||||
url: "{:url('contactus/message')}",
|
||||
type: "post",
|
||||
data: form.serialize(),
|
||||
dataType: "json",
|
||||
success: function (r) {
|
||||
if (r.code == 0) {
|
||||
form.get(0).reset();
|
||||
}
|
||||
alert(r.msg);
|
||||
},
|
||||
error: function (e) {
|
||||
alert(e.msg);
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
</script>
|
||||
{/block}
|
||||
@@ -1,9 +1,10 @@
|
||||
.orico_Page_contact {
|
||||
width: 100%;
|
||||
position: relative;
|
||||
height: 100vh;
|
||||
min-height: 100vh;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
padding-bottom: 3.75rem;
|
||||
background: #f1f1f1;
|
||||
}
|
||||
.orico_Page_contact .contactMain {
|
||||
@@ -25,7 +26,6 @@
|
||||
border-radius: 1.5rem;
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
width: 100%;
|
||||
padding: 4rem;
|
||||
margin-top: 3rem;
|
||||
}
|
||||
@@ -116,6 +116,7 @@
|
||||
background: #f2f2f2;
|
||||
border: none;
|
||||
font-family: Montserrat-Regular, Montserrat;
|
||||
resize: none;
|
||||
}
|
||||
.orico_Page_contact .contactMain .contact_c .all_contact .question .question_form .list .form_input input,
|
||||
.orico_Page_contact .contactMain .contact_c .all_contact .question .question_form .list .form_input textarea {
|
||||
|
||||
BIN
public/static/index/images/ContactUs.png
Executable file
BIN
public/static/index/images/ContactUs.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 MiB |
BIN
public/static/index/images/contact_icon01.png
Executable file
BIN
public/static/index/images/contact_icon01.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
BIN
public/static/index/images/contact_icon02.png
Executable file
BIN
public/static/index/images/contact_icon02.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
BIN
public/static/index/images/contact_icon03.png
Executable file
BIN
public/static/index/images/contact_icon03.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
Reference in New Issue
Block a user