提交 d865872b 编写于 作者: D devil_gong

新增规格重量,规格支持图片

上级 6a419a66
......@@ -169,15 +169,16 @@
{{foreach $specifications.type as $type_v}}
<th class="table-title table-title-{{$type_v.id}}">
<i class="am-close am-close-spin title-nav-remove" data-index="{{$type_v.id}}">×</i>
<input type="text" name="specifications_name_{{$type_v.id}}" placeholder="规格名" value="{{$type_v.name}}" />
<input type="text" name="specifications_name_{{$type_v.id}}" placeholder="规格名" value="{{$type_v.name}}" data-validation-message="请填写规格名" required />
</th>
{{/foreach}}
{{/if}}
<th class="title-start">价格(元)</th>
<th class="title-start">价格(元)</th>
<th>库存</th>
<th>重量(kg)</th>
<th>规格编码</th>
<th>条形码</th>
<th>原价(元) </th>
<th>原价(元)</th>
<th class="operation-btn">操作</th>
</tr>
</thead>
......@@ -191,7 +192,10 @@
<input type="number" name="specifications_number[]" placeholder="库存" class="am-radius" min="1" max="100000000" pattern="^-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$" data-validation-message="库存数量 1~100000000" required />
</td>
<td>
<input type="text" name="specifications_coding[]" placeholder="规格编码" class="am-radius" maxlength="80" data-validation-message="规格编码最多80个字符" />
<input type="number" name="specifications_weight[]" placeholder="重量" class="am-radius" maxlength="80" data-validation-message="请填写有效的规格重量" />
</td>
<td>
<input type="text" name="specifications_coding[]" placeholder="编码" class="am-radius" maxlength="80" data-validation-message="规格编码最多80个字符" />
</td>
<td>
<input type="text" name="specifications_barcode[]" placeholder="条形码" class="am-radius" maxlength="80" data-validation-message="条形码最多80个字符" />
......@@ -213,7 +217,7 @@
{{switch v.data_type}}
{{case spec}}
<td class="table-value table-value-{{$v.data.key}}">
<input type="text" name="specifications_value_{{$v.data.key}}[]" placeholder="规格值" value="{{$v.data.value}}" />
<input type="text" name="specifications_value_{{$v.data.key}}[]" placeholder="规格值" value="{{$v.data.value}}" data-validation-message="请填写规格值" required />
</td>
{{/case}}
......@@ -225,7 +229,10 @@
<input type="number" name="specifications_number[]" placeholder="库存" class="am-radius" min="0" max="100000000" data-validation-message="库存数量 0~100000000" value="{{$v.data.inventory}}" required />
</td>
<td>
<input type="text" name="specifications_coding[]" placeholder="规格编码" class="am-radius" maxlength="80" data-validation-message="规格编码最多80个字符" value="{{$v.data.coding}}" />
<input type="number" name="specifications_weight[]" placeholder="重量" class="am-radius" min="0" max="100000000" data-validation-message="规格重量 0~100000000" value="{{if $v['data']['weight'] gt 0}}{{$v.data.weight}}{{/if}}" />
</td>
<td>
<input type="text" name="specifications_coding[]" placeholder="编码" class="am-radius" maxlength="80" data-validation-message="规格编码最多80个字符" value="{{$v.data.coding}}" />
</td>
<td>
<input type="text" name="specifications_barcode[]" placeholder="条形码" class="am-radius" maxlength="80" data-validation-message="条形码最多80个字符" value="{{$v.data.barcode}}" />
......@@ -252,16 +259,18 @@
</table>
<span class="business-operations-submit specifications-nav-title-add">+添加规格</span>
<span class="business-operations-submit specifications-line-add">+添加一行</span>
<ul class="spec-images-list">
<!-- <li>
<ul class="plug-file-upload-view spec-images-view" data-form-name="spec_images[]" data-max-number="1" data-delete='0' data-dialog-type="images">
<li>
<input type="hidden" name="spec_images[]" value="" />
<img src="{{$image_host}}/static/admin/default/images/default-images.png" />
</li>
</ul>
<div class="plug-file-upload-submit" data-view-tag="ul.spec-images-view">+上传图片</div>
</li> -->
<ul class="spec-images-list" {{if empty($specifications['images'])}} style="display: none"{{/if}}>
{{foreach $specifications.images as $spec_images}}
<li>
<ul class="plug-file-upload-view spec-images-view-{{$spec_images.name}}" data-form-name="spec_images[{{$spec_images.name}}]" data-max-number="1" data-delete='0' data-dialog-type="images">
<li>
<input type="hidden" name="spec_images[{{$spec_images.name}}]" value="{{$spec_images.images_old}}" data-validation-message="请上传规格图片" required />
<img src="{{$spec_images.images}}" />
</li>
</ul>
<div class="plug-file-upload-submit" data-view-tag="ul.spec-images-view-{{$spec_images.name}}">+上传图片</div>
</li>
{{/foreach}}
</ul>
</div>
</div>
......@@ -333,7 +342,7 @@
{{/foreach}}
{{/if}}
</ul>
<label class="business-operations-submit content-app-items-add-sub">+添加手机详情</label>
<span class="business-operations-submit content-app-items-add-sub">+添加手机详情</span>
</div>
<!-- web内容 -->
......
......@@ -10,8 +10,8 @@
<link rel="stylesheet" type="text/css" href="{{$Think.__MY_ROOT__}}static/common/lib/amazeui-chosen/amazeui.chosen.css" />
<link rel="stylesheet" type="text/css" href="{{$Think.__MY_ROOT__}}static/common/lib/amazeui-tagsinput/amazeui.tagsinput.css" />
<link rel="stylesheet" type="text/css" href="{{$Think.__MY_ROOT__}}static/common/css/common.css" />
<link rel="stylesheet" type="text/css" href="{{$Think.__MY_ROOT__}}static/Admin/{{$default_theme}}/css/common.css" />
<link rel="stylesheet" type="text/css" href="{{$Think.__MY_ROOT__}}static/Admin/{{$default_theme}}/css/iconfontmenu.css" />
<link rel="stylesheet" type="text/css" href="{{$Think.__MY_ROOT__}}static/admin/{{$default_theme}}/css/common.css" />
<link rel="stylesheet" type="text/css" href="{{$Think.__MY_ROOT__}}static/admin/{{$default_theme}}/css/iconfontmenu.css" />
{{if !empty($module_css)}}
<link rel="stylesheet" type="text/css" href="{{$Think.__MY_ROOT__}}static/{{$module_css}}" />
{{/if}}
......
{{include file="public/header" /}}
<!-- nav start -->
{{include file="public/nav" /}}
<!-- nav end -->
<!-- header top nav -->
{{include file="public/header_top_nav" /}}
......@@ -48,9 +44,7 @@
<div class="box">
<div class="tb-booth tb-pic tb-s310">
{{if !empty($goods['photo'][0])}}
<a href="{{$goods['photo'][0]['images']}}">
<img src="{{$goods['photo'][0]['images']}}" alt="{{$goods.title}}" rel="{{:str_replace('compr', 'original', $goods['photo'][0]['images'])}}" class="jqzoom" />
</a>
<img src="{{$goods['photo'][0]['images']}}" alt="{{$goods.title}}" rel="{{$goods['photo'][0]['images']}}" class="jqzoom" />
{{/if}}
</div>
<ul class="tb-thumb" id="thumblist">
......@@ -59,7 +53,7 @@
<li class="{{if $photo_key eq 0}}tb-selected{{else /}} tb-pic{{/if}}">
<div class="tb-pic tb-s40">
<a href="javascript:;">
<img src="{{$photo.images}}" mid="{{$photo.images}}" big="{{:str_replace('compr', 'original', $photo.images)}}" class="tb-s40" />
<img src="{{$photo.images}}" mid="{{$photo.images}}" big="{{$photo.images}}" class="tb-s40" />
</a>
</div>
</li>
......@@ -100,7 +94,7 @@
<dt>促销价</dt>
<dd>
<em>¥</em>
<b class="sys_item_price">{{$goods.price}}</b>
<b class="sys_item_price" data-original-price="{{$goods.price}}">{{$goods.price}}</b>
</dd>
</div>
<div class="goods-qrcode am-hide-sm-only">
......@@ -143,14 +137,19 @@
<div class="theme-popbod dform">
<form class="theme-signin" name="loginform" action="javascript:;">
<div class="theme-signin-left">
{{if !empty($goods['specifications'])}}
{{foreach $goods.specifications as $key=>$spec}}
{{if !empty($goods['specifications']['type'])}}
{{foreach $goods.specifications.type as $key=>$spec}}
{{if !empty($spec['value'])}}
<div class="theme-options sku-items">
<div class="cart-title">{{$spec.name}}</div>
<ul>
{{foreach $spec.value as $keys=>$specs}}
<li class="sku-line {{if $key gt 0}} sku-dont-choose{{/if}}" data-type-value="{{$spec.name}}" data-value="{{$specs}}">{{$specs}}<i></i></li>
<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]}}" />
{{/if}}
{{$specs}}<i></i>
</li>
{{/foreach}}
</ul>
</div>
......@@ -162,10 +161,10 @@
<dd>
<div class="am-input-group am-input-group-sm number-tag">
<button class="am-input-group-label" id="min" type="button">-</button>
<input type="number" class="am-form-field" value="1" id="text_box" min="1" max="{{$goods.inventory}}" />
<input type="number" class="am-form-field" value="1" id="text_box" min="1" max="{{$goods.inventory}}" data-original-max="{{$goods.inventory}}" />
<button class="am-input-group-label" id="add" type="button">+</button>
</div>
<span class="tb-hidden stock-tips">库存<span class="stock">{{$goods.inventory}}</span>{{$goods.inventory_unit}}</span>
<span class="tb-hidden stock-tips">库存<span class="stock" data-original-stock="{{$goods.inventory}}">{{$goods.inventory}}</span>{{$goods.inventory_unit}}</span>
</dd>
</div>
......@@ -179,7 +178,7 @@
<img src="{{$goods.images}}" />
</div>
<div class="text-info">
<span class="price-now">¥{{$goods.price}}</span>
<span class="price-now" data-original-price="{{$goods.price}}">¥{{$goods.price}}</span>
</div>
</div>
</form>
......
......@@ -32,7 +32,7 @@
var __my_url__ = '{{:__MY_URL__}}';
var __public__ = '{{$Think.__MY_ROOT__}}';
var __default_theme__ = '{{$default_theme}}';
var __modal_login_url__ = '{{:Url('index/User/ModalLoginInfo')}}';
var __modal_login_url__ = '{{:Url('index/user/modallogininfo')}}';
var __user_id__ = {{if empty($user['id'])}}0{{else /}}{{$user.id}}{{/if}};
</script>
</head>
......
......@@ -106,19 +106,19 @@ class GoodsService
{
if(!empty($data) && is_array($data))
{
$images_host = config('IMAGE_HOST');
$image_host = config('IMAGE_HOST');
foreach($data as &$v)
{
if(is_array($v))
{
if(isset($v['icon']))
{
$v['icon'] = empty($v['icon']) ? null : $images_host.$v['icon'];
$v['icon'] = empty($v['icon']) ? null : $image_host.$v['icon'];
}
if(isset($v['big_images']))
{
$v['big_images_old'] = $v['big_images'];
$v['big_images'] = empty($v['big_images']) ? null : $images_host.$v['big_images'];
$v['big_images'] = empty($v['big_images']) ? null : $image_host.$v['big_images'];
}
}
}
......@@ -236,7 +236,7 @@ class GoodsService
$is_category = (isset($params['is_category']) && $params['is_category'] == true) ? true : false;
// 开始处理数据
$images_host = config('IMAGE_HOST');
$image_host = config('IMAGE_HOST');
foreach($data as &$v)
{
// 商品url地址
......@@ -249,21 +249,21 @@ class GoodsService
if(isset($v['images']))
{
$v['images_old'] = $v['images'];
$v['images'] = empty($v['images']) ? null : $images_host.$v['images'];
$v['images'] = empty($v['images']) ? null : $image_host.$v['images'];
}
// 视频
if(isset($v['video']))
{
$v['video_old'] = $v['video'];
$v['video'] = empty($v['video']) ? null : $images_host.$v['video'];
$v['video'] = empty($v['video']) ? null : $image_host.$v['video'];
}
// 商品首页推荐图片,不存在则使用商品封面图片
if(isset($v['home_recommended_images']))
{
$v['home_recommended_images_old'] = $v['home_recommended_images'];
$v['home_recommended_images'] = empty($v['home_recommended_images']) ? (empty($v['images']) ? null : $v['images']) : $images_host.$v['home_recommended_images'];
$v['home_recommended_images'] = empty($v['home_recommended_images']) ? (empty($v['images']) ? null : $v['images']) : $image_host.$v['home_recommended_images'];
}
// PC内容处理
......@@ -305,7 +305,7 @@ class GoodsService
foreach($v['photo'] as &$vs)
{
$vs['images_old'] = $vs['images'];
$vs['images'] = $images_host.$vs['images'];
$vs['images'] = $image_host.$vs['images'];
}
}
}
......@@ -341,11 +341,11 @@ class GoodsService
$data = Db::name('GoodsContentApp')->where(['goods_id'=>$params['goods_id']])->field('id,images,content')->order('sort asc')->select();
if(!empty($data))
{
$images_host = config('IMAGE_HOST');
$image_host = config('IMAGE_HOST');
foreach($data as &$v)
{
$v['images_old'] = $v['images'];
$v['images'] = empty($v['images']) ? null : $images_host.$v['images'];
$v['images'] = empty($v['images']) ? null : $image_host.$v['images'];
$v['content_old'] = $v['content'];
$v['content'] = empty($v['content']) ? null : explode("\n", $v['content']);
}
......@@ -364,16 +364,32 @@ class GoodsService
*/
public static function GoodsSpecifications($params = [])
{
$data = Db::name('GoodsSpecType')->where(['goods_id'=>$params['goods_id']])->order('id asc')->select();
if(!empty($data))
// 条件
$where = ['goods_id'=>$params['goods_id']];
// 规格类型
$type = Db::name('GoodsSpecType')->where($where)->order('id asc')->select();
if(!empty($type))
{
foreach($data as &$v)
foreach($type as &$temp_type)
{
$v['value'] = json_decode($v['value'], true);
$v['add_time'] = date('Y-m-d H:i:s');
$temp_type['value'] = json_decode($temp_type['value'], true);
$temp_type['add_time'] = date('Y-m-d H:i:s');
}
}
return $data;
// 规格图片
$images = Db::name('GoodsSpecImages')->where($where)->column('name,images');
if(!empty($images))
{
$image_host = config('IMAGE_HOST');
foreach($images as &$temp_iamges)
{
$temp_iamges = $image_host.$temp_iamges;
}
}
return ['type'=>$type, 'images'=>$images];
}
/**
......@@ -562,12 +578,12 @@ class GoodsService
$data = Db::name('GoodsFavor')->alias('f')->join(['__GOODS__'=>'g'], 'g.id=f.goods_id')->field($field)->where($where)->limit($m, $n)->order($order_by)->select();
if(!empty($data))
{
$images_host = config('IMAGE_HOST');
$image_host = config('IMAGE_HOST');
foreach($data as &$v)
{
// 图片
$v['images_old'] = $v['images'];
$v['images'] = empty($v['images']) ? null : $images_host.$v['images'];
$v['images'] = empty($v['images']) ? null : $image_host.$v['images'];
$v['goods_url'] = HomeUrl('goods', 'index', ['id'=>$v['goods_id']]);
}
......@@ -709,11 +725,11 @@ class GoodsService
$data = Db::name('GoodsBrowse')->alias('b')->join(['__GOODS__'=>'g'], 'g.id=b.goods_id')->field($field)->where($where)->limit($m, $n)->order($order_by)->select();
if(!empty($data))
{
$images_host = config('IMAGE_HOST');
$image_host = config('IMAGE_HOST');
foreach($data as &$v)
{
$v['images_old'] = $v['images'];
$v['images'] = empty($v['images']) ? null : $images_host.$v['images'];
$v['images'] = empty($v['images']) ? null : $image_host.$v['images'];
$v['goods_url'] = HomeUrl('goods', 'index', ['id'=>$v['goods_id']]);
}
}
......@@ -1069,6 +1085,7 @@ class GoodsService
{
$data = [];
$title = [];
$images = [];
// 规格值
foreach($params as $k=>$v)
......@@ -1092,7 +1109,7 @@ class GoodsService
// 规格名称
if(!empty($data[0]))
{
$count = count($data[0])-5;
$count = count($data[0])-6;
if($count > 0)
{
$names = array_slice($data[0], 0, $count);
......@@ -1130,7 +1147,14 @@ class GoodsService
} else {
return DataReturn('请填写规格', -1);
}
return DataReturn('success', 0, ['data'=>$data, 'title'=>$title]);
// 规格图片
if(!empty($params['spec_images']))
{
$images = $params['spec_images'];
}
return DataReturn('success', 0, ['data'=>$data, 'title'=>$title, 'images'=>$images]);
}
/**
......@@ -1310,6 +1334,7 @@ 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']))
......@@ -1317,7 +1342,7 @@ class GoodsService
foreach($data['title'] as &$v)
{
$v['goods_id'] = $goods_id;
$v['value'] = json_encode($v['value']);
$v['value'] = json_encode(array_values($v['value']));
$v['add_time'] = time();
}
if(Db::name('GoodsSpecType')->insertAll($data['title']) < count($data['title']))
......@@ -1331,10 +1356,11 @@ class GoodsService
{
// 基础字段
$count = count($data['data'][0]);
$temp_key = ['price', 'inventory', 'coding', 'barcode', 'original_price'];
$temp_key = ['price', 'inventory', 'weight', 'coding', 'barcode', 'original_price'];
$key_count = count($temp_key);
// 等于5则只有一列基础规格
if($count == 5)
// 等于key总数则只有一列基础规格
if($count == $key_count)
{
$temp_data = [
'goods_id' => $goods_id,
......@@ -1352,7 +1378,7 @@ class GoodsService
// 多规格操作
} else {
$base_start = $count-5;
$base_start = $count-$key_count;
$value = [];
$base = [];
foreach($data['data'] as $v)
......@@ -1395,6 +1421,26 @@ class GoodsService
}
}
}
// 规格图片
if(!empty($data['images']))
{
$images = [];
foreach($data['images'] as $k=>$v)
{
$images[] = [
'goods_id' => $goods_id,
'name' => $k,
'images' => ResourcesService::AttachmentPathHandle($v),
'add_time' => time(),
];
}
if(Db::name('GoodsSpecImages')->insertAll($images) < count($images))
{
return DataReturn('规格图片添加失败', -1);
}
}
return DataReturn('添加成功', 0);
}
......@@ -1556,7 +1602,7 @@ class GoodsService
{
foreach($value as $k=>&$v)
{
$base = Db::name('GoodsSpecBase')->field('price,inventory,coding,barcode,original_price')->find($k);
$base = Db::name('GoodsSpecBase')->find($k);
$v[] = [
'data_type' => 'base',
'data' => $base,
......@@ -1564,16 +1610,29 @@ class GoodsService
}
}
} else {
$base = Db::name('GoodsSpecBase')->where($where)->field('price,inventory,coding,barcode,original_price')->find();
$base = Db::name('GoodsSpecBase')->where($where)->find();
$value[][] = [
'data_type' => 'base',
'data' => $base,
];
}
// 规格图片
$images = Db::name('GoodsSpecImages')->where($where)->select();
if(!empty($images))
{
$image_host = config('IMAGE_HOST');
foreach($images as &$temp_iamges)
{
$temp_iamges['images_old'] = $temp_iamges['images'];
$temp_iamges['images'] = $image_host.$temp_iamges['images'];
}
}
return [
'type' => $type,
'value' => array_values($value),
'type' => $type,
'value' => array_values($value),
'images' => $images,
];
}
......
......@@ -49,7 +49,7 @@ class ResourcesService
*/
public static function AttachmentPathHandle($value)
{
return str_replace([__MY_URL__, __MY_ROOT__], DS, $value);
return empty($value) ? '' : str_replace([__MY_URL__, __MY_ROOT__], DS, $value);
}
/**
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -20,13 +20,13 @@ $(function()
var index = parseInt(Math.random()*1000001);
html = '<th class="table-title table-title-'+index+'">';
html += '<i class="am-close am-close-spin title-nav-remove" data-index="'+index+'">&times;</i>';
html += '<input type="text" name="specifications_name_'+index+'" placeholder="规格名" />';
html += '<input type="text" name="specifications_name_'+index+'" placeholder="规格名" class="am-radius" data-validation-message="请填写规格名" required />';
html += '</th>';
$('.title-start').before(html);
// value
html = '<td class="table-value table-value-'+index+'">';
html += '<input type="text" name="specifications_value_'+index+'[]" placeholder="规格值" />';
html += '<input type="text" name="specifications_value_'+index+'[]" placeholder="规格值" class="am-radius" data-validation-message="请填写规格值" required />';
html += '</td>';
$('.value-start').before(html);
......@@ -35,7 +35,7 @@ $(function()
});
// 规格列移除
$('.specifications-table').on('click', '.title-nav-remove', function()
$(document).on('click', '.specifications-table .title-nav-remove', function()
{
var index = $(this).data('index');
$('.table-title-'+index).remove();
......@@ -78,7 +78,7 @@ $(function()
});
// 规格行复制
$('.specifications-table').on('click', '.line-copy', function()
$(document).on('click', '.specifications-table .line-copy', function()
{
var $parent = $(this).parents('tr');
$parent.find('input').each(function(k, v)
......@@ -92,7 +92,7 @@ $(function()
});
// 规格行移除
$('.specifications-table').on('click', '.line-remove', function()
$(document).on('click', '.specifications-table .line-remove', function()
{
$(this).parents('tr').remove();
......@@ -114,7 +114,7 @@ $(function()
});
// 规格第一列输入事件
$('.specifications-table tbody tr').on('change', 'td:eq(0) input', function()
$(document).on('change', '.specifications-table tbody tr td.table-value input', function()
{
// 规格图片
SpecImagesHandle();
......@@ -125,25 +125,36 @@ $(function()
{
if($('.spec-images-tips input').prop('checked'))
{
// 清空规格
$('ul.spec-images-list').html('');
// 获取第一列数据值
var temp_spec_all = {}, spec_all = [];
$('.specifications-table tbody tr').each(function(k, v)
{
var value = $(this).find('td:eq(0) input').val();
temp_spec_all[value] = value;
var value = $(this).find('td.table-value:eq(0) input').val();
if((value || null) != null)
{
temp_spec_all[value] = value;
}
});
spec_all = Object.keys(temp_spec_all);
console.log(spec_all)
// 添加规格图片
if(spec_all.length > 0)
{
$('.spec-images-list').show();
for(var i in spec_all)
{
var temp_class = 'spec-images-items-'+spec_all[i];
if($('ul.spec-images-list').find('.'+temp_class).length <= 0)
{
var html = '<li class="'+temp_class+'">';
html += '<input type="text" value="'+spec_all[i]+'" disabled="disabled" />'
html += '<ul class="plug-file-upload-view spec-images-view-'+spec_all[i]+'" data-form-name="spec_images[]" data-max-number="1" data-delete="0" data-dialog-type="images">';
html += '<input type="text" value="'+spec_all[i]+'" class="am-radius t-c" disabled="disabled" />'
html += '<ul class="plug-file-upload-view spec-images-view-'+spec_all[i]+'" data-form-name="spec_images['+spec_all[i]+']" data-max-number="1" data-delete="0" data-dialog-type="images">';
html += '<li>';
html += '<input type="hidden" name="spec_images[]" value="" />';
html += '<input type="text" name="spec_images['+spec_all[i]+']" value="" data-validation-message="请上传规格图片" required />';
html += '<img src="'+__image_host__+'/static/admin/default/images/default-images.png" />';
html += '</li>';
html += '</ul>';
......@@ -152,9 +163,12 @@ $(function()
$('ul.spec-images-list').append(html);
}
}
} else {
$('.spec-images-list').hide();
}
} else {
$('ul.spec-images-list').html('');
$('.spec-images-list').hide();
}
}
......
......@@ -38,8 +38,10 @@ input{font-size:12px;font-size:100%;outline:none;line-height:normal;color:#444;}
.theme-signin-left{padding-bottom:30px;max-height:250px ;overflow-y: scroll;background: #fff;}
.theme-options{display: block;overflow: hidden;padding-left: 10px;padding-right:10px; margin-bottom: 5px;}
.theme-signin-left .cart-title{font-size:14px ;font-weight: 600;}
.theme-signin-left .sku-line{float: left; margin:10px;margin-left:0;border-radius:3px ; background:#efefef ;padding:0px 8px; border: 1px solid #efefef;}
.theme-signin-left .sku-line.selected{background:#e23f36;color: #fff; border: 1px solid #e33d2f;}
.theme-signin-left .sku-line{float: left; margin:10px;margin-left:0;border-radius:3px ; background:#efefef ;padding:0px 8px; border: 1px solid #d5d5d5;}
.theme-signin-left .sku-line.selected{background:#d2364c;color: #fff; border: 1px solid #d2364c;}
.sku-line-images { padding:3px !important; }
.sku-line-images img { width: 30px; height: 30px; }
.theme-signin .btn{width:100%;font-size: 16px;padding:5px ;}
.btn-op{position:fixed;left:0;bottom: 0;width:100%; z-index: 3;}
......@@ -463,4 +465,7 @@ li.am-comment{ width:100%}
/* 视频操作 */
.scoll .goods-video-submit-close { bottom: 50px; }
/* 底部 */
.am-footer { padding-bottom: 55px; }
}
\ No newline at end of file
// 规格弹窗PC显示
function poptit_pc_show()
{
$(document.body).css("position", "static");
$(document.body).css('position', 'static');
$('.theme-signin-left').scrollTop(0);
$('.theme-popover-mask').hide();
$('.theme-popover').slideDown(0);
......@@ -11,7 +11,7 @@ function poptit_close()
{
if($(window).width() < 1025)
{
$(document.body).css("position", "static");
$(document.body).css('position', 'static');
$('.theme-signin-left').scrollTop(0);
$('.theme-popover-mask').hide();
$('.theme-popover').slideUp(100);
......@@ -161,7 +161,7 @@ function GoodsSpecDetail()
$.AMUI.progress.done();
if(result.code == 0)
{
$('.text-info .price-now').text(result.data.price);
$('.text-info .price-now').text(''+result.data.price);
$('.sys_item_price').text(result.data.price);
$('.number-tag input[type="number"]').attr('max', result.data.inventory);
$('.stock-tips .stock').text(result.data.inventory);
......@@ -272,18 +272,34 @@ function GoodsSpecType()
});
}
/**
* 商品基础数据恢复
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-12-25
* @desc description
*/
function GoodsBaseRestore()
{
$('.text-info .price-now').text(''+$('.text-info .price-now').data('original-price'));
$('.sys_item_price').text($('.sys_item_price').data('original-price'));
$('.number-tag input[type="number"]').attr('max', $('.number-tag input[type="number"]').data('original-max'));
$('.stock-tips .stock').text($('.stock-tips .stock').data('original-stock'));
}
$(function() {
// 商品规格选择
$(".theme-options").each(function()
$('.theme-options').each(function()
{
$(this).find('ul>li').on('click', function()
{
var length = $('.theme-signin-left .sku-items').length;
var index = $(this).parents('.sku-items').index();
if($(this).hasClass("selected"))
if($(this).hasClass('selected'))
{
$(this).removeClass("selected");
$(this).removeClass('selected');
// 去掉元素之后的禁止
$('.theme-signin-left .sku-items').each(function(k, v)
......@@ -293,12 +309,16 @@ $(function() {
$(this).find('li').removeClass('sku-items-disabled').removeClass('selected').addClass('sku-dont-choose');
}
});
// 数据还原
GoodsBaseRestore();
} else {
if($(this).hasClass('sku-items-disabled') || $(this).hasClass('sku-dont-choose'))
{
return false;
}
$(this).addClass("selected").siblings("li").removeClass("selected");
$(this).addClass('selected').siblings('li').removeClass('selected');
$(this).parents('.sku-items').removeClass('attr-not-active');
// 去掉元素之后的禁止
......@@ -313,6 +333,22 @@ $(function() {
});
}
// 是否存在规格图片
var spec_images = $(this).data('type-images') || null;
if(spec_images != null)
{
$('.jqzoom').attr('src', spec_images);
$('.jqzoom').attr('rel', spec_images);
$('.img-info img').attr('src', spec_images);
}
// 后面是否还有未选择的规格
if(index < length-1)
{
// 数据还原
GoodsBaseRestore();
}
// 获取下一个规格类型
GoodsSpecType();
......@@ -323,11 +359,11 @@ $(function() {
});
// 放大镜初始化
$(".jqzoom").imagezoom();
$("#thumblist li a").on('mouseover', function() {
$(this).parents("li").addClass("tb-selected").siblings().removeClass("tb-selected");
$(".jqzoom").attr('src', $(this).find("img").attr("mid"));
$(".jqzoom").attr('rel', $(this).find("img").attr("big"));
$('.jqzoom').imagezoom();
$('#thumblist li a').on('mouseover', function() {
$(this).parents('li').addClass('tb-selected').siblings().removeClass('tb-selected');
$('.jqzoom').attr('src', $(this).find('img').attr('mid'));
$('.jqzoom').attr('rel', $(this).find('img').attr('big'));
});
//弹出规格选择
......@@ -336,7 +372,7 @@ $(function() {
// 是否登录
if(__user_id__ != 0)
{
$(document.body).css("position", "fixed");
$(document.body).css('position', 'fixed');
$('.theme-popover-mask').show();
$('.theme-popover').slideDown(200);
......@@ -453,51 +489,6 @@ $(function() {
});
// 购买导航动画显示/隐藏
var temp_scroll = 0;
var scroll_type = -1;
var location_scroll = 0;
var nav_status = 1;
var $buy_nav= $("div.buy-nav");
$(window).scroll(function()
{
if($(window).width() <= 625)
{
var scroll = $(document).scrollTop();
if(scroll != temp_scroll)
{
var temp_scroll_type = (scroll > temp_scroll) ? 1 : 0;
if(temp_scroll_type != scroll_type)
{
scroll_type = temp_scroll_type;
location_scroll = scroll;
}
if(scroll_type == 1)
{
if(nav_status == 1 && scroll > location_scroll+200)
{
nav_status = 0;
if(!$buy_nav.is(":animated"))
{
$buy_nav.slideUp(500);
}
}
} else {
if(nav_status == 0 && scroll < location_scroll-50)
{
nav_status = 1;
if(!$buy_nav.is(":animated"))
{
$buy_nav.slideDown(500);
}
}
}
temp_scroll = scroll;
}
}
});
// 浏览器窗口实时事件
$(window).resize(function()
{
......@@ -512,11 +503,11 @@ $(window).resize(function()
$(document).ready(function() {
//获得文本框对象
var t = $("#text_box");
var t = $('#text_box');
//初始化数量为1,并失效减
$('#min').attr('disabled', true);
//数量增加操作
$("#add").on('click', function() {
$('#add').on('click', function() {
var stock = parseInt($('.stock-tips .stock').text());
var number = parseInt(t.val());
if(number < stock)
......@@ -532,7 +523,7 @@ $(document).ready(function() {
});
//数量减少操作
$("#min").on('click', function() {
$('#min').on('click', function() {
t.val(parseInt(t.val()) - 1);
if (parseInt(t.val()) == 1) {
$('#min').attr('disabled', true);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册