From fc782e23cd5d878083e28d697d1a70c6a6f4be7a Mon Sep 17 00:00:00 2001 From: linyaostalker <602604991@qq.com> Date: Sat, 7 Dec 2019 09:56:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=B9=E6=8D=AE=E4=B8=B4?= =?UTF-8?q?=E6=97=B6=E6=96=87=E4=BB=B6id=E5=B0=86=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=BF=9D=E5=AD=98=E5=9C=A8=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=AD=E6=96=B9=E6=B3=95=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/file/logic/file/FileManager.php | 14 ++++---- backend/modules/goods/views/goods/express.php | 35 +++++++++++++++++++ 2 files changed, 41 insertions(+), 8 deletions(-) create mode 100755 backend/modules/goods/views/goods/express.php diff --git a/backend/modules/file/logic/file/FileManager.php b/backend/modules/file/logic/file/FileManager.php index 80d2f26..ba555a7 100755 --- a/backend/modules/file/logic/file/FileManager.php +++ b/backend/modules/file/logic/file/FileManager.php @@ -15,7 +15,7 @@ class FileManager const TYPE_WORD = 4;//word文本 const TYPE_TXT = 5;//txt文本 - public static $extension = [ + private $extension = [ self::TYPE_IMAGE => ['jpg', 'png', 'jpeg'], self::TYPE_VIDEO => ['mp4'], self::TYPE_EXCEL => [], @@ -29,16 +29,14 @@ class FileManager * @return array * 根据文件拓展名在$extension中查找对应的文件类型,若不存在则返回false */ - public function searchType($array, $keyword) + public function searchType($keyword) { - foreach($array as $key => $value){ - foreach ($value as $k => $v) { - if($v == $keyword){ - return ['status' => true, 'info' => '操作成功', 'type' => $key]; - } + foreach($this->extension as $key => $type){ + if (in_array($keyword, $type)) { + return $key; } } - return ['status' => false, 'info' => '操作失败']; + return 0; } /** diff --git a/backend/modules/goods/views/goods/express.php b/backend/modules/goods/views/goods/express.php new file mode 100755 index 0000000..022f640 --- /dev/null +++ b/backend/modules/goods/views/goods/express.php @@ -0,0 +1,35 @@ + +field($model, 'coverImageId')->hiddenInput()->label('') ?> +field($model, 'coverImagePath')->widget(\iron\widgets\Upload::className(), [ + 'url' => 'upload', + 'deleteUrl' => 'img-id-del', + 'dragdropWidth'=> 800, + 'afterSave' => 'save-file', + 'maxCount' => 1, + 'fillInAttribute' => 'coverImageId', + 'model' => $model, + 'previewConfig' => [ + 'url' => Url::to(['image-file', 'fileidstr' => $model->coverImageId, 'ruleverify' => $model->ruleVerify]), + ], +])->label('商品封面图') ?> + +field($model, 'detailImageId')->hiddenInput()->label('') ?> +field($model, 'detailImagePath')->widget(\iron\widgets\Upload::className(), [ + 'url' => 'upload', + 'deleteUrl' => 'img-id-del', + 'dragdropWidth'=> 800, + 'afterSave' => 'save-file', + 'maxCount' => 5, + 'fillInAttribute' => 'detailImageId', + 'model' => $model, + 'previewConfig' => [ + 'url' => Url::to(['image-file', 'fileidstr' => $model->detailImageId, 'ruleverify' => $model->ruleVerify]), + ], +])->label('商品详情图') ?>