diff --git a/models/common/CommonGoodsEditForm.php b/models/common/CommonGoodsEditForm.php index f55cab0..834e5cf 100644 --- a/models/common/CommonGoodsEditForm.php +++ b/models/common/CommonGoodsEditForm.php @@ -67,12 +67,15 @@ class CommonGoodsEditForm extends Model public $date; public $signing_foot_img; public $signing_head_img; + public $video_url_data_title; + public $video_url_data_url; + public $video_url_data_img; public function rules() { return [ [['name', 'subtitle', 'detail', 'cover_pic', 'video_url', 'unit', 'plugin_sign', 'goods_no',], 'trim'], - [['name', 'subtitle', 'detail', 'price', 'cover_pic', 'video_url', 'video_banner_urls', 'banner_urls', 'unit', 'plugin_sign', 'goods_no', 'date', 'signing_head_img', 'signing_foot_img'], 'string'], + [['name', 'subtitle','video_url_data_url','video_url_data_title','video_url_data_img', 'detail', 'price', 'cover_pic', 'video_url', 'video_banner_urls', 'banner_urls', 'unit', 'plugin_sign', 'goods_no', 'date', 'signing_head_img', 'signing_foot_img'], 'string'], [['original_price', 'cost_price', 'goods_weight'], 'number'], [['type', 'use_attr', 'goods_stock', 'virtual_sales', 'confine_count', 'freight_id', 'sort', 'cx_mch_id'], 'integer'], @@ -185,6 +188,18 @@ class CommonGoodsEditForm extends Model $goods_hub = new GoodsHub(); $goods_hub->cx_mch_id = $this->cx_mch_id; } + $video_url_data_arr = []; + if(!empty($this->video_url_data_url)){ + $video_url_data_arr[0]['url'] = $this->video_url_data_url; + } + if(!empty($this->video_url_data_title)){ + $video_url_data_arr[0]['title'] = $this->video_url_data_title; + } + if(!empty($this->video_url_data_img)){ + $video_url_data_arr[0]['img'] = $this->video_url_data_img; + } + + $goods_hub->video_url_data = json_encode($video_url_data_arr,JSON_UNESCAPED_UNICODE); $goods_hub->name = $this->name; $goods_hub->subtitle = $this->subtitle; // $goods_hub->original_price = $this->original_price ? $this->original_price : $this->price; @@ -333,6 +348,9 @@ class CommonGoodsEditForm extends Model private function addAttrGroupsId($list, &$id = 1) { + if(!is_array($list)){ + return []; + } $newId = 1; foreach ($list as $key => $item) { if (isset($item['attr_list'])) { @@ -401,7 +419,7 @@ class CommonGoodsEditForm extends Model ]; // 未使用规格情况下,要把上一次的规格ID 存回去,不然规格记录会重复添加 - if (count($this->attr) === 1 && isset($this->attr[0]['id'])) { + if (!empty($this->attr) && count($this->attr) === 1 && isset($this->attr[0]['id'])) { $newAttrs[0]['id'] = $this->attr[0]['id']; } diff --git a/modules/admin/controllers/mall/GoodsController.php b/modules/admin/controllers/mall/GoodsController.php index 85b05a8..7d21a92 100644 --- a/modules/admin/controllers/mall/GoodsController.php +++ b/modules/admin/controllers/mall/GoodsController.php @@ -219,8 +219,16 @@ class GoodsController extends Controller $attr[$index] = $item; } } + $video_url_data_url = ""; + $video_url_data_title = ""; + $video_url_data_img = ""; + if(!empty($model->goodsHub->video_url_data)){ + $json_decode = json_decode($model->goodsHub->video_url_data,true); + $video_url_data_url = $json_decode[0]['url']; + $video_url_data_title = $json_decode[0]['title']; + $video_url_data_img = $json_decode[0]['img']; - + } return $this->render('edit', [ 'cat_list' => $cat_list, @@ -232,6 +240,9 @@ class GoodsController extends Controller 'attr_groups' => $attr_groups, 'model' => $model, 'return_url' => $return_url, + 'video_url_data_url' => $video_url_data_url, + 'video_url_data_title' => $video_url_data_title, + 'video_url_data_img' => $video_url_data_img, ]); } diff --git a/modules/admin/views/mall/goods/edit.php b/modules/admin/views/mall/goods/edit.php index 0adcb84..8f12662 100644 --- a/modules/admin/views/mall/goods/edit.php +++ b/modules/admin/views/mall/goods/edit.php @@ -198,7 +198,7 @@ $this->params['breadcrumbs'][] = $this->title; foreach ($json_de as $key => $val) { $explode = explode('/', $val); $end = end($explode); - // + //12G $temp_arr[] = [ 'name' => $end, 'url' => $val, @@ -208,13 +208,44 @@ $this->params['breadcrumbs'][] = $this->title; } ?> + = PickFile::widget([ + 'accept' => 'video', + 'multiple' => false, + 'id' => 'video_url_data_url', + 'name' => 'video_url_data_url', + 'label' => '冠军视频', + 'value' => $video_url_data_url ? $video_url_data_url : '', + 'tip' => '视频最大50M', + 'required' => false + ]) ?> +
| {{attr_group['attr_group_name']}} | +
+ 价格
+
+
+
+
+
+
+ |
+
+ 库存
+
+
+
+
+
+
+ |
+
- 价格
+ 积分
-
+
-
-
+
+
|
-
+
+
+ 货号
+ |
+
+ 重量
+ |
+
+ 图片
+ |
-
|---|---|---|---|---|---|---|
| {{attr_val.attr_name}} | -- - | |||||
| {{attr_val.attr_name}} | ++ | + + | + + | + | + |
+
+
+
+
+
+
+
+
+ |
+