index.html
11.0 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>购物车</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1, minimum-scale=1">
<link rel="stylesheet" href="__TMPL__/public/assets/css/base.css">
<link rel="stylesheet" href="__TMPL__/public/assets/css/swiper.min.css">
<link rel="stylesheet" href="__TMPL__/public/assets/css/common/buy_car.css">
<script src="__TMPL__/public/assets/js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="__TMPL__/public/assets/js/swiper.min.js" type="text/javascript" charset="utf-8"></script>
<script src="__TMPL__/public/assets/js/base.js" type="text/javascript" charset="utf-8"></script>
<style>
.changeNone{
display: none;
}
.show{
display: block;
}
</style>
</head>
<body>
<header class="mui_bar">
<div class="delete_box">
<img class="del_img" src="__TMPL__/public/assets/images/sdfadgas@2x.png" alt="">
<p class="del_p">删除</p>
</div>
<h1 class="mui_title">购物车</h1>
</header>
<div class="container">
<div class="con_warp">
<ul class="con_list_ul first_ul">
<volist name="cart" id="cart">
<li class="con_list_li">
<div class="check_radio first_radio">
<!-- <input type="radio"> -->
<img class="sel_img changeNone" src="__TMPL__/public/assets/images/sure.png" alt="">
</div>
<img class="con_list_img" src="{:cmf_get_image_url($cart.pic)}" alt="">
<div class="goods_box" index="{$cart.id}">
<p class="goods_title">{$cart.name}</p>
<span class="goods_content">{$cart.intro}</span>
<p class="goods_money">¥<span class="onlyMoney">{$cart.money}</span></p>
<div class="join">
<img class="subtract_img" src="__TMPL__/public/assets/images/item_reduce.png " alt="">
<p class="number">{$cart.num} </p>
<img class="add_img" src="__TMPL__/public/assets/images/item_add.png" alt="">
</div>
</div>
</li>
</volist>
</ul>
</div>
</div>
<div class="zhifu">
<div class="radio_box">
<div class="all_ckeck ">
<!-- <input type="radio"> -->
<img class="all changeNone" src="__TMPL__/public/assets/images/sure.png" alt="">
</div>
<p>全选</p>
</div>
<div class="pay">
<p class="to_pay">前往支付</p>
<p class="all_price"> 合计:<span>¥<span class="change_money">0.00</span></span></p>
</div>
</div>
<footer class="footer">
<ul class="bottom_list">
<li id="index_bar" class="mainpage_botlist index_bar"><img src="__TMPL__/public/assets/images/index.png" alt=""><span>首页</span></li>
<li id="buy_car" class="mainpage_botlist buy_car"><img src="__TMPL__/public/assets/images/cdvcd@1x_checked.png" alt=""><span>购物车</span></li>
<li id="personal_center" class="mainpage_botlist personal_center"><img src="__TMPL__/public/assets/images/personal.png" alt=""><span>我的</span></li>
</ul>
</footer>
</div>
<script src="__TMPL__/public/assets/js/common.js"></script>
<script>
// 购物车数量 start
var shopping_id = 0;
var is_add = 0;
// 购物车数量减少
$('.subtract_img').click(function () {
shopping_id = $(this).parent().parent().attr('index');
is_add = 2;
changenum($(this));
});
// 购物车数量增加
$('.add_img').click(function () {
shopping_id = $(this).parent().parent().attr('index');
is_add = 1;
changenum($(this));
});
function changenum(k) {
$.ajax({
type:"POST",
url:"{:url('Shopping/changeShopping')}",
data:{
"shopping_id":shopping_id,
"is_add":is_add,
},
success:function (data) {
var count_allFirst = 0;
if(data.code == '1'){
k.parent().find('.number').html(data.data.number);
var is_has = k.parent().parent().parent().find('.sel_img').hasClass('show');
if(is_has == true){
$('.show').map(function () {
var money = $(this).parent().parent().find('.onlyMoney').text();
var num = $(this).parent().parent().find('.number').text();
count_allFirst += parseFloat(money)*parseFloat(num);
})
// 更改总额
var final = count_allFirst.toFixed(2);
$('.change_money').text(final);
}
}else{
alert(data.message);
}
},
error:function () {
}
})
}
// end
// 选中
$('.first_radio').click(function () {
// 增加样式
var count_all = 0;
if($(this).find('.sel_img').hasClass('show')){
$(this).find('.sel_img').removeClass('show');
$(this).find('.sel_img').addClass('changeNone');
}else{
$(this).find('.sel_img').removeClass('changeNone');
$(this).find('.sel_img').addClass('show');
}
$('.first_radio .show').map(function () {
var money = $(this).parent().parent().find('.onlyMoney').text();
var num = $(this).parent().parent().find('.number').text();
count_all += parseFloat(money)*parseFloat(num);
})
// 更改总额
var final = count_all.toFixed(2);
$('.change_money').text(final);
// 全选
var all_con = $(".first_ul .con_list_li").length;
var choose_con = $(".first_ul .show").length;
if(all_con == choose_con){
$('.all_ckeck').find('.all').removeClass('changeNone');
$('.all_ckeck').find('.all').addClass('show');
}else{
$('.all_ckeck').find('.all').removeClass('show');
$('.all_ckeck').find('.all').addClass('changeNone');
}
});
// 全选
$('.all_ckeck').click(function () {
if($('.all_ckeck').find('img').hasClass('show')){
$('.first_ul li').find('.sel_img').removeClass('show');
$('.first_ul li').find('.sel_img').addClass('changeNone');
$('.all_ckeck').find('img').removeClass('show');
$('.all_ckeck').find('img').addClass('changeNone');
}else{
$('.first_ul li').find('.sel_img').removeClass('changeNone');
$('.first_ul li').find('.sel_img').addClass('show');
$('.all_ckeck').find('img').removeClass('changeNone');
$('.all_ckeck').find('img').addClass('show');
}
var count_all = 0;
$('.first_radio .show').map(function () {
var money = $(this).parent().parent().find('.onlyMoney').text();
var num = $(this).parent().parent().find('.number').text();
count_all += parseFloat(money)*parseFloat(num);
})
// 更改总额
var final = count_all.toFixed(2);
$('.change_money').text(final);
})
//删除
$('.delete_box').on('click', function() {
var del_arr = [];
$('.first_ul').find('.show').map(function () {
var del_id = $(this).parent().parent().find('.goods_box').attr('index');
del_arr.push(del_id);
})
if(del_arr.length == 0){
alert('请选择您要删除的物品!')
}else{
$.ajax({
type:"POST",
url:"{:url('Shopping/delShopping')}",
data:{
"shopping_id":del_arr,
},
success:function (data) {
alert(data.message);
if(data.code == 1){
window.location.reload();
}
},
error:function () {
}
})
}
});
// $(document).ready(function() {
// var $menu_box = $('.content_body .con_title>li');
// $menu_box.click(function() {
// $(this).addClass('con_curr').siblings().removeClass('con_curr');
// var index = $menu_box.index(this);
// $('.con_all .con_warp').eq(index).show().siblings().hide();
// });
// })
//勾选
// $('.check_radio').on('click', function() {
//
// if ($('.check_radio img').is(':hidden')) { //如果当前隐藏
// $('.check_radio img').show(); //那么就显示div
// $('.check_radio').css('border', '0.01rem solid #FFF');
//
// } else { //否则
// $('.check_radio img').hide(); //就隐藏div
// $('.check_radio').css('border', '0.01rem solid rgba(0,0,0,0.4)');
// }
// if ($('.con_list_li').length == 1 && $('.check_radio img').is(':hidden') == false) {
// $('.all_ckeck img').show();
// $('.all_ckeck').css('border', '0.01rem solid #FFF');
// } else {
// $('.all_ckeck img').hide();
// $('.all_ckeck').css('border', '0.01rem solid rgba(0,0,0,0.4)');
//
// }
// })
// //全部勾选
// $('.all_ckeck').on('click', function() {
// if ($('.all_ckeck img').is(':hidden')) { //如果当前隐藏
// $('.all_ckeck img').show(); //那么就显示tupain
// $('.all_ckeck').css('border', '0.01rem solid #FFF');
// $('.check_radio img').show(); //那么就显示div
// $('.check_radio').css('border', '0.01rem solid #FFF');
// } else {
// $('.check_radio img').hide();
// $('.check_radio').css('border', 'none')
// $('.check_radio').css('border', '0.01em solid rgba(0,0,0,0.4)');
// $('.all_ckeck img').hide(); //那么就显示div
// $('.all_ckeck ').css('border', '0.01rem solid rgba(0,0,0,0.4)');
//
// }
//
// })
//导航栏跳转
$('#index_bar').on('click', function() { window.location.href = "{:url('Index/index')}" });
$('#personal_center').on('click', function() { window.location.href = "{:url('User/index')}"})
</script>
</body>
</html>