123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title></title>
- <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
- <meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="apple-mobile-web-app-status-bar-style" content="black">
- <link rel="stylesheet" type="text/css" href="css/mui.min.css" />
- <link rel="stylesheet" type="text/css" href="css/style.css" />
- <style>
- .clear{clear:both;}
-
- .drawbanner{display:block;width:85%;margin:0 auto;}
- .drawbanner .turnplate{display:block;width:100%;position:relative;}
- .drawbanner .turnplate canvas.item{width:100%;}
- .drawbanner .turnplate img.pointer{
- position: absolute;
- width: 25%;
- height: 30%;
- left: 37.5%;
- top: 32%;
- }
- #img-box{display:none;}
- </style>
- </head>
- <body style="background: #fff3f4;">
- <div class="loading-bg">
- <div class="mui-loading">
- <div class="mui-spinner">
- </div>
- 加载中...
- </div>
- </div>
- <div class="mui-content" style="background: #fff3f4;">
- <div style="margin-bottom: 10px;">
- <img width="100%" src="images/wheel-title1.png" />
- </div>
- <div style="position: relative;">
- <div id="img-box">
- </div>
- <div class="drawbanner">
- <div class="turnplate" style="background-image:url(images/turnplate-bg.png);background-size:100% 98%;background-repeat: no-repeat;">
- <canvas class="item" id="wheelcanvas" width="422px" height="422px"></canvas>
- <img class="pointer" src="images/turnplate-pointer.png"/>
- </div>
- </div>
- <div style="text-align: center;">
- <button class="pointer" type="button" style="background: #e9004c;color: #fff;border: 0;border-radius: 5px;display: block;width:70%;margin:20px 15%;padding:11px 0;">立即抽奖</button>
- </div>
- </div>
- </div>
- </div>
- <script src="js/mui.min.js"></script>
- <script src="js/jquery-2.1.1.min.js"></script>
- <script src="js/awardRotate.js"></script>
- <script src="js/main.js"></script>
- <script type="text/javascript" src="js/page/wechat-utils-1.0.js"></script>
- <script type="text/javascript">
- var turnplate={
- restaraunts:[],
- colors:[],
- outsideRadius:166,
- textRadius:140,
- insideRadius:40,
- startAngle:0,
- bRotate:false
- };
- var prizeList = null;
- $(document).ready(function(){
- window.repleFlag = false;
- window.wxFriend = {
- "appId": "",
- "imgUrl":domanUrl + '/iamberry/common/shop/images/1.png',
- "link":"https:" + domanUrl+"/iamberry/wechat/activity/share_luck_draw",
- "desc":"哎呀!我差一点就抽到iPhone7了!亮黑版,32G啊!小伙伴你也来试试吧!",
- "title":"我离iPhone7亮黑版 32G仅一步之遥,小伙伴你快来一起抽吧!",
- "netError":"您的网络异常,请刷新重试!如多次刷新无效,请向我们反应 ~",
- "shareTimeSuccess":"分享成功",
- "shareTimeCancel":"已取消分享",
- "shareAppSuccess":"分享成功",
- "shareAppCancel":"已取消分享"
- };
- getConfig();
-
- $.ajax('/iamberry/wechat/game/get_prize_info',{
- data: {
- prizeGameId:1
- },
- dataType:'json',
- async:true,
- type:'post',
- timeout:15000,
- xhrFields: {
- withCredentials: true
- },
- crossDomain: true,
- success:function(dt){
- if (dt.isRedirect) {
- location.href = dt.redirectURL;
- } else {
- if (dt.status) {
- prizeList = dt.data;
-
- mui(prizeList).each(function(index){
- turnplate.restaraunts[index] = this.prizeName;
- if ((index + 1) % 2 == 0) {
- turnplate.colors[index] = "#ff9c9d";
- } else {
- if (index == (prizeList.length - 1)) {
- turnplate.colors[index] = "#f99eaa";
- } else {
- turnplate.colors[index] = "#f76f7d";
- }
- }
-
- $("#img-box").append('<img src="'+this.prizeImage+'" id="'+this.prizeId+'"/>');
- });
-
- setTimeout(function(){
- drawRouletteWheel()
- document.querySelector('.loading-bg').style.display = 'none';
- },1000);
- } else {
- }
- }
- },
- error:function(xhr,type,errorThrown){
- }
- });
-
- var rotateFn = function (item, txt, to){
- var angles = item * (360 / turnplate.restaraunts.length) - (360 / (turnplate.restaraunts.length*2));
- if(angles<270){
- angles = 270 - angles;
- }else{
- angles = 360 - angles + 270;
- }
- $('#wheelcanvas').stopRotate();
- $('#wheelcanvas').rotate({
- angle:0,
- animateTo:(to == null ? (angles+1800) : to),
- duration:3000,
- callback:function (){
- turnplate.bRotate = !turnplate.bRotate;
- }
- });
- };
- $(".pointer").on("click",function(){
-
- mui.openWindow({
- url: base_path + '/index.html'
- });
- });
- });
- function drawRouletteWheel() {
- var canvas = dc("wheelcanvas");
- if (canvas.getContext) {
-
- var arc = Math.PI / (turnplate.restaraunts.length/2);
- var ctx = canvas.getContext("2d");
-
- ctx.clearRect(0,0,422,422);
-
- ctx.strokeStyle = "rgba(0,0,0,0)";
-
- ctx.font = '17px Arial';
- for(var i = 0; i < turnplate.restaraunts.length; i++) {
-
- if (prizeList != null) {
- var angle = turnplate.startAngle + i * arc;
- ctx.fillStyle = turnplate.colors[i];
- ctx.beginPath();
-
- ctx.arc(211, 211, turnplate.outsideRadius, angle, angle + arc, false);
- ctx.arc(211, 211, turnplate.insideRadius, angle + arc, angle, true);
- ctx.stroke();
- ctx.fill();
-
- ctx.save();
-
- ctx.fillStyle = "#fff";
- var text = turnplate.restaraunts[i];
- var line_height = 17;
-
- ctx.translate(211 + Math.cos(angle + arc / 2) * turnplate.textRadius, 211 + Math.sin(angle + arc / 2) * turnplate.textRadius);
-
- ctx.rotate(angle + arc / 2 + Math.PI / 2);
-
-
-
- ctx.fillText(text, -ctx.measureText(text).width / 2, 0);
- var img= dc(prizeList[i].prizeId);
- ctx.drawImage(img,-25,10);
-
- }
-
- ctx.restore();
- }
- }
- }
- </script>
- </body>
- </html>
|