liyongli 5 bulan lalu
induk
melakukan
c8a8009904
1 mengubah file dengan 17 tambahan dan 20 penghapusan
  1. 17 20
      src/view/finance2024/index.vue

+ 17 - 20
src/view/finance2024/index.vue

@@ -175,13 +175,8 @@ audio.oncanplay = () => {
 audio.onplaying = () => (play_stats.value = !audio.paused);
 audio.onpause = () => (play_stats.value = !audio.paused);
 const play = () => {
-  if (audio.paused) {
-    // 播放
-    audio.play();
-  } else {
-    // 暂停
-    audio.pause();
-  }
+  if (audio.paused) audio.play(); // 播放
+  else audio.pause(); // 暂停
 };
 
 const init = () => {
@@ -193,8 +188,8 @@ const init = () => {
 const look_more = ref(false);
 
 const createhb = () => {
-    if (img_local.value) showImagePreview([localStorage.getItem('hb20241022')]);
-    else show.value = true;
+  if (img_local.value) showImagePreview([localStorage.getItem('hb20241022')]);
+  else show.value = true;
 };
 
 const canvas_init = (uname, num) => {
@@ -205,21 +200,23 @@ const canvas_init = (uname, num) => {
     img.src = 'https://cxzx.smcic.net/topic/tool/img/hb2024.png';
     if (!d2) d2 = canvas.getContext('2d');
     img.onload = () => {
-      d2.drawImage(img, 0, 0, 750, 2500);
-      let line1 = [140, 2380];
-
+      d2.drawImage(img, 0, 0, canvas.width, canvas.height);
+      let line1 = 2380;
       d2.font = '50px ZhangqingpingXingkai';
       d2.fillStyle = '#000000';
       d2.fillText(uname, 700 - d2.measureText(uname).width, 2340);
-
       d2.font = '30px ZhangqingpingXingkai';
       const fontWidth30 = d2.measureText('第').width;
       const fontWidth50 = d2.measureText(num).width;
-      d2.fillText('个参与本次活动的人', 700 - fontWidth30 * 9, line1[1]);
-      d2.fillText('第',  700 - fontWidth50 - fontWidth30 * 9 - d2.measureText('第').width, line1[1]);
+      d2.fillText('个参与本次活动的人', 700 - fontWidth30 * 9, line1);
+      d2.fillText(
+        '第',
+        700 - fontWidth50 - fontWidth30 * 9 - d2.measureText('第').width,
+        line1
+      );
       d2.fillStyle = '#fb0301';
-      d2.fillText(num, 700 - fontWidth50 - fontWidth30 * 9, line1[1]);
-
+      d2.font = '50px ZhangqingpingXingkai';
+      d2.fillText(num, 700 - fontWidth50 - fontWidth30 * 9, line1);
       resolve();
     };
   });
@@ -227,9 +224,9 @@ const canvas_init = (uname, num) => {
 
 const onSubmit = e => {
   if (e === 'cancel') return true;
-  if (username.value.length > 10) return showToast('姓名字数不得超过5个');
-  if (!username.value) {
-    showToast('请输入姓名');
+  // 正则规避  姓名只能是汉字 数量不能超过5个
+  if (!/^[\u4e00-\u9fa5]{2,5}$/.test(username.value)) {
+    showToast('姓名必须是汉字');
     return false;
   }
   saveUser({