feat: 联系我们 - 客户服务

This commit is contained in:
2025-04-21 17:30:50 +08:00
committed by jsasg
parent e18d39247f
commit be48d8a951
6 changed files with 202 additions and 0 deletions

View File

@@ -11,6 +11,7 @@ use app\index\model\SysBannerModel;
use app\index\validate\ContactUsDistributorValidate;
use app\index\validate\ContactUsMessageValidate;
use think\facade\View;
use \think\helper\Str;
/**
* 联系我们控制器
@@ -22,6 +23,36 @@ class ContactUs extends Common
*/
public function index()
{
$focus_image = [];
$info_datas = [];
// 获取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_6805e3d32dcc2', 'BANNER_6806090c1838f'])
->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_6805e3d32dcc2')?->items->first()?->toArray();
$info_datas = data_get($banner_map, 'BANNER_6806090c1838f')?->items->each(function($item) {
if (Str::contains($item->title, '<br/>')) {
$title = explode('<br/>', $item->title);
$item->title = $title[0];
$item->title_short = $title[1];
}
return $item;
})->chunk(4)->toArray();
}
View::assign('focus_image', $focus_image);
View::assign('info_datas', $info_datas);
return View::fetch('index');
}