liyongli 2 жил өмнө
parent
commit
53452b85be

+ 26 - 17
src/view/WorldCup/components/match.vue

@@ -52,19 +52,14 @@
     </div>
     <br />
     <div style="padding: 0 10vw" v-if="!isWin">
-      <van-button
-        round
-        type="primary"
-        block
-        @click="upData"
-        color="#c11616"
+      <van-button round type="primary" block @click="upData" color="#c11616"
         >完成预测</van-button
       >
     </div>
   </div>
 </template>
 <script setup>
-import { ref, reactive, inject,defineEmits } from "vue";
+import { ref, reactive, inject, defineEmits } from "vue";
 import { Toast } from "vant";
 import { forecast } from "@/api/worldCup.js";
 // import { onMounted, reactive } from "vue";
@@ -79,7 +74,7 @@ const availWidth = inject("availWidth");
 const maxcol = inject("maxcol");
 const team = inject("team");
 const user = inject("user");
-const emits = defineEmits(["upWay"]);
+const emits = defineEmits(["upWay", "toLogin"]);
 const width = ref(availWidth - 4);
 const flag = reactive([]);
 const line = reactive([]);
@@ -185,8 +180,15 @@ function line3(x, textY, col, colWidth) {
 
 function selectFlag(index) {
   const select = flag[index];
-  if (select[2] == 4 || select[4].text === '?' || select[6].isED || select[6].isForeast) return;
-  const linkSelect = flag[select[3] % 2 === 0 ? index + 1 : index - 1] || undefined;
+  if (
+    select[2] == 4 ||
+    select[4].text === "?" ||
+    select[6].isED ||
+    select[6].isForeast
+  )
+    return;
+  const linkSelect =
+    flag[select[3] % 2 === 0 ? index + 1 : index - 1] || undefined;
   const startRow = select[2]; // 行数
   const startCol = select[3]; // 点击列数
   const isDown = startRow < 4 ? 1 : -1; // 递增系数
@@ -215,7 +217,7 @@ function selectFlag(index) {
     return;
   }
   // 多行已经选择
-  if(flag[coordinate[len - 1].indexNum][4].text == '?') len--;
+  if (flag[coordinate[len - 1].indexNum][4].text == "?") len--;
   for (let i = 0; i < len; i++) {
     if (
       !linkSelect ||
@@ -228,6 +230,11 @@ function selectFlag(index) {
 }
 
 function upData() {
+  if (!user.phone) return emits("toLogin", upDataOri);
+  upDataOri();
+}
+
+function upDataOri() {
   const objFlag = [];
   for (let i = 0; i < flag.length; i++) {
     const v = flag[i];
@@ -243,12 +250,14 @@ function upData() {
     phone: user.phone,
     nickName: user.name,
     preRaceItems: objFlag,
-  }).then(() => {
-    Toast("预测成功!");
-    emits("upWay");
-  }).catch(()=>{
-    emits("upWay");
-  });
+  })
+    .then(() => {
+      Toast("预测成功!");
+      emits("upWay");
+    })
+    .catch(() => {
+      emits("upWay");
+    });
 }
 </script>
 <style lang="scss" scoped>