Browse Source

1.编辑器加布 2.修改宣传资料页面

(cherry picked from commit 87a5247552d4b5d117977f350464e7392d5df1df)
moshaorui 2 days ago
parent
commit
27e984b4b4

+ 1 - 1
app/Admin/bootstrap.php

@@ -52,7 +52,7 @@ $user = Admin::guard()->check() ? Admin::user() : null;
 config(['app.locale' => Cookie::get('lang') ?: config('app.locale')]);
 //编辑器配置
 Editor::resolving(function (Editor $editor) {
-    $editor->setView('admin.form_custom.editor');
+    //$editor->setView('admin.form_custom.editor');
     // 设置默认配置
     $editor->options([
         'plugins'=>["advlist","autolink","link","image","media","lists","preview","code","help","fullscreen","table","autoresize","codesample"],

+ 8 - 0
app/Distributor/Controllers/ImportProductController.php

@@ -27,6 +27,13 @@ class ImportProductController extends AdminDistController
      */
     public function index(Content $content)
     {
+        return $content
+            ->header($this->title())
+            ->description('')
+            //->breadcrumb(['text'=>'Product Management','url'=>''])
+            ->body($this->grid());
+
+        /*
         //记录folder_id
         $folderId = isset($_GET['folder_id']) ? intval($_GET['folder_id']) : 0;
         //保存临时变量
@@ -36,6 +43,7 @@ class ImportProductController extends AdminDistController
             ->body($this->indexForm());
         $html = $html->render();
         return $this->filterHtml($html);
+        */
     }
 
     protected function indexForm()

+ 130 - 5
app/Distributor/Controllers/SiteAlbumController.php

@@ -5,10 +5,13 @@ namespace App\Distributor\Controllers;
 
 use App\Admin\Actions\Grid\RpcAlbumImport;
 use App\Admin\Forms\RpcAlbumImportForm;
+use App\Distributor\Repositories\NullRepository;
 use App\Distributor\Repositories\RpcAlbum;
 use App\Distributor\Repositories\RpcAlbumFolder;
 use App\Distributor\Repositories\DistAdminDistributor;
 use App\Libraries\CommonHelper;
+use Dcat\Admin\Admin;
+use Dcat\Admin\Form;
 use Dcat\Admin\Grid;
 use Dcat\Admin\Http\Controllers\AdminController;
 use Dcat\Admin\Layout\Content;
@@ -26,12 +29,126 @@ class SiteAlbumController extends AdminController
      */
     public function index(Content $content)
     {
-        return $content
+//        return $content
+//            ->header(admin_trans( 'admin.promotional_materials'))
+//            ->breadcrumb(['text'=>'list','url'=>''])
+//            ->body($this->grid());
+        //记录folder_id
+        $folderId = isset($_GET['folder_id']) ? intval($_GET['folder_id']) : 0;
+        //保存临时变量
+        setTempValue('folderId', $folderId);
+        $html =  $content
             ->header(admin_trans( 'admin.promotional_materials'))
-            ->breadcrumb(['text'=>'list','url'=>''])
-            ->body($this->grid());
+            ->body($this->indexForm());
+        $html = $html->render();
+        return $this->filterHtml($html);
+
+    }
+    protected function indexForm()
+    {
+        return Form::make(new NullRepository(), function (Form $form) {
+            $lang = config('app.locale');//当前语言
+            $letf_block_width = 2;
+            $right_block_width = 10;
+            if ($lang == 'en') {
+                $letf_block_width = 3;
+                $right_block_width = 9;
+            }
+            $lang = config('app.locale');//当前语言
+            $form->action('/site-album');
+            $folderTree = RpcAlbumFolder::siteAlbumFolderAllNodes();
+            //显示左边树形菜单
+            $form->block($letf_block_width, function (Form\BlockForm $form) use ($lang,$folderTree) {
+                $type = [
+                    'default'  => [
+                        'icon' => true,
+                    ],
+                ];
+                $plugins = ['types'];
+                if ($lang == 'en') {
+                    $form->tree()
+                        ->setTitleColumn('title_en')
+                        ->nodes($folderTree)
+                        ->type($type)
+                        ->plugins($plugins)
+                        ->width(12,0);
+                } else {
+                    $form->tree()
+                        ->setTitleColumn('title')
+                        ->nodes($folderTree)
+                        ->type($type)
+                        ->plugins($plugins)
+                        ->width(12,0);
+                }
+            });
+            //右边相删内容
+            $form->block($right_block_width, function (Form\BlockForm $form)  {
+                $form->html($this->grid())->width(12);
+            });
+            //以下JS代码用于点击文件夹时,自动跳转到相应页面
+            Admin::script(
+                <<<JS
+// 使用定时器检测容器是否存在
+const interval = setInterval(() => {
+    const containerUl = document.getElementsByClassName('jstree-node');
+    if (containerUl.length > 0) {
+        clearInterval(interval); // 找到容器后停止检测
+        // 以下是原有逻辑(已优化)
+        const folderId = $('select[name="folder_id"]').data('value'); // 提取 folderId 到外层,避免重复查询[1](@ref)
+        const anchors = document.querySelectorAll('a.jstree-anchor');
+
+        anchors.forEach(anchor => {
+            const id = anchor.id.split('_')[0];
+            const href = `/dist/site-album?folder_id=`+id;
+
+            // 绑定点击事件(阻止默认行为)
+            anchor.addEventListener('click', event => {
+                event.preventDefault();
+                window.location.href = href;
+            });
+
+            // 高亮当前节点
+            if (folderId == id) {
+                anchor.classList.add('jstree-clicked');
+            }
+        });
     }
+}, 100); // 每100ms检测一次
 
+        const firstCheckbox = document.querySelector('.vs-checkbox-primary');
+        // 如果找到元素,则隐藏它
+        if (firstCheckbox) {
+            firstCheckbox.style.display = 'none';
+        }
+        //清空_previous_
+        const input = document.querySelector('input[name="_previous_"]');
+        if (input) {
+            // 清空其值
+            input.value = '';
+        }
+JS
+            );
+        });
+    }
+
+    /**
+     * @return void 过滤html 把form去掉,修复form引起的BUG
+     */
+    private function filterHtml($html)
+    {
+        //删除第一个formID对应的JS代码
+        preg_match('/<form[^>]*id="([^"]*)"[^>]*>/', $html, $matches);
+        if (isset($matches[1])) {
+            $formId = $matches[1]; // 获取 id 的值
+            // echo "找到的 form id: " . $formId . "\n";
+            // 2. 根据 id 值,删除对应的 JavaScript 代码
+            $pattern = '/\$\(\'#' . preg_quote($formId, '/') . '\'\)\.form\(\{.*?\}\);/s';
+            $html = preg_replace($pattern, '', $html);
+        }
+        //把第一个form标签替换成div标签
+        $html = preg_replace('/<form([^>]*)>(.*?)<\/form>/s', '<div$1>$2</div>', $html, 1);
+        return $html;
+    }
 
 
     //屏蔽删除
@@ -85,8 +202,16 @@ class SiteAlbumController extends AdminController
             $grid->filter(function (Grid\Filter $filter) use ($rpcAlbumFolder, $lang) {
                 $filter->panel();
                 $filter->expand();
-                $filter->equal('model')->width(2);
-                $filter->equal('folder_id',admin_trans_label('product_category'))->select($rpcAlbumFolder)->width(3);
+                //$filter->equal('model')->width(2);
+                $lang = config('app.locale');//当前语言
+                if ($lang == 'en') {
+                    $filter->equal('title_en')->width(3);
+                    $filter->equal('folder_id',admin_trans_label('product_category'))->select(RpcAlbumFolder::selectOptions($lang))->width(4);
+                } else {
+                    $filter->equal('title')->width(3);
+                    $filter->equal('folder_id',admin_trans_label('product_category'))->select(RpcAlbumFolder::selectOptions($lang))->width(3);
+                }
+               // $filter->equal('folder_id',admin_trans_label('product_category'))->select($rpcAlbumFolder)->width(3);
             });
             // 删除新增按钮
             $grid->disableCreateButton();

+ 5 - 0
config/admin.php

@@ -407,4 +407,9 @@ return [
      * 默认分页条数
      */
     'per_page'=> 10,
+
+    /*
+     * oss域名
+     */
+    'oss_host' => "https://".env('OSS_BUCKET').'.'.env('OSS_ENDPOINT'),
 ];

+ 5 - 0
config/distributor.php

@@ -393,4 +393,9 @@ return [
         // 设置为true启用,false则是停用
         'distributor' => true,
     ],
+
+    /*
+     * oss域名
+     */
+    'oss_host' => "https://".env('OSS_BUCKET').'.'.env('OSS_ENDPOINT'),
 ];

+ 4 - 2
resources/views/admin/form_custom/editor.blade.php

@@ -36,7 +36,7 @@
             tooltip: 'Insert Left Layout',
             onAction: function ()  {
                 const html = tinymce.get(editor.id).getContent();
-                const insterEle = '<div style="padding: 0px 20px 0px 20px;display: block;color: #666;font-size: 16px;line-height: 1.75;-webkit-box-sizing: border-box;font-family: \'Poppins\', \'sans-serif\', \'Arial\';-webkit-font-smoothing: antialiased;unicode-bidi: isolate;"><div style="display: flex;"><div style="width: 65%;padding: 40px 60px;margin: 0;webkit-box-sizing: border-box;font-family: \'Poppins\', \'sans-serif\', \'Arial\';-webkit-font-smoothing: antialiased;display: block;unicode-bidi: isolate;color: #666;font-size: 16px;line-height: 1.75;"><h3 style="font-size: 36px;font-weight: bold;color: #333;margin-bottom: 36px;line-height: 1.75;margin-top: 1em;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;font-family: \'Poppins\', \'sans-serif\', \'Arial\';-webkit-font-smoothing: antialiased;">Intelligent cutting and pasting all-in-one machine </h3><p style="padding: 0;margin: 0;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;font-family: \'Poppins\', \'sans-serif\', \'Arial\';-webkit-font-smoothing: antialiased;color: #666;font-size: 16px;">Intelligent cutting and pasting all-in-one machineFull process automation: integrated cloud database to retrieve model data, laser cutting, vacuum adsorption film, UV curing and other links, eliminating the cumbersome operation of multi-equipment switching, to achieve “one-click” service.</p><\/div><div style="line-height: 1.75;margin-bottom: 1.5em;"><img src="https://mietubl-website.oss-cn-hongkong.aliyuncs.com/static/common/images/500px.png"  style="max-width: 100%;border: 0;overflow-clip-margin: content-box;overflow: clip;"><\/div><\/div><\/div><br \/>';
+                const insterEle = '<div class="product-contect-box"><div class="flex"><div class="i-box"><h3>Intelligent cutting and pasting all-in-one machine</h3><p>Intelligent cutting and pasting all-in-one machineFull process automation: integrated cloud database to retrieve model data, laser cutting, vacuum adsorption film, UV curing and other links, eliminating the cumbersome operation of multi-equipment switching, to achieve “one-click” service.</p><\/div><div class="i-box"><img src="https://mietubl-website.oss-cn-hongkong.aliyuncs.com/static/common/images/500px.png" alt="ANC noise cancelling headphone"><\/div><\/div><\/div><br \/>';
                 tinymce.activeEditor.setContent(html+insterEle);
             }
         });
@@ -47,11 +47,13 @@
             tooltip: 'Insert Right Layout',
             onAction: function ()  {
                 const html = tinymce.get(editor.id).getContent();
-                const insterEle = '<div style="padding: 0px 20px 0px 20px;display: block;color: #666;font-size: 16px;line-height: 1.75;-webkit-box-sizing: border-box;font-family: \'Poppins\', \'sans-serif\', \'Arial\';-webkit-font-smoothing: antialiased;unicode-bidi: isolate;"><div style="display: flex;"><div style="width: 65%;padding: 40px 60px;margin: 0;webkit-box-sizing: border-box;font-family: \'Poppins\', \'sans-serif\', \'Arial\';-webkit-font-smoothing: antialiased;display: block;unicode-bidi: isolate;color: #666;font-size: 16px;line-height: 1.75;"><h3 style="font-size: 36px;font-weight: bold;color: #333;margin-bottom: 36px;line-height: 1.75;margin-top: 1em;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;font-family: \'Poppins\', \'sans-serif\', \'Arial\';-webkit-font-smoothing: antialiased;">European Union certified intelligent film cutting machine</h3><p style="padding: 0;margin: 0;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;font-family: \'Poppins\', \'sans-serif\', \'Arial\';-webkit-font-smoothing: antialiased;color: #666;font-size: 16px;">24000+ models updated in the cloud, on-demand cut phone/tablet/watch film, open consumables, personalized back film customization, one machine to solve the inventory problem.</p><\/div><div style="order: -1;line-height: 1.75;margin-bottom: 1.5em;"><img src="https://mietubl-website.oss-cn-hongkong.aliyuncs.com/static/common/images/500px.png" style="max-width: 100%;border: 0;overflow-clip-margin: content-box;overflow: clip;"><\/div><\/div><\/div><br \/>';
+                const insterEle = '<div class="product-contect-box"><div class="flex fright"><div class="i-box"><h3>European Union certified intelligent film cutting machine</h3><p>24000+ models updated in the cloud, on-demand cut phone/tablet/watch film, open consumables, personalized back film customization, one machine to solve the inventory problem.</p><\/div><div class="i-box"><img src="https://mietubl-website.oss-cn-hongkong.aliyuncs.com/static/common/images/500px.png" alt="ANC headphone"><\/div><\/div><\/div><br \/>';
                 tinymce.activeEditor.setContent(html+insterEle);
             }
         });
     }
     opts.max_height = 730;
+    opts.content_css = '{{ config('admin.oss_host') }}/static/common/css/common.css';
     tinymce.init(opts)
 </script>
+

+ 4 - 2
resources/views/distributor/form_custom/editor.blade.php

@@ -36,7 +36,7 @@
             tooltip: 'Insert Left Layout',
             onAction: function ()  {
                 const html = tinymce.get(editor.id).getContent();
-                const insterEle = '<div style="padding: 0px 20px 0px 20px;display: block;color: #666;font-size: 16px;line-height: 1.75;-webkit-box-sizing: border-box;font-family: \'Poppins\', \'sans-serif\', \'Arial\';-webkit-font-smoothing: antialiased;unicode-bidi: isolate;"><div style="display: flex;"><div style="width: 65%;padding: 40px 60px;margin: 0;webkit-box-sizing: border-box;font-family: \'Poppins\', \'sans-serif\', \'Arial\';-webkit-font-smoothing: antialiased;display: block;unicode-bidi: isolate;color: #666;font-size: 16px;line-height: 1.75;"><h3 style="font-size: 36px;font-weight: bold;color: #333;margin-bottom: 36px;line-height: 1.75;margin-top: 1em;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;font-family: \'Poppins\', \'sans-serif\', \'Arial\';-webkit-font-smoothing: antialiased;">Intelligent cutting and pasting all-in-one machine </h3><p style="padding: 0;margin: 0;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;font-family: \'Poppins\', \'sans-serif\', \'Arial\';-webkit-font-smoothing: antialiased;color: #666;font-size: 16px;">Intelligent cutting and pasting all-in-one machineFull process automation: integrated cloud database to retrieve model data, laser cutting, vacuum adsorption film, UV curing and other links, eliminating the cumbersome operation of multi-equipment switching, to achieve “one-click” service.</p><\/div><div style="line-height: 1.75;margin-bottom: 1.5em;"><img src="https://mietubl-website.oss-cn-hongkong.aliyuncs.com/static/common/images/500px.png"  style="max-width: 100%;border: 0;overflow-clip-margin: content-box;overflow: clip;"><\/div><\/div><\/div><br \/>';
+                const insterEle = '<div class="product-contect-box"><div class="flex"><div class="i-box"><h3>Intelligent cutting and pasting all-in-one machine</h3><p>Intelligent cutting and pasting all-in-one machineFull process automation: integrated cloud database to retrieve model data, laser cutting, vacuum adsorption film, UV curing and other links, eliminating the cumbersome operation of multi-equipment switching, to achieve “one-click” service.</p><\/div><div class="i-box"><img src="https://mietubl-website.oss-cn-hongkong.aliyuncs.com/static/common/images/500px.png" alt="ANC noise cancelling headphone"><\/div><\/div><\/div><br \/>';
                 tinymce.activeEditor.setContent(html+insterEle);
             }
         });
@@ -47,11 +47,13 @@
             tooltip: 'Insert Right Layout',
             onAction: function ()  {
                 const html = tinymce.get(editor.id).getContent();
-                const insterEle = '<div style="padding: 0px 20px 0px 20px;display: block;color: #666;font-size: 16px;line-height: 1.75;-webkit-box-sizing: border-box;font-family: \'Poppins\', \'sans-serif\', \'Arial\';-webkit-font-smoothing: antialiased;unicode-bidi: isolate;"><div style="display: flex;"><div style="width: 65%;padding: 40px 60px;margin: 0;webkit-box-sizing: border-box;font-family: \'Poppins\', \'sans-serif\', \'Arial\';-webkit-font-smoothing: antialiased;display: block;unicode-bidi: isolate;color: #666;font-size: 16px;line-height: 1.75;"><h3 style="font-size: 36px;font-weight: bold;color: #333;margin-bottom: 36px;line-height: 1.75;margin-top: 1em;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;font-family: \'Poppins\', \'sans-serif\', \'Arial\';-webkit-font-smoothing: antialiased;">European Union certified intelligent film cutting machine</h3><p style="padding: 0;margin: 0;-webkit-box-sizing: border-box;-moz-box-sizing: border-box;font-family: \'Poppins\', \'sans-serif\', \'Arial\';-webkit-font-smoothing: antialiased;color: #666;font-size: 16px;">24000+ models updated in the cloud, on-demand cut phone/tablet/watch film, open consumables, personalized back film customization, one machine to solve the inventory problem.</p><\/div><div style="order: -1;line-height: 1.75;margin-bottom: 1.5em;"><img src="https://mietubl-website.oss-cn-hongkong.aliyuncs.com/static/common/images/500px.png" style="max-width: 100%;border: 0;overflow-clip-margin: content-box;overflow: clip;"><\/div><\/div><\/div><br \/>';
+                const insterEle = '<div class="product-contect-box"><div class="flex fright"><div class="i-box"><h3>European Union certified intelligent film cutting machine</h3><p>24000+ models updated in the cloud, on-demand cut phone/tablet/watch film, open consumables, personalized back film customization, one machine to solve the inventory problem.</p><\/div><div class="i-box"><img src="https://mietubl-website.oss-cn-hongkong.aliyuncs.com/static/common/images/500px.png" alt="ANC headphone"><\/div><\/div><\/div><br \/>';
                 tinymce.activeEditor.setContent(html+insterEle);
             }
         });
     }
     opts.max_height = 730;
+    opts.content_css = '{{ config('distributor.oss_host') }}/static/common/css/common.css';
     tinymce.init(opts)
 </script>
+