商品规格图片优化
parent
7f71091554
commit
7b54a3c48c
|
|
@ -171,8 +171,7 @@ class Common extends Controller
|
|||
{
|
||||
exit(json_encode(DataReturn($name.' 非法访问', -1000)));
|
||||
} else {
|
||||
$this->assign('msg', $name.' 非法访问');
|
||||
return $this->fetch('public/error');
|
||||
exit($name.' 非法访问');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@ class Error extends Common
|
|||
{
|
||||
exit(json_encode(DataReturn($request->controller().' 控制器不存在', -1000)));
|
||||
} else {
|
||||
$this->assign('msg', $request->controller().' 控制器不存在');
|
||||
return $this->fetch('public/error');
|
||||
exit($request->controller().' 控制器不存在');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -255,23 +255,29 @@
|
|||
<span class="business-operations-submit specifications-line-add">+添加一行</span>
|
||||
<span class="business-operations-submit specifications-line-images-add m-l-10">+添加规格图片</span>
|
||||
<ul class="spec-images-list">
|
||||
{{if !empty($specifications['images'])}}
|
||||
<div class="am-alert am-alert-warning am-radius" data-am-alert>
|
||||
<button type="button" class="am-close">×</button>
|
||||
<p class="fs-12">规格名称与规格值保持一致,相同规格名称添加一次即可,重复添加则后面覆盖前面,顺序不影响前端展示效果。</p>
|
||||
</div>
|
||||
{{foreach $specifications.images as $spec_images}}
|
||||
<li class="spec-images-items spec-images-items-{{$spec_images.id}}">
|
||||
<input type="text" name="spec_images_name[{{$spec_images.id}}]" placeholder="规格名称" class="am-radius t-c" data-validation-message="请填写规格名称" value="{{$spec_images.name}}" required >
|
||||
<ul class="plug-file-upload-view spec-images-view-{{$spec_images.id}}" data-form-name="spec_images[{{$spec_images.id}}]" data-max-number="1" data-delete='0' data-dialog-type="images">
|
||||
<li>
|
||||
<input type="hidden" name="spec_images[{{$spec_images.id}}]" value="{{$spec_images.images_old}}" data-validation-message="请上传规格图片" required />
|
||||
<img src="{{$spec_images.images}}" />
|
||||
<i>×</i>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="plug-file-upload-submit" data-view-tag="ul.spec-images-view-{{$spec_images.id}}">+上传图片</div>
|
||||
</li>
|
||||
{{if !empty($specifications['type'])}}
|
||||
{{foreach $specifications.type as $type}}
|
||||
{{if !empty($type['value'])}}
|
||||
{{foreach $type.value as $spec_key=>$spec}}
|
||||
{{if !empty($spec['images'])}}
|
||||
<li class="spec-images-items spec-images-items-{{$type.id}}{{$spec_key}}">
|
||||
<input type="text" name="spec_images_name[{{$type.id}}{{$spec_key}}]" placeholder="规格名称" class="am-radius t-c" data-validation-message="请填写规格名称" value="{{$spec.name}}" required >
|
||||
<ul class="plug-file-upload-view spec-images-view-{{$type.id}}{{$spec_key}}" data-form-name="spec_images[{{$type.id}}{{$spec_key}}]" data-max-number="1" data-delete='0' data-dialog-type="images">
|
||||
<li>
|
||||
<input type="hidden" name="spec_images[{{$type.id}}{{$spec_key}}]" value="{{$spec.images_old}}" data-validation-message="请上传规格图片" required />
|
||||
<img src="{{$spec.images}}" />
|
||||
<i>×</i>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="plug-file-upload-submit" data-view-tag="ul.spec-images-view-{{$type.id}}{{$spec_key}}">+上传图片</div>
|
||||
</li>
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,5 @@
|
|||
{{include file="public/header" /}}
|
||||
|
||||
<!-- nav start -->
|
||||
{{include file="public/nav" /}}
|
||||
<!-- nav end -->
|
||||
|
||||
<!-- header top nav -->
|
||||
{{include file="public/header_top_nav" /}}
|
||||
|
||||
|
|
|
|||
|
|
@ -144,11 +144,11 @@
|
|||
<div class="cart-title">{{$spec.name}}</div>
|
||||
<ul>
|
||||
{{foreach $spec.value as $keys=>$specs}}
|
||||
<li class="sku-line {{if !empty($goods['specifications']['images'][$specs])}} sku-line-images{{/if}} {{if $key gt 0}} sku-dont-choose{{/if}}" data-type-value="{{$spec.name}}" data-value="{{$specs}}" {{if !empty($goods['specifications']['images'][$specs])}} data-type-images="{{$goods.specifications.images[$specs]}}"{{/if}}>
|
||||
{{if !empty($goods['specifications']['images'][$specs])}}
|
||||
<img src="{{$goods.specifications.images[$specs]}}" />
|
||||
<li class="sku-line {{if !empty($specs['images'])}} sku-line-images{{/if}} {{if $key gt 0}} sku-dont-choose{{/if}}" data-type-value="{{$spec.name}}" data-value="{{$specs.name}}" {{if !empty($specs['images'])}} data-type-images="{{$specs.images}}"{{/if}}>
|
||||
{{if !empty($specs['images'])}}
|
||||
<img src="{{$specs.images}}" />
|
||||
{{/if}}
|
||||
{{$specs}}<i></i>
|
||||
{{$specs.name}}<i></i>
|
||||
</li>
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,5 @@
|
|||
{{include file="public/header" /}}
|
||||
|
||||
<!-- nav start -->
|
||||
{{include file="public/nav" /}}
|
||||
<!-- nav end -->
|
||||
|
||||
<!-- header top nav -->
|
||||
{{include file="public/header_top_nav" /}}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
{{include file="public/header" /}}
|
||||
|
||||
<!-- nav start -->
|
||||
{{include file="public/nav" /}}
|
||||
<!-- nav end -->
|
||||
|
||||
<!-- header top nav -->
|
||||
{{include file="public/header_top_nav" /}}
|
||||
|
||||
|
|
|
|||
|
|
@ -371,25 +371,20 @@ class GoodsService
|
|||
$type = Db::name('GoodsSpecType')->where($where)->order('id asc')->select();
|
||||
if(!empty($type))
|
||||
{
|
||||
// 数据处理
|
||||
$images_host = config('images_host');
|
||||
foreach($type as &$temp_type)
|
||||
{
|
||||
$temp_type['value'] = json_decode($temp_type['value'], true);
|
||||
$temp_type_value = json_decode($temp_type['value'], true);
|
||||
foreach($temp_type_value as &$vs)
|
||||
{
|
||||
$vs['images'] = empty($vs['images']) ? '' : $images_host.$vs['images'];
|
||||
}
|
||||
$temp_type['value'] = $temp_type_value;
|
||||
$temp_type['add_time'] = date('Y-m-d H:i:s');
|
||||
}
|
||||
}
|
||||
|
||||
// 规格图片
|
||||
$images = Db::name('GoodsSpecImages')->where($where)->column('name,images');
|
||||
if(!empty($images))
|
||||
{
|
||||
$images_host = config('images_host');
|
||||
foreach($images as &$temp_iamges)
|
||||
{
|
||||
$temp_iamges = $images_host.$temp_iamges;
|
||||
}
|
||||
}
|
||||
|
||||
return ['type'=>$type, 'images'=>$images];
|
||||
return ['type'=>$type];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1155,13 +1150,9 @@ class GoodsService
|
|||
{
|
||||
if(!empty($params['spec_images'][$k]))
|
||||
{
|
||||
$images[$v] = [
|
||||
'name' => $v,
|
||||
'images' => $params['spec_images'][$k],
|
||||
];
|
||||
$images[$v] = $params['spec_images'][$k];
|
||||
}
|
||||
}
|
||||
$images = array_values($images);
|
||||
}
|
||||
|
||||
return DataReturn('success', 0, ['data'=>$data, 'title'=>$title, 'images'=>$images]);
|
||||
|
|
@ -1344,15 +1335,22 @@ class GoodsService
|
|||
Db::name('GoodsSpecType')->where(['goods_id'=>$goods_id])->delete();
|
||||
Db::name('GoodsSpecValue')->where(['goods_id'=>$goods_id])->delete();
|
||||
Db::name('GoodsSpecBase')->where(['goods_id'=>$goods_id])->delete();
|
||||
Db::name('GoodsSpecImages')->where(['goods_id'=>$goods_id])->delete();
|
||||
|
||||
// 类型
|
||||
if(!empty($data['title']))
|
||||
{
|
||||
foreach($data['title'] as &$v)
|
||||
{
|
||||
$spec = [];
|
||||
foreach($v['value'] as $vs)
|
||||
{
|
||||
$spec[] = [
|
||||
'name' => $vs,
|
||||
'images' => isset($data['images'][$vs]) ? ResourcesService::AttachmentPathHandle($data['images'][$vs]) : '',
|
||||
];
|
||||
}
|
||||
$v['goods_id'] = $goods_id;
|
||||
$v['value'] = json_encode(array_values($v['value']));
|
||||
$v['value'] = json_encode($spec);
|
||||
$v['add_time'] = time();
|
||||
}
|
||||
if(Db::name('GoodsSpecType')->insertAll($data['title']) < count($data['title']))
|
||||
|
|
@ -1432,25 +1430,6 @@ class GoodsService
|
|||
}
|
||||
}
|
||||
|
||||
// 规格图片
|
||||
if(!empty($data['images']))
|
||||
{
|
||||
$images = [];
|
||||
foreach($data['images'] as $v)
|
||||
{
|
||||
$images[] = [
|
||||
'goods_id' => $goods_id,
|
||||
'name' => $v['name'],
|
||||
'images' => ResourcesService::AttachmentPathHandle($v['images']),
|
||||
'add_time' => time(),
|
||||
];
|
||||
}
|
||||
if(Db::name('GoodsSpecImages')->insertAll($images) < count($images))
|
||||
{
|
||||
return DataReturn('规格图片添加失败', -1);
|
||||
}
|
||||
}
|
||||
|
||||
return DataReturn('添加成功', 0);
|
||||
}
|
||||
|
||||
|
|
@ -1578,11 +1557,19 @@ class GoodsService
|
|||
if(!empty($type))
|
||||
{
|
||||
// 数据处理
|
||||
foreach($type as &$v)
|
||||
$images_host = config('images_host');
|
||||
foreach($type as &$temp_type)
|
||||
{
|
||||
$v['value'] = json_decode($v['value'], true);
|
||||
$temp_type_value = json_decode($temp_type['value'], true);
|
||||
foreach($temp_type_value as &$vs)
|
||||
{
|
||||
$vs['images_old'] = $vs['images'];
|
||||
$vs['images'] = empty($vs['images']) ? '' : $images_host.$vs['images'];
|
||||
}
|
||||
$temp_type['value'] = $temp_type_value;
|
||||
}
|
||||
|
||||
|
||||
// 获取规格值
|
||||
$temp_value = Db::name('GoodsSpecValue')->where($where)->field('goods_spec_base_id,value')->order('id asc')->select();
|
||||
if(!empty($temp_value))
|
||||
|
|
@ -1592,10 +1579,13 @@ class GoodsService
|
|||
$key = '';
|
||||
foreach($type as $type_v)
|
||||
{
|
||||
if(in_array($value_v['value'], $type_v['value']))
|
||||
foreach($type_v['value'] as $type_vs)
|
||||
{
|
||||
$key = $type_v['id'];
|
||||
break;
|
||||
if($type_vs['name'] == $value_v['value'])
|
||||
{
|
||||
$key = $type_v['id'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$value[$value_v['goods_spec_base_id']][] = [
|
||||
|
|
@ -1627,22 +1617,9 @@ class GoodsService
|
|||
];
|
||||
}
|
||||
|
||||
// 规格图片
|
||||
$images = Db::name('GoodsSpecImages')->where($where)->select();
|
||||
if(!empty($images))
|
||||
{
|
||||
$images_host = config('images_host');
|
||||
foreach($images as &$temp_iamges)
|
||||
{
|
||||
$temp_iamges['images_old'] = $temp_iamges['images'];
|
||||
$temp_iamges['images'] = $images_host.$temp_iamges['images'];
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'type' => $type,
|
||||
'value' => array_values($value),
|
||||
'images' => $images,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue