Quellcode durchsuchen

Update抽奖页面调整

YueYunyun vor 2 Jahren
Ursprung
Commit
8a5ed59882

+ 70 - 6
YZXYH2017/YZXYH2017/Controllers/LuckDrawController.cs

@@ -298,13 +298,77 @@ namespace YZXYH2017.Controllers
            var lotteries = ExcelHelper.ExcelToEntityList<Lottery>(new Dictionary<string, string>() {{"LotteryName", "姓名"},{"Mobile","手机"}},
                 virtualPath, out errorMsg);
            UnitOfWork.LotteryRepository.Delete(i=>i.LotteryGroup==group);
-           foreach (var lottery in lotteries)
+          
+
+           try
            {
-               lottery.LotteryGroup = group;
-               lottery.ExpLotteryType = "N";
-               UnitOfWork.LotteryRepository.Insert(lottery);
-           }
-            return Json(new { Success = UnitOfWork.Save() });
+               foreach (var lottery in lotteries)
+               {
+                   if (lottery == null||lottery.LotteryName==null)
+                   {
+                       continue;
+                   }
+                   // lottery.LotteryName = lottery.LotteryName.Replace(" ", "&nbsp;");
+                   string name=lottery.LotteryName.Replace(" ","");
+                   if (name.Contains("届"))
+                   {
+                       var arr = name.Split('届');
+                       if (arr.Length <2)
+                       {
+                            continue;
+                       }
+                        name = arr[0]+ "届&nbsp;";
+                        if (arr[1].Length == 2)
+                        {
+                            name += $"{arr[1][0]}&nbsp;&nbsp;{arr[1][1]}";
+                        }
+                        else
+                        {
+                            name += arr[1];
+                        }
+                   }
+                   else if (name.StartsWith("老师"))
+                   {
+                       name = name.Replace("老师", "老师&nbsp;");
+                   }
+                   else if (name.EndsWith("老师"))
+                   {
+                       name = name.Replace("老师", "&nbsp;老师");
+                   }
+                   else if (name.EndsWith("先生"))
+                   {
+                       name = name.Replace("先生", "&nbsp;先生");
+                   }
+                   else if (name.EndsWith("女士"))
+                   {
+                       name = name.Replace("女士", "&nbsp;女士");
+                   }
+                   else if (name.StartsWith("嘉宾"))
+                   {
+                       name = name.Replace("嘉宾", "嘉宾&nbsp;");
+                   } 
+                   else if (name.EndsWith("嘉宾"))
+                   {
+                       name = name.Replace("嘉宾", "&nbsp;嘉宾");
+                   }
+                   else
+                   {
+                       continue;
+                   }
+
+                    lottery.LotteryName=name;
+                   lottery.LotteryGroup = group;
+                   lottery.ExpLotteryType = "N";
+                   lottery.Mobile = lottery.Mobile ?? "";
+                   UnitOfWork.LotteryRepository.Insert(lottery);
+                   UnitOfWork.Save();
+               }
+                return Json(new { Success = true });
+            }
+            catch (Exception e)
+            {
+                return Json(new { Success = false });
+            }
         }
         #endregion
 

+ 1 - 0
YZXYH2017/YZXYH2017/Views/LuckDraw/Index.cshtml

@@ -134,6 +134,7 @@
                 flex-direction: row;
                 justify-content: space-between;
                 flex-wrap: wrap;
+                font-weight: 600;
             }
 
                 .draw-list-box .list .item {

+ 9 - 5
YZXYH2017/YZXYH2017/Views/MessageWall/Index.cshtml

@@ -129,7 +129,7 @@
     </style>
 </head>
 <body class="">
-    @* <canvas id="canvas"></canvas> *@
+     <canvas id="canvas"></canvas> 
     <div id="msg-box"></div>
     <script src="~/Scripts/jquery.signalR-2.4.1.min.js"></script>
     <script src="~/signalr/hubs"></script>
@@ -347,14 +347,16 @@
         };
     </script>
 
-    <script>
+<script>
 
         ////Based on https://www.youtube.com/watch?v=3CycKKJiwis
         var canvas = document.getElementById("canvas");
         var mobile = navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i);
-        canvas.width = window.innerWidth;
-        canvas.height = window.innerHeight; // Initialize the GL context
-
+        //canvas.width = window.innerWidth;
+        //canvas.height = window.innerHeight; // Initialize the GL context
+        // 背景调整为图片,canvas宽度为0
+        canvas.width = 0;
+        canvas.height = 0;
         var gl = canvas.getContext('webgl');
 
         if (!gl) {
@@ -379,6 +381,8 @@
         function onWindowResize() {
             canvas.width = window.innerWidth;
             canvas.height = window.innerHeight;
+            canvas.width = 0;
+            canvas.height = 0;
             gl.viewport(0, 0, canvas.width, canvas.height);
             gl.uniform1f(widthHandle, window.innerWidth);
             gl.uniform1f(heightHandle, window.innerHeight);