微信开发中如何实现大转盘功能(微信开发,移动开发)

时间:2024-05-06 12:24:38 作者 : 石家庄SEO 分类 : 移动开发
  • TAG :

一、使用

1. 新建一个大转盘的活动:

微信开发中如何实现大转盘功能

2. 奖项设置

微信开发中如何实现大转盘功能

3. 保存后,在微信里给公众号发一个“大转盘”的消息, 就会收到大转盘的内容

微信开发中如何实现大转盘功能

4. 点击进入大转盘活动,然后点击中间的 “点击抽奖”:

微信开发中如何实现大转盘功能 微信开发中如何实现大转盘功能

二、实现

1. 页面

1.1 前台代码
<%if(ErrLevel<100){Response.Write(ErrorInfo);}elseif(ErrLevel==101){//活动已结束,跳转到结束页面%><scripttype="text/javascript">window.location.href="end.aspx?wid="+<%=wid%>+"&aid="+<%=aid%>+"&openid="+<%=openid%>+";";</script><%}else{%><!DOCTYPEhtml><htmlxmlns="http://www.w3.org/1999/xhtml"><headid="Head1"runat="server"><metahttp-equiv="Content-Type"content="text/html;charset=UTF-8"><metaname="viewport"content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;"><metaname="apple-mobile-web-app-capable"content="yes"><metaname="apple-mobile-web-app-status-bar-style"content="black"><metaname="format-detection"content="telephone=no"><metaname="description"content="微信"><metahttp-equiv="Pragma"content="no-cache"><metahttp-equiv="Cache-Control"content="no-cache"><metahttp-equiv="Expires"content="0"><title>幸运大转盘抽奖</title><scriptsrc="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"type="text/javascript"></script><scripttype="text/javascript"src="../../scripts/jquery/jquery.query.js"></script><scriptsrc="../../scripts/jquery/alert.js"type="text/javascript"></script><linkhref="css/activity-style2.css"rel="stylesheet"type="text/css"><style>.activity-lottery-winning{background:url(images/beijing.gif)repeatscroll00#7E65AB;background-size:120pxauto;overflow:hidden;}</style></head><bodyclass="activity-lottery-winning"><formid="form1"runat="server"><pclass="main"><asp:HiddenFieldID="hidStatus"runat="server"Value=""EnableViewState="false"/><asp:HiddenFieldID="hidErrInfo"runat="server"EnableViewState="false"/><asp:HiddenFieldID="hidAwardId"runat="server"EnableViewState="false"Value="0"/><pid="outercont"><pid="outer-cont"><pid="outer"><imgsrc="images/zp<%=picIndex%>-.png"></p></p><pid="inner-cont"><pid="inner"><imgsrc="images/activity-lottery-2.png"></p></p></p><pclass="content"><pclass="boxcontentboxwhite"id="zjl"style="display:none"><pclass="box"><pclass="title-orange"><span>恭喜你中奖了</span></p><pclass="Detail"><p>你中了:<spanclass="red"id="prizetype"><asp:LiteralID="litzjlJP"runat="server"EnableViewState="false"Text=""></asp:Literal></span></p><p>兑奖SN码:<spanclass="red"id="sncode"><asp:LiteralID="litzjlSN"runat="server"EnableViewState="false"Text=""></asp:Literal></span></p><pclass="red"><asp:LiteralID="litContentInfo"runat="server"EnableViewState="false"></asp:Literal></p><p><inputname=""class="px"id="tel"value=""type="text"placeholder="用户请输入您的手机号"></p><asp:LiteralID="litPwd"runat="server"EnableViewState="false"Text=""></asp:Literal><p><inputclass="pxbtn"name="提交"id="save-btn"type="button"value="用户提交"></p></p></p></p><pclass="boxcontentboxwhite"id="result"style="display:none;"><pclass="box"><pclass="title-orange"><span>恭喜你中奖了</span></p><pclass="Detail"><p>你中了:<spanclass="red"id="jiangping"><asp:LiteralID="litJp"runat="server"EnableViewState="false"Text=""></asp:Literal></span></p><p>兑奖sn码为:<spanclass="red"id="jpsn"><asp:LiteralID="litSNM"runat="server"EnableViewState="false"></asp:Literal></span></p><pclass="red">你已经兑奖成功,本SN码自定作废!</p></p></p></p><pclass="boxcontentboxwhite"><pclass="box"><pclass="title-red"><span>奖项设置:</span></p><pclass="Detail"><asp:LiteralID="litOtherTip"runat="server"EnableViewState="false"></asp:Literal><asp:LiteralID="litJiangXing"runat="server"EnableViewState="false"></asp:Literal></p></p></p><pclass="boxcontentboxwhite"><pclass="box"><pclass="title-red">活动说明:</p><pclass="Detail"><pclass="red">本次活动每天可以转<asp:LiteralID="litdaysTimes"runat="server"EnableViewState="false"></asp:Literal>次,总共可以转<asp:LiteralID="littotTimes"runat="server"EnableViewState="false"></asp:Literal>次你已经转了<spanid="zhuantimes"><asp:LiteralID="litHasUsedTimes"runat="server"EnableViewState="false"></asp:Literal></span>次</p><p><asp:LiteralID="litRemark"runat="server"EnableViewState="false"></asp:Literal></p></p></p></p></p></p><scripttype="text/javascript">varthisurl=document.URL;varwid=<%=wid%>;varaid=<%=aid%>;varstatus=$("#hidStatus").val();varshowInfo=$("#hidErrInfo").val();varopenid="<%=openid%>";varjxname="";varjpname="";varcjtip="";varzhuantimes=parseInt($("#zhuantimes").text());varzjl=false;//没中奖为false中奖为true<%if(isZhJing){%>$("#outercont").hide();$("#result").show();<%}%>if(status=="2"){$("#outercont").hide();}elseif(status=="100"){$("#outercont").hide();$("#result").hide();$("#zjl").show();}$(function(){window.requestAnimFrame=(function(){returnwindow.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(callback){window.setTimeout(callback,1000/60)}})();vartotalDeg=360*3+0;varsteps=[];varlostDeg=[360];varprizeDeg=<%=shuzu%>;varprize,sncode;varcount=0;varnow=0;vara=0.01;varoutter,inner,timer,running=false;functioncountSteps(){vart=Math.sqrt(2*totalDeg/a);varv=a*t;for(vari=0;i<t;i++){steps.push((2*v*i-a*i*i)/2)}steps.push(totalDeg)}functionstep(){//alert('rotate('+steps[now++]+'deg)');outter.style.webkitTransform='rotate('+steps[now++]+'deg)';outter.style.MozTransform='rotate('+steps[now++]+'deg)';if(now<steps.length){running=true;requestAnimFrame(step)}else{running=false;setTimeout(function(){$("#zhuantimes").text(++zhuantimes);if(zjl){$("#sncode").text(sncode);$("#jpsn").text(sncode);$("#jiangping").text(jxname+""+jpname);$("#prizetype").text(jxname+""+jpname);$("#zjl").slideToggle(500);$("#outercont").slideUp(500)}else{alert(cjtip);}},200)}}functionstart(deg){deg=deg||lostDeg[parseInt(lostDeg.length*Math.random())];running=true;clearInterval(timer);totalDeg=360*5+deg;steps=[];now=0;countSteps();requestAnimFrame(step)}window.start=start;outter=document.getElementById('outer');inner=document.getElementById('inner');i=10;$("#inner").click(function(){if(status=="2"){alert(showInfo);}if(running)return;$.ajax({url:"dzpAct.ashx",dataType:"json",data:{openid:openid,myact:"choujiang",aid:aid,wid:wid,rad:Math.random()},beforeSend:function(){running=true;timer=setInterval(function(){i+=5;outter.style.webkitTransform='rotate('+i+'deg)';outter.style.MozTransform='rotate('+i+'deg)'},1)},success:function(data){if(data.error=="sys"||data.error=="nostart"){cjtip=data.content;count=100;clearInterval(timer);return}elseif(data.error=="notimes"){cjtip=data.content;start();}elseif(data.error=="succ"){zjl=true;cjtip=data.content;prize=data.sortid;sncode=data.sn;jpname=data.jpname;jxname=data.jxname;$("#hidAwardId").val(data.uid);start(prizeDeg[data.sortid-1])}else{cjtip=data.content;start()}running=false;count++},error:function(){prize=null;start();running=false;count++},timeout:1000})})});$("#save-btn").bind("click",function(){varbtn=$(this);vartel=$("#tel").val();varpwd="";varhidAwardId=$("#hidAwardId").val();if($("#parssword").length>0&&$.trim($("#parssword").val())==""){alert("请输入兑奖密码!");return}if($.trim(tel)==""){alert("请输入手机号!");return}if($("#parssword").length>0){pwd=$("#parssword").val();}varrad=Math.random();varsubmitData={id:hidAwardId,aid:aid,pwd:pwd,snumber:$("#sncode").text(),tel:tel,rad:rad,openid:openid};$.post('dzpAct.ashx?myact=update',submitData,function(data){if(data.success=="1"){alert("提交成功!");$("#result").slideToggle(500);$("#zjl").slideToggle(500);$("#outercont").slideUp(500);}else{alert(data.msg);}},"json")});</script><scripttype="text/javascript">document.addEventListener('WeixinJSBridgeReady',functiononBridgeReady(){window.shareData={"imgUrl":"","timeLineLink":thisurl+"&is_share=1","sendFriendLink":thisurl+"&is_share=1","weiboLink":thisurl+"&is_share=1","tTitle":"<%=dzpAction.actName%>","tContent":"请关注后,再来抽奖。<%=dzpAction.brief%>","fTitle":"请关注后,再来抽奖。<%=dzpAction.actName%>","fContent":"请关注后,再来抽奖。<%=dzpAction.brief%>","wContent":"请关注后,再来抽奖。<%=dzpAction.brief%>"};//发送给好友WeixinJSBridge.on('menu:share:appmessage',function(argv){WeixinJSBridge.invoke('sendAppMessage',{"img_url":window.shareData.imgUrl,"img_width":"640","img_height":"640","link":window.shareData.sendFriendLink,"desc":window.shareData.fContent,"title":window.shareData.fTitle},function(res){_report('send_msg',res.err_msg);})});//分享到朋友圈WeixinJSBridge.on('menu:share:timeline',function(argv){WeixinJSBridge.invoke('shareTimeline',{"img_url":window.shareData.imgUrl,"img_width":"640","img_height":"640","link":window.shareData.timeLineLink,"desc":window.shareData.tContent,"title":window.shareData.tTitle},function(res){_report('timeline',res.err_msg);});});//分享到微博WeixinJSBridge.on('menu:share:weibo',function(argv){WeixinJSBridge.invoke('shareWeibo',{"content":window.shareData.wContent,"url":window.shareData.weiboLink,},function(res){_report('weibo',res.err_msg);});});},false)</script></form><pstyle="display:none">©微布斯科技提供qq121285904www.webus.cn</p></body></html><%}%>
2.1 后台代码
///<summary>///ErrLevel:100表示正确无误,1表示严重错误,2表示业务方面有问题;3直接跳转到结束页面///</summary>publicintErrLevel=100;publicstringErrorInfo="";publicModel.wx_dzpActionInfodzpAction;publicintpicIndex=0;publicintaid=0;publicintwid=0;publicboolisZhJing=false;publicstringopenid="";publicstringshuzu="";BLL.wx_dzpAwardUserubll=newBLL.wx_dzpAwardUser();BLL.wx_dzpUsersTemputbll=newBLL.wx_dzpUsersTemp();BLL.wx_dzpActionInfoactBll=newBLL.wx_dzpActionInfo();BLL.wx_dzpAwardItemitemBll=newBLL.wx_dzpAwardItem();protectedvoidPage_Load(objectsender,EventArgse){OnlyWeiXinLook();aid=MyCommFun.RequestInt("aid",0);wid=MyCommFun.RequestInt("wid",0);openid=MyCommFun.RequestOpenid();if(aid==0||wid==0||openid.Trim()==""){ErrLevel=1;ErrorInfo="访问参数错误!";return;}BindData();}privatevoidBindData(){dzpAction=actBll.GetModel(aid);IList<Model.wx_dzpAwardItem>itemlist=itemBll.GetModelList("actId="+aid);if(dzpAction==null||itemlist==null||itemlist.Count<=0){ErrLevel=1;ErrorInfo="未获得到数据";return;}this.Title=dzpAction.actName;if(dzpAction.endDate<=DateTime.Now){//说明活动已经结束ErrLevel=101;ErrorInfo="活动已结束";return;}StringBuildersb=newStringBuilder("");Model.wx_dzpAwardItemitem=newModel.wx_dzpAwardItem();intttJpNum=0;shuzu="[";for(inti=0;i<itemlist.Count;i++){item=itemlist[i];sb.Append("<p>"+item.jxName+":"+item.jpName+"数量:"+item.jpNum+"</p>");ttJpNum+=item.jpRealNum.Value;picIndex++;if(i<(itemlist.Count-1)){shuzu+=item.jiaodu_min+",";}else{shuzu+=item.jiaodu_min;}}shuzu+="]";litJiangXing.Text=sb.ToString();litRemark.Text=dzpAction.brief;litContentInfo.Text=dzpAction.contractInfo;littotTimes.Text=dzpAction.personMaxTimes==null?"0":dzpAction.personMaxTimes.Value.ToString();litdaysTimes.Text=dzpAction.dayMaxTimes==null?"0":dzpAction.dayMaxTimes.Value.ToString();if(dzpAction.djPwd.Trim().Length>0){litPwd.Text="<p><inputname=\"\"class=\"px\"id=\"parssword\"type=\"password\"value=\"\"placeholder=\"商家输入兑奖密码\"></p>";}if(dzpAction.beginDate>DateTime.Now){hidStatus.Value="-2";ErrorInfo=hidErrInfo.Value="活动尚未开始";}inthasCjTimes=utbll.getCJCiShu(aid,openid);//返回该用户的抽奖次数this.litHasUsedTimes.Text=hasCjTimes.ToString();intdayMaxTimes=dzpAction.dayMaxTimes==null?0:dzpAction.dayMaxTimes.Value;intperMaxTimes=dzpAction.personMaxTimes==null?0:dzpAction.personMaxTimes.Value;//判断是否中奖了Model.wx_dzpAwardUseraward=ubll.getZJinfoByOpenid(aid,openid);if(award!=null&&award.id>0){//您中奖了if(award.uTel!=null&&award.uTel.ToString().Trim()!=""){//已经中奖,并且提交了litJp.Text="["+award.jxName+"]"+award.jpName;litSNM.Text=award.sn;isZhJing=true;}else{//已经中奖,但是未提交hidStatus.Value="100";litzjlJP.Text="["+award.jxName+"]"+award.jpName;litzjlSN.Text=award.sn;hidAwardId.Value=award.id.ToString();litJp.Text="["+award.jxName+"]"+award.jpName;litSNM.Text=award.sn;}}else{//判断每人最大抽奖次数,是否超过了if(hasCjTimes>=dzpAction.personMaxTimes){hidStatus.Value="2";//litOtherTip.Text="<pclass='red'>您已经抽了"+hasCjTimes+"次了。</p>";}if(isTodayOverSum(dayMaxTimes)){hidStatus.Value="2";//litOtherTip.Text="<pclass='red'>每人每天只有"+dayMaxTimes.ToString()+"次抽奖机会,您已经使用完了。</p>";}}}#region方法///<summary>///判断今天是否已经超出抽奖次数///todayTTTimes:能抽奖的总次数///</summary>///<paramname="openid"></param>///<paramname="todayTTTimes">每天的抽奖总次数</param>///<returns></returns>privateboolisTodayOverSum(inttodayTTTimes){if(todayTTTimes<=0){returntrue;}DateTimetodaybegin=DateTime.Parse(DateTime.Now.ToShortDateString());DateTimemingtianBegin=todaybegin.AddDays(1);if(!utbll.ExistsOpenid("actId="+aid+"andopenid='"+openid+"'andcreateDate>='"+todaybegin+"'andcreateDate<'"+mingtianBegin+"'")){returnfalse;}Model.wx_dzpUsersTempmodel=utbll.getModelByAidOpenid(aid,openid);if(model.times>=todayTTTimes){returntrue;}else{returnfalse;}}#endregion

undefined

2. 实现逻辑

undefined

publicclassdzpAct:IHttpHandler{BLL.wx_dzpActionInfoactbll=newBLL.wx_dzpActionInfo();BLL.wx_dzpAwardUserubll=newBLL.wx_dzpAwardUser();BLL.wx_dzpUsersTemputbll=newBLL.wx_dzpUsersTemp();publicvoidProcessRequest(HttpContextcontext){context.Response.ContentType="text/json";string_action=MyCommFun.QueryString("myact");intaid=MyCommFun.RequestInt("aid");stringopenid=MyCommFun.RequestOpenid();//得到微信用户的openidif(_action=="choujiang"){Dictionary<string,string>jsonDict=newDictionary<string,string>();try{//抽奖Model.wx_dzpActionInfodzpAction=newModel.wx_dzpActionInfo();BLL.wx_dzpAwardItemitemBll=newBLL.wx_dzpAwardItem();#region判断intwid=MyCommFun.RequestInt("wid");if(aid==0||wid==0||openid.Trim()==""){jsonDict.Add("error","sys");jsonDict.Add("content","参数错误!");context.Response.Write(MyCommFun.getJsonStr(jsonDict));return;}dzpAction=actbll.GetModel(aid);if(dzpAction==null){jsonDict.Add("error","sys");jsonDict.Add("content","参数错误!");context.Response.Write(MyCommFun.getJsonStr(jsonDict));return;}if(dzpAction.endDate<=DateTime.Now){//说明活动已经结束//非活动期间jsonDict.Add("error","end");jsonDict.Add("content","活动已结束");context.Response.Write(MyCommFun.getJsonStr(jsonDict));return;}elseif(dzpAction.beginDate>DateTime.Now){//活动未开始//非活动期间jsonDict.Add("error","nostart");jsonDict.Add("content","活动未开始");context.Response.Write(MyCommFun.getJsonStr(jsonDict));return;}intdayMaxTimes=dzpAction.dayMaxTimes==null?0:dzpAction.dayMaxTimes.Value;intperMaxTimes=dzpAction.personMaxTimes==null?0:dzpAction.personMaxTimes.Value;//判断每人最大抽奖次数,是否超过了if(personCJTimes(openid,aid)>=dzpAction.personMaxTimes){jsonDict.Add("error","notimes");jsonDict.Add("content","您已抽过奖了,欢迎下次再来!");context.Response.Write(MyCommFun.getJsonStr(jsonDict));return;}if(isTodayOverSum(aid,openid,dayMaxTimes)){jsonDict.Add("error","notimes");jsonDict.Add("content","每人每天只有"+dayMaxTimes.ToString()+"次抽奖机会。");context.Response.Write(MyCommFun.getJsonStr(jsonDict));return;}Model.wx_dzpAwardUseraward=ubll.getZJinfoByOpenid(aid,openid);if(award!=null){//您中奖了jsonDict.Add("error","notimes");jsonDict.Add("content","您中奖了,欢迎下次再来!");context.Response.Write(MyCommFun.getJsonStr(jsonDict));return;}#endregion#region计算中奖信息///处理是否中奖///hidStatus状态为-1:不能抽奖,直接跳转到end.aspx页面;///0:抽奖次数超过设置的最高次数;///1:还可以继续抽奖;///2:中奖了;List<Model.wx_dzpAwardItem>itemlist=itemBll.GetModelList("actId="+aid);//该活动的所有奖项信息intttJpNum=0;for(inti=0;i<itemlist.Count;i++){ttJpNum+=itemlist[i].jpRealNum.Value;}IList<Model.wx_dzpAwardUser>auserlist=ubll.getHasZJList(aid);//已经中奖的人列表intZhongJiangNum=0;if(auserlist!=null){ZhongJiangNum=auserlist.Count;//已经中奖的人数}intsyZjNum=ttJpNum-ZhongJiangNum;//剩余的奖品数量if(syZjNum<=0){//说明已经没有奖品了jsonDict.Add("error","-1");jsonDict.Add("content",dzpAction.cfcjhf);context.Response.Write(MyCommFun.getJsonStr(jsonDict));return;}dzpAction.personNum=MyCommFun.Obj2Int(dzpAction.personNum,1);dzpAction.personMaxTimes=MyCommFun.Obj2Int(dzpAction.personMaxTimes,1);intfenmo=dzpAction.personNum.Value*dzpAction.personMaxTimes.Value;Randomrd=newRandom((int)DateTime.Now.Ticks);intradNum=rd.Next(0,fenmo);//从0到fenmo里随机出一个值if(radNum<syZjNum){//中奖了,再从剩余奖品里抽取一个奖品Model.wx_dzpAwardItemdajiang=getZJItem(itemlist,auserlist);if(dajiang!=null){//这是中的中奖了stringsnumber=Get_snumber(aid);intuId=ubll.Add(aid,"","",openid,dajiang.jxName,dajiang.jpName,snumber);jsonDict.Add("error","succ");jsonDict.Add("content","恭喜你中奖了!");jsonDict.Add("sortid",dajiang.sort_id.Value.ToString());jsonDict.Add("jxname",dajiang.jxName);jsonDict.Add("jpname",dajiang.jpName);jsonDict.Add("uid",uId.ToString());jsonDict.Add("sn",snumber);context.Response.Write(MyCommFun.getJsonStr(jsonDict));return;}else{//奖品已经全部中完了jsonDict.Add("error","-1");jsonDict.Add("content",dzpAction.cfcjhf);context.Response.Write(MyCommFun.getJsonStr(jsonDict));return;}}else{//这个条件说明:未中奖//抛出未中奖的数据jsonDict.Add("error","-1");jsonDict.Add("content",dzpAction.cfcjhf);context.Response.Write(MyCommFun.getJsonStr(jsonDict));return;}#endregion}catch(Exceptionex){jsonDict.Add("error","sys");jsonDict.Add("content","计算抽奖出现未知错误,请联系管理员!");context.Response.Write(MyCommFun.getJsonStr(jsonDict));return;}}elseif(_action=="update"){try{#region提交手机///提交手机号码stringtel=MyCommFun.QueryString("tel");stringpwd=MyCommFun.QueryString("pwd");stringsnumber=MyCommFun.QueryString("snumber");intid=MyCommFun.RequestInt("id");if(aid==0||id==0||snumber==""||tel==""){context.Response.Write("{\"msg\":\"提交出现异常!!\",\"success\":\"0\"}");return;}if((pwd.Length>0)&&(!actbll.ExistsPwd(aid,pwd))){context.Response.Write("{\"msg\":\"商家兑换密码错误!!\",\"success\":\"0\"}");return;}BLL.wx_dzpAwardUserubll=newBLL.wx_dzpAwardUser();Model.wx_dzpAwardUsermodel=ubll.GetModel(id);if(model==null){context.Response.Write("{\"msg\":\"提交出现异常2!!\",\"success\":\"0\"}");return;}model.uTel=tel;if(pwd.Length>0){model.hasLingQu=true;}else{model.hasLingQu=false;}ubll.Update(model);context.Response.Write("{\"msg\":\"提交成功!\",\"success\":\"1\"}");return;#endregion}catch{context.Response.Write("{\"msg\":\"提交出现异常!!\",\"success\":\"0\"}");return;}}}#region方法///<summary>///取中奖的项目///</summary>///<paramname="itemlist">所有的奖品信息</param>///<paramname="haszjlist">已经中奖的列表</param>///<returns></returns>privateModel.wx_dzpAwardItemgetZJItem(IList<Model.wx_dzpAwardItem>itemlist,IList<Model.wx_dzpAwardUser>haszjlist){IList<Model.wx_dzpAwardItem>zjItemlist=newList<Model.wx_dzpAwardItem>();//剩余奖品列表Model.wx_dzpAwardItemtmpItem=newModel.wx_dzpAwardItem();Model.wx_dzpAwardItemstmpItem=newModel.wx_dzpAwardItem();IList<Model.wx_dzpAwardUser>thiszjRs;for(inti=0;i<itemlist.Count;i++){tmpItem=itemlist[i];thiszjRs=(fromuserinhaszjlistwhereuser.jpName==tmpItem.jpName&&user.jxName==tmpItem.jxNameselectuser).ToArray<Model.wx_dzpAwardUser>();inttmpSYNum=0;if(thiszjRs!=null){tmpSYNum=MyCommFun.Obj2Int(tmpItem.jpRealNum)-thiszjRs.Count;}if(tmpSYNum<=0){continue;}for(intj=0;j<tmpSYNum;j++){stmpItem=newModel.wx_dzpAwardItem();stmpItem.jpName=tmpItem.jpName;stmpItem.jxName=tmpItem.jxName;stmpItem.sort_id=tmpItem.sort_id;zjItemlist.Add(stmpItem);}}Randomrd=newRandom((int)DateTime.Now.Ticks);intjpIndex=rd.Next(0,zjItemlist.Count);//从0到zjItemlist.Count里随机出一个值returnzjItemlist[jpIndex];}///<summary>///判断该用户的抽奖次数///</summary>///<paramname="openid"></param>///<returns></returns>privateintpersonCJTimes(stringopenid,intaid){inttimes=0;times=utbll.GetRecordCount("actId="+aid+"andopenid='"+openid+"'");returntimes;}///<summary>///判断今天是否已经超出抽奖次数///todayTTTimes:能抽奖的总次数///</summary>///<paramname="openid"></param>///<paramname="todayTTTimes">每天的抽奖总次数</param>///<returns></returns>privateboolisTodayOverSum(intaid,stringopenid,inttodayTTTimes){if(todayTTTimes<=0){returntrue;}Model.wx_dzpUsersTempmodel=newModel.wx_dzpUsersTemp();model.openid=openid;DateTimetodaybegin=DateTime.Parse(DateTime.Now.ToShortDateString());DateTimemingtianBegin=todaybegin.AddDays(1);if(!utbll.ExistsOpenid("actId="+aid+"andopenid='"+openid+"'andcreateDate>='"+todaybegin+"'andcreateDate<'"+mingtianBegin+"'")){//第一次,插入model.times=1;model.createDate=DateTime.Now;model.openid=openid;model.actId=aid;utbll.Add(model);returnfalse;}model=utbll.getModelByAidOpenid(aid,openid);if(model.times>=todayTTTimes){returntrue;}else{model.times+=1;utbll.Update(model);returnfalse;}}///<summary>///返回中奖序列号///</summary>///<paramname="id"></param>///<returns></returns>publicstringGet_snumber(intaid){Randomrd=newRandom((int)DateTime.Now.Ticks);intradNum=rd.Next(0,9);//从0到9里随机出一个值return"SNdzp"+aid+"_"+MyCommFun.ConvertDateTimeInt(DateTime.Now)+radNum;}#endregionpublicboolIsReusable{get{returnfalse;}}}
 </div> <div class="zixun-tj-product adv-bottom"></div> </div> </div> <div class="prve-next-news">
本文:微信开发中如何实现大转盘功能的详细内容,希望对您有所帮助,信息来源于网络。
上一篇:如何利用JFinal Weixin进行微信开发下一篇:

11 人围观 / 0 条评论 ↓快速评论↓

(必须)

(必须,保密)

阿狸1 阿狸2 阿狸3 阿狸4 阿狸5 阿狸6 阿狸7 阿狸8 阿狸9 阿狸10 阿狸11 阿狸12 阿狸13 阿狸14 阿狸15 阿狸16 阿狸17 阿狸18