Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
php
/
samsung-christmas
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c9aaf6c3
authored
Dec 17, 2019
by
doszhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dos
parent
7e48f9f7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
136 additions
and
26 deletions
+136
-26
Application/Home/Controller/IndexController.class.php
+66
-8
Application/Home/View/default/layout.tpl
+2
-0
Public/static/js/common.js
+68
-18
No files found.
Application/Home/Controller/IndexController.class.php
View file @
c9aaf6c3
...
...
@@ -29,9 +29,49 @@ class IndexController extends Controller
session_start
();
$_SESSION
[
'joinTime'
]
=
time
();
$this
->
assign
(
'type'
,
$user
[
'is_prize'
]);
$this
->
assign
(
'tel'
,
$user
[
'tel'
]);
$this
->
display
();
}
public
function
submit
()
{
$referer
=
$_SERVER
[
'HTTP_REFERER'
];
$refererInfo
=
parse_url
(
$referer
);
if
(
$refererInfo
[
'host'
]
!=
$_SERVER
[
'HTTP_HOST'
]
)
{
header
(
"HTTP/1.0 404 Not Found"
);
exit
;
}
session_start
();
if
(
!
$_SESSION
[
'joinTime'
]
||
time
()
-
$_SESSION
[
'joinTime'
]
<
2
)
{
header
(
"HTTP/1.0 404 Not Found"
);
exit
;
}
$user
=
$this
->
get_user_info_from_cookie
();
if
(
!
$user
)
{
$this
->
ajaxReturn
(
array
(
'status'
=>
404
,
'msg'
=>
'用户信息错误'
,
'step'
=>
0
));
return
;
}
M
(
'user'
)
->
where
(
array
(
'id'
=>
$user
[
'id'
]
))
->
save
(
array
(
'tel'
=>
$_POST
[
'tel'
]
));
$this
->
ajaxReturn
(
array
(
'status'
=>
1
,
'msg'
=>
'提交成功'
,
'step'
=>
0
));
return
;
}
public
function
tryPrize
()
{
$referer
=
$_SERVER
[
'HTTP_REFERER'
];
...
...
@@ -57,22 +97,40 @@ class IndexController extends Controller
return
;
}
$count
=
M
(
'prize'
)
->
where
(
array
(
'user_id'
=>
$user
[
'id'
]
))
->
count
();
if
(
$count
>
0
)
if
(
$user
[
'is_prize'
]
!=
0
)
{
$this
->
ajaxReturn
(
array
(
'status'
=>
0
,
'msg'
=>
'很遗憾,没有中奖'
,
'prize_type'
=>
0
,
'step'
=>
3
,
));
return
false
;
}
else
{
$count
=
M
(
'prize'
)
->
where
(
array
(
'user_id'
=>
$user
[
'id'
]
))
->
count
();
if
(
$count
>
0
)
{
$this
->
ajaxReturn
(
array
(
'status'
=>
0
,
'msg'
=>
'很遗憾,没有中奖'
,
'prize_type'
=>
0
,
'step'
=>
5
,
'status'
=>
0
,
'msg'
=>
'很遗憾,没有中奖'
,
'prize_type'
=>
0
,
'step'
=>
5
,
));
return
false
;
}
}
$prize
=
$this
->
get_random_prize
(
$user
);
if
(
$prize
)
{
M
(
'user'
)
->
where
(
array
(
'id'
=>
$user
[
'id'
]
))
->
save
(
array
(
'is_prize'
=>
$prize
[
'type'
]
));
$this
->
ajaxReturn
(
array
(
'status'
=>
1
,
'msg'
=>
'恭喜您中奖了!'
,
...
...
Application/Home/View/default/layout.tpl
View file @
c9aaf6c3
...
...
@@ -93,6 +93,8 @@
<script>
window
.
base_resource_url
=
'__CDN__'
;
window
.
type
=
'{:$type|default:0}'
;
window
.
tel
=
'{:$tel|default:null}'
;
var
link
=
location
.
origin
;
var
friend_title
=
''
;
...
...
Public/static/js/common.js
View file @
c9aaf6c3
...
...
@@ -60,6 +60,8 @@ var videoStatus = false;
var
video
=
document
.
getElementsByClassName
(
'video'
);
video
=
video
[
0
];
var
allowChangeTel
=
false
;
$
(
document
).
ready
(
function
()
{
$
(
"input"
).
on
(
"blur"
,
function
(){
window
.
scroll
(
0
,
0
);
//失焦后强制让页面归位
...
...
@@ -80,10 +82,46 @@ $(document).ready(function () {
$
(
'.map-page .sy'
).
on
(
'click'
,
{
types
:
0
},
handleCityClick
);
//奖品页返回城市选择页
$
(
'.prize-page .btn-backtomap'
).
on
(
'click'
,
backToMap
);
//手机号被修改
$
(
'input[name=tel]'
).
on
(
'change'
,
changeTel
);
//提交手机号
$
(
'.prize-page .btn-submit'
).
on
(
'click'
,
submitTel
);
});
function
submitTel
()
{
var
tel
=
$
(
'input[name=tel]'
).
val
();
if
(
!
tel
.
match
(
/^1
\d{10}
$/
))
{
$
(
'#notification_area'
).
remove
();
my_notify
(
'手机号码格式不正确'
);
return
false
;
}
$
.
ajax
({
url
:
'/index/submit'
,
type
:
'POST'
,
data
:
{
tel
:
tel
},
success
:
function
(
resp
)
{
if
(
resp
.
status
==
1
)
{
$
(
'#notification_area'
).
remove
();
my_notify
(
'提交成功'
);
}
}
})
}
function
changeTel
()
{
if
(
$
(
'input[name=tel]'
).
val
()
!=
window
.
tel
)
{
$
(
'.prize-page .btn-submit'
).
show
();
}
else
{
$
(
'.prize-page .btn-submit'
).
hide
();
}
}
function
backToMap
()
{
$
(
'.prize-page'
).
hide
();
$
(
'.map-page'
).
show
();
...
...
@@ -91,23 +129,35 @@ function backToMap () {
function
videoEnd
(
event
)
{
$
(
'.video-block'
).
hide
();
$
.
ajax
({
url
:
'/index/tryprize'
,
type
:
'POST'
,
success
:
function
(
resp
)
{
if
(
resp
.
status
==
1
||
resp
.
status
==
0
)
{
$
(
'.map-page'
).
hide
();
$
(
'.prize-page'
).
show
();
showPrize
(
resp
.
prize_type
);
video
.
removeEventListener
(
'ended'
,
videoEnd
);
if
(
window
.
type
==
0
)
{
$
.
ajax
({
url
:
'/index/tryprize'
,
type
:
'POST'
,
success
:
function
(
resp
)
{
if
(
resp
.
status
==
1
||
resp
.
status
==
0
)
{
$
(
'.map-page'
).
hide
();
$
(
'.prize-page'
).
show
();
showPrize
(
resp
.
prize_type
);
video
.
removeEventListener
(
'ended'
,
videoEnd
);
}
}
}
});
//奖品请求后跳转页面
});
}
else
{
$
(
'.map-page'
).
hide
();
$
(
'.prize-page'
).
show
();
showPrize
(
window
.
type
);
//提示领过奖并显示手机号
$
(
'#notification_area'
).
remove
();
my_notify
(
'您已经中过奖啦!'
);
$
(
'input[name=tel]'
).
val
(
window
.
tel
);
$
(
'.btn-submit'
).
hide
();
allowChangeTel
=
true
;
video
.
removeEventListener
(
'ended'
,
videoEnd
);
}
}
function
handleCityClick
(
event
)
{
...
...
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