Index.cshtml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. @using CommonTool
  2. @using YZXYH.Repository.Models
  3. @{
  4. string color = ViewBag.Color;
  5. }
  6. <!DOCTYPE html>
  7. <html>
  8. <head>
  9. <meta charset="utf-8">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  11. <meta name="renderer" content="webkit">
  12. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  13. <meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
  14. <title>盐城中学校友会——抽奖</title>
  15. <meta name="keywords" content="盐城中学,盐中校友会,校友会,盐中">
  16. <meta name="description" content="">
  17. <link href="~/Content/css/bootstrap.min.css" rel="stylesheet" />
  18. <link href="~/Content/css/font-awesome.min.css" rel="stylesheet" />
  19. <link href="~/Content/css/animate.min.css" rel="stylesheet" />
  20. <script src="~/Content/js/jquery.min.js"></script>
  21. <script src="~/Content/js/bootstrap.min.js"></script>
  22. <script src="~/Scripts/jquery.signalR-2.4.1.min.js"></script>
  23. <script src="~/signalr/hubs"></script>
  24. <style>
  25. body , .draw:before{
  26. background: url('@(GlobalConst.LotteryBackGroupImageUrl)') 0 / cover fixed;
  27. }
  28. .draw {
  29. color: #fff;
  30. color: @(Html.Raw(color));
  31. }
  32. </style>
  33. <style>
  34. body {
  35. /*background: linear-gradient(135deg, #6e8efb, #a777e3);
  36. background-repeat: no-repeat;
  37. background-size: 100%;*/
  38. width: 100vw;
  39. height: 100vh;
  40. overflow: hidden;
  41. color: #000;
  42. font-family: '微软雅黑', sans-serif;
  43. font-size: 16px;
  44. position: relative;
  45. top: 0;
  46. left: 0;
  47. bottom: 0;
  48. right: 0;
  49. display: flex;
  50. justify-content: center;
  51. align-items: center;
  52. }
  53. /* body:before{
  54. background: linear-gradient(0,rgba(255,255,255,0.8),rgba(255,255,255,0.6));
  55. content: '';
  56. position: absolute;
  57. top: 0;
  58. right: 0;
  59. bottom: 0;
  60. left: 0;
  61. z-index:-1;
  62. } */
  63. .draw {
  64. position: relative;
  65. overflow: hidden;
  66. cursor: none;
  67. width: 1000px;
  68. height: 100vh;
  69. padding: 0 20px;
  70. overflow: hidden;
  71. position: relative;
  72. border-radius: 20px;
  73. /*margin-top: -200px;*/
  74. z-index: 2;
  75. /*--h: 100vh;*/
  76. display: flex;
  77. justify-content: center;
  78. align-items: center;
  79. }
  80. .draw:before {
  81. content: '';
  82. position: absolute;
  83. top: 0;
  84. right: 0;
  85. bottom: 0;
  86. left: 0;
  87. filter: blur(15px);
  88. margin: -30px;
  89. z-index: -1;
  90. }
  91. .draw-box {
  92. height: 700px;
  93. }
  94. .title {
  95. text-align: center;
  96. color: inherit;
  97. font-size: 60px;
  98. margin-top: 60px;
  99. margin-bottom: 30px;
  100. }
  101. #luck-draw-box {
  102. /*margin-top: -30px;*/
  103. height: 300px;
  104. overflow: hidden;
  105. }
  106. .luck-draw-box {
  107. /*--h: 100vh;*/
  108. }
  109. .luck-draw-info {
  110. list-style: none;
  111. text-align: center;
  112. font-size: 80px;
  113. /*line-height:calc(var(--h) - 50px);*/
  114. line-height: 300px;
  115. }
  116. .draw-list-box {
  117. /*--h: calc(100vh - 550px);*/
  118. /*--h: 100vhx;*/
  119. }
  120. .draw-list-box .list {
  121. padding: 10px 20px;
  122. display: flex;
  123. flex-direction: row;
  124. justify-content: space-between;
  125. flex-wrap: wrap;
  126. font-weight: 600;
  127. }
  128. .draw-list-box .list .item {
  129. text-align: center;
  130. color: inherit;
  131. /*font-weight: bold;*/
  132. font-family: "仿宋";
  133. }
  134. .draw-list-box .list-0 .item {
  135. padding-top: 50px;
  136. font-size: 75px;
  137. width: 100%;
  138. }
  139. .draw-list-box .list-1 .item {
  140. font-size: 45px;
  141. width: 100%;
  142. }
  143. .draw-list-box .list-2 .item {
  144. font-size: 40px;
  145. width: 50%;
  146. }
  147. .draw-list-box .list-3 .item {
  148. font-size: 40px;
  149. width: 33%;
  150. }
  151. .draw-list-box .list-4 .item {
  152. font-size: 30px;
  153. width: 33%;
  154. }
  155. .group {
  156. display: none;
  157. }
  158. .group, .type {
  159. font-size: 100%;
  160. font-family: "楷体";
  161. font-weight: bold
  162. }
  163. </style>
  164. </head>
  165. <body class="">
  166. @*<div id="luck-draw" style="display: none">
  167. <div class="luck-draw-box draw">
  168. <div class="draw-box">
  169. <h2 class="title">
  170. <span class="group"></span><span class="type"></span> 抽奖中
  171. </h2>
  172. <ul class="" id="luck-draw-box">
  173. <li class="luck-draw-info"></li>
  174. </ul>
  175. </div>
  176. </div>
  177. </div>*@
  178. <div id="draw-list" style="display: none">
  179. <div class="draw-list-box draw">
  180. <div class="draw-box">
  181. <h2 class="title">
  182. <span class="group"></span><span class="type"></span> <span class="content">中奖名单</span>
  183. </h2>
  184. <div id="list-box" style="">
  185. <div class="list list-3"></div>
  186. </div>
  187. </div>
  188. </div>
  189. </div>
  190. <div class="" style="display: none">
  191. <audio id="voice" controls="controls" preload="auto" loop src="@(GlobalConst.LotteryMusicUrl)"></audio>
  192. </div>
  193. <script>
  194. //var userData = [];
  195. //var flag = true, interval = 150;
  196. //var colors = ['#6666FF', '#66FF99', '#FF6666', '#FF66CC', '#FF6699', '#99FF99', '#9966FF', '#666699'];
  197. //function Run() {
  198. // var info = userData[parseInt(Math.random() * userData.length, 10)];
  199. // if (info) {
  200. // //var color = colors[parseInt(Math.random() * colors.length, 10)];
  201. // //+ (info.Mobile ? ' ' + info.Mobile : '')
  202. // $('<li class="luck-draw-info">' + info.LotteryName + '</li>')
  203. // .appendTo('#luck-draw-box').css({ 'opacity': '0' }).animate({ 'opacity': '1' }, interval);
  204. // $('#luck-draw-box .luck-draw-info').eq(0).animate({ 'opacity': '0' }, interval, function () {
  205. // $(this).remove();
  206. // if (flag) {
  207. // Run();
  208. // }
  209. // });
  210. // }
  211. //}
  212. function FormatterItem(data) {
  213. if (!data || data.length <= 0) {
  214. return '';
  215. }
  216. var str = '';
  217. for (var i = 0; i < data.length; i++) {
  218. var item = data[i];
  219. //var info = item.Mobile ? item.Mobile + '(' + item.LotteryName + ')' : item.LotteryName;
  220. str += '<div class="item">' + item.LotteryName + '</div>';
  221. }
  222. return str;
  223. }
  224. </script>
  225. <script>
  226. var timerInterval;
  227. $(function() {
  228. var chat = $.connection.xyhHub;
  229. //抽奖结果
  230. chat.client.showLotteryMsg = function(msg) {
  231. if (msg) {
  232. var data = JSON.parse(msg);
  233. if (data) {
  234. //flag = false;
  235. //$('#luck-draw').hide();
  236. clearInterval(timerInterval);
  237. var classStr = 'list list-' +
  238. (data.LotteryRecord.length <= 1
  239. ? '0'
  240. : data.LotteryRecord.length <= 6
  241. ? '1'
  242. : data.LotteryRecord.length <= 10
  243. ? '2'
  244. : data.LotteryRecord.length <= 18
  245. ? '3'
  246. : '4');
  247. var str = '<div class="' + classStr + '">';
  248. str += FormatterItem(data.LotteryRecord);
  249. str += '</div>';
  250. var group = data.LotteryGroup ? data.LotteryGroup : "";
  251. var type = data.LotteryType ? data.LotteryType : "";
  252. $('#draw-list .type').html(type);
  253. $('#draw-list .group').html(group);
  254. $('#draw-list .content').html('中奖名单');
  255. $('#list-box').html(str);
  256. $('#draw-list').fadeIn(800);
  257. console.log("ShowLotteryMsg:", "显示抽奖结果");
  258. } else {
  259. console.log("ShowLotteryMsg:", msg);
  260. }
  261. } else {
  262. console.log("ShowLotteryMsg错误:", msg);
  263. }
  264. }
  265. //开始抽奖
  266. chat.client.startLotteryMsg = function(msg) {
  267. if (msg) {
  268. console.log("StartLotteryMsg:", msg);
  269. var data = JSON.parse(msg);
  270. $.ajax({
  271. url: '@Url.Action("GetAllLottery", "LuckDraw")',
  272. type: 'post',
  273. data: { LotteryGroup: data.LotteryGroup },
  274. success: function(res) {
  275. //if (res ) {
  276. // userData = res;
  277. //}
  278. var group = data.LotteryGroup ? data.LotteryGroup : "";
  279. var type = data.LotteryType ? data.LotteryType : "";
  280. $('#draw-list .type').html(type);
  281. $('#draw-list .group').html(group);
  282. $('#draw-list .content').html('抽奖中...');
  283. //$('#draw-list').hide();
  284. //$('#luck-draw').fadeIn(400);
  285. //flag = true;
  286. //Run();
  287. $('#draw-list').fadeIn(800);
  288. function times() {
  289. var res2 = getArrayItems(res, data.LotteryCount);
  290. var classStr = 'list list-' +
  291. (res2.length <= 1
  292. ? '0'
  293. : res2.length <= 6
  294. ? '1'
  295. : res2.length <= 10
  296. ? '2'
  297. :res2.length <= 18
  298. ? '3'
  299. : '4');
  300. var str = '<div class="' + classStr + '">';
  301. str += FormatterItem(res2);
  302. str += '</div>';
  303. $('#list-box').html(str);
  304. }
  305. timerInterval = setInterval(times, 0);
  306. console.log("StartLotteryMsg:","开始抽奖");
  307. }
  308. });
  309. } else {
  310. console.log("StartLotteryMsg错误消息:", msg);
  311. }
  312. }
  313. //刷新页面
  314. chat.client.getReload = function(msg) {
  315. if (msg) {
  316. console.log("Reload:", msg);
  317. window.location.reload();
  318. } else {
  319. console.log("getReload错误消息:", msg);
  320. }
  321. }
  322. //背景音乐
  323. var voice = $('#voice')[0];
  324. chat.client.getMusic = function(msg) {
  325. if (msg==="0") {
  326. voice.pause();
  327. } else if (msg==="1") {
  328. voice.play();
  329. }else {
  330. console.log("getMusic错误消息:", msg);
  331. }
  332. }
  333. //字体颜色
  334. chat.client.textColor = function(msg) {
  335. if (msg) {
  336. $('.draw').css("color", msg);
  337. } else {
  338. console.log("textColor错误消息:", msg);
  339. }
  340. }
  341. });
  342. $.connection.hub.start().done(function() {
  343. console.log("XYH:Signalr已连接服务器!");
  344. });
  345. function getArrayItems(arr, num) {
  346. //新建一个数组,将传入的数组复制过来,用于运算,而不要直接操作传入的数组;
  347. var tempArray = new Array();
  348. for (var index in arr) {
  349. if (arr.hasOwnProperty(index)) {
  350. tempArray.push(arr[index]);
  351. }
  352. }
  353. //取出的数值项,保存在此数组
  354. var reArray = new Array();
  355. for (var i = 0; i < num; i++) {
  356. //判断如果数组还有可以取出的元素,以防下标越界
  357. if (tempArray.length > 0) {
  358. //在数组中产生一个随机索引
  359. var arrIndex = Math.floor(Math.random() * tempArray.length);
  360. //将此随机索引的对应的数组元素值复制出来
  361. reArray[i] = tempArray[arrIndex];
  362. //然后删掉此索引的数组元素,这时候temp_array变为新的数组
  363. tempArray.splice(arrIndex, 1);
  364. } else {
  365. //数组中数据项取完后,退出循环,比如数组本来只有10项,但要求取出20项.
  366. break;
  367. }
  368. }
  369. return reArray;
  370. }
  371. </script>
  372. </body>
  373. </html>