|
@@ -10,39 +10,45 @@ |
|
@@ -10,39 +10,45 @@ |
10
|
// 异步渲染的模板统一插入 #chose-panel ,兼容页面多个选择框
|
10
|
// 异步渲染的模板统一插入 #chose-panel ,兼容页面多个选择框
|
11
|
|
11
|
|
12
|
var $ = require('jquery'),
|
12
|
var $ = require('jquery'),
|
13
|
- Handlebars = require('yoho.handlebars'),
|
|
|
14
|
tip = require('../plugin/tip'),
|
13
|
tip = require('../plugin/tip'),
|
15
|
loading = require('../plugin/loading');
|
14
|
loading = require('../plugin/loading');
|
16
|
|
15
|
|
17
|
-var panelTmpl,
|
|
|
18
|
- $chosePanel = $('#chose-panel'),
|
16
|
+var $chosePanel = $('#chose-panel'),
|
19
|
$num,
|
17
|
$num,
|
20
|
$chosed,
|
18
|
$chosed,
|
21
|
|
19
|
|
|
|
20
|
+ // panelTmpl,
|
22
|
// re = /\d+/,
|
21
|
// re = /\d+/,
|
23
|
leftNum,
|
22
|
leftNum,
|
24
|
confirming,
|
23
|
confirming,
|
25
|
- hasChooseColor = false,
|
|
|
26
|
- hasChooseSize = false,
|
|
|
27
|
curColorIndex,
|
24
|
curColorIndex,
|
28
|
curSizeIndex,
|
25
|
curSizeIndex,
|
29
|
$curSizeRow,
|
26
|
$curSizeRow,
|
30
|
- $curSizeBlock = null,
|
|
|
31
|
- $sizeRowList = $('.size-list ul');
|
27
|
+ hasChooseColor,
|
|
|
28
|
+ hasChooseSize,
|
|
|
29
|
+ $curSizeBlock,
|
|
|
30
|
+ $sizeRowList;
|
32
|
|
31
|
|
33
|
// 读取模板
|
32
|
// 读取模板
|
34
|
-$.get('/cart/index/giftinfoTpl', function(html) {
|
|
|
35
|
- if (!html) {
|
|
|
36
|
- tip.show('网络错误');
|
|
|
37
|
- return;
|
|
|
38
|
- }
|
|
|
39
|
- panelTmpl = Handlebars.compile(html);
|
|
|
40
|
-}).fail(function() {
|
|
|
41
|
- tip.show('网络错误');
|
|
|
42
|
-});
|
33
|
+// $.get('/cart/index/giftinfoTpl', function(html) {
|
|
|
34
|
+// if (!html) {
|
|
|
35
|
+// tip.show('网络错误');
|
|
|
36
|
+// return;
|
|
|
37
|
+// }
|
|
|
38
|
+// panelTmpl = Handlebars.compile(html);
|
|
|
39
|
+// }).fail(function() {
|
|
|
40
|
+// tip.show('网络错误');
|
|
|
41
|
+// });
|
43
|
|
42
|
|
44
|
//初始化购物车面板显示
|
43
|
//初始化购物车面板显示
|
45
|
function init() {
|
44
|
function init() {
|
|
|
45
|
+ var $firstRow;
|
|
|
46
|
+
|
|
|
47
|
+ hasChooseColor = false;
|
|
|
48
|
+ hasChooseSize = false;
|
|
|
49
|
+ $curSizeBlock = null;
|
|
|
50
|
+ $sizeRowList = $('.size-list ul');
|
|
|
51
|
+ $firstRow = $sizeRowList.eq(0);
|
46
|
|
52
|
|
47
|
//$colorList = $('.chose-panel .color-list ul>li');
|
53
|
//$colorList = $('.chose-panel .color-list ul>li');
|
48
|
//$sizeList = $('.chose-panel .size-list ul>li');
|
54
|
//$sizeList = $('.chose-panel .size-list ul>li');
|
|
@@ -55,11 +61,10 @@ function init() { |
|
@@ -55,11 +61,10 @@ function init() { |
55
|
// }
|
61
|
// }
|
56
|
//});
|
62
|
//});
|
57
|
|
63
|
|
58
|
- var $firstRow = $sizeRowList.eq(0);
|
|
|
59
|
-
|
|
|
60
|
$firstRow.toggleClass('hide');
|
64
|
$firstRow.toggleClass('hide');
|
61
|
$curSizeRow = $firstRow;
|
65
|
$curSizeRow = $firstRow;
|
62
|
}
|
66
|
}
|
|
|
67
|
+init();
|
63
|
|
68
|
|
64
|
function checkColorSizeNum() {
|
69
|
function checkColorSizeNum() {
|
65
|
if (!hasChooseColor && !hasChooseSize) {
|
70
|
if (!hasChooseColor && !hasChooseSize) {
|
|
@@ -75,11 +80,9 @@ function checkColorSizeNum() { |
|
@@ -75,11 +80,9 @@ function checkColorSizeNum() { |
75
|
return true;
|
80
|
return true;
|
76
|
}
|
81
|
}
|
77
|
|
82
|
|
78
|
-init();
|
|
|
79
|
-
|
|
|
80
|
-function show(data) {
|
|
|
81
|
- if (data) {
|
|
|
82
|
- $chosePanel.html(panelTmpl(data));
|
83
|
+function show(html) {
|
|
|
84
|
+ if (html) {
|
|
|
85
|
+ $chosePanel.html(html);
|
83
|
init();
|
86
|
init();
|
84
|
}
|
87
|
}
|
85
|
$('.chose-panel').show();
|
88
|
$('.chose-panel').show();
|