From 7b075b01a09618afa8a5ccd6939fec6639e6c1db Mon Sep 17 00:00:00 2001
From: maochaoying <925670706@qq.com>
Date: Fri, 22 Sep 2023 11:10:43 +0800
Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E9=99=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/Tabs.vue | 15 +++++++++++---
src/components/modals/LoginModal.vue | 39 +++++++++++++++++++++++++++++++++---
src/main.js | 3 ++-
src/store/modules/tab.js | 4 ++++
4 files changed, 54 insertions(+), 7 deletions(-)
diff --git a/src/components/Tabs.vue b/src/components/Tabs.vue
index 34e9c10..d3648c9 100644
--- a/src/components/Tabs.vue
+++ b/src/components/Tabs.vue
@@ -88,7 +88,7 @@
v-if="ejectModalVisible"
:handleModalVisible="handleModalVisible"
/>
-
+
@@ -103,6 +103,11 @@ const router = useRouter()
const tabStore = useTabStore()
const ejectModalVisible = ref(false)
+const loginVisible = ref(false)
+
+const handleLoginVisible = () => {
+ loginVisible.value = false
+}
const handleModalVisible = () => {
ejectModalVisible.value = false
@@ -115,8 +120,12 @@ const changeTab = index => {
tabStore.updatePreActiveTab(1)
}
if (index == 2) {
- router.push('/test')
- tabStore.updatePreActiveTab(2)
+ if (tabStore.isLogin) {
+ tabStore.updatePreActiveTab(2)
+ router.push('/test')
+ } else {
+ loginVisible.value = true
+ }
}
if (index == 3) {
ejectModalVisible.value = true
diff --git a/src/components/modals/LoginModal.vue b/src/components/modals/LoginModal.vue
index 150506e..ac23c83 100644
--- a/src/components/modals/LoginModal.vue
+++ b/src/components/modals/LoginModal.vue
@@ -3,7 +3,7 @@
@@ -40,11 +40,44 @@
import Close from '@/assets/img/close.png'
import Eye from '@/assets/img/eye.png'
import CloseEye from '@/assets/img/close_eye.png'
+import { useTabStore } from '@/store'
import { ref } from 'vue'
+import { showSuccessToast, showFailToast } from 'vant'
+import { useRouter } from 'vue-router'
+const tabStore = useTabStore()
+const router = useRouter()
const inputType = ref(false)
const password = ref('')
const show = ref(false)
+
+const props = defineProps({
+ handleModalVisible: {
+ type: Function,
+ },
+})
+
+const handleCancel = () => {
+ props.handleModalVisible()
+ // 将底部tab高亮至操作
+ tabStore.updateActiveTab(1)
+}
+
+const handleLogin = () => {
+ const val = password.value
+ if (val == '9527') {
+ // 登陆成功
+ showSuccessToast('登陆成功')
+ tabStore.updateIsLogin(true)
+ tabStore.updatePreActiveTab(2)
+ props.handleModalVisible()
+ router.push('/test')
+ } else {
+ // 登陆失败
+ showFailToast('登陆失败')
+ tabStore.updateIsLogin(false)
+ }
+}