Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
php
/
pingan-maruko
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
98bd1df2
authored
Jul 07, 2020
by
doszhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dos
parent
344ba4b1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
145 additions
and
8 deletions
+145
-8
Application/Home/Controller/IndexController.class.php
+104
-0
Application/Home/View/default/layout.tpl
+7
-6
Public/static/js/common.js
+34
-2
No files found.
Application/Home/Controller/IndexController.class.php
View file @
98bd1df2
...
...
@@ -19,9 +19,112 @@ class IndexController extends Controller
public
function
index
()
{
session_start
();
$_SESSION
[
'joinTime'
]
=
time
();
$user
=
$this
->
get_user_info_from_cookie
();
// 如果没有获取到用户信息,引导用户授权
if
(
!
$user
)
{
$this
->
request_auth
(
$this
->
get_url
());
return
;
}
M
(
'join_num'
)
->
where
(
'id=1'
)
->
setInc
(
'num'
);
$joinNum
=
M
(
'join_num'
)
->
where
(
'id=1'
)
->
find
();
$this
->
assign
(
'pt'
,
$user
[
'prize_type'
]);
$this
->
assign
(
'join_num'
,
$joinNum
[
'num'
]);
$this
->
display
();
}
public
function
get_random_prize
(
$user
)
{
$v
=
rand
(
0
,
1000000
)
/
1000000
;
$today_ratio
=
0
;
if
(
$v
>
$today_ratio
)
{
return
false
;
}
$now
=
time
();
$type
=
1
;
$c
=
M
(
'prize'
)
->
where
(
array
(
'type'
=>
$type
,
))
->
count
();
if
(
$c
>=
20
)
{
return
false
;
}
$prize
=
M
(
'Prize'
)
->
where
(
array
(
'is_get'
=>
0
,
'uid'
=>
0
))
->
order
(
'rand()'
)
->
limit
(
1
)
->
find
();
if
(
!
$prize
)
{
return
false
;
}
$result
=
M
(
'Prize'
)
->
where
(
array
(
'id'
=>
$prize
[
'id'
],
'is_get'
=>
0
,
'uid'
=>
0
,
))
->
save
(
array
(
'is_get'
=>
1
,
'uid'
=>
$user
[
'id'
],
'take_time'
=>
$now
));
if
(
$result
>
0
)
{
return
$prize
;
}
return
false
;
}
public
function
tryPrize
()
{
$user
=
$this
->
get_user_info_from_cookie
();
if
(
!
$user
)
{
$this
->
ajaxReturn
(
array
(
'status'
=>
404
,
'msg'
=>
'用户信息错误'
,
'step'
=>
0
));
return
;
}
if
(
$user
[
'prize_type'
]
!==
0
)
{
$this
->
ajaxReturn
(
array
(
'status'
=>
-
1
,
'msg'
=>
'很遗憾,没有中奖'
,
'step'
=>
3
,
'times'
=>
$playTimes
,
));
return
;
}
$prize
=
$this
->
get_random_prize
(
$user
);
if
(
$prize
)
{
M
(
'user'
)
->
where
(
array
(
'id'
=>
$user
[
'id'
]
))
->
save
(
array
(
'prize_type'
=>
1
))
$this
->
ajaxReturn
(
array
(
'status'
=>
1
,
'msg'
=>
'恭喜您中奖了!'
,
'step'
=>
4
));
}
else
{
M
(
'user'
)
->
where
(
array
(
'id'
=>
$user
[
'id'
]
))
->
save
(
array
(
'prize_type'
=>
2
))
$this
->
ajaxReturn
(
array
(
'status'
=>
2
,
'msg'
=>
'恭喜您中奖了!'
,
'step'
=>
5
,
));
}
}
public
function
ceshi
()
{
for
(
$i
=
0
;
$i
<
20
;
$i
++
)
{
M
(
'Prize'
)
->
add
(
array
(
'type'
=>
'1'
,
'prize_name'
=>
'樱桃小丸子系列CP礼盒'
,
));
}
}
}
\ No newline at end of file
Application/Home/View/default/layout.tpl
View file @
98bd1df2
...
...
@@ -72,11 +72,11 @@
}
</script>
<title>
{:block name='title'}Girlcult和樱桃小丸子的祈福之旅{:/block}
</title>
{:if $projectId
&&
strpos( $smarty.server.HTTP_HOST , 'dev.iacode.cn') !== false}
<link
rel=
"stylesheet"
type=
"text/css"
href=
"http://projectx.dev.iacode.cn/api/css/rem/{:$rem}/id/{:$projectId}?version={:$version}"
media=
"all"
/>
{:if $projectId
&&
strpos( $smarty.server.HTTP_HOST , 'dev.iacode.cn') !== false}
<link
rel=
"stylesheet"
type=
"text/css"
href=
"http://projectx.dev.iacode.cn/api/css/rem/{:$rem}/id/{:$projectId}?version={:$version}"
media=
"all"
/>
{:else}
<link
rel=
"stylesheet"
type=
"text/css"
href=
"__CDN__/css/main.min.css"
media=
"all"
/>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"__CDN__/css/main.min.css"
media=
"all"
/>
{:/if}
{:block name='css'}{:/block}
<link
rel=
"stylesheet"
type=
"text/css"
href=
"__CDN__/css/notify.css?version={:$version}"
media=
"all"
/>
...
...
@@ -86,10 +86,10 @@
<body>
<audio
src=
"__CDN__/media/1.mp3"
autoplay
preload=
"auto"
loop=
"loop"
id=
"music"
style=
"display:none"
></audio>
<audio
src=
"__CDN__/media/1.mp3"
autoplay
preload=
"auto"
loop=
"loop"
id=
"music"
style=
"display:none"
></audio>
<div
class=
"wrap"
>
<div
class=
"wrap-inner"
>
{:if $projectId
&&
strpos( $smarty.server.HTTP_HOST , 'dev.iacode.cn') !== false}
{:if $projectId
&&
strpos( $smarty.server.HTTP_HOST , 'dev.iacode.cn') !== false}
{:"http://projectx.dev.iacode.cn/api/html/id/`$projectId`"|file_get_contents}
{:else}
{:block name='body'}{:/block}
...
...
@@ -101,6 +101,7 @@
<script>
window
.
base_resource_url
=
'__CDN__'
;
window
.
joinNum
=
'{:$join_num|default:0}'
;
window
.
pt
=
'{:$pt|default:0}'
;
var
link
=
location
.
origin
;
var
friend_title
=
'Girlcult和樱桃小丸子的祈福之旅|神秘大礼等你!~'
;
...
...
Public/static/js/common.js
View file @
98bd1df2
...
...
@@ -134,12 +134,27 @@ $(document).ready(function () {
$
(
'.page1 .btn-intro'
).
on
(
'click'
,
showIntro
)
$
(
'.rule-page .btn-close-rule'
).
on
(
'click'
,
hideRule
)
$
(
'.intro-page .btn-close-intro'
).
on
(
'click'
,
hideIntro
)
$
(
'.page7 .btn-close-second'
).
on
(
'click'
,
hideSecond
)
$
(
'.page7 .btn-share'
).
on
(
'click'
,
showShare
)
$
(
'.share-block'
).
on
(
'click'
,
hideShare
)
// $('.page').on('click', function () {
// var audio = document.getElementById('music');
// audio.play();
// })
});
function
hideShare
()
{
$
(
'.share-block'
).
hide
();
}
function
showShare
()
{
$
(
'.share-block'
).
show
();
}
function
hideSecond
()
{
$
(
'.second-block'
).
hide
()
}
function
hideIntro
()
{
$
(
'.intro-page'
).
hide
();
$
(
'.wrap-inner'
).
scrollTop
(
introScrolltop
);
...
...
@@ -251,8 +266,25 @@ function toPage3() {
function
showResult
(
event
)
{
if
(
!
createPosterLock
)
{
const
resultFlag
=
/-
(\d)\s
/g
.
exec
(
$
(
event
.
target
).
attr
(
'class'
))[
1
]
createPoster
(
resultFlag
)
createPosterLock
=
true
;
if
(
window
.
pt
!==
0
)
{
$
.
ajax
({
url
:
'/index/tryprize'
,
type
:
'POST'
,
success
:
function
(
resp
)
{
if
(
resp
.
status
==
1
)
{
resultFlag
=
10
$
(
'.page7 .first-block'
).
show
();
}
else
{
$
(
'.page7 .second-block'
).
show
();
}
createPoster
(
resultFlag
)
createPosterLock
=
true
;
}
})
}
else
{
createPoster
(
resultFlag
)
createPosterLock
=
true
;
}
}
}
...
...
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