diff --git a/src/App.vue b/src/App.vue index 381e880..d57fcee 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,16 +1,15 @@ @@ -19,15 +18,4 @@ page { min-height: 100vh; background-color: #f5f5f5; } - -.container { - padding: 30rpx; - box-sizing: border-box; -} - -.flex-center { - display: flex; - align-items: center; - justify-content: center; -} diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index fdccb37..3cc8c28 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -1,77 +1,36 @@ diff --git a/src/pages/login/login.vue b/src/pages/login/login.vue index 2ea1a1f..029122c 100644 --- a/src/pages/login/login.vue +++ b/src/pages/login/login.vue @@ -1,38 +1,46 @@ @@ -44,27 +52,42 @@ import { showToast } from '../../utils' const userStore = useUserStore() const loading = ref(false) +const showFallback = ref(false) const form = reactive({ username: '', password: '' }) -async function handleLogin() { +/** 微信一键登录 */ +async function handleWxLogin() { + loading.value = true + try { + await userStore.wxLogin() + showToast('登录成功', 'success') + setTimeout(() => { + uni.switchTab({ url: '/packages/user/pages/index/index' }) + }, 1000) + } catch (err: any) { + console.error('微信登录失败:', err) + showToast(err.message || '登录失败') + } finally { + loading.value = false + } +} + +/** 账号密码登录(降级方案 / H5 用) */ +async function handleFallbackLogin() { if (!form.username || !form.password) { showToast('请输入账号和密码') return } - loading.value = true try { - await userStore.login({ - username: form.username, - password: form.password - }) + await userStore.login({ username: form.username, password: form.password }) showToast('登录成功', 'success') setTimeout(() => { - uni.switchTab({ url: '/pages/profile/profile' }) + uni.switchTab({ url: '/packages/user/pages/index/index' }) }, 1000) } catch (err: any) { console.error('登录失败:', err) @@ -76,81 +99,129 @@ async function handleLogin() {