瀏覽代碼

新增 報到音效 子女匯入JSON
修改 中獎清單 來賓顯示

maa3520 2 年之前
父節點
當前提交
6a068ed182

+ 2 - 2
app/Http/Controllers/CheckInController.php

@@ -118,8 +118,8 @@ class CheckInController extends Controller
      */
     public function update(UpdateCheckInRequest $request, CheckIn $checkIn)
     {
-        CheckIn::where('user_id', $request->user_id)->update(['is_checked_in' => true]);
-        return 'success';
+        $checkIn = CheckIn::where('user_id', $request->user_id)->update(['is_checked_in' => true]);
+        return $checkIn;
     }
 
     public function check_out(UpdateCheckInRequest $request, CheckIn $checkIn)

+ 98 - 0
database/child_count.json

@@ -0,0 +1,98 @@
+{
+    "1205": {
+       "children_count": 1
+    },
+    "1241": {
+       "children_count": 1
+    },
+    "1521": {
+       "children_count": 1
+    },
+    "1808": {
+       "children_count": 2
+    },
+    "1837": {
+       "children_count": 2
+    },
+    "1924": {
+       "children_count": 2
+    },
+    "2101": {
+       "children_count": 2
+    },
+    "2106": {
+       "children_count": 1
+    },
+    "2140": {
+       "children_count": 2
+    },
+    "2246": {
+       "children_count": 1
+    },
+    "2345": {
+       "children_count": 1
+    },
+    "2547": {
+       "children_count": 2
+    },
+    "2675": {
+       "children_count": 1
+    },
+    "2710": {
+       "children_count": 2
+    },
+    "2784": {
+       "children_count": 1
+    },
+    "2888": {
+       "children_count": 1
+    },
+    "2922": {
+       "children_count": 1
+    },
+    "2980": {
+       "children_count": 2
+    },
+    "2983": {
+       "children_count": 1
+    },
+    "2998": {
+       "children_count": 1
+    },
+    "3056": {
+       "children_count": 1
+    },
+    "3173": {
+       "children_count": 2
+    },
+    "3178": {
+       "children_count": 1
+    },
+    "3200": {
+       "children_count": 1
+    },
+    "3242": {
+       "children_count": 2
+    },
+    "3351": {
+       "children_count": 1
+    },
+    "3409": {
+       "children_count": 1
+    },
+    "3519": {
+       "children_count": 1
+    },
+    "3549": {
+       "children_count": 2
+    },
+    "3559": {
+       "children_count": 2
+    },
+    "3612": {
+       "children_count": 2
+    },
+    "3645": {
+       "children_count": 1
+    }
+ }

+ 6 - 4
database/seeders/CheckInSeeder.php

@@ -18,9 +18,10 @@ class CheckInSeeder extends Seeder
     {
         CheckIn::truncate();
         $json = File::get("database/MAA.json");
-        $countries = json_decode($json);
-
-        foreach ($countries as $key => $value) {
+        $child_json = File::get("database/child_count.json");
+        $maas = json_decode($json);
+        $child = json_decode($child_json);
+        foreach ($maas as $key => $value) {
             if ($value->department_id != 'xxx') {
                 switch ($value->department_id) {
                     case 'B00':
@@ -32,13 +33,14 @@ class CheckInSeeder extends Seeder
                     default:
                         $region = '北區';
                 }
+                $children_count = isset($child->{$value->user_id}) ? ($child->{$value->user_id}->children_count) : 0;
                 CheckIn::create([
                     'user_id' => $value->user_id,
                     'name' => $value->name,
                     'department_id' => $value->department_id,
                     'region' => $region,
                     'is_checked_in' => false,
-                    'children_count' => 0,
+                    'children_count' => $children_count,
                     'is_awarded' => false,
                     'activity_id' => 1,
                     'created_at' => now(),

二進制
public/報到失敗.mp3


二進制
public/報到成功.mp3


二進制
public/查無此人.mp3


+ 1 - 1
resources/js/src/views/lottery/Activities/ActivityPage.vue

@@ -39,6 +39,7 @@
                 <b-card no-body border-variant="info" class="text-center">
                     <b-card-body>
                         <b-button variant="success"
+                            target="_blank"
                             :to="{ name: 'playPrizeList', params: { 'activity_id': this.$route.params.activity_id } }">中獎輪播名單</b-button>
                     </b-card-body>
                 </b-card>
@@ -47,7 +48,6 @@
                 <b-card no-body border-variant="info" class="text-center">
                     <b-card-body>
                         <b-button variant="success"
-                            target="_blank"
                             :to="{ name: 'prizeList', params: { 'activity_id': this.$route.params.activity_id } }">主持人中獎名單</b-button>
                     </b-card-body>
                 </b-card>

+ 85 - 19
resources/js/src/views/lottery/CheckIn.vue

@@ -132,6 +132,27 @@ export default {
 				if (response.data.user) {
 					this.user = response.data.user;
 				} else {
+					const path = "/查無此人.mp3";
+					const audio = new Audio(path);
+					let variant = "warning";
+					var playPromise = audio.play();
+					if (playPromise !== undefined) {
+						playPromise.then(_ => {
+							this.$toast({
+								component: ToastificationContent,
+								props: {
+									title: '查無此人',
+									icon: 'CheckCircleIcon',
+									text: this.user.user_id + '查無此人!',
+									variant,
+								},
+							})
+							this.user.is_checked_in = 1;
+						})
+							.catch(error => {
+								console.log(`playSound error: ${error}`);
+							});
+					}
 					this.user = { name: "查無此人", user_id: " ", department: " ", children_count: 0 };
 				}
 				this.input = "";
@@ -148,28 +169,73 @@ export default {
 
 			useJwt.postData('/api/check_in/update', { 'user_id': this.user.user_id }).then(response => {
 				console.log(response.data)
-				this.$toast({
-					component: ToastificationContent,
-					props: {
-						title: '報到成功',
-						icon: 'CheckCircleIcon',
-						text: this.user.user_id + '報到成功!',
-						variant,
-					},
-				})
-				this.user.is_checked_in = 1;
+				if (response.data == 1) {
+					const path = "/報到成功.mp3";
+					const audio = new Audio(path);
+					var playPromise = audio.play();
+					if (playPromise !== undefined) {
+						playPromise.then(_ => {
+							this.$toast({
+								component: ToastificationContent,
+								props: {
+									title: '報到成功',
+									icon: 'CheckCircleIcon',
+									text: this.user.user_id + '報到成功!',
+									variant,
+								},
+							})
+							this.user.is_checked_in = 1;
+						})
+							.catch(error => {
+								console.log(`playSound error: ${error}`);
+							});
+					}
+				} else {
+					const path = "/查無此人.mp3";
+					const audio = new Audio(path);
+					variant = "warning";
+					var playPromise = audio.play();
+					if (playPromise !== undefined) {
+						playPromise.then(_ => {
+							this.$toast({
+								component: ToastificationContent,
+								props: {
+									title: '查無此人',
+									icon: 'CheckCircleIcon',
+									text: this.user.user_id + '查無此人!',
+									variant,
+								},
+							})
+							this.user.is_checked_in = 1;
+						})
+							.catch(error => {
+								console.log(`playSound error: ${error}`);
+							});
+					}
+				}
 			}).catch(error => {
 				console.log(error)
 				variant = 'danger'
-				this.$toast({
-					component: ToastificationContent,
-					props: {
-						title: '報到失敗',
-						icon: 'CheckCircleIcon',
-						text: '報到失敗! 原因: ' + error,
-						variant,
-					},
-				})
+				const path = "/報到失敗.mp3";
+				const audio = new Audio(path);
+				var playPromise = audio.play();
+				if (playPromise !== undefined) {
+					playPromise.then(_ => {
+						this.$toast({
+							component: ToastificationContent,
+							props: {
+								title: '報到失敗',
+								icon: 'CheckCircleIcon',
+								text: '報到失敗! 原因: ' + error,
+								variant,
+							},
+						})
+					})
+						.catch(error => {
+							console.log(`playSound error: ${error}`);
+						});
+				}
+
 			});
 
 

+ 0 - 3
resources/js/src/views/lottery/PrizeList.vue

@@ -93,9 +93,6 @@ export default {
         console.log("error: " + error);
       });
     },
-    padEnd(string) {
-      string.padEnd(6, " ");
-    },
     prizeBadge(item) {
       if (item.alias == '來賓') {
         return item.alias.padEnd(6, " ") + " " + item.name.padEnd(7, " ")

+ 11 - 45
resources/js/src/views/lottery/playPrizeList.vue

@@ -21,20 +21,17 @@
       <b-row v-if="prizeList1.length > 0">
         <b-col style=" margin-right: 0rem; margin-left: 0rem;">
           <div class="prize-list" :key="index" v-for="(item, index) in prizeList1">
-            <b-badge pill :variant="isClaim(item.is_claimed)">{{ item.alias.padEnd(6, " ") + " " + item.user_id + " " +
-              item.name.padEnd(4, " ") }}</b-badge>
+            <b-badge pill :variant="isClaim(item.is_claimed)">{{ prizeBadge(item) }}</b-badge>
           </div>
         </b-col>
         <b-col style=" margin-right: 0rem; margin-left: 0rem;">
           <div class="prize-list" :key="index" v-for="(item, index) in prizeList2">
-            <b-badge pill :variant="isClaim(item.is_claimed)">{{ item.alias.padEnd(6, " ") + " " + item.user_id + " " +
-              item.name.padEnd(4, " ") }}</b-badge>
+            <b-badge pill :variant="isClaim(item.is_claimed)">{{ prizeBadge(item) }}</b-badge>
           </div>
         </b-col>
         <b-col style=" margin-right: 0rem; margin-left: 0rem;">
           <div class="prize-list" :key="index" v-for="(item, index) in prizeList3">
-            <b-badge pill :variant="isClaim(item.is_claimed)">{{ item.alias.padEnd(6, " ") + " " + item.user_id + " " +
-              item.name.padEnd(4, " ") }}</b-badge>
+            <b-badge pill :variant="isClaim(item.is_claimed)">{{ prizeBadge(item) }}</b-badge>
           </div>
 
         </b-col>
@@ -82,7 +79,7 @@ export default {
       variant: 'danger',
       value: 0,
       timer: null,
-      isPause: false,
+      isPause: true,
       delayTimer: 150,
     }
   },
@@ -129,6 +126,7 @@ export default {
     },
     getPrizeList(prize_id,direction) {
       useJwt.postData('/api/recipient/indexByPrize', { prize_id: prize_id }).then(response => {
+        console.log(response.data)
         this.prizeList = response.data.list;
         this.pageMax = Math.ceil(this.prizeList.length / 33);
         this.page = direction == 1 ? 1 : this.pageMax;
@@ -186,46 +184,14 @@ export default {
     },
     isClaim(status) {
       return status == 1 ? 'success' : 'danger';
-    },
-    toggleFullscreen(ref) {
-      const elem = this.$refs[ref];
-      const isFullscreen = document.fullscreenElement !== null;
-
-      if (isFullscreen) {
-        this.closeFullscreen();
+    },   
+    prizeBadge(item) {
+      if (item.alias == '來賓') {
+        return item.alias.padEnd(6, " ") + " " + item.name.padEnd(7, " ")
       } else {
-        this.openFullscreen(elem);
-      }
-    },
-    openFullscreen(elem) {
-      if (elem.requestFullscreen) {
-        elem.requestFullscreen();
-      } else if (elem.mozRequestFullScreen) {
-        /* Firefox */
-        elem.mozRequestFullScreen();
-      } else if (elem.webkitRequestFullscreen) {
-        /* Chrome, Safari and Opera */
-        elem.webkitRequestFullscreen();
-      } else if (elem.msRequestFullscreen) {
-        /* IE/Edge */
-        elem.msRequestFullscreen();
-      }
-    },
-    closeFullscreen() {
-      if (document.exitFullscreen) {
-        document.exitFullscreen();
-      } else if (document.mozCancelFullScreen) {
-        /* Firefox */
-        document.mozCancelFullScreen();
-      } else if (document.webkitExitFullscreen) {
-        /* Chrome, Safari and Opera */
-        document.webkitExitFullscreen();
-      } else if (document.msExitFullscreen) {
-        /* IE/Edge */
-        document.msExitFullscreen();
+        return item.alias.padEnd(6, " ") + " " + item.user_id + " " +
+          item.name.padEnd(4, " ");
       }
-    }, padEnd(string) {
-      string.padEnd(6, " ");
     },
     pauseSwitch() {
       this.isPause = !this.isPause;