bundbuy.html
7.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
{echo:JS::import('dialog?skin=brief');}
{echo:JS::import('dialogtools');}
{echo:JS::import('form');}
<!--S 产品展示-->
<link type="text/css" rel="stylesheet" href="{url:@static/css/product.css}" />
<script type='text/javascript' src="{url:@static/js/jquery.enlarge.js}"></script>
<div class="clearfix mt10" style="position: relative;">
<div class="content box" style="overflow:visible">
<div class="bundling-bar clearfix">
<dl class="bund-info">
<dt>优惠套餐:</dt>
<dd><div>原价:<del>{$currency_symbol}{$goods_price}</del></div></dd>
<dd><span class="price-caption">套餐价:</span></dd>
<dd><span class="price"><b>{$currency_symbol}{$bund['price']}</b></span></dd>
</dl>
<div class="save-top">
<div class="save-price">{$currency_symbol}{echo:sprintf('%01.2f',$goods_price-$bund['price'])}</div>
</div>
</div>
<h3 class="bundling-spec">请选择商品规格:</h3>
<ul class=" clearfix " style="position: relative;margin-top:28px;">
{set:$sets_enable=true;}
{list:items=$goods}
<li class=" p10 clearfix" style="position: relative;background:#fff;border-bottom:#eee 1px solid">
<div class="fl" style="height:210px;">
<a href="{url:/index/product/id/$item[id]}" target="_blank"><img class="big-pic" src="{url:@}{echo:Common::thumb($item['img'],220,220)}" width=220></a>
</div>
<div class="product-info" style="margin-left:230px;" gid="{$item['id']}">
<ul>
<li ><h1 class="f18">{$item['name']}</h1></li>
<li class="product-price"><label>销售价:</label><span id="sell_price" class="price">{$currency_symbol}{$item['sell_price']}</span></li>
{if:$item['store_nums']<=0}{set:$sets_enable=false;}{/if}
<li class="product-price"><label>库存:</label>(<span>{$item['store_nums']}</span>)</li>
</ul>
{set:$specs = unserialize($item['specs']);}
{if:!empty($specs)}
<div class=" mt10 p10 spec-info box" >
{list:items=$specs item=$spec}
<dl class="spec-item clearfix">
<dt>{$spec['name']}:</dt>
<dd>
<ul class="spec-values" spec_id="{$spec['id']}">
{list:items=$spec['value'] item=$value}
<li data-value="{$spec['id']}:{$value['id']}">{if:$value['img']==''}<span>{$value['name']}</span>{else:}<img src="{url:@}{echo:Common::thumb($value['img'],36,36)}" width="36" height="36"><label>{$value['name']}</label>{/if}<i></i></li>
{/list}
</ul>
</dd>
</dl>
{/list}
<dl class="spec-msg" class="spec-item clearfix" style="display: none;">
<dt></dt>
<dd ><p class="msg"><i class="icon icon-alert"></i><span >请选择您要购买的商品规格</span></p>
</dd>
</dl>
</div>
{/if}
</div>
</li>
{/list}
</ul>
<div class="bundling-bbar clearfix">
<dl class="bund-info">
<dt>优惠套餐:</dt>
<dd><div>原价:<del>{$currency_symbol}{$goods_price}</del></div></dd>
<dd><span class="price-caption">套餐价:</span></dd>
<dd><span class="price"><b>{$currency_symbol}{$bund['price']}</b></span></dd>
</dl>{if:$sets_enable}<a href="javascript:;" id="buy-now" class="btn fr">立即购买</a>
{else:}
<a href="javascript:;" class="btn btn-disable fr">库存不足</a>
{/if}
</div>
</div>
</div>
<script type="text/javascript">
var skuMap = {echo:JSON::encode($skumap)};
$(".product-info").each(function(){
var spec = $(this);
$(".spec-values li",spec).each(function(){
$(this).on("click",function(){
var disabled = $(this).hasClass('disabled');
if(disabled) return;
var flage = $(this).hasClass('selected');
$(this).parent().find("li").removeClass("selected");
if(!flage){
$(this).addClass("selected");
}
changeStatus(spec);
if($(".spec-values",spec).length == $(".spec-values .selected",spec).length){
var sku = new Array();
$(".spec-values .selected",spec).each(function(i){
sku[i]= $(this).attr("data-value");
})
var sku_key = ";"+sku.join(";")+";";
if(skuMap[sku_key]!=undefined){
var sku = skuMap[sku_key];
}
$(".spec-msg",spec).css("display","none");
}
})
})
});
function changeStatus(spec){
var specs_array = new Array();
$(".spec-values",spec).each(function(i){
var selected = $(this).find(".selected");
if(selected.length>0)specs_array[i]=selected.attr("data-value");
else specs_array[i] = "\\\d+:\\\d+";
});
$(".spec-values",spec).each(function(i){
var selected = $(this).find(".selected");
$(this).find("li").removeClass("disabled");
var k = i;
$(this).find("li").each(function(){
var temp = specs_array.slice();
temp[k] = $(this).attr('data-value');
var flage = false;
for(sku in skuMap){
var reg = new RegExp(';'+temp.join(";")+';');
if(reg.test(sku) && skuMap[sku]['store_nums']>0) flage = true;
}
if(!flage)$(this).addClass("disabled");
})
});
}
//立即团购
$("#buy-now").on("click",function(){
var product = currentProduct();
var error_flag = false;
var ids = new Array();
for(i in product){
if(product[i]){
ids[i] = product[i]['id'];
}
else{
error_flag = true;
$(".spec-msg:eq("+i+")").css("display","");
showMsgBar('alert',"请选择您要购买的商品规格!");
}
}
if(!error_flag){
ids = ids.join('-');
var url = "{url:/simple/order_info/type/bundbuy/id/$id/pid/}"+ids;
window.location.href = url;
}
});
//取得当前商品
function currentProduct(){
var result = new Array();
$(".product-info").each(function(i){
var spec = $(this);
if($(".spec-values",spec).length==0){
result[i] = skuMap[spec.attr("gid")];
}else if($(".spec-values",spec).length == $(".spec-values .selected",spec).length){
var sku = new Array();
$(".spec-values .selected",spec).each(function(i){
sku[i]= $(this).attr("data-value");
})
var sku_key = ";"+sku.join(";")+";";
if(skuMap[sku_key]!=undefined){
result[i] = skuMap[sku_key];
}else result[i] = null;
}
else result[i] = null;
});
return result;
}
//展示信息
function showMsgBar(type,text){
$(".msg").find("span").text(text);
$(".msg").find("i").attr("class","icon icon-"+type);
}
</script>
<!--E 产品展示-->