This commit is contained in:
尖叫 2023-11-29 11:40:43 +08:00
parent 9a21291172
commit b769d2eceb
4 changed files with 71 additions and 5 deletions

View File

@ -176,9 +176,13 @@ class CommonGoodsEditForm extends Model
$goods_hub->cost_price = $this->cost_price ? $this->cost_price : $this->price;
$goods_hub->detail = $this->detail;
$goods_hub->cover_pic = $this->cover_pic;
$pic_urls = is_string($this->pic_urls) ? $this->pic_urls : json_encode($this->pic_urls);
$goods_hub->pic_urls = $pic_urls;
$goods_hub->video_url = $this->video_url;
$video_urls = is_string($this->video_url) ? $this->video_url : json_encode($this->video_url);
$goods_hub->video_url = $video_urls;
$goods_hub->unit = $this->unit;
$goods_hub->type = $this->type;
if (!$goods_hub->save()) {

View File

@ -196,7 +196,10 @@ class GoodsController extends Controller
$model->date = date('Y-m-d', $model->date);
// var_dump($model->goodsHub->video_url);
// var_dump($model->goodsHub->pic_urls);
//
// die();
return $this->render('edit', [
'cat_list' => $cat_list,
'cat_list1' => $cat_list1,

View File

@ -158,10 +158,39 @@ $this->params['breadcrumbs'][] = $this->title;
// 'imageCompressEnable' => 1,
// 'imageCompressBorder' => 750,
]) ?>
<?php
if (!empty($model->goodsHub->video_url)) {
$json_de = json_decode($model->goodsHub->video_url, true);
$temp_arr = [];
foreach ($json_de as $key => $val) {
if($_SERVER['REMOTE_ADDR'] == '127.0.0.1'){
$val_model = filesize('D:/phpstudy_pro/WWW/cxgj/web' . $val);
}else{
$val_model = filesize(\app\components\SiteHelper::getFullUrl($val));
}
$explode = explode('/', $val);
$end = end($explode);
//
$temp_arr[] = [
'name' => $end,
'url' => $val,
'size_cn' => $val_model,
];
}
$model->goodsHub->video_url = json_encode($temp_arr, JSON_UNESCAPED_UNICODE);
}
?>
<?= PickFile::widget([
'accept' => 'video',
'accept' => 'file',
'multiple' => true,
'id' => 'video_url',
'name' => 'video_url',
'label' => '冠军视频',
@ -212,6 +241,13 @@ $this->params['breadcrumbs'][] = $this->title;
var returnUrl = "<?= $return_url ?>";
var data = obj.field;
var urls = []
urls = window._filelist_video_url.map(function (val) {
console.log(val)
return val.url
})
data.video_url = JSON.stringify(urls);
// if (data.use_attr == 1) {
// for (var i in data.attr) {

View File

@ -97,6 +97,29 @@ $this->params['breadcrumbs'][] = $this->title;
</div>
<?php
if (!empty($model->cover_pic)) {
$json_de = json_decode($model->cover_pic, true);
$temp_arr = [];
foreach ($json_de as $key => $val) {
if ($_SERVER['REMOTE_ADDR'] == '127.0.0.1') {
$val_model = filesize('D:/phpstudy_pro/WWW/cxgj/web' . $val);
} else {
$val_model = filesize(\app\components\SiteHelper::getFullUrl($val));
}
$explode = explode('/', $val);
$end = end($explode);
//
$temp_arr[] = [
'name' => $end,
'url' => $val,
'size_cn' => $val_model,
];
}
$model->cover_pic = json_encode($temp_arr, JSON_UNESCAPED_UNICODE);
}
?>
<?= PickFile::widget([
'accept' => 'file',
'multiple' => true,
@ -177,7 +200,7 @@ $this->params['breadcrumbs'][] = $this->title;
form.render();
$('.layui-card-body').change(function(){
$('.layui-card-body').change(function () {
console.log(window._filelist_cover_pic)
})
@ -195,7 +218,7 @@ $this->params['breadcrumbs'][] = $this->title;
var returnUrl = "<?= $return_url ?>";
var data = obj.field;
var urls = []
urls = window._filelist_cover_pic.map(function(val){
urls = window._filelist_cover_pic.map(function (val) {
console.log(val)
return val.url
})