系统优化
parent
1b1af214b0
commit
86c5e6dceb
|
|
@ -225,6 +225,15 @@ class Goods extends Common
|
|||
'goods_id' => $goods_id,
|
||||
'goods' => &$goods,
|
||||
]));
|
||||
|
||||
// 商品页面基础信息面板售价顶部钩子
|
||||
$this->assign('plugins_view_goods_detail_panel_price_top_data', Hook::listen('plugins_view_goods_detail_panel_price_top',
|
||||
[
|
||||
'hook_name' => 'plugins_view_goods_detail_panel_price_top',
|
||||
'is_backend' => false,
|
||||
'goods_id' => $goods_id,
|
||||
'goods' => &$goods,
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -173,20 +173,39 @@
|
|||
<!-- 基础面板 -->
|
||||
<div class="tb-detail-price">
|
||||
{{if isset($goods['original_price']) and $goods['original_price'] gt 0 and !empty($goods['show_field_original_price_text'])}}
|
||||
<div class="items price iteminfo_price">
|
||||
<!-- 原价 -->
|
||||
<div class="items price">
|
||||
<dt>{{$goods.show_field_original_price_text|raw}}</dt>
|
||||
<dd>
|
||||
<b class="sys_item_mktprice" data-original-price="{{$goods.original_price}}">¥ {{$goods.original_price}}</b>
|
||||
<b class="goods-original-price original-price-value" data-original-price="{{$goods.original_price}}">¥{{$goods.original_price}}</b>
|
||||
</dd>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<!-- 商品页面基础信息面板售价顶部钩子 -->
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
|
||||
<div class="plugins-tag">
|
||||
<span>plugins_view_goods_detail_panel_price_top</span>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{if !empty($plugins_view_goods_detail_panel_price_top_data) and is_array($plugins_view_goods_detail_panel_price_top_data)}}
|
||||
{{foreach $plugins_view_goods_detail_panel_price_top_data as $hook}}
|
||||
{{if is_string($hook) or is_int($hook)}}
|
||||
{{$hook|raw}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
|
||||
<!-- 售价 -->
|
||||
<div class="items price iteminfo_mktprice">
|
||||
<dt>{{if empty($goods['show_field_price_text'])}}销售价{{else /}}{{$goods.show_field_price_text|raw}}{{/if}}</dt>
|
||||
<dd>
|
||||
<em>¥</em>
|
||||
<b class="sys_item_price" data-original-price="{{$goods.price}}">{{$goods.price}}</b>
|
||||
<em>¥</em>
|
||||
<b class="goods-price" data-original-price="{{$goods.price}}">{{$goods.price}}</b>
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
<!-- 二维码 -->
|
||||
<div class="goods-qrcode am-hide-sm-only">
|
||||
<i class="am-icon-qrcode am-icon-sm"></i>
|
||||
<img class="qrcode-images am-img-thumbnail" src="{{$qrcode_url}}" />
|
||||
|
|
@ -281,7 +300,7 @@
|
|||
<img src="{{$goods.images}}" />
|
||||
</div>
|
||||
<div class="text-info">
|
||||
<span class="price-now" data-original-price="{{$goods.price}}">¥{{$goods.price}}</span>
|
||||
<span class="price-now" data-original-price="{{$goods.price}}">¥{{$goods.price}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
@ -516,7 +535,7 @@
|
|||
<p class="am-text-truncate" {{if !empty($v.title_color)}}style="color:{{$v.title_color}};"{{/if}}>{{$v.title}}</p>
|
||||
</a>
|
||||
<p class="price fl">
|
||||
<strong>¥{{$v.price}}</strong>
|
||||
<strong>¥{{$v.price}}</strong>
|
||||
</p>
|
||||
</div>
|
||||
</li>
|
||||
|
|
|
|||
|
|
@ -97,8 +97,8 @@ class BuyService
|
|||
'goods_id' => $goods_id,
|
||||
'title' => $goods['title'],
|
||||
'images' => $goods['images'],
|
||||
'original_price'=> $goods_base['data']['original_price'],
|
||||
'price' => $goods_base['data']['price'],
|
||||
'original_price'=> $goods_base['data']['spec_base']['original_price'],
|
||||
'price' => $goods_base['data']['spec_base']['price'],
|
||||
'stock' => intval($params['stock']),
|
||||
'spec' => empty($spec) ? '' : json_encode($spec),
|
||||
];
|
||||
|
|
@ -197,12 +197,12 @@ class BuyService
|
|||
$goods_base = GoodsService::GoodsSpecDetail(['id'=>$v['goods_id'], 'spec'=>$v['spec']]);
|
||||
if($goods_base['code'] == 0)
|
||||
{
|
||||
$v['inventory'] = $goods_base['data']['inventory'];
|
||||
$v['price'] = (float) $goods_base['data']['price'];
|
||||
$v['original_price'] = (float) $goods_base['data']['original_price'];
|
||||
$v['spec_weight'] = $goods_base['data']['weight'];
|
||||
$v['spec_coding'] = $goods_base['data']['coding'];
|
||||
$v['spec_barcode'] = $goods_base['data']['barcode'];
|
||||
$v['inventory'] = $goods_base['data']['spec_base']['inventory'];
|
||||
$v['price'] = (float) $goods_base['data']['spec_base']['price'];
|
||||
$v['original_price'] = (float) $goods_base['data']['spec_base']['original_price'];
|
||||
$v['spec_weight'] = $goods_base['data']['spec_base']['weight'];
|
||||
$v['spec_coding'] = $goods_base['data']['spec_base']['coding'];
|
||||
$v['spec_barcode'] = $goods_base['data']['spec_base']['barcode'];
|
||||
} else {
|
||||
return $goods_base;
|
||||
}
|
||||
|
|
@ -406,12 +406,12 @@ class BuyService
|
|||
$goods_base = GoodsService::GoodsSpecDetail(['id'=>$ret['data'][0]['goods_id'], 'spec'=>$ret['data'][0]['spec']]);
|
||||
if($goods_base['code'] == 0)
|
||||
{
|
||||
$ret['data'][0]['inventory'] = $goods_base['data']['inventory'];
|
||||
$ret['data'][0]['price'] = (float) $goods_base['data']['price'];
|
||||
$ret['data'][0]['original_price'] = (float) $goods_base['data']['original_price'];
|
||||
$ret['data'][0]['spec_weight'] = $goods_base['data']['weight'];
|
||||
$ret['data'][0]['spec_coding'] = $goods_base['data']['coding'];
|
||||
$ret['data'][0]['spec_barcode'] = $goods_base['data']['barcode'];
|
||||
$ret['data'][0]['inventory'] = $goods_base['data']['spec_base']['inventory'];
|
||||
$ret['data'][0]['price'] = (float) $goods_base['data']['spec_base']['price'];
|
||||
$ret['data'][0]['original_price'] = (float) $goods_base['data']['spec_base']['original_price'];
|
||||
$ret['data'][0]['spec_weight'] = $goods_base['data']['spec_base']['weight'];
|
||||
$ret['data'][0]['spec_coding'] = $goods_base['data']['spec_base']['coding'];
|
||||
$ret['data'][0]['spec_barcode'] = $goods_base['data']['spec_base']['barcode'];
|
||||
} else {
|
||||
return $goods_base;
|
||||
}
|
||||
|
|
@ -630,8 +630,8 @@ class BuyService
|
|||
$goods_base = GoodsService::GoodsSpecDetail(['id'=>$v['goods_id'], 'spec'=>isset($v['spec']) ? $v['spec'] : []]);
|
||||
if($goods_base['code'] == 0)
|
||||
{
|
||||
$goods['price'] = $goods_base['data']['price'];
|
||||
$goods['inventory'] = $goods_base['data']['inventory'];
|
||||
$goods['price'] = $goods_base['data']['spec_base']['price'];
|
||||
$goods['inventory'] = $goods_base['data']['spec_base']['inventory'];
|
||||
} else {
|
||||
return $goods_base;
|
||||
}
|
||||
|
|
@ -983,7 +983,7 @@ class BuyService
|
|||
if($base['code'] == 0)
|
||||
{
|
||||
// 扣除规格操作
|
||||
if(!Db::name('GoodsSpecBase')->where(['id'=>$base['data']['id'], 'goods_id'=>$v['goods_id']])->setDec('inventory', $v['buy_number']))
|
||||
if(!Db::name('GoodsSpecBase')->where(['id'=>$base['data']['spec_base']['id'], 'goods_id'=>$v['goods_id']])->setDec('inventory', $v['buy_number']))
|
||||
{
|
||||
return DataReturn('规格库存扣减失败['.$params['order_id'].'-'.$v['goods_id'].'('.$goods['inventory'].'-'.$v['buy_number'].')]', -10);
|
||||
}
|
||||
|
|
@ -1089,7 +1089,7 @@ class BuyService
|
|||
if($base['code'] == 0)
|
||||
{
|
||||
// 回滚规格操作
|
||||
if(!Db::name('GoodsSpecBase')->where(['id'=>$base['data']['id'], 'goods_id'=>$v['goods_id']])->setInc('inventory', $buy_number))
|
||||
if(!Db::name('GoodsSpecBase')->where(['id'=>$base['data']['spec_base']['id'], 'goods_id'=>$v['goods_id']])->setInc('inventory', $buy_number))
|
||||
{
|
||||
return DataReturn('规格库存回滚失败['.$params['order_id'].'-'.$v['goods_id'].']', -10);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -294,6 +294,16 @@ class GoodsService
|
|||
return $ret;
|
||||
}
|
||||
|
||||
// 商品价格容器
|
||||
$v['price_container'] = [
|
||||
'price' => isset($v['price']) ? $v['price'] : 0.00,
|
||||
'min_price' => isset($v['min_price']) ? $v['min_price'] : 0.00,
|
||||
'max_price' => isset($v['max_price']) ? $v['max_price'] : 0.00,
|
||||
'original_price' => isset($v['original_price']) ? $v['original_price'] : 0.00,
|
||||
'min_original_price' => isset($v['min_original_price']) ? $v['min_original_price'] : 0.00,
|
||||
'max_original_price' => isset($v['max_original_price']) ? $v['max_original_price'] : 0.00,
|
||||
];
|
||||
|
||||
// 商品url地址
|
||||
if(!empty($v['id']))
|
||||
{
|
||||
|
|
@ -1916,13 +1926,21 @@ class GoodsService
|
|||
// 单位 .00 处理
|
||||
$base['weight'] = PriceBeautify($base['weight']);
|
||||
|
||||
// 商品处理前钩子
|
||||
// 处理好的数据
|
||||
// 扩展元素标记与html内容数据
|
||||
// extends_element下包含多个元素 ['element'=>'', 'content'=>'']
|
||||
$data = [
|
||||
'spec_base' => $base,
|
||||
'extends_element' => [],
|
||||
];
|
||||
|
||||
// 商品获取规格钩子
|
||||
$hook_name = 'plugins_service_goods_spec_base';
|
||||
$ret = Hook::listen($hook_name, [
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => true,
|
||||
'params' => &$params,
|
||||
'spec_base' => &$base,
|
||||
'params' => $params,
|
||||
'data' => &$data,
|
||||
'goods_id' => $goods_id
|
||||
]);
|
||||
if(isset($ret['code']) && $ret['code'] != 0)
|
||||
|
|
@ -1931,7 +1949,7 @@ class GoodsService
|
|||
}
|
||||
|
||||
// 返回成功
|
||||
return DataReturn('操作成功', 0, $base);
|
||||
return DataReturn('操作成功', 0, $data);
|
||||
}
|
||||
|
||||
return DataReturn('没有相关规格', -100);
|
||||
|
|
@ -1972,9 +1990,9 @@ class GoodsService
|
|||
$where = [
|
||||
'goods_id' => intval($params['id']),
|
||||
];
|
||||
$value = [];
|
||||
|
||||
// 规格不为数组则为json字符串
|
||||
$value = [];
|
||||
if(!is_array($params['spec']))
|
||||
{
|
||||
$params['spec'] = json_decode(htmlspecialchars_decode($params['spec']), true);
|
||||
|
|
@ -1994,18 +2012,18 @@ class GoodsService
|
|||
if(!empty($temp_data))
|
||||
{
|
||||
// 根据基础值id分组
|
||||
$data = [];
|
||||
$group = [];
|
||||
foreach($temp_data as $v)
|
||||
{
|
||||
$data[$v['goods_spec_base_id']][] = $v;
|
||||
$group[$v['goods_spec_base_id']][] = $v;
|
||||
}
|
||||
|
||||
// 获取当前操作元素索引
|
||||
$last = end($params['spec']);
|
||||
$index = count($params['spec'])-1;
|
||||
$spec_str = implode('', array_column($params['spec'], 'value'));
|
||||
$value = [];
|
||||
foreach($data as $v)
|
||||
$spec_type = [];
|
||||
foreach($group as $v)
|
||||
{
|
||||
$temp_str = implode('', array_column($v, 'value'));
|
||||
if(isset($v[$index+1]) && stripos($temp_str, $spec_str) !== false)
|
||||
|
|
@ -2014,11 +2032,34 @@ class GoodsService
|
|||
$inventory = Db::name('GoodsSpecBase')->where(['id'=>$v[$index+1]['goods_spec_base_id']])->value('inventory');
|
||||
if($inventory > 0)
|
||||
{
|
||||
$value[$v[$index+1]['value']] = $v[$index+1]['value'];
|
||||
$spec_type[$v[$index+1]['value']] = $v[$index+1]['value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return DataReturn('操作成功', 0, array_values($value));
|
||||
|
||||
// 处理好的数据
|
||||
// 扩展元素标记与html内容数据
|
||||
// extends_element下包含多个元素 ['element'=>'', 'content'=>'']
|
||||
$data = [
|
||||
'spec_type' => array_values($spec_type),
|
||||
'extends_element' => [],
|
||||
];
|
||||
|
||||
// 商品获取规格类型钩子
|
||||
$hook_name = 'plugins_service_goods_spec_type';
|
||||
$ret = Hook::listen($hook_name, [
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => true,
|
||||
'params' => $params,
|
||||
'data' => &$data,
|
||||
'goods_id' => $goods_id
|
||||
]);
|
||||
if(isset($ret['code']) && $ret['code'] != 0)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
|
||||
return DataReturn('操作成功', 0, $data);
|
||||
}
|
||||
}
|
||||
return DataReturn('没有相关规格类型', -100);
|
||||
|
|
|
|||
|
|
@ -68,5 +68,13 @@ return array (
|
|||
array (
|
||||
0 => 'app\\plugins\\membershiplevel\\Hook',
|
||||
),
|
||||
'plugins_view_goods_detail_panel_price_top' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\membershiplevel\\Hook',
|
||||
),
|
||||
'plugins_service_goods_spec_type' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\membershiplevel\\Hook',
|
||||
),
|
||||
);
|
||||
?>
|
||||
|
|
@ -181,18 +181,17 @@ fieldset legend{margin-left:15px;padding-left:3px;padding-right:3px;color:#333;}
|
|||
/*价格*/
|
||||
.tb-detail-price{text-align: left; position: relative;}
|
||||
.tb-detail-price .price em {font-family: arial;}
|
||||
.iteminfo_price .sys_item_mktprice{text-decoration:line-through;padding-top:7px ;padding-bottom: 0px; font-size:14px; }
|
||||
.tb-detail-price .original-price-value {text-decoration:line-through; font-size:14px; }
|
||||
.iteminfo_mktprice {padding-top: 10px;}
|
||||
.iteminfo_mktprice em, .sys_item_price { color:#c00;}
|
||||
.sys_item_price { font-size:20px;}
|
||||
.tb-detail-price dd {display: inline-block;}
|
||||
.goods-favor-count { color: #999; }
|
||||
.iteminfo_mktprice em, .goods-price { color:#c00;}
|
||||
.tb-detail-price dd {display: inline-block;}
|
||||
.goods-favor-count { color: #999; }
|
||||
.iteminfo_parameter a:hover{text-decoration: none;color:initial ;}
|
||||
.tm-indcon .tm-label, .tb-detail-price dt, .specpara-title { white-space:nowrap; color:#666; font-weight: 400; }
|
||||
.tb-detail-price{ background: #fcf1e3 url(../images/goods-meta-bg.png); background-size: cover; -moz-background-size: cover; background-repeat: no-repeat; height:75px;padding:10px; }
|
||||
.tb-detail-price .items {display: block;margin-left:0 !important;}
|
||||
.tb-detail-price{ background: #fcf1e3 url(../images/goods-meta-bg.png); background-size: cover; -moz-background-size: cover; background-repeat: no-repeat; height:auto;padding:10px; }
|
||||
.tb-detail-price .items {display: block; margin: 5px 0;}
|
||||
.tb-detail-price .items dt { float:left; text-align: left;}
|
||||
.sys_item_price{font-size: 24px;font-weight: bold; line-height: 16px;}
|
||||
.tb-detail-price .goods-price {font-size: 24px;font-weight: bold; line-height: 16px;}
|
||||
|
||||
/* 二维码 */
|
||||
.goods-qrcode{position: absolute; bottom: 5px; right: 10px; cursor: pointer; color: #666; width: 150px; text-align: right;}
|
||||
|
|
|
|||
|
|
@ -255,16 +255,29 @@ function GoodsSpecDetail()
|
|||
$.AMUI.progress.done();
|
||||
if(result.code == 0)
|
||||
{
|
||||
$('.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);
|
||||
if(result.data.original_price > 0)
|
||||
$('.text-info .price-now').text('¥'+result.data.spec_base.price);
|
||||
$('.goods-price').text(result.data.spec_base.price);
|
||||
$('.number-tag input[type="number"]').attr('max', result.data.spec_base.inventory);
|
||||
$('.stock-tips .stock').text(result.data.spec_base.inventory);
|
||||
if(result.data.spec_base.original_price > 0)
|
||||
{
|
||||
$('.sys_item_mktprice').text('¥'+result.data.original_price);
|
||||
$('.sys_item_mktprice').show();
|
||||
$('.goods-original-price').text('¥'+result.data.spec_base.original_price);
|
||||
$('.goods-original-price').show();
|
||||
} else {
|
||||
$('.sys_item_mktprice').hide();
|
||||
$('.goods-original-price').hide();
|
||||
}
|
||||
|
||||
// 扩展数据处理
|
||||
var extends_element = result.data.extends_element || [];
|
||||
if(extends_element.length > 0)
|
||||
{
|
||||
for(var i in extends_element)
|
||||
{
|
||||
if((extends_element[i]['element'] || null) != null && extends_element[i]['content'] !== null)
|
||||
{
|
||||
$(extends_element[i]['element']).html(extends_element[i]['content']);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if($(window).width() < 640)
|
||||
|
|
@ -336,7 +349,7 @@ function GoodsSpecType()
|
|||
{
|
||||
$(this).removeClass('sku-dont-choose');
|
||||
var value = $(this).data('value').toString();
|
||||
if(result.data.indexOf(value) == -1)
|
||||
if(result.data.spec_type.indexOf(value) == -1)
|
||||
{
|
||||
$(this).addClass('sku-items-disabled');
|
||||
} else {
|
||||
|
|
@ -344,6 +357,19 @@ function GoodsSpecType()
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 扩展数据处理
|
||||
var extends_element = result.data.extends_element || [];
|
||||
if(extends_element.length > 0)
|
||||
{
|
||||
for(var i in extends_element)
|
||||
{
|
||||
if((extends_element[i]['element'] || null) != null && extends_element[i]['content'] !== null)
|
||||
{
|
||||
$(extends_element[i]['element']).html(extends_element[i]['content']);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if($(window).width() < 640)
|
||||
{
|
||||
|
|
@ -377,10 +403,22 @@ function GoodsSpecType()
|
|||
function GoodsBaseRestore()
|
||||
{
|
||||
$('.text-info .price-now').text('¥'+$('.text-info .price-now').data('original-price'));
|
||||
$('.sys_item_mktprice').text($('.sys_item_mktprice').data('original-price'));
|
||||
$('.sys_item_price').text($('.sys_item_price').data('original-price'));
|
||||
$('.goods-price').text($('.goods-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'));
|
||||
|
||||
// 价格处理
|
||||
if($('.tb-detail-price .original-price-value').length > 0)
|
||||
{
|
||||
$('.tb-detail-price .original-price-value').each(function(k, v)
|
||||
{
|
||||
var price = $(this).data('original-price');
|
||||
if(price !== undefined)
|
||||
{
|
||||
$(this).text('¥'+price);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$(function() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue