Showing
1 changed file
with
48 additions
and
0 deletions
1 | /** | 1 | /** |
2 | * 购物车选择尺寸、颜色和数量面板 | 2 | * 购物车选择尺寸、颜色和数量面板 |
3 | + * 显示时构造当前商品信息的HTML插入yoho-page;消失则是直接清除HTML | ||
3 | * @author: xuqi<qi.xu@yoho.cn> | 4 | * @author: xuqi<qi.xu@yoho.cn> |
4 | * @date: 2015/10/21 | 5 | * @date: 2015/10/21 |
5 | */ | 6 | */ |
@@ -9,6 +10,8 @@ var Handlebars = require('yoho.handlebars'); | @@ -9,6 +10,8 @@ var Handlebars = require('yoho.handlebars'); | ||
9 | 10 | ||
10 | var $page = $('.yoho-page'); | 11 | var $page = $('.yoho-page'); |
11 | 12 | ||
13 | +var $num; | ||
14 | + | ||
12 | var tpl; | 15 | var tpl; |
13 | 16 | ||
14 | //读取partials | 17 | //读取partials |
@@ -25,6 +28,51 @@ function show(data) { | @@ -25,6 +28,51 @@ function show(data) { | ||
25 | var html = tpl(data); | 28 | var html = tpl(data); |
26 | 29 | ||
27 | $page.append(html); | 30 | $page.append(html); |
31 | + | ||
32 | + $num = $('#good-num'); | ||
28 | } | 33 | } |
29 | 34 | ||
35 | +//移除当前Panel | ||
36 | +function remove() { | ||
37 | + $('.chose-panel').remove(); | ||
38 | +} | ||
39 | + | ||
40 | +$('.yoho-page').delegate('.chose-panel', 'touchstart', function(e) { | ||
41 | + var $cur = $(e.target); | ||
42 | + | ||
43 | + if ($cur.closest('.main').length > 0) { | ||
44 | + return; | ||
45 | + } | ||
46 | + | ||
47 | + //点击蒙版消失 | ||
48 | + remove(); | ||
49 | +}).delegate('#chose-btn-sure', 'touchstart', function() { | ||
50 | + | ||
51 | + //确定 | ||
52 | +}).delegate('.block', 'touchstart', function() { | ||
53 | + | ||
54 | + //尺寸颜色点选 | ||
55 | + var $this = $(this); | ||
56 | + | ||
57 | + if ($this.hasClass('.chosed') || $this.hasClass('disable')) { | ||
58 | + return; | ||
59 | + } | ||
60 | + | ||
61 | + $this.siblings('.chosed').removeClass('chosed'); | ||
62 | + $this.addClass('chosed'); | ||
63 | +}).delegate('.btn-minus', 'touchstart', function() { | ||
64 | + var num = +$num.val(); | ||
65 | + | ||
66 | + if (num === 1) { | ||
67 | + return; | ||
68 | + } | ||
69 | + | ||
70 | + $num.val(num - 1); | ||
71 | +}).delegate('.btn-plus', 'touchstart', function() { | ||
72 | + var num = +$num.val(); | ||
73 | + | ||
74 | + //TODO:库存数验证 | ||
75 | + $num.val(num + 1); | ||
76 | +}); | ||
77 | + | ||
30 | exports.show = show; | 78 | exports.show = show; |
-
Please register or login to post a comment