Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
php
/
sx-prize
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
fb4b7aa0
authored
Jul 07, 2019
by
张恒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
j
parent
3a1feab2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
55 additions
and
92 deletions
+55
-92
.idea/workspace.xml
+0
-0
.sass-cache/0adc96cee11bc739fc2ea1eeea463a9ab946286f/main.scssc
+0
-0
Application/Home/Controller/IndexController.class.php
+14
-31
Application/Home/View/default/Index_index.tpl
+3
-2
Public/static/css/main.css
+2
-2
Public/static/css/main.scss
+1
-1
Public/static/js/index.js
+35
-56
No files found.
.idea/workspace.xml
View file @
fb4b7aa0
This diff is collapsed.
Click to expand it.
.sass-cache/0adc96cee11bc739fc2ea1eeea463a9ab946286f/main.scssc
View file @
fb4b7aa0
No preview for this file type
Application/Home/Controller/IndexController.class.php
View file @
fb4b7aa0
...
...
@@ -46,13 +46,22 @@ class IndexController extends Controller
$this
->
request_auth
(
$this
->
get_url
());
return
;
}
$prize_type
=
M
(
'Prize'
)
->
where
(
array
(
'user_id'
=>
$user
[
'id'
]))
->
find
();
if
(
$prize_type
)
{
$type
=
1
;
}
else
{
$type
=
0
;
}
$this
->
assign
(
'type'
,
$type
);
$this
->
display
();
}
public
function
get_random_prize
(
$user
)
{
$v
=
rand
(
0
,
1000000
)
/
1000000
;
$today_ratio
=
1
;
if
(
$v
>
$today_ratio
)
{
return
false
;
...
...
@@ -69,7 +78,7 @@ class IndexController extends Controller
))
->
count
();
if
(
$type
==
1
)
{
if
(
$c
>=
10
00
)
{
if
(
$c
>=
10
)
{
continue
;
}
}
...
...
@@ -87,7 +96,6 @@ class IndexController extends Controller
if
(
!
$prize
)
{
return
false
;
}
$result
=
M
(
'Prize'
)
->
where
(
array
(
'id'
=>
$prize
[
'id'
],
'is_get'
=>
0
,
...
...
@@ -114,17 +122,7 @@ class IndexController extends Controller
));
return
;
}
$type_sate
=
$c
=
M
(
'Sate'
)
->
where
(
array
(
'id'
=>
1
,
))
->
getField
(
'sate'
);
if
(
$type_sate
==
0
)
{
$this
->
ajaxReturn
(
array
(
'errcode'
=>
1
,
'errmsg'
=>
'用户信息错误'
,
));
return
;
}
$prize
=
M
(
'Prize'
)
->
where
(
array
(
'user_id'
=>
$user
[
'id'
]
))
->
find
();
...
...
@@ -134,27 +132,13 @@ class IndexController extends Controller
'errmsg'
=>
null
,
'data'
=>
array
(
'prize'
=>
1
,
'url'
=>
$prize
[
'prize_url'
],
'type'
=>
1
,
'type'
=>
1
,
)
));
return
;
}
$ip
=
M
(
'Prize'
)
->
where
(
array
(
'last_ip'
=>
$user
[
'last_ip'
]
))
->
count
();
if
(
$ip
>=
9
)
{
$this
->
ajaxReturn
(
array
(
'errcode'
=>
0
,
'errmsg'
=>
null
,
'data'
=>
array
(
'prize'
=>
0
,
)
));
return
;
}
$now
=
time
();
$from
=
strtotime
(
date
(
'Y-m-d'
,
$now
));
$prize
=
$this
->
get_random_prize
(
$user
);
if
(
$prize
)
{
$this
->
ajaxReturn
(
array
(
...
...
@@ -162,8 +146,6 @@ class IndexController extends Controller
'errmsg'
=>
null
,
'data'
=>
array
(
'prize'
=>
1
,
'url'
=>
$prize
[
'prize_url'
],
'type'
=>
0
,
)
));
...
...
@@ -173,6 +155,7 @@ class IndexController extends Controller
'errmsg'
=>
null
,
'data'
=>
array
(
'prize'
=>
0
,
'time'
=>
$from
)
));
...
...
Application/Home/View/default/Index_index.tpl
View file @
fb4b7aa0
...
...
@@ -51,7 +51,8 @@
<body
ontouchmove=
"return false;"
>
<div
id=
"container"
>
<div
class=
"btn-prize"
>
点击抽奖
</div>
<div
class=
"btn-prize"
style=
"display: none"
>
点击抽奖
</div>
<div
class=
"prize-type"
style=
"display: none"
></div>
</div>
<script>
if
(
!
/android/i
.
test
(
navigator
.
userAgent
))
{
...
...
@@ -63,7 +64,7 @@
}
</script>
<script>
{*window.type='{:$type}'*}
window
.
type
=
'{:$type}'
</script>
<script
type=
"text/javascript"
src=
"http://api2.izhida.cn/wechat_js_config?app_id=wx4c3c856ab83a946b&v=1.2.1&api_list=all&app_stat_key=t6NkwipRePFcidTJ"
></script>
...
...
Public/static/css/main.css
View file @
fb4b7aa0
...
...
@@ -158,7 +158,7 @@ ul, li {
height
:
100%
;
}
.flex
,
#container
,
#container
.btn-prize
{
.flex
,
#container
,
#container
.btn-prize
,
#container
.prize-type
{
display
:
-webkit-box
;
/* OLD - iOS 6-, Safari 3.1-6 */
display
:
-moz-box
;
...
...
@@ -176,7 +176,7 @@ ul, li {
width
:
100%
;
height
:
100%
;
}
#container
.btn-prize
{
#container
.btn-prize
,
#container
.prize-type
{
width
:
200px
;
height
:
200px
;
font-size
:
27px
;
...
...
Public/static/css/main.scss
View file @
fb4b7aa0
...
...
@@ -197,7 +197,7 @@ ul, li {
@extend
.flex
;
width
:
100%
;
height
:
100%
;
.btn-prize
{
.btn-prize
,
.prize-type
{
@extend
.flex
;
width
:
torem
(
200px
);
height
:
torem
(
200px
);
...
...
Public/static/js/index.js
View file @
fb4b7aa0
var
prize_word
=
[
'家和万事兴'
,
'和谐美满'
,
'和和美美'
,
'和和睦睦 '
,
'和气生财'
,
'和蔼可亲'
];
var
prize_lock
=
1
;
$
(
document
).
ready
(
function
()
{
try
{
...
...
@@ -14,86 +23,57 @@ $(document).ready(function () {
this
.
css
(
'z-index'
,
window
[
'max_zindex'
]);
this
.
show
();
};
alert
(
1
);
if
(
window
.
type
==
1
){
$
(
'.prize-type'
).
text
(
'已中奖,请麻烦找官方登记信息'
).
show
();
}
else
{
$
(
'.btn-prize'
).
show
();
}
$
(
'.btn-prize'
).
on
(
'click'
,
function
()
{
if
(
prize_lock
==
2
){
my_notify
(
'点击太快'
);
return
;
}
btnPrize
();
});
});
function
btnPrize
()
{
prize_lock
=
2
;
$
.
ajax
({
url
:
'/index/tryPrize'
,
type
:
'post'
,
data
:
''
,
success
:
function
(
resp
)
{
setTimeout
(
function
()
{
prize_lock
=
1
;
},
500
);
var
rank
=
RandomNumBoth
(
0
,
10
);
if
(
resp
.
errcode
!=
0
)
{
my_notify
(
resp
.
errmsg
);
return
;
}
else
{
$
(
'.page'
).
hide
();
if
(
resp
.
data
.
prize
==
0
)
{
$
(
'.page_result'
).
show
();
$
(
'.no-prize'
).
show
();
my_notify
(
prize_word
[
rank
])
}
else
{
if
(
resp
.
data
.
type
==
1
){
$
(
'.t-s'
).
show
();
setTimeout
(
function
()
{
$
(
'.t-s'
).
hide
();
},
2500
)
}
$
(
'#code'
).
qrcode
(
resp
.
data
.
url
);
var
mycanvas1
=
document
.
getElementsByTagName
(
'canvas'
)[
0
];
var
img
=
convertCanvasToImage
(
mycanvas1
);
$
(
'.code'
).
append
(
img
);
//imagQrDiv表示你要插入的容器id
$
(
'.page'
).
hide
();
$
(
'.page_prize'
).
show
();
}
}
},
error
:
function
()
{
setTimeout
(
function
()
{
prize_lock
=
1
;
},
500
);
my_notify
(
'网络异常,请稍后重试'
);
}
});
}
function
convertCanvasToImage
(
canvas
)
{
//新Image对象,可以理解为DOM
var
image
=
new
Image
();
// canvas.toDataURL 返回的是一串Base64编码的URL,当然,浏览器自己肯定支持
// 指定格式 PNG
image
.
src
=
canvas
.
toDataURL
(
"image/png"
);
return
image
;
function
RandomNumBoth
(
Min
,
Max
)
{
var
Range
=
Max
-
Min
;
var
Rand
=
Math
.
random
();
var
num
=
Min
+
Math
.
round
(
Rand
*
Range
);
//四舍五入
return
num
;
}
window
.
wx
&&
wx
.
ready
(
function
()
{
document
.
getElementById
(
'y-x'
).
play
();
document
.
getElementById
(
'b-j'
).
play
();
// document.getElementById('b-j').pause();
document
.
getElementById
(
'y-x'
).
pause
();
var
base
=
location
.
origin
;
var
wxFriendData
=
{
'link'
:
base
,
'imgUrl'
:
base
+
'/Public/static/images/share.png'
,
// 内容
'desc'
:
'小伙伴快抢!'
,
// 标题
'title'
:
'【现在大乐透】进来抽吃喝玩乐福利,不定期限时派送!小伙伴快抢!'
,
trigger
:
function
()
{
},
success
:
function
()
{
}
};
var
wxTimelineData
=
{
'link'
:
base
,
'imgUrl'
:
base
+
'/Public/static/images/share.png'
,
'title'
:
'【现在大乐透】进来抽吃喝玩乐福利,不定期限时派送!小伙伴快抢!'
,
trigger
:
function
()
{
},
success
:
function
()
{
}
};
wx
.
onMenuShareAppMessage
(
wxFriendData
);
wx
.
onMenuShareTimeline
(
wxTimelineData
);
});
\ No newline at end of file
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