Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuywap-node
·
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
王水玲
6 years ago
Commit
22f51da4c680a9bae11fa17dc3b1929c00a2c649
1 parent
dacf4f7d
活动模版秒杀
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
36 deletions
public/js/activity/feature.page.js
public/js/activity/feature.page.js
View file @
22f51da
...
...
@@ -708,14 +708,21 @@ function formatTime(time) {
return
`
$
{
date
.
getMonth
()
+
1
}
月
$
{
date
.
getDate
()}
日`
;
}
function
viewSeckillProduct
(
products
)
{
function
setSeckillProductData
(
curProdcutList
,
products
)
{
curProdcutList
.
html
(
seckillProductTpl
({
isApp
:
yoho
.
isApp
,
list
:
products
,
productStyle
:
{
priceBgColor
:
curProdcutList
.
data
(
'priceBgColor'
),
brandBgColor
:
curProdcutList
.
data
(
'brandBgColor'
),
brandFontColor
:
curProdcutList
.
data
(
'brandFontColor'
),
priceFontColor
:
curProdcutList
.
data
(
'priceFontColor'
)
}
}));
}
function
viewSeckillProduct
(
products
,
dom
)
{
let
$productList
=
$
(
'.seckill .product-list'
);
let
productParams
=
{
priceBgColor
:
$productList
.
data
(
'priceBgColor'
),
brandBgColor
:
$productList
.
data
(
'brandBgColor'
),
brandFontColor
:
$productList
.
data
(
'brandFontColor'
),
priceFontColor
:
$productList
.
data
(
'priceFontColor'
)
};
let
num
=
$productList
.
data
(
'num'
);
if
(
products
&&
products
.
length
>
num
)
{
...
...
@@ -728,18 +735,18 @@ function viewSeckillProduct(products) {
$
(
'.out-product-list'
).
removeClass
(
'less-than-3'
);
}
$
(
'.seckill .product-list'
).
html
(
seckillProductTpl
({
isApp
:
yoho
.
isApp
,
list
:
products
,
productStyle
:
productParams
}));
if
(
dom
)
{
setSeckillProductData
(
dom
.
parents
(
'.seckill'
).
find
(
'.product-list'
),
products
);
}
else
{
$
(
'.seckill .product-list'
).
each
((
key
,
item
)
=>
{
setSeckillProductData
(
$
(
item
),
products
);
});
}
lazyLoad
(
$
(
'.seckill img.lazy'
));
}
function
loadSeckillList
()
{
let
$tab
=
$
(
'.seckill-tab'
);
$
.
ajax
({
url
:
'/product/seckill/list'
}).
then
(
function
(
result
)
{
...
...
@@ -757,14 +764,14 @@ function loadSeckillList() {
});
$
(
'.seckill .seckill-tab'
).
each
((
key
,
item
)
=>
{
let
$cur
Tab
=
$
(
$tab
[
key
]
);
let
$cur
Item
=
$
(
item
);
$
(
item
)
.
html
(
seckillTabTpl
({
$
curItem
.
html
(
seckillTabTpl
({
dateList
:
dateList
,
tabParams
:
{
tabColor
:
$curTab
.
data
(
'tabColor'
),
tabFontColor
:
$curTab
.
data
(
'tabFontColor'
),
tabSelectColor
:
$curTab
.
data
(
'tabSelectColor'
)
tabColor
:
$curItem
.
data
(
'tabColor'
),
tabFontColor
:
$curItem
.
data
(
'tabFontColor'
),
tabSelectColor
:
$curItem
.
data
(
'tabSelectColor'
)
}
}));
});
...
...
@@ -778,26 +785,12 @@ function loadSeckillList() {
});
}
function
refreshProductList
(
activityId
,
time
)
{
$
.
ajax
({
url
:
'/product/seckill/get-product-list'
,
data
:
{
activityId
:
activityId
,
startTime
:
time
}
}).
then
(
function
(
data
)
{
if
(
data
&&
data
.
products
)
{
viewSeckillProduct
(
data
.
products
||
[]);
}
else
{
$
(
'.seckill'
).
addClass
(
'hide'
);
}
});
}
function
seckillInit
()
{
loadSeckillList
();
$
(
document
).
on
(
'click'
,
'.seckill-tab .tab-item'
,
function
()
{
let
that
=
this
;
if
(
!
$
(
this
).
hasClass
(
'actived'
))
{
$
(
this
).
addClass
(
'actived'
).
css
({
background
:
$
(
this
).
parent
().
data
(
'tabSelectColor'
)
...
...
@@ -805,7 +798,19 @@ function seckillInit() {
background
:
$
(
this
).
parent
().
data
(
'tabColor'
)
});
refreshProductList
(
$
(
this
).
data
(
'id'
),
$
(
this
).
data
(
'time'
));
$
.
ajax
({
url
:
'/product/seckill/get-product-list'
,
data
:
{
activityId
:
$
(
this
).
data
(
'id'
),
startTime
:
$
(
this
).
data
(
'time'
)
}
}).
then
(
function
(
data
)
{
if
(
data
&&
data
.
products
)
{
viewSeckillProduct
(
data
.
products
||
[],
$
(
that
));
}
else
{
$
(
'.seckill'
).
addClass
(
'hide'
);
}
});
}
});
}
...
...
Please
register
or
login
to post a comment