liufumingren 8f1a8b7ddb feat(miniprogram): 新增 uni-app + Vue3 + TS 微信小程序
- 登录:微信一键登录(code2Session)+ 账号登录双 tab;个人中心为整页登录,其它页走抽屉
- 协议:登录前必须阅读并同意,版本号随登录上报落库
- 不强制登录:启动不弹窗,点功能或遇到 401 才提示(符合小程序审核)
- 页面:首页统计 / 扫码记录 / 个人中心;H5 预览端口 7304

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-21 00:47:16 +08:00

120 lines
2.6 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script setup lang="ts">
/**
* 登录底部抽屉:需要登录时就地弹出,登录完留在当前页
*
* 用法:tab 页面引一次 `<login-drawer />`,状态由 `composables/useLoginDrawer.ts` 共享。
* 打开时隐藏原生 tabBar(否则遮罩盖不住底部 tab),关闭时再显示。
* 表单与协议逻辑都在 `LoginPanel`(与页面版登录共用)。
*/
import { watch } from 'vue';
import LoginPanel from '@/components/LoginPanel.vue';
import {
closeLoginDrawer,
loginDrawerVisible,
} from '@/composables/useLoginDrawer';
function syncTabBar(open: boolean) {
if (open) uni.hideTabBar({ animation: false, fail: () => {} });
else uni.showTabBar({ animation: false, fail: () => {} });
}
watch(loginDrawerVisible, syncTabBar, { immediate: true });
</script>
<template>
<view class="login-drawer-root" :class="{ 'is-open': loginDrawerVisible }">
<view class="login-drawer-mask" @click="closeLoginDrawer" />
<view class="login-drawer">
<view class="login-drawer__handle" />
<view class="login-drawer__head">
<view>
<view class="login-drawer__title">登录</view>
<view class="login-drawer__sub">登录后查看设备与扫码记录</view>
</view>
</view>
<login-panel
:active="loginDrawerVisible"
show-cancel
@success="closeLoginDrawer"
@cancel="closeLoginDrawer"
/>
</view>
</view>
</template>
<style scoped>
.login-drawer-root {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 999;
visibility: hidden;
pointer-events: none;
}
.login-drawer-root.is-open {
visibility: visible;
pointer-events: auto;
}
.login-drawer-mask {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(15, 23, 42, 0.45);
opacity: 0;
transition: opacity 0.22s ease;
}
.login-drawer-root.is-open .login-drawer-mask {
opacity: 1;
}
.login-drawer {
position: absolute;
left: 0;
right: 0;
bottom: 0;
background: #fff;
border-radius: 28rpx 28rpx 0 0;
padding: 16rpx 40rpx calc(32rpx + env(safe-area-inset-bottom));
box-shadow: 0 -8rpx 40rpx rgba(15, 23, 42, 0.12);
transform: translateY(100%);
transition: transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.login-drawer-root.is-open .login-drawer {
transform: translateY(0);
}
.login-drawer__handle {
width: 72rpx;
height: 8rpx;
margin: 0 auto 24rpx;
border-radius: 999rpx;
background: #e2e6ee;
}
.login-drawer__head {
margin-bottom: 28rpx;
}
.login-drawer__title {
font-size: 38rpx;
font-weight: 600;
}
.login-drawer__sub {
margin-top: 4rpx;
color: var(--text-muted);
font-size: 24rpx;
}
</style>