diff --git a/app/index/controller/ContactUs.php b/app/index/controller/ContactUs.php index 56a3e8ec..1abc0130 100644 --- a/app/index/controller/ContactUs.php +++ b/app/index/controller/ContactUs.php @@ -3,9 +3,13 @@ declare (strict_types = 1); namespace app\index\controller; +use app\index\model\AgentBusinessTypeModel; +use app\index\model\AgentEnterpriseSizeTypeModel; +use app\index\model\AgentModel; use app\index\model\LeaveMessageModel; use app\index\model\SysBannerModel; -use app\index\validate\ContactUsValidate; +use app\index\validate\ContactUsDistributorValidate; +use app\index\validate\ContactUsMessageValidate; use think\facade\View; /** @@ -35,7 +39,7 @@ class ContactUs extends Common ]); // 数据校验 - $validate = new ContactUsValidate; + $validate = new ContactUsMessageValidate; if (!$validate->check($form_data)) { return error($validate->getError()); } @@ -92,7 +96,49 @@ class ContactUs extends Common { if (request()->isPost()) { // 提交留言处理 + $form_data = request()->post([ + 'corp_name', + 'email', + 'phone', + 'business_type', + 'enterprise_size', + 'address', + 'message' + ]); + + // 验证字段 + $validate = new ContactUsDistributorValidate; + if (!$validate->check($form_data)) { + return error($validate->getError()); + } + + // 保存留言 + $ret = AgentModel::create([ + 'language_id' => $this->lang_id, + 'corp_name' => $form_data['corp_name'], + 'email' => $form_data['email'], + 'phone' => $form_data['phone'], + 'referer_url' => request()->header('referer'), + 'website_url' => request()->header('host'), + 'business_type' => $form_data['business_type'], + 'enterprise_size' => $form_data['enterprise_size'], + 'address' => $form_data['address'], + 'message' => $form_data['message'], + 'ip' => request()->ip(), + ]); + if ($ret->isEmpty()) { + return error(lang('contact_distributor.send_fail')); + } + return success(lang('contact_distributor.send_success')); } + + // 获取企业规模 + $sizes = AgentEnterpriseSizeTypeModel::language($this->lang_id)->select(); + View::assign('sizes', $sizes); + + // 获取企业业务类型 + $types = AgentBusinessTypeModel::language($this->lang_id)->select(); + View::assign('types', $types); return View::fetch('distributor'); } diff --git a/app/index/lang/en-us.php b/app/index/lang/en-us.php index 1f212294..b154880f 100644 --- a/app/index/lang/en-us.php +++ b/app/index/lang/en-us.php @@ -47,27 +47,66 @@ return [ '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', + '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', ], + 'contact_distributor' => [ + 'title' => 'Become a Distributor', + 'section_title' => 'To Be Our Distributor', + 'section_desc_1' => 'Ready to join us?', + 'section_desc_2' => 'Enter your details below and our Sales team will get back to you within 2 business days.', + 'form_corp_name' => 'Company Name', + 'form_corp_name_placeholder' => 'Enter your Company Name', + 'form_email' => 'Contact Email', + 'form_email_placeholder' => 'Enter your Email', + 'form_phone' => 'Phone Number', + 'form_phone_placeholder' => 'This is your placeholder text', + 'form_business_type' => 'Type of Business', + 'form_online_shop_url' => 'Online Shop URL', + 'form_online_shop_url_placeholder' => 'This is your placeholder URL', + 'form_enterprise_size' => 'Enterprise size', + 'form_corp_address' => 'Company Address', + 'form_corp_address_placeholder' => 'Enter Address', + 'form_message' => 'Message', + 'form_message_placeholder' => 'Enter your message', + 'form_submit' => 'SUBMIT', + // 验证器中文本 + 'validate_name_required' => 'Company Name is required', + 'validate_name_max' => 'Company 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_phone_required' => 'Phone Number is required', + 'validate_phone_max' => 'Phone Number cannot exceed 64 characters', + 'validate_business_type_required' => 'Type of Business is required', + 'validate_business_type_max' => 'Type of Business cannot exceed 128 characters', + 'validate_enterprise_size_required' => 'Enterprise size is required', + 'validate_enterprise_size_max' => 'Enterprise size cannot exceed 128 characters', + 'validate_address_required' => 'Company Address is required', + 'validate_address_max' => 'Company Address cannot exceed 255 characters', + 'validate_message_required' => 'Message is required', + // 返回文本 + 'send_success' => 'Add Success!', + 'send_fail' => 'Add Fail!', + ] ]; \ No newline at end of file diff --git a/app/index/lang/zh-cn.php b/app/index/lang/zh-cn.php index 646b714d..fd6c195e 100644 --- a/app/index/lang/zh-cn.php +++ b/app/index/lang/zh-cn.php @@ -47,27 +47,66 @@ return [ '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' => '提交失败', + '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' => '提交失败', ], + 'contact_distributor' => [ + 'title' => '成为经销商', + 'section_title' => '成为经销商', + 'section_desc_1' => '准备好加入我们了吗?', + 'section_desc_2' => '在下面输入您的详细信息,我们的销售团队将在2个工作日内回复您。', + 'form_corp_name' => '公司名称', + 'form_corp_name_placeholder' => '请输入公司名称', + 'form_email' => '电子邮箱', + 'form_email_placeholder' => '请输入邮箱', + 'form_phone' => '电话号码', + 'form_phone_placeholder' => '请输入电话号码', + 'form_business_type' => '业务类型', + 'form_online_shop_url' => '在线商店网址', + 'form_online_shop_url_placeholder' => '请输入网址', + 'form_enterprise_size' => '企业规模', + 'form_corp_address' => '公司地址', + 'form_corp_address_placeholder' => '请输入地址', + 'form_message' => '留言', + 'form_message_placeholder' => '请输入留言', + 'form_submit' => '提交', + // 验证器中文本 + 'validate_name_required' => '公司名称不能为空', + 'validate_name_max' => '公司名称不能超过64个字符', + 'validate_email_required' => '邮箱不能为空', + 'validate_email_email' => '邮箱格式不正确', + 'validate_email_max' => '邮箱不能超过128个字符', + 'validate_phone_required' => '电话号码不能为空', + 'validate_phone_max' => '电话号码不能超过64个字符', + 'validate_business_type_required' => '业务类型不能为空', + 'validate_business_type_max' => '业务类型不能超过128个字符', + 'validate_enterprise_size_required' => '企业规模不能为空', + 'validate_enterprise_size_max' => '企业规模不能超过128个字符', + 'validate_address_required' => '公司地址不能为空', + 'validate_address_max' => '公司地址不能超过255个字符', + 'validate_message_required' => '留言内容不能为空', + // 返回文本 + 'send_success' => '信息已成功提交', + 'send_fail' => '信息提交失败', + ] ]; \ No newline at end of file diff --git a/app/index/model/AgentBusinessTypeModel.php b/app/index/model/AgentBusinessTypeModel.php new file mode 100644 index 00000000..0752df0c --- /dev/null +++ b/app/index/model/AgentBusinessTypeModel.php @@ -0,0 +1,19 @@ +where('language_id', '=', $language); + } +} diff --git a/app/index/model/AgentEnterpriseSizeTypeModel.php b/app/index/model/AgentEnterpriseSizeTypeModel.php new file mode 100644 index 00000000..93f59a20 --- /dev/null +++ b/app/index/model/AgentEnterpriseSizeTypeModel.php @@ -0,0 +1,19 @@ +where('language_id', '=', $language); + } +} diff --git a/app/index/model/AgentModel.php b/app/index/model/AgentModel.php new file mode 100644 index 00000000..54860172 --- /dev/null +++ b/app/index/model/AgentModel.php @@ -0,0 +1,15 @@ + ['规则1','规则2'...] + * + * @var array + */ + protected $rule = [ + 'corp_name' => 'require|max:64', + 'email' => 'require|email|max:128', + 'phone' => 'require|max:64', + 'business_type' => 'require|max:128', + 'enterprise_size' => 'require|max:128', + 'address' => 'require|max:255', + 'message' => 'require', + ]; + + /** + * 定义错误信息 + * 格式:'字段名.规则名' => '错误信息' + * + * @var array + */ + protected $message = [ + 'corp_name.require' => 'contact_distributor.validate_name_required', + 'corp_name.max' => 'contact_distributor.validate_name_max', + 'email.require' => 'contact_distributor.validate_email_required', + 'email.email' => 'contact_distributor.validate_email_email', + 'email.max' => 'contact_distributor.validate_email_max', + 'phone.require' => 'contact_distributor.validate_phone_required', + 'phone.max' => 'contact_distributor.validate_phone_max', + 'business_type.require' => 'contact_distributor.validate_business_type_required', + 'business_type.max' => 'contact_distributor.validate_business_type_max', + 'enterprise_size.require' => 'contact_distributor.validate_enterprise_size_required', + 'enterprise_size.max' => 'contact_distributor.validate_enterprise_size_max', + 'address.require' => 'contact_distributor.validate_address_required', + 'address.max' => 'contact_distributor.validate_address_max', + 'message.require' => 'contact_distributor.validate_message_required', + ]; +} diff --git a/app/index/validate/ContactUsValidate.php b/app/index/validate/ContactUsMessageValidate.php similarity index 95% rename from app/index/validate/ContactUsValidate.php rename to app/index/validate/ContactUsMessageValidate.php index 96609117..87fac7e8 100644 --- a/app/index/validate/ContactUsValidate.php +++ b/app/index/validate/ContactUsMessageValidate.php @@ -5,7 +5,7 @@ namespace app\index\validate; use think\Validate; -class ContactUsValidate extends Validate +class ContactUsMessageValidate extends Validate { /** * 定义验证规则 diff --git a/app/index/view/contact_us/distributor.html b/app/index/view/contact_us/distributor.html index e69de29b..7fe4cfdb 100644 --- a/app/index/view/contact_us/distributor.html +++ b/app/index/view/contact_us/distributor.html @@ -0,0 +1,105 @@ +{extend name="public/base" /} +{block name="title"} +{:lang('contact_distributor.title')} +{/block} +{block name="style"} + +{/block} +{block name="main"} +
+ +
+

{:lang('contact_distributor.section_title')}

+

{:lang('contact_distributor.section_desc_1')}

+

{:lang('contact_distributor.section_desc_2')}

+ +
+
+
+ +
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
{:lang('contact_distributor.form_submit')}
+
+
+
+{/block} +{block name="script"} + +{/block} \ No newline at end of file diff --git a/public/static/index/css/distributor.css b/public/static/index/css/distributor.css index d6ff554f..79e648fe 100755 --- a/public/static/index/css/distributor.css +++ b/public/static/index/css/distributor.css @@ -1,7 +1,7 @@ .orico_Page_distributor { width: 100%; position: relative; - height: 100vh; + min-height: 100vh; overflow-y: auto; overflow-x: hidden; background: #f2f2f2; @@ -12,7 +12,7 @@ background: #fff; border-radius: 1rem; padding: 4.375rem 2.4375rem; - margin: 2.5rem auto; + margin: 6rem auto 2.5rem auto; } .orico_Page_distributor .distributorMain .redtag { position: absolute; @@ -107,6 +107,7 @@ background: #f2f2f2; border: none; border-radius: 0.5rem; + resize: none; font-family: Montserrat-Regular, Montserrat; } .orico_Page_distributor .distributorMain .bttj { diff --git a/public/static/index/images/brand02.png b/public/static/index/images/brand02.png new file mode 100755 index 00000000..55e42e91 Binary files /dev/null and b/public/static/index/images/brand02.png differ