Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SURPRISED
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
华国豪
SURPRISED
Commits
7597127a
Commit
7597127a
authored
Nov 15, 2019
by
Mac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改活动页面逻辑
parent
6cbe87e1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
361 additions
and
161 deletions
+361
-161
GT_activities.html
html/GT_activities.html
+329
-140
jquery.dataStatistics.js
js/jquery.dataStatistics.js
+32
-21
No files found.
html/GT_activities.html
View file @
7597127a
...
...
@@ -157,7 +157,7 @@
</div>
<div
class=
"notice_img"
>
<img
src=
"../images/notice_2.png"
alt=
""
>
<p
class=
"notice_name"
></p>
<p
class=
"notice_name"
>
尊敬的客户
</p>
<p
class=
"notice_content"
></p>
<p
class=
"notice_content2"
></p>
<div
class=
"c_close"
>
...
...
@@ -223,7 +223,10 @@
}
var
str
=
''
for
(
var
i
=
0
;
i
<
dataList
.
length
;
i
++
)
{
str
+=
`<a href="#">
if
(
!
dataList
[
i
].
customerPhoto
){
dataList
[
i
].
customerPhoto
=
'../images/tx_bg.png'
}
str
+=
`<a href="javascript:void(0);">
<img src="
${
dataList
[
i
].
customerPhoto
}
"/>
${
dataList
[
i
].
customerName
}
抢到了优惠券
</a>`
...
...
@@ -309,12 +312,16 @@
}
}
if
(
login
==
true
){
}
var
ua
=
navigator
.
userAgent
.
toLowerCase
();
if
(
platform
==
'H5'
&&
ua
.
match
(
/MicroMessenger/i
)
!=
"micromessenger"
)
{
$
(
'.wx_bg'
).
css
(
'display'
,
"block"
);
//
$('.wx_bg').css('display', "block");
}
else
if
(
platform
==
'H5'
)
{
this
.
initOpenid
()
}
...
...
@@ -332,128 +339,95 @@
$
(
'.click_use p'
).
html
(
'立即登录'
);
}
$
.
ajax
({
type
:
"POST"
,
url
:
`
${
getApiUrl
().
urlJava
}
api/appActivity/getUserPurchaseTime`
,
contentType
:
"application/json"
,
data
:
getJavaData
({}),
async
:
false
,
$
.
ajax
({
type
:
"POST"
,
url
:
`
${
getApiUrl
().
urlJava
}
api/appActivity/getUserPurchaseTime`
,
contentType
:
"application/json"
,
data
:
getJavaData
({}),
async
:
false
,
success
:
function
(
res
)
{
if
(
res
.
resultCode
===
1
)
{
getTicketList
(
res
.
data
.
couponId
);
let
num
=
res
.
data
.
repertory
;
//优惠券总共数量
// let num = 5000; //优惠券总共数量
$
(
'.box_title_2 p'
).
html
(
res
.
data
.
redemptionPrice
+
'元抢购'
);
$
(
'.box_title h5'
).
html
(
res
.
data
.
remark
);
$
(
'.explain p'
).
html
(
'使用说明'
+
'<br/>'
+
res
.
data
.
instructions
);
if
(
login
==
false
)
{
$
(
'.use_o'
).
html
(
'暂无登录'
);
}
else
{
$
(
'.use_o'
).
html
(
res
.
data
.
contact
);
}
$
(
'.use_t'
).
html
(
res
.
data
.
customerName
);
$
(
'.dataStatistics'
).
dataStatistics
({
max
:
num
,
min
:
num
,
len
:
4
,
add
:
true
,
price
:
res
.
data
.
redemptionPrice
,
couponId
:
res
.
data
.
couponId
,
platform
:
platform
,
login
:
login
,
count
:
res
.
data
.
count
,
//判断是否可以抢购 0为不可以
});
//刚进入页面不执行动画
success
:
function
(
res
)
{
if
(
res
.
resultCode
===
1
)
{
getTicketList
(
res
.
data
.
couponId
);
let
num
=
res
.
data
.
repertory
;
//优惠券总共数量
// let num = 5000; //优惠券总共数量
$
(
'.box_title_2 p'
).
html
(
res
.
data
.
redemptionPrice
+
'元抢购'
);
$
(
'.box_title h5'
).
html
(
res
.
data
.
remark
);
let
activityStartDate
=
new
Date
(
res
.
data
.
activityStartDate
.
replace
(
'T'
,
' '
).
replace
(
/-/g
,
'/'
)).
getTime
();
//活动开始时间
let
activityEndDate
=
new
Date
(
res
.
data
.
activityEndDate
.
replace
(
'T'
,
' '
).
replace
(
/-/g
,
'/'
)).
getTime
();
//活动结束时间
let
nowDate
=
new
Date
(
res
.
data
.
currentTime
.
replace
(
'T'
,
' '
).
replace
(
/-/g
,
'/'
)).
getTime
();
//服务器时间
// let activityStartDate = new Date('2019/11/08 17:43:50').getTime();
// let activityEndDate = new Date('2019/11/14 11:23:00').getTime(); //活动结束时间
let
nextActivity
=
res
.
data
.
nextActivity
;
if
(
nextActivity
!=
null
)
{
let
nexttime
=
nextActivity
.
activityStartDate
;
let
year
=
nexttime
.
split
(
'T'
)[
0
].
split
(
'-'
)[
0
];
let
month
=
nexttime
.
split
(
'T'
)[
0
].
split
(
'-'
)[
1
];
let
day
=
nexttime
.
split
(
'T'
)[
0
].
split
(
'-'
)[
2
];
let
hour
=
nexttime
.
split
(
'T'
)[
1
].
split
(
':'
)[
0
];
$
(
'.notice_name'
).
html
(
'亲爱的'
+
nextActivity
.
userName
);
$
(
'.notice_content'
).
html
(
'下期活动将于'
+
year
+
'年'
+
month
+
'月'
+
day
+
'日'
+
hour
+
'点开始。'
);
$
(
'.notice_content2'
).
html
(
'届时会有'
+
nextActivity
.
couponCount
+
'张价值'
+
nextActivity
.
denomination
+
'的折扣券等待您的抢 购(抢购价'
+
nextActivity
.
redemptionPrice
+
'元),请准时参加。'
);
// var time2 = setInterval(setTimer3, 1000); //计时器
let
beforeDawn
=
new
Date
(
year
+
'/'
+
month
+
'/'
+
day
+
' 00:00:00'
).
getTime
()
let
time
=
((
beforeDawn
-
nowDate
)
/
1000
).
toFixed
(
0
);
runtime
(
time
)
$
(
'.explain p'
).
html
(
'活动规则'
+
'<br/>'
+
res
.
data
.
instructions
);
if
(
login
==
false
)
{
$
(
'.use_o'
).
html
(
'暂无登录'
);
}
else
{
$
(
'.use_o'
).
html
(
res
.
data
.
contact
);
}
}
$
(
'.use_t'
).
html
(
res
.
data
.
customerName
);
let
activityStartDate
=
new
Date
(
res
.
data
.
activityStartDate
.
replace
(
'T'
,
' '
).
replace
(
/-/g
,
'/'
)).
getTime
();
//活动开始时间
let
activityEndDate
=
new
Date
(
res
.
data
.
activityEndDate
.
replace
(
'T'
,
' '
).
replace
(
/-/g
,
'/'
)).
getTime
();
//活动结束时间
let
nowDate
=
new
Date
(
res
.
data
.
currentTime
.
replace
(
'T'
,
' '
).
replace
(
/-/g
,
'/'
)).
getTime
();
//服务器时间
$
(
'.dataStatistics'
).
dataStatistics
({
max
:
num
,
min
:
num
,
len
:
4
,
add
:
true
,
price
:
res
.
data
.
redemptionPrice
,
couponId
:
res
.
data
.
couponId
,
platform
:
platform
,
login
:
login
,
count
:
res
.
data
.
count
,
//判断是否可以抢购 0为不可以
activityStartDate
:
activityStartDate
,
activityEndDate
:
activityEndDate
,
});
//刚进入页面不执行动画
// let activityStartDate = new Date('2019/11/08 17:43:50').getTime();
// let activityEndDate = new Date('2019/11/14 11:23:00').getTime(); //活动结束时间
let
nextActivity
=
res
.
data
.
nextActivity
;
if
(
nextActivity
!=
null
)
{
let
nexttime
=
nextActivity
.
activityStartDate
;
let
year
=
nexttime
.
split
(
'T'
)[
0
].
split
(
'-'
)[
0
];
let
month
=
nexttime
.
split
(
'T'
)[
0
].
split
(
'-'
)[
1
];
let
day
=
nexttime
.
split
(
'T'
)[
0
].
split
(
'-'
)[
2
];
let
hour
=
nexttime
.
split
(
'T'
)[
1
].
split
(
':'
)[
0
];
$
(
'.notice_content'
).
html
(
'下期活动将于'
+
year
+
'年'
+
month
+
'月'
+
day
+
'日'
+
hour
+
'点开始。'
);
$
(
'.notice_content2'
).
html
(
'届时会有'
+
nextActivity
.
couponCount
+
'张价值'
+
nextActivity
.
denomination
+
'的折扣券等待您的抢 购(抢购价'
+
nextActivity
.
redemptionPrice
+
'元),请准时参加。'
);
// var time2 = setInterval(setTimer3, 1000); //计时器
let
beforeDawn
=
new
Date
(
year
+
'/'
+
month
+
'/'
+
day
+
' 00:00:00'
).
getTime
()
let
time
=
((
beforeDawn
-
nowDate
)
/
1000
).
toFixed
(
0
);
runtime
(
time
)
//判断当前时间是否到了抢购时间
if
(
activityStartDate
>=
nowDate
)
{
//没到抢购时间 显示抢购的具体时间
$
(
'#t1'
).
html
(
'抢购时间:'
);
$
(
'#t2'
).
html
(
''
);
let
startDate
=
res
.
data
.
activityStartDate
;
let
month
=
startDate
.
split
(
'T'
)[
0
].
split
(
'-'
)[
1
];
let
day
=
startDate
.
split
(
'T'
)[
0
].
split
(
'-'
)[
2
];
let
hour
=
startDate
.
split
(
'T'
)[
1
].
split
(
':'
)[
0
];
$
(
'#p1'
).
html
(
month
);
$
(
'#p2'
).
html
(
day
);
$
(
'#p3'
).
html
(
hour
);
$
(
'#t3'
).
html
(
'月'
);
$
(
'#t4'
).
html
(
'日'
);
$
(
'#t5'
).
html
(
'点整'
);
$
(
'.img_btn p'
).
html
(
'立即抢购'
);
$
(
'.img_btn'
).
css
(
"background-image"
,
"url(../images/nobuy_btn.png)"
);
$
(
'.img_btn p'
).
css
(
"color"
,
"#FFFFFF"
);
// $(".received_img").attr("src", "");
let
time
=
((
activityStartDate
-
nowDate
)
/
1000
).
toFixed
(
0
);
runtime
(
time
)
}
else
if
(
nowDate
>
activityEndDate
||
res
.
data
.
activityIsEnding
==
1
)
{
// 活动时间已过
// $(".received_img").attr("src", "");
$
(
'.img_bg_M'
).
css
(
"background-image"
,
"url(../images/MJ_200@3x.png)"
);
$
(
'.img_bg_p1'
).
css
(
"color"
,
"#CCCCCC"
);
$
(
'.img_bg_p2'
).
css
(
"color"
,
"#CCCCCC"
);
$
(
'.img_btn p'
).
css
(
"color"
,
"#FFFFFF"
);
$
(
'.img_btn p'
).
html
(
'活动结束'
)
$
(
'.box_content_t'
).
hide
()
$
(
'.img_btn'
).
css
(
"background-image"
,
"url(../images/nobuy_btn.png)"
);
$
(
'.dataStatistics'
).
css
(
'display'
,
"none"
);
$
(
'.deta_replace'
).
css
(
'display'
,
"flex"
);
$
(
'#notice'
).
css
(
'display'
,
"block"
);
$
(
'.notice_img'
).
css
(
'display'
,
"block"
);
}
else
{
// 到了抢购的时间显示距离结束时间的倒计时
currentTime
=
res
.
data
.
currentTime
.
replace
(
'T'
,
' '
).
replace
(
/-/g
,
'/'
);
end
=
res
.
data
.
activityEndDate
.
replace
(
'T'
,
' '
).
replace
(
/-/g
,
'/'
);
if
(
num
>
0
)
{
$
(
'#t1'
).
html
(
'结束倒计时:'
)
if
(
res
.
data
.
count
!=
0
)
{
// $(".received_img").attr("src", "");
}
$
(
'.img_btn p'
).
html
(
'立即抢购'
);
//判断当前时间是否到了抢购时间
if
(
activityStartDate
>=
nowDate
)
{
//没到抢购时间 显示抢购的具体时间
$
(
'#t1'
).
html
(
'抢购时间:'
);
$
(
'#t2'
).
html
(
''
);
let
startDate
=
res
.
data
.
activityStartDate
;
let
month
=
startDate
.
split
(
'T'
)[
0
].
split
(
'-'
)[
1
];
let
day
=
startDate
.
split
(
'T'
)[
0
].
split
(
'-'
)[
2
];
let
hour
=
startDate
.
split
(
'T'
)[
1
].
split
(
':'
)[
0
];
$
(
'#p1'
).
html
(
month
);
$
(
'#p2'
).
html
(
day
);
$
(
'#p3'
).
html
(
hour
);
$
(
'#t3'
).
html
(
'月'
);
$
(
'#t4'
).
html
(
'日'
);
$
(
'#t5'
).
html
(
'点整'
);
$
(
'.img_btn p'
).
html
(
'立即抢购'
);
$
(
'.img_btn'
).
css
(
"background-image"
,
"url(../images/nobuy_btn.png)"
);
}
else
{
$
(
'.img_btn p'
).
html
(
'去使用'
);
$
(
".received_img"
).
css
(
'display'
,
"block"
);
$
(
'.img_btn'
).
css
(
"background-image"
,
"url(../images/buy_btn.png)"
);
$
(
'.img_btn p'
).
css
(
"color"
,
"#FFFFFF"
);
// $(".received_img").attr("src", ""
);
let
time
=
((
activityStartDate
-
nowDate
)
/
1000
).
toFixed
(
0
);
runtime
(
time
)
}
}
else
{
}
else
if
(
nowDate
>
activityEndDate
||
res
.
data
.
activityIsEnding
==
1
)
{
// 活动时间已过
// $(".received_img").attr("src", "");
$
(
'.img_bg_M'
).
css
(
"background-image"
,
"url(../images/MJ_200@3x.png)"
);
...
...
@@ -463,26 +437,73 @@
$
(
'.img_btn p'
).
html
(
'活动结束'
)
$
(
'.box_content_t'
).
hide
()
$
(
'.img_btn'
).
css
(
"background-image"
,
"url(../images/nobuy_btn.png)"
);
$
(
'.dataStatistics'
).
css
(
'display'
,
"none"
);
$
(
'.deta_replace'
).
css
(
'display'
,
"flex"
);
$
(
'#notice'
).
css
(
'display'
,
"block"
);
$
(
'.notice_img'
).
css
(
'display'
,
"block"
);
}
else
{
// 到了抢购的时间显示距离结束时间的倒计时
currentTime
=
res
.
data
.
currentTime
.
replace
(
'T'
,
' '
).
replace
(
/-/g
,
'/'
);
end
=
res
.
data
.
activityEndDate
.
replace
(
'T'
,
' '
).
replace
(
/-/g
,
'/'
);
if
(
num
>
0
)
{
$
(
'#t1'
).
html
(
'结束倒计时:'
)
if
(
res
.
data
.
count
!=
0
)
{
// $(".received_img").attr("src", "");
$
(
'.img_btn p'
).
html
(
'立即抢购'
);
}
else
{
$
(
'.img_btn p'
).
html
(
'去使用'
);
$
(
".received_img"
).
css
(
'display'
,
"block"
);
$
(
'.img_btn'
).
css
(
"background-image"
,
"url(../images/buy_btn.png)"
);
}
}
else
{
// $(".received_img").attr("src", "");
$
(
'.img_bg_M'
).
css
(
"background-image"
,
"url(../images/MJ_200@3x.png)"
);
$
(
'.img_bg_p1'
).
css
(
"color"
,
"#CCCCCC"
);
$
(
'.img_bg_p2'
).
css
(
"color"
,
"#CCCCCC"
);
$
(
'.img_btn p'
).
css
(
"color"
,
"#FFFFFF"
);
$
(
'.img_btn p'
).
html
(
'活动结束'
)
$
(
'.box_content_t'
).
hide
()
$
(
'.img_btn'
).
css
(
"background-image"
,
"url(../images/nobuy_btn.png)"
);
$
(
'.dataStatistics'
).
css
(
'display'
,
"none"
);
$
(
'.deta_replace'
).
css
(
'display'
,
"flex"
);
$
(
'#notice'
).
css
(
'display'
,
"block"
);
$
(
'.notice_img'
).
css
(
'display'
,
"block"
);
}
}
}
//优惠券的有限时间
let
expirationDate
=
(
res
.
data
.
expirationDate
).
split
(
'T'
)[
0
].
replace
(
/-/g
,
'.'
);
let
title
=
$
(
'.img_bg_p1'
).
text
()
let
RushbuyTime
=
{
RushbuyTime
:
expirationDate
,
title
:
title
,
}
localStorage
.
RushbuyTime
=
JSON
.
stringify
(
RushbuyTime
)
$
(
'.img_bg_p2'
).
html
(
'有效期截止:'
+
expirationDate
)
//优惠券的有限时间
let
expirationDate
=
(
res
.
data
.
expirationDate
).
split
(
'T'
)[
0
].
replace
(
/-/g
,
'.'
);
let
title
=
$
(
'.img_bg_p1'
).
text
()
let
RushbuyTime
=
{
RushbuyTime
:
expirationDate
,
title
:
title
,
}
localStorage
.
RushbuyTime
=
JSON
.
stringify
(
RushbuyTime
)
$
(
'.img_bg_p2'
).
html
(
'有效期截止:'
+
expirationDate
)
}
else
{
$
(
'.dataStatistics'
).
dataStatistics
({
max
:
0
,
min
:
0
,
len
:
4
,
add
:
true
});
//刚进入页面不执行动画
}
else
{
}
// clearInterval(xhtime)
},
error
:
function
(
res
)
{
layer
.
msg
(
res
.
message
)
$
(
'.dataStatistics'
).
dataStatistics
({
max
:
0
,
min
:
0
,
...
...
@@ -491,18 +512,8 @@
});
//刚进入页面不执行动画
}
},
error
:
function
(
res
)
{
layer
.
msg
(
res
.
message
)
$
(
'.dataStatistics'
).
dataStatistics
({
max
:
0
,
min
:
0
,
len
:
4
,
add
:
true
});
//刚进入页面不执行动画
});
}
});
...
...
@@ -686,7 +697,185 @@
window
.
postMessage
(
JSON
.
stringify
(
data
));
})
setInterval
(()
=>
{
$
(
'.digit_set'
).
empty
()
$
.
ajax
({
type
:
"POST"
,
url
:
`
${
getApiUrl
().
urlJava
}
api/appActivity/getUserPurchaseTime`
,
contentType
:
"application/json"
,
data
:
getJavaData
({}),
async
:
false
,
success
:
function
(
res
)
{
if
(
res
.
resultCode
===
1
)
{
getTicketList
(
res
.
data
.
couponId
);
let
num
=
res
.
data
.
repertory
;
//优惠券总共数量
// let num = 5000; //优惠券总共数量
$
(
'.box_title_2 p'
).
html
(
res
.
data
.
redemptionPrice
+
'元抢购'
);
$
(
'.box_title h5'
).
html
(
res
.
data
.
remark
);
$
(
'.explain p'
).
html
(
'活动规则'
+
'<br/>'
+
res
.
data
.
instructions
);
if
(
login
==
false
)
{
$
(
'.use_o'
).
html
(
'暂无登录'
);
}
else
{
$
(
'.use_o'
).
html
(
res
.
data
.
contact
);
}
$
(
'.use_t'
).
html
(
res
.
data
.
customerName
);
let
activityStartDate
=
new
Date
(
res
.
data
.
activityStartDate
.
replace
(
'T'
,
' '
).
replace
(
/-/g
,
'/'
)).
getTime
();
//活动开始时间
let
activityEndDate
=
new
Date
(
res
.
data
.
activityEndDate
.
replace
(
'T'
,
' '
).
replace
(
/-/g
,
'/'
)).
getTime
();
//活动结束时间
let
nowDate
=
new
Date
(
res
.
data
.
currentTime
.
replace
(
'T'
,
' '
).
replace
(
/-/g
,
'/'
)).
getTime
();
//服务器时间
$
(
'.dataStatistics'
).
dataStatistics
({
max
:
num
,
min
:
num
,
len
:
4
,
add
:
true
,
price
:
res
.
data
.
redemptionPrice
,
couponId
:
res
.
data
.
couponId
,
platform
:
platform
,
login
:
login
,
count
:
res
.
data
.
count
,
//判断是否可以抢购 0为不可以
activityStartDate
:
activityStartDate
,
activityEndDate
:
activityEndDate
,
});
//刚进入页面不执行动画
// let activityStartDate = new Date('2019/11/08 17:43:50').getTime();
// let activityEndDate = new Date('2019/11/14 11:23:00').getTime(); //活动结束时间
let
nextActivity
=
res
.
data
.
nextActivity
;
if
(
nextActivity
!=
null
)
{
let
nexttime
=
nextActivity
.
activityStartDate
;
let
year
=
nexttime
.
split
(
'T'
)[
0
].
split
(
'-'
)[
0
];
let
month
=
nexttime
.
split
(
'T'
)[
0
].
split
(
'-'
)[
1
];
let
day
=
nexttime
.
split
(
'T'
)[
0
].
split
(
'-'
)[
2
];
let
hour
=
nexttime
.
split
(
'T'
)[
1
].
split
(
':'
)[
0
];
$
(
'.notice_content'
).
html
(
'下期活动将于'
+
year
+
'年'
+
month
+
'月'
+
day
+
'日'
+
hour
+
'点开始。'
);
$
(
'.notice_content2'
).
html
(
'届时会有'
+
nextActivity
.
couponCount
+
'张价值'
+
nextActivity
.
denomination
+
'的折扣券等待您的抢 购(抢购价'
+
nextActivity
.
redemptionPrice
+
'元),请准时参加。'
);
// var time2 = setInterval(setTimer3, 1000); //计时器
let
beforeDawn
=
new
Date
(
year
+
'/'
+
month
+
'/'
+
day
+
' 00:00:00'
).
getTime
()
let
time
=
((
beforeDawn
-
nowDate
)
/
1000
).
toFixed
(
0
);
runtime
(
time
)
}
//判断当前时间是否到了抢购时间
if
(
activityStartDate
>=
nowDate
)
{
//没到抢购时间 显示抢购的具体时间
$
(
'#t1'
).
html
(
'抢购时间:'
);
$
(
'#t2'
).
html
(
''
);
let
startDate
=
res
.
data
.
activityStartDate
;
let
month
=
startDate
.
split
(
'T'
)[
0
].
split
(
'-'
)[
1
];
let
day
=
startDate
.
split
(
'T'
)[
0
].
split
(
'-'
)[
2
];
let
hour
=
startDate
.
split
(
'T'
)[
1
].
split
(
':'
)[
0
];
$
(
'#p1'
).
html
(
month
);
$
(
'#p2'
).
html
(
day
);
$
(
'#p3'
).
html
(
hour
);
$
(
'#t3'
).
html
(
'月'
);
$
(
'#t4'
).
html
(
'日'
);
$
(
'#t5'
).
html
(
'点整'
);
$
(
'.img_btn p'
).
html
(
'立即抢购'
);
$
(
'.img_btn'
).
css
(
"background-image"
,
"url(../images/nobuy_btn.png)"
);
$
(
'.img_btn p'
).
css
(
"color"
,
"#FFFFFF"
);
// $(".received_img").attr("src", "");
let
time
=
((
activityStartDate
-
nowDate
)
/
1000
).
toFixed
(
0
);
runtime
(
time
)
}
else
if
(
nowDate
>
activityEndDate
||
res
.
data
.
activityIsEnding
==
1
)
{
// 活动时间已过
// $(".received_img").attr("src", "");
$
(
'.img_bg_M'
).
css
(
"background-image"
,
"url(../images/MJ_200@3x.png)"
);
$
(
'.img_bg_p1'
).
css
(
"color"
,
"#CCCCCC"
);
$
(
'.img_bg_p2'
).
css
(
"color"
,
"#CCCCCC"
);
$
(
'.img_btn p'
).
css
(
"color"
,
"#FFFFFF"
);
$
(
'.img_btn p'
).
html
(
'活动结束'
)
$
(
'.box_content_t'
).
hide
()
$
(
'.img_btn'
).
css
(
"background-image"
,
"url(../images/nobuy_btn.png)"
);
$
(
'.dataStatistics'
).
css
(
'display'
,
"none"
);
$
(
'.deta_replace'
).
css
(
'display'
,
"flex"
);
$
(
'#notice'
).
css
(
'display'
,
"block"
);
$
(
'.notice_img'
).
css
(
'display'
,
"block"
);
}
else
{
// 到了抢购的时间显示距离结束时间的倒计时
currentTime
=
res
.
data
.
currentTime
.
replace
(
'T'
,
' '
).
replace
(
/-/g
,
'/'
);
end
=
res
.
data
.
activityEndDate
.
replace
(
'T'
,
' '
).
replace
(
/-/g
,
'/'
);
if
(
num
>
0
)
{
$
(
'#t1'
).
html
(
'结束倒计时:'
)
if
(
res
.
data
.
count
!=
0
)
{
// $(".received_img").attr("src", "");
$
(
'.img_btn p'
).
html
(
'立即抢购'
);
}
else
{
$
(
'.img_btn p'
).
html
(
'去使用'
);
$
(
".received_img"
).
css
(
'display'
,
"block"
);
$
(
'.img_btn'
).
css
(
"background-image"
,
"url(../images/buy_btn.png)"
);
}
}
else
{
// $(".received_img").attr("src", "");
$
(
'.img_bg_M'
).
css
(
"background-image"
,
"url(../images/MJ_200@3x.png)"
);
$
(
'.img_bg_p1'
).
css
(
"color"
,
"#CCCCCC"
);
$
(
'.img_bg_p2'
).
css
(
"color"
,
"#CCCCCC"
);
$
(
'.img_btn p'
).
css
(
"color"
,
"#FFFFFF"
);
$
(
'.img_btn p'
).
html
(
'活动结束'
)
$
(
'.box_content_t'
).
hide
()
$
(
'.img_btn'
).
css
(
"background-image"
,
"url(../images/nobuy_btn.png)"
);
$
(
'.dataStatistics'
).
css
(
'display'
,
"none"
);
$
(
'.deta_replace'
).
css
(
'display'
,
"flex"
);
$
(
'#notice'
).
css
(
'display'
,
"block"
);
$
(
'.notice_img'
).
css
(
'display'
,
"block"
);
}
}
//优惠券的有限时间
let
expirationDate
=
(
res
.
data
.
expirationDate
).
split
(
'T'
)[
0
].
replace
(
/-/g
,
'.'
);
let
title
=
$
(
'.img_bg_p1'
).
text
()
let
RushbuyTime
=
{
RushbuyTime
:
expirationDate
,
title
:
title
,
}
localStorage
.
RushbuyTime
=
JSON
.
stringify
(
RushbuyTime
)
$
(
'.img_bg_p2'
).
html
(
'有效期截止:'
+
expirationDate
)
}
else
{
$
(
'.dataStatistics'
).
dataStatistics
({
max
:
0
,
min
:
0
,
len
:
4
,
add
:
true
});
//刚进入页面不执行动画
}
// clearInterval(xhtime)
},
error
:
function
(
res
)
{
layer
.
msg
(
res
.
message
)
$
(
'.dataStatistics'
).
dataStatistics
({
max
:
0
,
min
:
0
,
len
:
4
,
add
:
true
});
//刚进入页面不执行动画
}
});
},
300000
)
//5分钟请求一次接口
</script>
</body>
</html>
\ No newline at end of file
</html>
js/jquery.dataStatistics.js
View file @
7597127a
...
...
@@ -9,6 +9,9 @@ $.fn.dataStatistics = function(options) {
platform
:
'app'
,
count
:
0
,
login
:
true
,
activityStartDate
:
0
,
activityEndDate
:
0
,
nowDate
:
0
},
options
||
{});
var
ths
=
this
;
//解决this指向问题
...
...
@@ -60,6 +63,7 @@ $.fn.dataStatistics = function(options) {
var
difference
=
0
;
//执行次数
var
nownumber
=
options
.
min
;
//优惠券数量
var
Activityendtime
=
''
;
//活动结束时间
let
nodisplay
=
false
;
function
run
(
diff
)
{
if
(
diff
)
{
difference
=
diff
...
...
@@ -71,7 +75,6 @@ $.fn.dataStatistics = function(options) {
clearInterval
(
timer2
);
//优惠券用完 清楚定时器
// $(".received_img").attr("src", "");
$
(
'.img_bg_M'
).
css
(
"background-image"
,
"url(../images/MJ_200@3x.png)"
);
$
(
'.img_bg_p1'
).
css
(
"color"
,
"#CCCCCC"
);
...
...
@@ -80,10 +83,13 @@ $.fn.dataStatistics = function(options) {
$
(
'.img_btn p'
).
html
(
'活动结束'
)
$
(
'.box_content_t'
).
hide
()
$
(
'.img_btn'
).
css
(
"background-image"
,
"url(../images/nobuy_btn.png)"
);
$
(
'.dataStatistics'
).
css
(
'display'
,
"none"
);
$
(
'.deta_replace'
).
css
(
'display'
,
"flex"
);
$
(
'#notice'
).
css
(
'display'
,
"block"
);
$
(
'.notice_img'
).
css
(
'display'
,
"block"
);
if
(
nodisplay
==
true
){
//显示活动预告
$
(
'.dataStatistics'
).
css
(
'display'
,
"none"
);
$
(
'.deta_replace'
).
css
(
'display'
,
"flex"
);
$
(
'#notice'
).
css
(
'display'
,
"block"
);
$
(
'.notice_img'
).
css
(
'display'
,
"block"
);
}
// layer.msg('优惠券被抢光了!')
}
...
...
@@ -139,17 +145,16 @@ $.fn.dataStatistics = function(options) {
var
timer2
=
setInterval
(()
=>
{
$
.
ajax
({
type
:
"POST"
,
url
:
`
${
getApiUrl
().
urlJava
}
api/appActivity/get
UserPurchaseTime
`
,
url
:
`
${
getApiUrl
().
urlJava
}
api/appActivity/get
CurrentActivity
`
,
contentType
:
"application/json"
,
data
:
getJavaData
({}),
data
:
getJavaData
({
couponId
:
options
.
couponId
}),
async
:
false
,
success
:
function
(
res
)
{
if
(
res
.
resultCode
===
1
)
{
nodisplay
=
true
if
(
nownumber
>
0
)
{
let
num
=
nownumber
-
res
.
data
.
repertory
;
// 算出动画执行的次数
nownumber
=
res
.
data
.
repertory
;
// 算出现在的数字
// let num = 10 ; // 算出动画执行的次数
// // nownumber = 900; // 算出现在的数字
if
(
num
>
0
)
{
if
(
num
>
5
){
...
...
@@ -160,11 +165,13 @@ $.fn.dataStatistics = function(options) {
min
:
nownumber
,
len
:
4
,
add
:
true
,
price
:
res
.
data
.
redemptionP
rice
,
couponId
:
res
.
data
.
couponId
,
price
:
options
.
p
rice
,
couponId
:
options
.
couponId
,
platform
:
options
.
platform
,
login
:
options
.
login
,
count
:
res
.
data
.
count
,
//判断是否可以抢购 0为不可以
count
:
options
.
count
,
//判断是否可以抢购 0为不可以
activityStartDate
:
options
.
activityStartDate
,
activityEndDate
:
options
.
activityEndDate
,
});
//刚进入页面不执行动画
}
else
{
...
...
@@ -178,23 +185,26 @@ $.fn.dataStatistics = function(options) {
min
:
nownumber
,
len
:
4
,
add
:
true
,
price
:
res
.
data
.
redemptionP
rice
,
couponId
:
res
.
data
.
couponId
,
price
:
options
.
p
rice
,
couponId
:
options
.
couponId
,
platform
:
options
.
platform
,
login
:
options
.
login
,
count
:
res
.
data
.
count
,
//判断是否可以抢购 0为不可以
count
:
options
.
count
,
//判断是否可以抢购 0为不可以
activityStartDate
:
options
.
activityStartDate
,
activityEndDate
:
options
.
activityEndDate
,
});
//刚进入页面不执行动画
}
if
(
nownumber
==
0
)
{
Activityendtime
=
res
.
data
.
expirationDate
.
replace
(
'T'
,
' '
).
replace
(
/-/g
,
'/'
);
}
options
.
count
=
res
.
data
.
count
;
let
activityStartDate
=
new
Date
(
res
.
data
.
activityStartDate
.
replace
(
'T'
,
' '
).
replace
(
/-/g
,
'/'
)).
getTime
()
;
let
activityEndDate
=
new
Date
(
res
.
data
.
activityEndDate
.
replace
(
'T'
,
' '
).
replace
(
/-/g
,
'/'
)).
getTime
()
;
//
options.count = res.data.count;
let
activityStartDate
=
options
.
activityStartDate
;
let
activityEndDate
=
options
.
activityEndDate
;
let
nowDate
=
new
Date
(
res
.
data
.
currentTime
.
replace
(
'T'
,
' '
).
replace
(
/-/g
,
'/'
)).
getTime
();
//服务器时间
let
nowDate
=
new
Date
(
res
.
data
.
currentTime
.
replace
(
/-/g
,
'/'
)).
getTime
();
//服务器时间
// let nowDate = options.nowDate; //服务器时间
if
(
activityStartDate
>=
nowDate
)
{
//活动还没开始
clearInterval
(
timer2
);
...
...
@@ -215,7 +225,7 @@ $.fn.dataStatistics = function(options) {
clearInterval
(
timer2
);
//活动结束 清楚定时器
}
else
{
if
(
nownumber
>
0
)
{
if
(
res
.
data
.
count
!=
0
)
{
if
(
options
.
count
!=
0
)
{
// $(".received_img").attr("src", "");
$
(
'.img_btn p'
).
html
(
'立即抢购'
)
}
else
{
...
...
@@ -239,7 +249,6 @@ $.fn.dataStatistics = function(options) {
$
(
'.notice_img'
).
css
(
'display'
,
"block"
);
}
}
}
else
{
...
...
@@ -283,6 +292,8 @@ $.fn.dataStatistics = function(options) {
}
if
(
options
.
platform
==
'app'
)
{
window
.
postMessage
(
JSON
.
stringify
(
data
));
}
else
if
(
options
.
platform
==
'H5'
){
window
.
location
.
href
=
'https://activity.oytour.com/html/downloadApp.html'
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment