|
@@ -10,50 +10,37 @@ |
|
@@ -10,50 +10,37 @@ |
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
|
|
22
|
// re = /\d+/,
|
20
|
// re = /\d+/,
|
23
|
leftNum,
|
21
|
leftNum,
|
24
|
confirming,
|
22
|
confirming,
|
25
|
- hasChooseColor,
|
|
|
26
|
- hasChooseSize,
|
|
|
27
|
curColorIndex,
|
23
|
curColorIndex,
|
28
|
curSizeIndex,
|
24
|
curSizeIndex,
|
29
|
$curSizeRow,
|
25
|
$curSizeRow,
|
|
|
26
|
+ hasChooseColor,
|
|
|
27
|
+ hasChooseSize,
|
30
|
$curSizeBlock,
|
28
|
$curSizeBlock,
|
31
|
$sizeRowList;
|
29
|
$sizeRowList;
|
32
|
|
30
|
|
33
|
-// 读取模板
|
|
|
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
|
-});
|
|
|
43
|
-
|
|
|
44
|
//初始化购物车面板显示
|
31
|
//初始化购物车面板显示
|
45
|
function init() {
|
32
|
function init() {
|
46
|
var $firstRow;
|
33
|
var $firstRow;
|
47
|
|
34
|
|
|
|
35
|
+ hasChooseColor = false;
|
|
|
36
|
+ hasChooseSize = false;
|
|
|
37
|
+ $curSizeBlock = null;
|
48
|
$sizeRowList = $('.size-list ul');
|
38
|
$sizeRowList = $('.size-list ul');
|
49
|
$firstRow = $sizeRowList.eq(0);
|
39
|
$firstRow = $sizeRowList.eq(0);
|
50
|
- $curSizeBlock = null,
|
|
|
51
|
-
|
|
|
52
|
- hasChooseSize = false,
|
|
|
53
|
- hasChooseColor = false,
|
|
|
54
|
$firstRow.toggleClass('hide');
|
40
|
$firstRow.toggleClass('hide');
|
55
|
$curSizeRow = $firstRow;
|
41
|
$curSizeRow = $firstRow;
|
56
|
}
|
42
|
}
|
|
|
43
|
+init();
|
57
|
|
44
|
|
58
|
function checkColorSizeNum() {
|
45
|
function checkColorSizeNum() {
|
59
|
if (!hasChooseColor && !hasChooseSize) {
|
46
|
if (!hasChooseColor && !hasChooseSize) {
|
|
@@ -69,9 +56,9 @@ function checkColorSizeNum() { |
|
@@ -69,9 +56,9 @@ function checkColorSizeNum() { |
69
|
return true;
|
56
|
return true;
|
70
|
}
|
57
|
}
|
71
|
|
58
|
|
72
|
-function show(data) {
|
|
|
73
|
- if (data) {
|
|
|
74
|
- $chosePanel.html(panelTmpl(data));
|
59
|
+function show(html) {
|
|
|
60
|
+ if (html) {
|
|
|
61
|
+ $chosePanel.html(html);
|
75
|
init();
|
62
|
init();
|
76
|
}
|
63
|
}
|
77
|
$('.chose-panel').show();
|
64
|
$('.chose-panel').show();
|