Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHO-ACTIVITY-PHP
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
毕凯
9 years ago
Commit
a95117bbd73e90794d93afa28a36b87c2c7a3f90
1 parent
62515af2
加价购 加入购物车
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
56 deletions
static/js/cart/chose-panel.js
static/js/cart/gift-advance.js
static/sass/cart/_gift-advance-good.scss
static/js/cart/chose-panel.js
View file @
a95117b
...
...
@@ -5,46 +5,53 @@
* @date: 2015/10/21
*/
var
$
=
require
(
'jquery'
),
tip
=
require
(
'../plugin/tip'
),
loading
=
require
(
'../plugin/loading'
);
// Handlebars = require('yoho.handlebars');
// bikai
// 增加init函数,异步请求的接口需要重新初始化一下选择列表
// 异步渲染的模板统一插入 #chose-panel ,兼容页面多个选择框
// var $page = $('.yoho-page');
var
$
=
require
(
'jquery'
),
Handlebars
=
require
(
'yoho.handlebars'
),
tip
=
require
(
'../plugin/tip'
),
loading
=
require
(
'../plugin/loading'
);
var
$num
,
var
panelTmpl
,
$chosePanel
=
$
(
'#chose-panel'
),
$num
,
$chosed
,
re
=
/
\d
+/
,
leftNum
,
$colorList
=
$
(
'.color-list ul>li'
),
$sizeList
=
$
(
'.size-list ul>li'
),
firstColorId
=
$colorList
.
eq
(
0
).
data
(
'id'
),
$colorList
,
$sizeList
,
firstColorId
,
colorIndex
,
confirming
;
//初始化购物车面板显示
$sizeList
.
each
(
function
()
{
colorIndex
=
$
(
this
).
data
(
'colorid'
);
if
(
colorIndex
===
firstColorId
)
{
$
(
this
).
removeClass
(
'hide'
);
// 读取模板
$
.
get
(
'/cart/index/giftinfoTpl'
,
function
(
html
)
{
if
(
!
html
)
{
tip
.
show
(
'网络错误'
);
return
;
}
panelTmpl
=
Handlebars
.
compile
(
html
);
}).
fail
(
function
()
{
tip
.
show
(
'网络错误'
);
});
//初始化购物车面板显示
function
init
()
{
$colorList
=
$
(
'.chose-panel .color-list ul>li'
);
$sizeList
=
$
(
'.chose-panel .size-list ul>li'
);
firstColorId
=
$colorList
.
eq
(
0
).
data
(
'id'
);
$sizeList
.
each
(
function
()
{
colorIndex
=
$
(
this
).
data
(
'colorid'
);
if
(
colorIndex
===
firstColorId
)
{
$
(
this
).
removeClass
(
'hide'
);
}
});
}
// var tpl;
//读取partials
// $.ajax({
// type: 'GET',
// url: '/shoppingCart/tpl',
// success: function(data) {
// tpl = Handlebars.compile(data);
// }
// });
init
();
//显示
// function show(data) {
...
...
@@ -57,7 +64,12 @@ $sizeList.each(function() {
function
show
()
{
function
show
(
data
)
{
if
(
data
)
{
$chosePanel
.
html
(
panelTmpl
(
data
));
init
();
}
$
(
'.chose-panel'
).
show
();
$
(
'body'
).
css
(
'overflow'
,
'hidden'
);
...
...
@@ -112,16 +124,18 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
isEdit
:
isEdit
}
}).
done
(
function
(
res
)
{
loading
.
hideLoadingMask
();
if
(
res
.
code
===
200
)
{
loading
.
hideLoadingMask
();
$
(
'.num-tag'
).
html
(
numInCart
+
buyNumber
);
$
(
'.num-tag'
).
removeClass
(
'hide'
);
confirming
=
false
;
remove
();
}
if
(
res
.
message
)
{
tip
.
show
(
res
.
message
);
}
}).
fail
(
function
()
{
tip
.
show
(
'网络出了点问题~'
);
}).
always
(
function
()
{
confirming
=
false
;
});
}
...
...
@@ -241,5 +255,5 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
$num
.
val
(
num
+
1
);
});
exports
.
show
=
show
;
\ No newline at end of file
exports
.
init
=
init
;
exports
.
show
=
show
;
...
...
static/js/cart/gift-advance.js
View file @
a95117b
...
...
@@ -6,27 +6,14 @@
var
$
=
require
(
'jquery'
),
lazyLoad
=
require
(
'yoho.lazyload'
),
Handlebars
=
require
(
'yoho.handlebars'
),
tip
=
require
(
'../plugin/tip'
),
loading
=
require
(
'../plugin/loading'
),
chosePanel
=
require
(
'./chose-panel'
);
var
panelTmpl
,
$page
=
$
(
'.gift-advance-page'
),
$chosePanel
=
$
(
'#chose-panel'
);
var
$page
=
$
(
'.gift-advance-page'
);
lazyLoad
(
$
(
'.lazy'
));
$
.
get
(
'/cart/index/giftinfoTpl'
,
function
(
html
)
{
if
(
!
html
)
{
tip
.
show
(
'网络错误'
);
return
;
}
panelTmpl
=
Handlebars
.
compile
(
html
);
}).
fail
(
function
()
{
tip
.
show
(
'网络错误'
);
});
function
getProductInfo
(
skn
,
promotionId
)
{
loading
.
showLoadingMask
();
$
.
get
(
'/cart/index/giftinfo'
,
{
...
...
@@ -37,14 +24,10 @@ function getProductInfo(skn, promotionId) {
tip
.
show
(
'网络错误'
);
return
;
}
if
(
!
panelTmpl
)
{
return
;
}
if
(
res
.
code
===
200
)
{
$chosePanel
.
html
(
panelTmpl
({
cartInfo
:
res
.
data
}));
chosePanel
.
show
();
chosePanel
.
show
({
cartInfo
:
res
.
data
});
}
else
{
tip
.
show
(
res
.
message
||
'网络错误'
);
}
...
...
static/sass/cart/_gift-advance-good.scss
View file @
a95117b
...
...
@@ -55,7 +55,7 @@
margin-left
:
135rem
/
$pxConvertRem
;
}
.name
{
.
gift-advance-good
.
name
{
margin-bottom
:
20rem
/
$pxConvertRem
;
width
:
440rem
/
$pxConvertRem
;
font-size
:
28rem
/
$pxConvertRem
;
...
...
Please
register
or
login
to post a comment