<?php
require_once "jssdk.php";
$jssdk = new JSSDK("wxc223c895f2d7684b", "70344fde33fdc1fe957d19ebe617ba97");
$signPackage = $jssdk->GetSignPackage();
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html" charset="utf-8" />
<meta name="viewport" content="initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<title>Rotate</title>
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<img class="ajax_hide" id="i_ajax_src" src="" />
<div class="rotate_wrap">
<img class="bg_img rotate_origin" id="i_bg" src="images/img1.png">
<img class="cont_img rotate_origin1" id="i_cont" src="images/img2.png">
</div>
<div class="btn" id="i_btn">开始</div>
<div class="btn1" id="i_back">退出</div>
<div class="overfloat" id="i_close_cont">
<div class="overfloat_cont">
<strong class="top_space">提交成功</strong>
<div><span id="i_time" class="font_red">5s</span> 后自动返回微信。</div>
<div id="i_close" class="btn">立即返回</div>
</div>
</div>
<div class="banner_wrap">
<img id="i_banner" src="images/banner1.png">
</div>
<script src="js/jquery-1.9.1.min.js"></script>
<?php require_once "share.php"; ?>
<script type="text/javascript" src="js/share_package_close_min.js"></script>
<script type="text/javascript">
// 转盘样式,a:旋转角度,p:概率(1代表100%),t:需要显示的其它信息(文案or分享)
var result_angle = [{a:0,p:0.1,t:'桃花朵朵开^_^'},{a:45,p:0.1,t:'哎呦,不错哦^_^'},{a:90,p:0.1,t:'天天开心呢^_^'},{a:135,p:0.3,t:'给姐笑一个^_^'},{a:180,p:0.1,t:'今天天气不错^_^'},{a:225,p:0.1,t:'心情大好哈哈^_^'},{a:270,p:0.1,t:'中奖五百万^_^'},{a:315,p:0.1,t:'打架你赢了^_^'}];
var rotate = {
rotate_angle : 0, //起始位置为0
flag_click : true, //转盘转动过程中不可再次触发
calculate_result:function(type,during_time){//type:0,箭头转动,1,背景转动;during_time:持续时间(s)
var self = this;
type = type || 0; // 默认为箭头转动
during_time = during_time || 1; // 默认为1s
var rand_num = Math.ceil(Math.random() * 100); // 用来判断的随机数,1-100
var result_index; // 最终要旋转到哪一块,对应result_angle的下标
var start_pos = end_pos = 0; // 判断的角度值起始位置和结束位置
for(var i in result_angle){
start_pos = end_pos + 1; // 区块的起始值
end_pos = end_pos + 100 * result_angle[i].p; // 区块的结束值
if(rand_num >= start_pos && rand_num <= end_pos){ // 如果随机数落在当前区块,那么获取到最终要旋转到哪一块
result_index = i;
break;
}
}
var rand_circle = Math.ceil(Math.random() * 2) + 1; // 附加多转几圈,2-3
self.flag_click = false; // 旋转结束前,不允许再次触发
if(type == 1){ // 转动盘子
self.rotate_angle = self.rotate_angle - rand_circle * 360 - result_angle[result_index].a - self.rotate_angle % 360;
$('#i_bg').css({
'transform': 'rotate('+self.rotate_angle+'deg)',
'-ms-transform': 'rotate('+self.rotate_angle+'deg)',
'-webkit-transform': 'rotate('+self.rotate_angle+'deg)',
'-moz-transform': 'rotate('+self.rotate_angle+'deg)',
'-o-transform': 'rotate('+self.rotate_angle+'deg)',
'transition': 'transform ease-out '+during_time+'s',
'-moz-transition': '-moz-transform ease-out '+during_time+'s',
'-webkit-transition': '-webkit-transform ease-out '+during_time+'s',
'-o-transition': '-o-transform ease-out '+during_time+'s'
});
}else{ // 转动指针
self.rotate_angle = self.rotate_angle + rand_circle * 360 + result_angle[result_index].a - self.rotate_angle % 360;
$('#i_cont').css({
'transform': 'rotate('+self.rotate_angle+'deg)',
'-ms-transform': 'rotate('+self.rotate_angle+'deg)',
'-webkit-transform': 'rotate('+self.rotate_angle+'deg)',
'-moz-transform': 'rotate('+self.rotate_angle+'deg)',
'-o-transform': 'rotate('+self.rotate_angle+'deg)',
'transition': 'transform ease-out '+during_time+'s',
'-moz-transition': '-moz-transform ease-out '+during_time+'s',
'-webkit-transition': '-webkit-transform ease-out '+during_time+'s',
'-o-transition': '-o-transform ease-out '+during_time+'s'
});
}
// 旋转结束后,允许再次触发
setTimeout(function(){
self.flag_click = true;
// 告诉结果
alert(result_angle[result_index].t);
},during_time*1000);
}
}
//统计
var rand_num = Math.floor(Math.random() * ( 1000 + 1));
var app_src_view = 'http://vd.ppickup.com/incr.php?k=game_star_call_test_view&v='+rand_num;
var app_src_play = 'http://vd.ppickup.com/incr.php?k=game_star_call_test_play&v='+rand_num;
$('#i_ajax_src').attr('src',app_src_view);//view
//统计banner
$('#i_banner').bind({
'click' : function(){//touchstart
var rand_num = Math.floor(Math.random() * ( 1000 + 1));
var app_src_download = 'http://vd.ppickup.com/incr.php?k=game_star_call_test_download&v='+rand_num;
$('#i_banner').attr('src',app_src_download); //todo
setTimeout(function(){
window.location = 'http://a.app.qq.com/o/simple.jsp?pkgname=com.daxiangce123';
}, 1000);
return false;
}
});
$(document).ready(function(){
$('#i_btn').click(function(){
if(rotate.flag_click){ // 旋转结束前,不允许再次触发
rotate.calculate_result(1,1);
}
//统计
$('#i_ajax_src').attr('src',app_src_play);//play
});
var t=5;//5秒后返回微信
function f_t(){
setTimeout(function(){
t--;
$("#i_time").html(t+"s");
f_t();
if(t<=0){
// $("#i_close_cont").hide();
wx_sdk.close_window();//微信返回
}
},1000)
}
//换banner
var n=0;//5秒后返回微信
function banner(){
setTimeout(function(){
n++;
if(n%2==0){
$('#i_banner').attr('src','images/banner2.png');
}else{
$('#i_banner').attr('src','images/banner1.png');
}
banner();
},1000)
}
banner();
//关闭返回微信
wx_sdk.init({
appId: '<?php echo $signPackage["appId"];?>',
timestamp: <?php echo $signPackage["timestamp"];?>,
nonceStr: '<?php echo $signPackage["nonceStr"];?>',
signature: '<?php echo $signPackage["signature"];?>',
debug:false, // 把debug写成false或不写这一行,代表非调试状态,debug为true是调试状态
menuOpen:true //menuOpen,true:显示右上角菜单,false:隐藏右上角菜单,默认为true
});
$('#i_back').click(function(){
$("#i_close_cont").show();
f_t();
});
$('#i_close').bind({
'touchstart' : function(){
// $("#i_close_cont").hide();
wx_sdk.close_window();
}
});
});
//分享
window.ShareData = {
link : auto_domain+'smallgame/web/star_call_test/index.php', // 链接地址
img : auto_domain+'smallgame/web/star_call_test/images/img1.png', // 分享图标
TimelineTitle : '瞅瞅【幸运奖】是什么!', // 朋友圈标题
FriendTitle : '瞅瞅【幸运奖】是五百万呢!', // 朋友标题
FriendDesc : '这是一个神奇的大转盘,随便转就中奖五百万^_^', // 朋友描述
TimelineSuccess : function(){ // 朋友圈分享成功
},
NormalSuccess : function(){
}
};
set_weixin_share();
</script>
</body>
</html>
评论4
最新资源