From 448f88a77ef1341eda508ac5c0f30c9b6d99f056 Mon Sep 17 00:00:00 2001 From: kron Date: Sun, 15 Jun 2025 15:53:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 20 ---- src/apis.js | 5 +- src/components/AppFooter.vue | 14 +-- src/components/BowData.vue | 109 +++++++++++++++++++ src/components/BowTarget.vue | 10 +- src/components/Container.vue | 2 +- src/components/Header.vue | 4 +- src/components/SButton.vue | 6 +- src/components/ScorePanel.vue | 8 +- src/components/ScoreResult.vue | 9 +- src/components/Signin.vue | 185 +++++++++++++++++++++++++++++++++ src/components/Swiper.vue | 2 +- src/components/UserItem.vue | 6 +- src/manifest.json | 6 +- src/pages/first-try.vue | 8 +- src/pages/index.vue | 135 ++++-------------------- src/pages/melee-match.vue | 12 ++- src/pages/my-growth.vue | 20 +++- src/pages/practise-one.vue | 15 ++- src/pages/practise-two.vue | 10 +- src/pages/team-match.vue | 16 ++- 21 files changed, 424 insertions(+), 178 deletions(-) create mode 100644 src/components/BowData.vue create mode 100644 src/components/Signin.vue diff --git a/src/App.vue b/src/App.vue index 3ecba08..b5db4a8 100644 --- a/src/App.vue +++ b/src/App.vue @@ -39,32 +39,12 @@ button { line-height: 1; outline: none; box-sizing: border-box; - -webkit-tap-highlight-color: transparent; /* 添加这行,去除点击高亮 */ } button::after { border: none; } -/* 修改点击态样式 */ -button:active { - border: none; - background: none !important; /* 添加 !important 确保覆盖默认样式 */ - opacity: 1 !important; /* 防止透明度变化 */ -} - -/* 去除按钮的默认边框和点击效果 */ -button[plain] { - border: none; - background: none !important; -} - -/* 去除点击态的所有效果 */ -button:hover, -button.hover { - background: none !important; -} - .guide-tips { display: flex; flex-direction: column; diff --git a/src/apis.js b/src/apis.js index 1e70183..210f24c 100644 --- a/src/apis.js +++ b/src/apis.js @@ -72,6 +72,10 @@ export const createPractiseAPI = (arrows) => { }); }; +export const getPractiseAPI = (id) => { + return request("GET", `/user/practice/get?id=${id}`); +}; + export const createRoomAPI = (gameType, teamSize) => { return request("POST", "/user/createroom", { gameType, @@ -207,6 +211,5 @@ export const getBattleListAPI = async (page, battleType) => { .sort((a, b) => b.totalScore - a.totalScore), }); }); - console.log(1111, result); return data; }; diff --git a/src/components/AppFooter.vue b/src/components/AppFooter.vue index 88fe31c..120d0f5 100644 --- a/src/components/AppFooter.vue +++ b/src/components/AppFooter.vue @@ -4,6 +4,13 @@ import { storeToRefs } from "pinia"; const store = useStore(); const { user } = storeToRefs(store); +const props = defineProps({ + signin: { + type: Function, + default: () => {}, + }, +}); + const tabs = [ { image: "../static/tab-vip.png" }, { image: "../static/tab-grow.png" }, @@ -11,12 +18,7 @@ const tabs = [ ]; function handleTabClick(index) { - if (!user.value.id) { - return uni.showToast({ - title: "还未登录", - icon: "none", - }); - } + if (!user.value.id) return props.signin(); if (index === 1) { uni.navigateTo({ url: "/pages/my-growth", diff --git a/src/components/BowData.vue b/src/components/BowData.vue new file mode 100644 index 0000000..34ec99e --- /dev/null +++ b/src/components/BowData.vue @@ -0,0 +1,109 @@ + + + + + diff --git a/src/components/BowTarget.vue b/src/components/BowTarget.vue index c583cc0..08bb0ae 100644 --- a/src/components/BowTarget.vue +++ b/src/components/BowTarget.vue @@ -41,16 +41,20 @@ const props = defineProps({ }); const showRoundTips = ref(false); +const showLatestArrow = ref(false); +const prevLength = ref(0); watch( () => props.scores, (newVal) => { - if (newVal.length > 0) { + if (newVal.length - prevLength.value === 1) { showRoundTips.value = true; + showLatestArrow.value = true; setTimeout(() => { showRoundTips.value = false; - }, 2000); + }, 1000); } + prevLength.value = newVal.length; }, { deep: true, @@ -93,7 +97,7 @@ function calcRealY(num) { v-for="(bow, index) in scores" :key="index" :src=" - index === scores.length - 1 && !blueScores.length + index === scores.length - 1 && !blueScores.length && showLatestArrow ? '../static/hit-icon-green.png' : '../static/hit-icon.png' " diff --git a/src/components/Container.vue b/src/components/Container.vue index ba7b84a..0ce4d82 100644 --- a/src/components/Container.vue +++ b/src/components/Container.vue @@ -26,7 +26,7 @@ defineProps({ diff --git a/src/components/Swiper.vue b/src/components/Swiper.vue index 6cce7db..671bbae 100644 --- a/src/components/Swiper.vue +++ b/src/components/Swiper.vue @@ -69,7 +69,7 @@ const handleChange = (e) => { .dots { position: absolute; - bottom: 12%; + bottom: 14%; left: 50%; transform: translateX(-50%); display: flex; diff --git a/src/components/UserItem.vue b/src/components/UserItem.vue index a54c1de..49aba96 100644 --- a/src/components/UserItem.vue +++ b/src/components/UserItem.vue @@ -20,13 +20,13 @@ defineProps({ diff --git a/src/manifest.json b/src/manifest.json index 78df3e2..aa432b2 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -61,11 +61,7 @@ "usingComponents": true, "darkmode": true, "themeLocation": "theme.json", - "permission": { - "scope.userInfo": { - "desc": "用于完善用户资料" - } - }, + "permission": {}, "requiredPrivateInfos": ["getLocation", "chooseLocation"] } } diff --git a/src/pages/first-try.vue b/src/pages/first-try.vue index 2587fa5..1da48e1 100644 --- a/src/pages/first-try.vue +++ b/src/pages/first-try.vue @@ -192,9 +192,11 @@ const onClose = () => { :result="practiseResult" /> - {{ - stepButtonTexts[step] - }} + + {{ + stepButtonTexts[step] + }} + diff --git a/src/pages/index.vue b/src/pages/index.vue index 155f968..e97af44 100644 --- a/src/pages/index.vue +++ b/src/pages/index.vue @@ -4,69 +4,15 @@ import AppFooter from "@/components/AppFooter.vue"; import AppBackground from "@/components/AppBackground.vue"; import UserHeader from "@/components/UserHeader.vue"; import SModal from "@/components/SModal.vue"; -import SButton from "@/components/SButton.vue"; -import { getAppConfig, getHomeData, getMyDevicesAPI, loginAPI } from "@/apis"; +import Signin from "@/components/Signin.vue"; +import { getAppConfig, getHomeData, getMyDevicesAPI } from "@/apis"; import useStore from "@/store"; - import { storeToRefs } from "pinia"; const store = useStore(); const { updateConfig, updateUser, updateDevice } = store; // 使用storeToRefs,用于UI里显示,保持响应性 const { user } = storeToRefs(store); const showModal = ref(false); -const agree = ref(false); - -const getDevice = async () => { - const devices = await getMyDevicesAPI(); - if (devices.bindings.length) { - updateDevice(devices.bindings[0].deviceId, devices.bindings[0].deviceName); - } -}; - -const handleAgree = () => { - agree.value = !agree.value; -}; -const handleLogin = () => { - if (!agree.value) { - return uni.showToast({ - title: "请先同意协议", - icon: "none", - }); - } - - // 先调用wx.getUserProfile获取用户信息 - wx.getUserProfile({ - desc: "用于完善用户资料", // 声明获取用户个人信息后的用途 - success: (res) => { - const { nickName, avatarUrl } = res.userInfo; - // 再获取登录凭证 - uni.login({ - provider: "weixin", - success: async (loginRes) => { - const { code } = loginRes; - const result = await loginAPI(nickName, avatarUrl, code); - updateUser({ ...result.user, nickName, avatarUrl }); - await getDevice(); - showModal.value = false; - }, - fail: (err) => { - uni.showToast({ - title: "登录失败", - icon: "none", - }); - console.error("登录失败:", err); - }, - }); - }, - fail: (err) => { - console.log("获取用户信息失败:", err); - uni.showToast({ - title: "获取用户信息失败", - icon: "none", - }); - }, - }); -}; const toPage = (path) => { if (!user.value.id) { @@ -86,7 +32,13 @@ onMounted(async () => { const result = await getHomeData(); if (result.user) { updateUser(result.user); - await getDevice(); + const devices = await getMyDevicesAPI(); + if (devices.bindings.length) { + updateDevice( + devices.bindings[0].deviceId, + devices.bindings[0].deviceName + ); + } } console.log("首页数据:", result); } catch (error) { @@ -103,14 +55,11 @@ onMounted(async () => { - - 微信登录 + - @@ -204,38 +153,21 @@ onMounted(async () => { - diff --git a/src/pages/melee-match.vue b/src/pages/melee-match.vue index 55d349e..4a7ed1f 100644 --- a/src/pages/melee-match.vue +++ b/src/pages/melee-match.vue @@ -115,7 +115,7 @@ onUnmounted(() => { diff --git a/src/pages/my-growth.vue b/src/pages/my-growth.vue index 81fc787..9c68a59 100644 --- a/src/pages/my-growth.vue +++ b/src/pages/my-growth.vue @@ -2,7 +2,12 @@ import { onMounted } from "vue"; import Container from "@/components/Container.vue"; import Avatar from "@/components/Avatar.vue"; -import { getBattleListAPI, getPractiseResultListAPI } from "@/apis"; +import BowData from "@/components/BowData.vue"; +import { + getBattleListAPI, + getPractiseResultListAPI, + getPractiseAPI, +} from "@/apis"; import { ref } from "vue"; @@ -12,6 +17,8 @@ const matchList = ref([]); const battlePage = ref(1); const battleList = ref([]); const practiseList = ref([]); +const showBowData = ref(false); +const arrows = ref([]); const handleSelect = async (index) => { if (index === 0 && matchList.value.length === 0) { @@ -36,6 +43,11 @@ const toMatchDetail = (id) => { url: `/pages/match-detail?id=${id}`, }); }; +const getPractiseDetail = async (id) => { + const result = await getPractiseAPI(id); + arrows.value = JSON.parse(result.UserPracticeRound.arrows); + showBowData.value = true; +}; onMounted(async () => { const result = await getBattleListAPI(matchPage.value, 2); matchList.value = result; @@ -154,12 +166,18 @@ onMounted(async () => { v-for="(item, index) in practiseList" :key="index" class="practice-record" + @click="() => getPractiseDetail(item.id)" > 单组练习 {{ item.createdAt }} + diff --git a/src/pages/practise-one.vue b/src/pages/practise-one.vue index 2f31a31..e596ddb 100644 --- a/src/pages/practise-one.vue +++ b/src/pages/practise-one.vue @@ -8,6 +8,10 @@ import ScoreResult from "@/components/ScoreResult.vue"; import SButton from "@/components/SButton.vue"; import { createPractiseAPI } from "@/apis"; import { MESSAGETYPES, roundsName } from "@/constants"; +import useStore from "@/store"; +import { storeToRefs } from "pinia"; +const store = useStore(); +const { user } = storeToRefs(store); const start = ref(false); const showScore = ref(false); const scores = ref([]); @@ -18,12 +22,13 @@ const power = ref(0); const onReady = async () => { await createPractiseAPI(total); start.value = true; + scores.value = []; }; async function onReceiveMessage(content) { const messages = JSON.parse(content).data.updates || []; messages.forEach((msg) => { - if (start.value && msg.constructor === MESSAGETYPES.ShootSyncMeArrowID) { + if (msg.constructor === MESSAGETYPES.ShootSyncMeArrowID) { scores.value.push(msg.target); power.value = msg.target.battery; if (scores.value.length === total) { @@ -67,8 +72,8 @@ onUnmounted(() => { /> @@ -81,7 +86,9 @@ onUnmounted(() => { :result="practiseResult" /> - 准备好了,直接开始 + + 准备好了,直接开始 + diff --git a/src/pages/practise-two.vue b/src/pages/practise-two.vue index 9adf448..9442946 100644 --- a/src/pages/practise-two.vue +++ b/src/pages/practise-two.vue @@ -8,6 +8,10 @@ import ScoreResult from "@/components/ScoreResult.vue"; import SButton from "@/components/SButton.vue"; import { createPractiseAPI } from "@/apis"; import { MESSAGETYPES } from "@/constants"; +import useStore from "@/store"; +import { storeToRefs } from "pinia"; +const store = useStore(); +const { user } = storeToRefs(store); const start = ref(false); const showScore = ref(false); const scores = ref([]); @@ -59,7 +63,7 @@ onUnmounted(() => { @@ -77,7 +81,9 @@ onUnmounted(() => { :result="practiseResult" /> - 准备好了,直接开始 + + 准备好了,直接开始 + diff --git a/src/pages/team-match.vue b/src/pages/team-match.vue index 684cf2d..d0972d4 100644 --- a/src/pages/team-match.vue +++ b/src/pages/team-match.vue @@ -141,7 +141,11 @@ onUnmounted(() => {