1var turnplate = { 2 restaraunts:[], 3 //大转çå¥ååç§° 4 colors:[], 5 //大转çå¥ååºå对åºèæ¯é¢è² 6 outsideRadius:175, 7 //大转çå¤åçåå¾ 8 textRadius:135, 9 //大转çå¥åä½ç½®è·ç¦»åå¿çè·ç¦» 10 insideRadius:55, 11 //大转çå åçåå¾ 12 startAngle:0, 13 //å¼å§è§åº¦ 14 bRotate:false 15}; 16 17function readyTurnplate(restaraunts, colors, actionUrl, params, limitEle, regionData, regionUrl, saveurl) { 18 //å¨ææ·»å 大转ççå¥åä¸å¥ååºåèæ¯é¢è² 19 turnplate.restaraunts = restaraunts; 20 turnplate.colors = colors; 21 var rotateTimeOut = function() { 22 $("#wheelcanvas").rotate({ 23 angle:0, 24 animateTo:2160, 25 duration:8e3, 26 callback:function() { 27 Message.error("ç½ç»è¶ æ¶ï¼è¯·æ£æ¥æ¨çç½ç»è®¾ç½®ï¼"); 28 } 29 }); 30 }; 31 //æè½¬è½¬ç item:å¥åä½ç½®; txtï¼æç¤ºè¯; 32 var rotateFn = function(item, txt, redirect, dataEl, responseData) { 33 var angles = item * (360 / turnplate.restaraunts.length) - 360 / (turnplate.restaraunts.length * 2); 34 if (angles < 270) { 35 angles = 270 - angles; 36 } else { 37 angles = 360 - angles + 270; 38 } 39 $("#wheelcanvas").stopRotate(); 40 $("#wheelcanvas").rotate({ 41 angle:0, 42 animateTo:angles + 1800, 43 duration:8e3, 44 callback:function() { 45 //å¼¹åºæ½å°çå¥å 46 var lotteryType = txt.substring(txt.indexOf('-')+1, txt.indexOf('+')); 47 txt = "æåä½ ï¼è·å¾" + txt.substr(txt.indexOf('+') + 1); 48 if(lotteryType == 'none') { 49 Message.error("å¾éæ¾ï¼æªä¸å¥ï¼"); 50 } else if(lotteryType == 'hongbao'){ 51 if(responseData.hongbaotype != null && responseData.hongbaotype == "stochastic") { 52 txt = "æåä½ ï¼è·å¾éæºçº¢å " + responseData.hongbaomoney + "å "; 53 } else { 54 txt = "æåä½ ï¼è·å¾çº¢å " + responseData.hongbaomoney + "å "; 55 } 56 Message.success(txt); 57 } else { 58 Message.success(txt); 59 } 60 turnplate.bRotate = !turnplate.bRotate; 61 } 62 }); 63 }; 64 $(".pointer").click(function() { 65 var lotteryLimit = Number($.trim($(".prize-result").find(".lotter-limit").text())); 66 if (turnplate.bRotate) return; 67 turnplate.bRotate = !turnplate.bRotate; 68 params.lottery_joint_limit = lotteryLimit; 69 $.post(actionUrl, params, function(rs) { 70 if(rs.error) { 71 Message.error(rs.message); 72 turnplate.bRotate = !turnplate.bRotate; 73 74 if(rs.redirect) { 75 setTimeout(function() { 76 window.location.href = rs.redirect; 77 }, 1500); 78 } 79 } 80 if(rs.success) { 81 var redirect = rs.redirect; 82 var id = rs.message.id 83 limitEle.text(rs.message.lottery_joint_limit); 84 85 //è·åä¸å¥å¥åçç´¢å¼å¼ 86 var index = 0; 87 for(var i = 0; i < turnplate.restaraunts.length; i++) { 88 if(turnplate.restaraunts[i].indexOf(id + '-') == 0) { 89 index = i; 90 break; 91 } 92 } 93 var regionData = $(this).parent().find('label'); 94 rotateFn(index + 1 , turnplate.restaraunts[index], redirect, regionData, rs.message); 95 } 96 }); 97 }); 98} 99 100function rnd(n, m) { 101 var random = Math.floor(Math.random() * (m - n + 1) + n); 102 return random; 103} 104 105function drawRouletteWheel() { 106 var canvas = document.getElementById("wheelcanvas"); 107 if (canvas.getContext) { 108 //æ ¹æ®å¥å个æ°è®¡ç®åå¨è§åº¦ 109 var arc = Math.PI / (turnplate.restaraunts.length / 2); 110 var ctx = canvas.getContext("2d"); 111 //å¨ç»å®ç©å½¢å æ¸ ç©ºä¸ä¸ªç©å½¢ 112 ctx.clearRect(0, 0, 422, 422); 113 //strokeStyle 屿§è®¾ç½®æè¿åç¨äºç¬è§¦çé¢è²ãæ¸åææ¨¡å¼ 114 ctx.strokeStyle = "#FFBE04"; 115 //font 屿§è®¾ç½®æè¿åç»å¸ä¸ææ¬å 容çå½ååä½å±æ§ 116 ctx.font = "16px Microsoft YaHei"; 117 for (var i = 0; i < turnplate.restaraunts.length; i++) { 118 var angle = turnplate.startAngle + i * arc; 119 ctx.fillStyle = turnplate.colors[i]; 120 ctx.beginPath(); 121 //arc(x,y,r,èµ·å§è§,ç»æè§,ç»å¶æ¹å) æ¹æ³å建弧/æ²çº¿ï¼ç¨äºå建åæé¨ååï¼ 122 ctx.arc(211, 211, turnplate.outsideRadius, angle, angle + arc, false); 123 ctx.arc(211, 211, turnplate.insideRadius, angle + arc, angle, true); 124 ctx.stroke(); 125 ctx.fill(); 126 //éç»å¸(为äºä¿åä¹åçç»å¸ç¶æ) 127 ctx.save(); 128 //----ç»å¶å¥åå¼å§---- 129 ctx.fillStyle = "#E5302F"; 130 var key = turnplate.restaraunts[i].substring(0, turnplate.restaraunts[i].indexOf('-')); 131 var lotteryType = turnplate.restaraunts[i].substring(turnplate.restaraunts[i].indexOf('-')+1, turnplate.restaraunts[i].indexOf('+')); 132 var text = turnplate.restaraunts[i].substr(turnplate.restaraunts[i].indexOf('+')+1); 133 var line_height = 17; 134 //translateæ¹æ³éæ°æ å°ç»å¸ä¸ç (0,0) ä½ç½®
135 ctx.translate(211 + Math.cos(angle + arc / 2) * turnplate.textRadius, 211 + Math.sin(angle + arc / 2) * turnplate.textRadius); 136 //rotateæ¹æ³æè½¬å½åçç»å¾ 137 ctx.rotate(angle + arc / 2 + Math.PI / 2); 138 /** ä¸é¢ä»£ç æ ¹æ®å¥åç±»åãå¥ååç§°é¿åº¦æ¸²æä¸åææï¼å¦åä½ãé¢è²ãå¾çææã(å ·ä½æ ¹æ®å®é æ 嵿¹å) **/ 139 if (text.indexOf("M") > 0) { 140 //æµéå 141 var texts = text.split("M"); 142 for (var j = 0; j < texts.length; j++) { 143 ctx.font = j == 0 ? "bold 16px Microsoft YaHei" :"14px Microsoft YaHei"; 144 if (j == 0) { 145 ctx.fillText(texts[j] + "M", -ctx.measureText(texts[j] + "M").width / 2, j * line_height); 146 } else { 147 ctx.fillText(texts[j], -ctx.measureText(texts[j]).width / 2, j * line_height); 148 } 149 } 150 } else if (text.indexOf("M") == -1 && text.length > 6) { 151 //å¥ååç§°é¿åº¦è¶ è¿ä¸å®èå´ 152 text = text.substring(0, 6) + "||" + text.substring(6); 153 var texts = text.split("||"); 154 for (var j = 0; j < texts.length; j++) { 155 ctx.fillText(texts[j], -ctx.measureText(texts[j]).width / 2, j * line_height); 156 } 157 } else { 158 //å¨ç»å¸ä¸ç»å¶å¡«è²çææ¬ãææ¬çé»è®¤é¢è²æ¯é»è² 159 //measureText()æ¹æ³è¿åå å«ä¸ä¸ªå¯¹è±¡ï¼è¯¥å¯¹è±¡å å«ä»¥åç´ è®¡çæå®åä½å®½åº¦ 160 ctx.fillText(text, -ctx.measureText(text).width / 2, 0); 161 } 162 //æ·»å 对åºå¾æ 163 if (lotteryType == "point") { 164 var img = document.getElementById("point_" + key); 165 if(img != null) { 166 img.onload = function() { 167 ctx.drawImage(img, -20, 10, 40, 40); 168 }; 169 ctx.drawImage(img, -20, 10, 40, 40); 170 } 171 } 172 else if (lotteryType == "none") { 173 var img = document.getElementById("none_" + key); 174 if(img != null) { 175 img.onload = function() { 176 ctx.drawImage(img, -20, 10, 40, 40); 177 }; 178 ctx.drawImage(img, -20, 10, 40, 40); 179 } 180 } 181 else if (lotteryType == "hongbao") { 182 var img = document.getElementById("hongbao_" + key); 183 if(img != null) { 184 img.onload = function() { 185 ctx.drawImage(img, -20, 10, 40, 40); 186 }; 187 ctx.drawImage(img, -20, 10, 40, 40); 188 } 189 } 190 else if(lotteryType == "custom"){ 191 var img = document.getElementById("custom_" + key); 192 if(img != null) { 193 img.onload = function() { 194 ctx.drawImage(img, -20, 10, 40, 40); 195 }; 196 ctx.drawImage(img, -20, 10, 40, 40); 197 } 198 } 199 //æå½åç»å¸è¿åï¼è°æ´ï¼å°ä¸ä¸ä¸ªsave()ç¶æä¹å 200 ctx.restore(); 201 } 202 } 203}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.