瀏覽代碼

feat: 修复BUG

xiansin 2 年之前
父節點
當前提交
1f6b99a2fa

+ 7 - 1
mini/pages/product/detail.vue

xqd xqd xqd
@@ -198,6 +198,9 @@ export default {
     },
     getDetail() {
       this.$api.product.detail(this.id).then(res => {
+        wx.setNavigationBarTitle({
+          title: res.data.name
+        })
         this.loading = false
         res.data.specs.forEach(obj => {
           obj.show = true
@@ -252,6 +255,9 @@ export default {
         padding: 10rpx 0 20rpx 30rpx;
         color: #333;
         font-size: 26rpx;
+        .icon{
+          padding-right: 150rpx;
+        }
       }
       &.show{
         display: flex;
@@ -293,7 +299,7 @@ export default {
   .float-btn{
     position: fixed;
     bottom: 120rpx;
-    right: 10rpx;
+    right: 0rpx;
   }
   .float-view{
     position: fixed;

+ 2 - 3
mini/pages/product/index.vue

xqd xqd
@@ -22,7 +22,7 @@
           @click="$u.route({url: `/pages/product/list?cate_id=${item.id}`})"
         >
           <view class="detail dir-top-wrap">
-            <text>热销品类排名</text>
+            <!--            <text>热销品类排名</text>-->
             <view class="name"> {{ item.name }}</view>
           </view>
           <view class="cover-img">
@@ -73,9 +73,8 @@ export default {
 
 <style lang="scss" scoped>
 .product-page {
-  padding: 0 30rpx;
+  padding: 0 30rpx 100rpx;
   overflow: hidden;
-  height: 100vh;
   .logo{
     margin: 30rpx auto;
   }

+ 32 - 23
server/app/Admin/Controllers/ProductController.php

xqd xqd xqd xqd xqd
@@ -13,6 +13,7 @@ use Dcat\Admin\Layout\Row;
 use Dcat\Admin\Show;
 use Dcat\Admin\Http\Controllers\AdminController;
 use Dcat\Admin\Widgets\Tab;
+use function AlibabaCloud\Client\json;
 
 class ProductController extends AdminController
 {
@@ -91,7 +92,7 @@ class="img img-thumbnail">';
                 })->width(2);
                 $filter->like('name')->width(2);
 
-                $filter->between('name')->datetime()->width(4);
+                //$filter->between('name')->datetime()->width(4);
             });
 
             $grid->batchActions([new BatchProduct()]);
@@ -103,15 +104,15 @@ class="img img-thumbnail">';
                     'name'       => '产品名称',
                     'cate_name'  => '产品分类',
                     'cover_img'  => '产品截面图',
-                    'cases'      => '案例',
-                    'tech_param' => '技术参数文件',
-                    'cad_model'  => 'CAD模型文件',
-                    'cad_design' => 'CAD设计文件',
-                    'su_model'   => 'SU模型文件',
-                    'other'      => '其他文件',
-                    'is_opened'  => '上架状态',
+                    'cases_value'      => '案例',
+                    'tech_param_value' => '技术参数文件',
+                    'cad_model_value'  => 'CAD模型文件',
+                    'cad_design_value' => 'CAD设计文件',
+                    'su_model_value'   => 'SU模型文件',
+                    'other_value'      => '其他文件',
+                    'opened_value'  => '上架状态',
                     'sort'       => '排序(越大越靠前)',
-                    'specs'      => '规格',
+                    'specs_value'      => '规格',
                 ])->rows(function ($rows){
                     foreach ($rows as $index => &$row) {
                         $specs = [];
@@ -123,18 +124,19 @@ class="img img-thumbnail">';
                             $specs[] = $spec['name'].':('.implode(",",$arr).')';
                         }
                         $row['cate_name'] = $row['cate']['name'];
-                        $row['cases'] = implode(",",$row['cases']);
-                        $row['tech_param']   = implode(",",$row['tech_param']);
-                        $row['cad_model']  = implode(",",$row['cad_model']);
-                        $row['cad_design']   = implode(",",$row['cad_design']);
-                        $row['su_model']  = implode(",",$row['su_model']);
-                        $row['other']  = implode(',', $row['other']);
-                        $row['is_opened']  = config('global.bool_status')[$row['is_opened']];
-                        $row['specs']  = implode(",",$specs);
+                        $row['cases_value'] = implode(";",$row['cases']);
+                        $row['tech_param_value']   = implode(";", array_column($row['tech_param'],'url'));
+                        $row['cad_model_value']  = implode(";",  array_column($row['cad_model'],'url'));
+                        $row['cad_design_value']   = implode(";", array_column($row['cad_design'],'url'));
+                        $row['su_model_value']  = implode(";", array_column($row['su_model'],'url'));
+                        $row['other_value']  = implode(';',  array_column($row['other'],'url'));
+                        $row['opened_value']  = config('global.bool_status')[$row['is_opened']];
+                        $row['specs_value']  = implode(";",$specs);
+
                     }
                     return $rows;
                 })
-                ->xlsx()
+                ->csv()
                 ->disableExportSelectedRow();
         });
     }
@@ -195,25 +197,32 @@ class="img img-thumbnail">';
                 ->width(4)->sortable();
 
             $form->table('tech_param', function (Form\NestedForm $table) {
-                $table->url('url','链接')->required();
+                $table->url('url','链接');
             });
             $form->table('cad_model', function (Form\NestedForm $table) {
-                $table->url('url','链接')->required();
+                $table->url('url','链接');
             });
             $form->table('cad_design', function (Form\NestedForm $table) {
-                $table->url('url','链接')->required();
+                $table->url('url','链接');
             });
             $form->table('su_model', function (Form\NestedForm $table) {
-                $table->url('url','链接')->required();
+                $table->url('url','链接');
             });
             $form->table('other', function (Form\NestedForm $table) {
                 $table->text('name','名称')->required();
-                $table->url('url','链接')->required();
+                $table->url('url','链接');
             });
 
 
             $form->radio('is_opened')->options(config('global.bool_status'))->default(1);
             $form->number('sort');
+            $form->saving(function (Form $form) {
+                $form->tech_param = $form->tech_param ?? [];
+                $form->cad_model = $form->cad_model ?? [];
+                $form->cad_design = $form->cad_design ?? [];
+                $form->su_model = $form->su_model ?? [];
+                $form->other = $form->other ?? [];
+            });
 
             $form->disableViewButton();
             $form->disableDeleteButton();

+ 9 - 3
server/app/Admin/Controllers/ProductHotController.php

xqd
@@ -85,10 +85,16 @@ class ProductHotController extends AdminController
         return Form::make(new ProductHot(), function (Form $form) {
             $form->display('id');
             $form->hidden('type')->value($this->type);
-            $cates = Product::select(['id','name'])->where('is_opened',1)->get()->toArray();
-            $form->multipleSelect('product_id')
+            $cates = ProductCategory::select(['id','name'])->where('is_opened',1)->get()->toArray();
+            $form->multipleSelect(null,'分类')
                 ->options(array_column($cates,'name','id'))
-                ->required();
+                ->when(2, function (Form $form){
+                    $products = Product::select(['id','name'])->where('is_opened',1)->get()->toArray();
+                    $form->multipleSelect('product_id')
+                        ->options(array_column($products,'name','id'))
+                        ->required();
+                });
+
             $form->image('cover_img','爆款图片(宽高比 1.34:1)')->saveFullUrl()
                 ->uniqueName()->autoUpload()
                 ->autoSave(false)

+ 1 - 1
server/app/Admin/Controllers/ProductSpecController.php

xqd
@@ -69,7 +69,7 @@ class ProductSpecController extends AdminController
      */
     protected function grid()
     {
-        return Grid::make(new ProductSpec(), function (Grid $grid) {
+        return Grid::make(ProductSpec::where('product_id', $this->product_id), function (Grid $grid) {
             $grid->model()->orderByDesc('sort');
             $grid->column('id')->sortable();
             $grid->column('name')->label('primary');

+ 52 - 1
server/app/Admin/bootstrap.php

xqd xqd
@@ -5,7 +5,6 @@ use Dcat\Admin\Grid;
 use Dcat\Admin\Form;
 use Dcat\Admin\Grid\Filter;
 use Dcat\Admin\Show;
-
 /**
  * Dcat-admin - admin builder based on Laravel.
  * @author jqh <https://github.com/jqhph>
@@ -24,3 +23,55 @@ use Dcat\Admin\Show;
  * Admin::js('/packages/prettydocs/js/main.js');
  *
  */
+
+Form\Field\Editor::resolving(function (Form\Field\Editor $editor) {
+    $editor->options([
+        'file_picker_types' => 'media',
+        'file_picker_callback' => \Dcat\Admin\Support\JavaScript::make(<<<JS
+            function file_picker_callback (callback, value, meta) {
+                // 设置上传地址为原富文本框图片文件上传地址
+                var upurl = opts.images_upload_url;
+                var filetype = '';
+                // 处理媒体类型文件能选择的文件类型
+                if (meta.filetype == 'media') {
+                    filetype = '.mp4,.webm,.ogg'
+                }
+                //模拟出一个input用于添加本地文件
+                var input = document.createElement('input');
+                input.setAttribute('type', 'file');
+                input.setAttribute('accept', filetype);
+                // 模拟点击file input
+                input.click();
+                input.onchange = function() {
+                    // 文件选择后进行上传
+                    var file = this.files[0];
+                    var xhr, formData;
+                    console.log(file.name);
+                    Dcat.loading()
+                    xhr = new XMLHttpRequest();
+                    xhr.withCredentials = false;
+                    xhr.open('POST', upurl);
+                    xhr.onload = function() {
+                        var json;
+                        if (xhr.status != 200) {
+                            failure('HTTP Error: ' + xhr.status);
+                            return;
+                        }
+                        json = JSON.parse(xhr.responseText);
+                        if (!json || typeof json.location != 'string') {
+                            failure('Invalid JSON: ' + xhr.responseText);
+                            return;
+                        }
+                        json.location = json.location.replace('http://','https://')
+                        json.location = json.location.replace('-internal','')
+                        Dcat.loading(false)
+                        callback(json.location);
+                    };
+                    formData = new FormData();
+                    formData.append('file', file, file.name );
+                    xhr.send(formData);
+                }
+            }
+        JS)
+    ]);
+});

+ 4 - 2
server/app/Casts/HttpToHttps.php

xqd
@@ -6,12 +6,14 @@ class HttpToHttps  implements CastsAttributes
 {
     public function get($model, string $key, $value, array $attributes)
     {
-        return  str_replace('http://','https://',$value);
+        $value = str_replace('http://','https://',$value);
+        return str_replace('-internal','',$value);
     }
 
 
     public function set($model, string $key, $value, array $attributes)
     {
-        return str_replace('http://','https://',$value);
+        $value = str_replace('http://','https://',$value);
+        return str_replace('-internal','',$value);
     }
 }

+ 3 - 1
server/app/Casts/HttpToHttpsArray.php

xqd xqd
@@ -9,8 +9,9 @@ class HttpToHttpsArray  implements CastsAttributes
         $arr = json_decode($value,true);
         foreach ($arr as &$item){
             $item = str_replace('http://','https://',$item);
+            $item = str_replace('-internal','',$item);
         }
-        return  $arr;
+        return $arr;
     }
 
 
@@ -18,6 +19,7 @@ class HttpToHttpsArray  implements CastsAttributes
     {
         foreach ($value as &$item){
             $item = str_replace('http://','https://',$item);
+            $item = str_replace('-internal','',$item);
         }
         return json_encode($value);
     }

+ 2 - 2
server/app/Http/Controllers/V1/ProductController.php

xqd
@@ -32,8 +32,8 @@ class ProductController extends Controller
                 return $query->where('name','like', "%$keywords%");
             })
             ->orderByDesc('sort')
-            ->limit($limit)
-            ->offset($offset)
+//            ->limit($limit)
+//            ->offset($offset)
             ->get();
 
         return $this->success($lists);