From d172adc93d39e57df09deb18aafd78df117e468e Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Tue, 22 Apr 2025 14:30:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=89=B9=E9=87=8F=E8=B4=AD=E4=B9=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/index/controller/ContactUs.php | 62 +++++++++++ app/index/lang/en-us.php | 39 ++++++- app/index/lang/zh-cn.php | 39 ++++++- app/index/model/BulkPurchaseInquiryModel.php | 15 +++ app/index/model/SysConfigModel.php | 6 + app/index/route/route.php | 4 + .../validate/ContactUsBulkBuyValidate.php | 49 +++++++++ app/index/view/contact_us/bulkbuy.html | 104 ++++++++++++++++++ ...224032339_create_bulk_purchase_inquiry.php | 2 +- .../{bussiness.css => contactus_bulkbuy.css} | 3 +- 10 files changed, 319 insertions(+), 4 deletions(-) create mode 100644 app/index/model/BulkPurchaseInquiryModel.php create mode 100644 app/index/validate/ContactUsBulkBuyValidate.php create mode 100644 app/index/view/contact_us/bulkbuy.html rename public/static/index/css/{bussiness.css => contactus_bulkbuy.css} (98%) diff --git a/app/index/controller/ContactUs.php b/app/index/controller/ContactUs.php index d41ab4b9..70fe3b45 100644 --- a/app/index/controller/ContactUs.php +++ b/app/index/controller/ContactUs.php @@ -6,8 +6,11 @@ namespace app\index\controller; use app\index\model\AgentBusinessTypeModel; use app\index\model\AgentEnterpriseSizeTypeModel; use app\index\model\AgentModel; +use app\index\model\BulkPurchaseInquiryModel; use app\index\model\LeaveMessageModel; use app\index\model\SysBannerModel; +use app\index\model\SysConfigModel; +use app\index\validate\ContactUsBulkBuyValidate; use app\index\validate\ContactUsDistributorValidate; use app\index\validate\ContactUsMessageValidate; use think\facade\View; @@ -173,4 +176,63 @@ class ContactUs extends Common return View::fetch('distributor'); } + + /** + * 留言批量购买 + */ + public function bulkbuy() + { + if (request()->isPost()) { + // 提交留言处理 + $form_data = request()->post([ + 'corp_name', + 'url', + 'first_name', + 'last_name', + 'email', + 'phone', + 'interested', + 'message' + ]); + + // 验证字段 + $validate = new ContactUsBulkBuyValidate; + if (!$validate->check($form_data)) { + return error($validate->getError()); + } + + // 保存留言 + $ret = BulkPurchaseInquiryModel::create([ + 'language_id' => $this->lang_id, + 'corp_name' => $form_data['corp_name'], + 'url' => $form_data['url'], + 'first_name' => $form_data['first_name'], + 'last_name' => $form_data['last_name'], + 'email' => $form_data['email'], + 'phone' => $form_data['phone'], + 'interested' => $form_data['interested'], + 'referer_url' => request()->header('referer'), + 'website_url' => request()->header('host'), + 'message' => $form_data['message'], + 'ip' => request()->ip(), + ]); + if ($ret->isEmpty()) { + return error(lang('contact_bulkbuy.send_fail')); + } + return success(lang('contact_bulkbuy.send_success')); + } + + // 获取可选产品品类配置 + $config = SysConfigModel::hasWhere('group', function($query) { + $query->where('language_id', '=', $this->lang_id); + }) + ->byName('bulk_purchase_inquiry_interested') + ->find(); + if (empty($config)) { + return error('当前选定语言的采购可选品类配置出错'); + } + View::assign('interested', explode(',', preg_replace('/\r?\n/', ',', $config->value))); + + return View::fetch('bulkbuy'); + } } diff --git a/app/index/lang/en-us.php b/app/index/lang/en-us.php index ed7d75cb..7b060d94 100644 --- a/app/index/lang/en-us.php +++ b/app/index/lang/en-us.php @@ -119,5 +119,42 @@ return [ // 返回文本 'send_success' => 'Add Success!', 'send_fail' => 'Add Fail!', - ] + ], + 'contact_bulkbuy' => [ + 'title' => '', + 'form_title' => 'Bulk Buy', + 'form_corp_name_label' => 'Company Name', + 'form_corp_name_placeholder' => 'Legal business name', + 'form_website_url_label' => 'Official website', + 'form_website_url_placeholder' => 'Please paste the URL', + 'form_username_label' => 'Your Name', + 'form_firstname_placeholder' => 'First name', + 'form_lastname_placeholder' => 'Last name', + 'form_email_label' => 'Email', + 'form_email_placeholder' => 'Please enter your email', + 'form_phone_label' => 'Phone Numbe', + 'form_phone_placeholder' => 'Please enter your phone number', + 'form_checkbox_label' => 'Products you are interested in?', + 'form_message_label' => 'Message', + 'form_message_placeholder' => 'Methods used', + 'form_submit' => 'SUBMIT', + // 验证器中文本 + 'validate_corp_name_require' => 'Company Name is required', + 'validate_corp_name_max' => 'Company Name cannot exceed 128 characters', + 'validate_url_max' => 'URL cannot exceed 255 characters', + 'validate_first_name_require' => 'First Name is required', + 'validate_first_name_max' => 'First Name cannot exceed 64 characters', + 'validate_last_name_require' => 'Last Name is required', + 'validate_last_name_max' => 'Last Name cannot exceed 64 characters', + 'validate_email_require' => 'Email is required', + 'validate_email_email' => 'Email format is incorrect', + 'validate_email_max' => 'Email cannot exceed 128 characters', + 'validate_phone_max' => 'Phone Number cannot exceed 32 characters', + 'validate_interested_max' => 'Interested in cannot exceed 255 characters', + 'validate_message_require' => 'Message is required', + 'validate_message_max' => 'Message cannot exceed 1024 characters', + // 返回文本 + '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 cede4917..aa344cac 100644 --- a/app/index/lang/zh-cn.php +++ b/app/index/lang/zh-cn.php @@ -119,5 +119,42 @@ return [ // 返回文本 'send_success' => '信息已成功提交', 'send_fail' => '信息提交失败', - ] + ], + 'contact_bulkbuy' => [ + 'title' => '商务订单', + 'form_title' => '批量购买', + 'form_corp_name_label' => '公司名称', + 'form_corp_name_placeholder' => '法定营业名称', + 'form_website_url_label' => '官方网站', + 'form_website_url_placeholder' => '请粘贴网址', + 'form_username_label' => '姓名', + 'form_firstname_placeholder' => '名', + 'form_lastname_placeholder' => '姓', + 'form_email_label' => '电子邮箱', + 'form_email_placeholder' => '请输入邮箱', + 'form_phone_label' => '电话号码', + 'form_phone_placeholder' => '请输入电话号码', + 'form_checkbox_label' => '您对哪个产品品类感兴趣?', + 'form_message_label' => '留言', + 'form_message_placeholder' => '请输入留言', + 'form_submit' => '提交', + // 验证器中文本 + 'validate_corp_name_require' => '公司名称不能为空', + 'validate_corp_name_max' => '公司名称不能超过128个字符', + 'validate_url_max' => '网址不能超过255个字符', + 'validate_first_name_require' => '名不能为空', + 'validate_first_name_max' => '名不能超过64个字符', + 'validate_last_name_require' => '姓不能为空', + 'validate_last_name_max' => '姓不能超过64个字符', + 'validate_email_require' => '邮箱不能为空', + 'validate_email_email' => '邮箱格式不正确', + 'validate_email_max' => '邮箱不能超过128个字符', + 'validate_phone_max' => '电话号码不能超过32个字符', + 'validate_interested_max' => '感兴趣的产品种类不能超过255个字符', + 'validate_message_require' => '留言内容不能为空', + 'validate_message_max' => '留言内容不能超过1024个字符', + // 返回文本 + 'send_success' => '信息已成功提交', + 'send_fail' => '信息提交失败', + ], ]; \ No newline at end of file diff --git a/app/index/model/BulkPurchaseInquiryModel.php b/app/index/model/BulkPurchaseInquiryModel.php new file mode 100644 index 00000000..61b2a8a5 --- /dev/null +++ b/app/index/model/BulkPurchaseInquiryModel.php @@ -0,0 +1,15 @@ +belongsTo(SysConfigGroupModel::class, 'group_id', 'id'); } + + // 所属名称标识范围查询 + public function scopeByName($query, $name) + { + $query->where('name', '=', $name); + } } diff --git a/app/index/route/route.php b/app/index/route/route.php index 84564f6f..5edd4edb 100644 --- a/app/index/route/route.php +++ b/app/index/route/route.php @@ -70,6 +70,10 @@ Route::group('contactus', function() { Route::get('distributor', 'ContactUs/distributor'); // 提交留言成为分销商 Route::post('distributor', 'ContactUs/distributor'); + // 留言批量购买 + Route::get('bulkbuy', 'ContactUs/bulkbuy'); + // 提交留言批量购买 + Route::post('bulkbuy', 'ContactUs/bulkbuy'); }); // 数据迁移 Route::get('/data/migration', 'DataMigration/index'); diff --git a/app/index/validate/ContactUsBulkBuyValidate.php b/app/index/validate/ContactUsBulkBuyValidate.php new file mode 100644 index 00000000..df009494 --- /dev/null +++ b/app/index/validate/ContactUsBulkBuyValidate.php @@ -0,0 +1,49 @@ + ['规则1','规则2'...] + * + * @var array + */ + protected $rule = [ + 'corp_name' => 'require|max:128', + 'url' => 'max:255', + 'first_name' => 'require|max:64', + 'last_name' => 'require|max:64', + 'email' => 'require|email|max:128', + 'phone' => 'max:32', + 'interested' => 'max:255', + 'message' => 'require|max:1024', + ]; + + /** + * 定义错误信息 + * 格式:'字段名.规则名' => '错误信息' + * + * @var array + */ + protected $message = [ + 'corp_name.require' => 'valudate_corp_name_require', + 'corp_name.max' => 'valudate_corp_name_max', + 'url.max' => 'valudate_url_max', + 'first_name.require' => 'valudate_first_name_require', + 'first_name.max' => 'valudate_first_name_max', + 'last_name.require' => 'valudate_last_name_require', + 'last_name.max' => 'valudate_last_name_max', + 'email.require' => 'valudate_email_require', + 'email.email' => 'valudate_email_email', + 'email.max' => 'valudate_email_max', + 'phone.max' => 'valudate_phone_max', + 'interested.max' => 'valudate_interested_max' , + 'message.require' => 'valudate_message_require', + 'message.max' => 'valudate_message_max', + ]; +} diff --git a/app/index/view/contact_us/bulkbuy.html b/app/index/view/contact_us/bulkbuy.html new file mode 100644 index 00000000..3d351454 --- /dev/null +++ b/app/index/view/contact_us/bulkbuy.html @@ -0,0 +1,104 @@ +{extend name="public/base" /} +{block name="title"} +{notempty name=":lang('contact_bulkbuy.title')"}{:lang('contact_bulkbuy.title')}{else /}{__BLOCK__}{/notempty} +{/block} +{block name="style"} + +{/block} +{block name="main"} +
+ +
+
+

{:lang('contact_bulkbuy.form_title')}

+ +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+ {notempty name="interested"} + {volist name="interested" id="it"} + + {/volist} + {/notempty} +
+
+
+
+
+
+ + +
+
+
+
+ +
{:lang('contact_bulkbuy.form_submit')}
+
+
+
+{/block} +{block name="script"} + +{/block} \ No newline at end of file diff --git a/database/migrations/20241224032339_create_bulk_purchase_inquiry.php b/database/migrations/20241224032339_create_bulk_purchase_inquiry.php index b672be34..e77a5c50 100644 --- a/database/migrations/20241224032339_create_bulk_purchase_inquiry.php +++ b/database/migrations/20241224032339_create_bulk_purchase_inquiry.php @@ -29,7 +29,7 @@ class CreateBulkPurchaseInquiry extends Migrator { $table = $this->table('bulk_purchase_inquiry', ['engine' => 'MyISAM', 'comment' => '批量采购询盘表']); $table->addColumn('language_id', 'integer', ['signed' => false, 'null' => false, 'comment' => '语言ID']) - ->addColumn('corp_name', 'string', ['limit' => 64, 'null' => false, 'comment' => '公司名称']) + ->addColumn('corp_name', 'string', ['limit' => 128, 'null' => false, 'comment' => '公司名称']) ->addColumn('first_name', 'string', ['limit' => 64, 'null' => false, 'comment' => '姓']) ->addColumn('last_name', 'string', ['limit' => 64, 'null' => false, 'comment' => '名']) ->addColumn('email', 'string', ['limit' => 128, 'null' => false, 'comment' => '邮箱']) diff --git a/public/static/index/css/bussiness.css b/public/static/index/css/contactus_bulkbuy.css similarity index 98% rename from public/static/index/css/bussiness.css rename to public/static/index/css/contactus_bulkbuy.css index d0af630b..432b20c4 100755 --- a/public/static/index/css/bussiness.css +++ b/public/static/index/css/contactus_bulkbuy.css @@ -1,7 +1,7 @@ .orico_Page_bussiness { width: 100%; position: relative; - height: 100vh; + min-height: 100vh; overflow-y: auto; overflow-x: hidden; background: #f2f2f2; @@ -10,6 +10,7 @@ width: 100%; background: #f2f2f2; position: relative; + padding-top: 2.5rem; } .orico_Page_bussiness .bussinessMain .bd_main { max-width: 1366px;