再次优化了登陆注册界面与跳转逻辑

This commit is contained in:
yml
2026-05-22 23:52:15 +08:00
parent b68411166d
commit 94edda9710
6 changed files with 473 additions and 593 deletions
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed, ref } from "vue";
import { computed, onMounted, ref } from "vue";
import { useRouter, useRoute } from "vue-router";
import { useSessionStore } from "@/stores/session";
import { showDialog, showToast } from "vant";
@@ -88,6 +88,13 @@ function isNavActive(path: string) {
}
const isLoggedIn = computed(() => Boolean(session.token));
onMounted(() => {
if (!isLoggedIn.value) {
router.replace({ path: "/m/login", query: { redirect: route.fullPath } });
}
});
const displayName = computed(() =>
session.phone
? `用户${session.phone.slice(-6)}`
@@ -99,39 +106,12 @@ const maskedPhone = computed(() =>
? `${session.phone.slice(0, 3)}****${session.phone.slice(-4)}`
: "登录后查看手机号"
);
function goToLogin() {
router.push("/m/login");
}
</script>
<template>
<main class="mobile-profile-shell">
<!-- 未登录区 - 自定义卡片布局 -->
<template v-if="!isLoggedIn">
<section class="guest-card">
<div class="guest-logo"></div>
<h1>登录大锤商行</h1>
<p>登录后查看订单管理发布提现余额并享受平台担保交易服务</p>
<van-button
type="primary"
block
round
class="guest-login-btn"
@click="goToLogin"
>
立即登录
</van-button>
<div class="guest-benefits">
<van-tag type="primary" plain size="medium" round>担保交易</van-tag>
<van-tag type="primary" plain size="medium" round>订单留痕</van-tag>
<van-tag type="primary" plain size="medium" round>安全交接</van-tag>
</div>
</section>
</template>
<!-- 已登录区 -->
<template v-else>
<template v-if="isLoggedIn">
<!-- Hero 顶部蓝色横幅 -->
<section class="profile-hero">
<div class="hero-bg"></div>
@@ -267,64 +247,6 @@ function goToLogin() {
padding: 0 0 60px;
}
/* ========== 未登录区 - 自定义卡片 ========== */
.guest-card {
text-align: center;
padding: 34px 26px;
margin: 12px;
border-radius: 16px;
background: #fff;
box-shadow: 0 8px 26px rgba(24, 30, 45, 0.06);
}
.guest-card h1 {
margin: 18px 0 0;
font-size: 22px;
font-weight: 900;
color: #1a202c;
}
.guest-card p {
margin: 10px 0 0;
font-size: 14px;
color: #667386;
line-height: 1.7;
}
.guest-logo {
display: grid;
width: 74px;
height: 74px;
margin: 0 auto;
place-items: center;
border-radius: 22px;
background: #1477ff;
color: #fff;
font-size: 30px;
font-weight: 900;
}
.guest-login-btn {
margin-top: 20px;
border-radius: 13px;
background: #1477ff;
border-color: transparent;
font-size: 16px;
font-weight: 900;
height: 48px;
}
.guest-benefits {
display: flex;
justify-content: center;
gap: 8px;
margin-top: 16px;
}
.guest-benefits :deep(.van-tag) {
font-weight: 800;
}
/* ========== 已登录区 - Hero蓝色横幅 ========== */
.profile-hero {
position: relative;