为什么冒险岛2幸运大转盘盘每次都是谢谢参与

有奖活动 | 关注浩亭微信,手机话费抢不停!
福利!福利 ! 福利!
全球连接器及工业网络科技领导者
——浩亭HARTING
即日起,开启“幸运大转盘活动”
即可抽取5元、20元、50元手机话费
百分百有奖,拒绝“谢谢参与”
参与方式:
第二步:在对话框输入“浩亭连接技术”,开启“幸运大转盘”活动;
第三步:输入个人信息,开始抽取话费。
提示:话费是自动充值,所以填写信息一定要正确噢!
额外好礼,分享有奖
只要将此图片分享至朋友圈,然后将截图通过对话框发送给我们,“控制工程中文版”将会额外送上神秘礼物一份。
责任编辑:
声明:本文由入驻搜狐号的作者撰写,除搜狐官方账号外,观点仅代表作者本人,不代表搜狐立场。
今日搜狐热点asp.net+jQueryRotate开发幸运大转盘
时间: 10:20:40
&&&& 阅读:113
&&&& 评论:
&&&& 收藏:0
标签:&&&&&&&&&&&&在线抽奖程序在很多网站上很多,抽奖形式多种多样,Flash抽奖偏多,本文将给大家介绍jQuery转盘抽奖,结合代码实例将使用jQuery和asp.net来实现转盘抽奖程序,为了便于理解,文章贴出实现源代码作为分享。通过转动转盘指针来完成抽奖的一种抽奖形式,根据旋转角度来控制指针停留的位置——幸运大转盘。
1、先来张幸运大抽奖效果图
2、Default.aspx页面代码
&span style=&font-family:Microsoft YaHfont-size:14&&&%@ Page Language=&C#& AutoEventWireup=&true&
CodeFile=&Default.aspx.cs& Inherits=&_Default& %&
&!DOCTYPE html PUBLIC &-//W3C//DTD XHTML 1.0 Transitional//EN& &http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&&
&html xmlns=&http://www.w3.org/1999/xhtml&&
&head runat=&server&&
&meta http-equiv=&Content-Type& content=&text/ charset=utf-8&/&
&meta content=&width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0& name=&viewport&&
&meta content=&yes& name=&apple-mobile-web-app-capable&&
&title&幸运大转盘&/title&
&style type=&text/css&&
.demo{ position:}
#disk{ position: z-index:1;}
#start{ position: top:-0; z-index:9;}
#start img{cursor: border:}
&script src=&Scripts/jquery-1.7.1.min.js&
type=&text/javascript&&&/script&
&script src=&Scripts/jQueryRotate.2.1.js& type=&text/javascript&&&/script&
&script type=&text/javascript&&
$(function () {
$(&#startbtn&).click(function () {
lottery();
function lottery() {
type: 'POST',
url: 'data.aspx',
dataType: 'json',
cache: false,
error: function () {
alert('出错了!');
success: function (json) {
$(&#startbtn&).unbind('click').css(&cursor&, &default&);
var a = json. //角度
var p = json. //奖项
$(&#startbtn&).rotate({
duration: 8000, //转动时间
animateTo: 2880+ a, //转动角度
easing: $.easing.easeOutSine,
callback: function () {
var con = confirm('恭喜你,中得' + p + '\n还要再来一次吗?');
if (con) {
lottery();
$(&#startbtn&).click(function () {
lottery();
}).css(&cursor&, &pointer&);
&form id=&form1& runat=&server&&
&div class=&demo&&
&div id=&disk&&&img src=&img/disk.jpg& width=&100%& style=&max-width:640&/&&/div&
&div id=&start&&&a href=&###&&&img src=&img/start.png& id=&startbtn& width=&100%& style=&max-width:640&/&&/a&&/div&
我们构建自定义函数lottery(),在lottery()我们向data.php发送一个POST请求,如果成功返回中奖信息后,调用rotate插件开始转动,转动角度由后台返回的角度决定,这里我们用2880+a表示转动的角度,即指针转动8圈+a度后停止,然后我们在单击“开始抽奖”按钮时调用lottery(),于是转盘抽奖就完成。
3、data.aspx中奖逻辑代码
&span style=&font-family:Microsoft YaHfont-size:14&&using S
using System.C
using System.Collections.G
using System.W
using System.Web.UI;
using System.Web.UI.WebC
public partial class data : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
Hashtable ht = new Hashtable();
Hashtable p1 = new Hashtable();
p1.Add(&id&, 1);
p1.Add(&min&, 1);
p1.Add(&max&, 59);
p1.Add(&prize&, &500积分&);
p1.Add(&v&, 1);
ht.Add(0, p1);
Hashtable p2 = new Hashtable();
p2.Add(&id&, 2);
p2.Add(&min&, 60);
p2.Add(&max&, 119);
p2.Add(&prize&, &100积分&);
p2.Add(&v&, 5);
ht.Add(1, p2);
Hashtable p3 = new Hashtable();
p3.Add(&id&, 3);
p3.Add(&min&, 121);
p3.Add(&max&, 179);
p3.Add(&prize&, &10元商品&);
p3.Add(&v&, 5);
ht.Add(2, p3);
Hashtable p4 = new Hashtable();
p4.Add(&id&, 4);
p4.Add(&min&, 180);
p4.Add(&max&, 240);
p4.Add(&prize&, &500积分&);
p4.Add(&v&, 10);
ht.Add(3, p4);
Hashtable p5 = new Hashtable();
p5.Add(&id&, 5);
p5.Add(&min&, 240);
p5.Add(&max&, 300);
p5.Add(&prize&, &谢谢参与&);
p5.Add(&v&, 80);
ht.Add(4, p5);
Hashtable p6 = new Hashtable();
p6.Add(&id&, 6);
p6.Add(&min&, 300);
p6.Add(&max&, 360);
p6.Add(&prize&, &订单免单&);
p6.Add(&v&, 1);
ht.Add(5, p6);
//Hashtable p7 = new Hashtable();
//p7.Add(&id&, 7);
//p7.Add(&min&, new int[6] { 32, 92, 152, 212, 272, 332 });
//p7.Add(&max&, new int[6] { 58, 118, 178, 238, 298, 358 });
//p7.Add(&prize&, &谢谢参与&);
//p7.Add(&v&, 50);
//ht.Add(6, p7);
//Console.WriteLine(ht[0]);
int htlength = ht.C
int[] proArr = new int[htlength];
foreach(DictionaryEntry single in ht)
Hashtable subObj = single.Value as H
proArr[(int)single.Key] = (int)subObj[&v&];
int rid = this.getRand(proArr);
int jiaodu = 0;
string prize =
Hashtable res = ht[rid] as H
Random ran = new Random();
if ((int)res[&id&] == 7)
int[] mins = (int[])res[&min&];
int[] maxs = (int[])res[&max&];
int i = ran.Next(0, 5);
jiaodu = ran.Next(mins[i], maxs[i]);
int mins = (int)res[&min&];
int maxs = (int)res[&max&];
jiaodu = ran.Next(mins, maxs);
prize = res[&prize&].ToString();
string json = &{\&angle\&:& + jiaodu.ToString() + &,\&prize\&:\&& + prize + &\&}&;
Response.Write(json);
//Dictionary&string, Dictionary&string,string&& dt = new Dictionary&string, Dictionary&string,string&&();
public int getRand(int[] proArr)
int result = -1;
int proSum = 0;
foreach(int val in proArr)
int length = proArr.L
for (int i = 0; i & i++)
Random ran = new Random();
int ranNum = ran.Next(1, proSum);
if (ranNum &= proArr[i])
proSum -= proArr[i];
}&/span&V参数代表百分比,默认为100,V月大代表该奖项中奖率越高,越小中奖率越小。
标签:&&&&&&&&&&&&原文:http://blog.csdn.net/fuyifang/article/details/
教程昨日排行
&&国之画&&&& &&&&&&
&& &&&&&&&&&&&&&&
鲁ICP备号-4
打开技术之扣,分享程序人生!

我要回帖

更多关于 微信幸运大转盘 的文章

 

随机推荐