1
This commit is contained in:
parent
ac52c0f6b8
commit
7a486377ed
@ -1,16 +1,23 @@
|
||||
<template>
|
||||
<view class="sections">
|
||||
<view v-for="section in sections" :key="section.key" class="section">
|
||||
<view v-if="section.title" class="section__title">{{ section.title }}</view>
|
||||
<view v-if="section.title" class="section__head">
|
||||
<view class="section__bar"></view>
|
||||
<text class="section__title">{{ section.title }}</text>
|
||||
</view>
|
||||
<view class="grid">
|
||||
<view
|
||||
v-for="item in section.leaves"
|
||||
:key="item.key"
|
||||
class="grid__item"
|
||||
hover-class="grid__item--active"
|
||||
:hover-stay-time="80"
|
||||
@click="emit('select', item)"
|
||||
>
|
||||
<up-icon :name="item.icon || 'grid'" color="#2979ff" size="26"></up-icon>
|
||||
<text class="grid__item-text">{{ item.title }}</text>
|
||||
<view class="grid__icon">
|
||||
<up-icon :name="item.icon || 'grid'" color="#2979ff" size="26"></up-icon>
|
||||
</view>
|
||||
<text class="grid__text">{{ item.title }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -43,34 +50,69 @@ const emit = defineEmits<{ (e: 'select', leaf: EntryLeaf): void }>()
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.sections {
|
||||
padding-bottom: 8rpx;
|
||||
padding: 4rpx 0 8rpx;
|
||||
}
|
||||
|
||||
.section {
|
||||
&__head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 28rpx 32rpx 4rpx;
|
||||
}
|
||||
|
||||
/* 标题前的渐变小竖条:给每段一个视觉锚点,替代纯文字标题 */
|
||||
&__bar {
|
||||
width: 6rpx;
|
||||
height: 26rpx;
|
||||
margin-right: 14rpx;
|
||||
border-radius: 4rpx;
|
||||
background: linear-gradient(180deg, #2979ff 0%, #6aa8ff 100%);
|
||||
}
|
||||
|
||||
&__title {
|
||||
padding: 16rpx 32rpx 0;
|
||||
font-size: 26rpx;
|
||||
color: #909399;
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
}
|
||||
|
||||
.grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
padding: 8rpx 0 24rpx;
|
||||
padding: 8rpx 12rpx 24rpx;
|
||||
|
||||
&__item {
|
||||
width: 33.333%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 24rpx 0;
|
||||
padding: 20rpx 6rpx;
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
|
||||
&__item-text {
|
||||
margin-top: 12rpx;
|
||||
font-size: 26rpx;
|
||||
color: #606266;
|
||||
/* 点按反馈(hover-class 指向本类) */
|
||||
&__item--active {
|
||||
background-color: #f2f6ff;
|
||||
}
|
||||
|
||||
&__icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 92rpx;
|
||||
height: 92rpx;
|
||||
border-radius: 26rpx;
|
||||
background: linear-gradient(180deg, #eef4ff 0%, #e2ecff 100%);
|
||||
}
|
||||
|
||||
&__text {
|
||||
max-width: 100%;
|
||||
margin-top: 14rpx;
|
||||
font-size: 25rpx;
|
||||
color: #4b5563;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -1,16 +1,40 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<!-- 顶部欢迎区 -->
|
||||
<!-- 顶部欢迎区:按时间段问候 + 当前身份;未登录时给一个「登录」入口(用户主动点击触发) -->
|
||||
<view class="hero">
|
||||
<view class="hero__title">首页</view>
|
||||
<view class="hero__desc">{{ heroDesc }}</view>
|
||||
<!-- 装饰光斑(纯视觉,不参与交互) -->
|
||||
<view class="hero__deco hero__deco--lg"></view>
|
||||
<view class="hero__deco hero__deco--sm"></view>
|
||||
|
||||
<view class="hero__row">
|
||||
<view class="hero__text">
|
||||
<view class="hero__greeting">{{ greeting }}</view>
|
||||
<view class="hero__name">{{ heroName }}</view>
|
||||
<view class="hero__desc">{{ heroDesc }}</view>
|
||||
</view>
|
||||
|
||||
<!-- 未登录 → 就地弹登录抽屉(不跳页,符合「登录由用户主动触发」的约定) -->
|
||||
<view
|
||||
v-if="!isLogin"
|
||||
class="hero__login"
|
||||
hover-class="hero__login--active"
|
||||
:hover-stay-time="80"
|
||||
@click="goLogin"
|
||||
>
|
||||
<text class="hero__login-text">登录</text>
|
||||
<up-icon name="arrow-right" color="#ffffff" size="11"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 功能入口:本地「常用功能」列表 + 后端菜单分类段(两段形态一致,见 toHomeSections) -->
|
||||
<view class="card">
|
||||
<!-- 登录后菜单尚未取到时的加载态(避免闪一下空态文案) -->
|
||||
<view v-if="loading" class="loading">
|
||||
<up-loading-icon mode="circle" size="18" text="加载中"></up-loading-icon>
|
||||
<!-- 登录后菜单尚未取到时的骨架屏(避免闪一下空态文案,也比转圈更贴合最终布局) -->
|
||||
<view v-if="loading" class="skeleton">
|
||||
<view v-for="n in 6" :key="n" class="skeleton__item">
|
||||
<view class="skeleton__icon"></view>
|
||||
<view class="skeleton__text"></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 「常用功能」段(本地)+ 后端分类段(如「外仓商品」);重复的 key 会自动去重 -->
|
||||
@ -45,6 +69,9 @@
|
||||
</empty-state>
|
||||
</view>
|
||||
|
||||
<!-- 未登录:一句轻提示(不阻断浏览,只是说明登录后还能看到什么) -->
|
||||
<view v-if="!isLogin" class="tip">登录后可查看仓库 / 货主等业务功能</view>
|
||||
|
||||
<!-- 运行信息:用于确认各端编译正常 -->
|
||||
<!-- <view class="card">
|
||||
<view class="card__title">运行信息</view>
|
||||
@ -84,16 +111,31 @@ const userStore = useUserStore()
|
||||
const { isLogin, sections, loading, loadEntries, onEntry, goLogin, goMine, emptyStateProps } =
|
||||
useEntrySections('public')
|
||||
|
||||
/** 按时间段问候(头部第一行,比写死的「首页」更有温度) */
|
||||
const greeting = computed(() => {
|
||||
const hour = new Date().getHours()
|
||||
if (hour < 6) return '夜深了'
|
||||
if (hour < 12) return '早上好'
|
||||
if (hour < 14) return '中午好'
|
||||
if (hour < 18) return '下午好'
|
||||
return '晚上好'
|
||||
})
|
||||
|
||||
/** 头部主标题:登录后显示用户名,未登录显示欢迎语 */
|
||||
const heroName = computed(() => {
|
||||
if (!isLogin.value) return '欢迎使用 WMS'
|
||||
// 微信已登录但未绑定:优先展示用户自己设置的微信昵称
|
||||
if (userStore.isWechatUnbound) return userStore.wechatNickname || '微信用户'
|
||||
return userStore.userName || '已登录'
|
||||
})
|
||||
|
||||
/** 头部副标题:当前身份 / 登录状态摘要 */
|
||||
const heroDesc = computed(() => {
|
||||
if (!isLogin.value) return 'WMS 仓储管理 · 微信小程序端'
|
||||
if (!isLogin.value) return '仓储管理 · 微信小程序端'
|
||||
// 微信已登录但未绑定:别显示“已登录”这么含糊的文案
|
||||
if (userStore.isWechatUnbound) return '微信已登录 · 待绑定 WMS 账号'
|
||||
const parts = [
|
||||
userStore.userName,
|
||||
userStore.roleTypeLabel,
|
||||
userStore.currentEmployee?.store_name
|
||||
].filter(Boolean)
|
||||
return parts.length ? parts.join(' · ') : 'WMS 仓储管理 · 微信小程序端'
|
||||
const parts = [userStore.roleTypeLabel, userStore.currentEmployee?.store_name].filter(Boolean)
|
||||
return parts.length ? parts.join(' · ') : '仓储管理 · 微信小程序端'
|
||||
})
|
||||
|
||||
/* 空态文案、取数(loadEntries)、点击跳转(onEntry)均收口在 useEntrySections */
|
||||
@ -115,43 +157,155 @@ useEntryScene()
|
||||
padding-bottom: 24rpx;
|
||||
}
|
||||
|
||||
/* 顶部欢迎区:渐变蓝 + 下沿圆角,卡片上移叠压形成层次 */
|
||||
.hero {
|
||||
padding: 48rpx 32rpx 56rpx;
|
||||
background-color: #2979ff;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
padding: 44rpx 32rpx 100rpx;
|
||||
background: linear-gradient(135deg, #2979ff 0%, #4b93ff 100%);
|
||||
border-radius: 0 0 32rpx 32rpx;
|
||||
|
||||
&__title {
|
||||
&__deco {
|
||||
position: absolute;
|
||||
border-radius: 50%;
|
||||
background-color: rgba(255, 255, 255, 0.1);
|
||||
|
||||
&--lg {
|
||||
top: -140rpx;
|
||||
right: -80rpx;
|
||||
width: 300rpx;
|
||||
height: 300rpx;
|
||||
}
|
||||
|
||||
&--sm {
|
||||
bottom: -70rpx;
|
||||
left: -40rpx;
|
||||
width: 160rpx;
|
||||
height: 160rpx;
|
||||
background-color: rgba(255, 255, 255, 0.07);
|
||||
}
|
||||
}
|
||||
|
||||
&__row {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
&__text {
|
||||
flex: 1;
|
||||
/* 允许长用户名截断(flex 子项默认 min-width: auto 会撑破容器) */
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__greeting {
|
||||
font-size: 24rpx;
|
||||
color: rgba(255, 255, 255, 0.85);
|
||||
}
|
||||
|
||||
&__name {
|
||||
margin-top: 10rpx;
|
||||
font-size: 44rpx;
|
||||
font-weight: 600;
|
||||
color: #ffffff;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__desc {
|
||||
margin-top: 12rpx;
|
||||
margin-top: 10rpx;
|
||||
font-size: 26rpx;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
|
||||
/* 未登录时的胶囊登录入口 */
|
||||
&__login {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-left: 20rpx;
|
||||
padding: 12rpx 24rpx;
|
||||
border-radius: 999rpx;
|
||||
background-color: rgba(255, 255, 255, 0.22);
|
||||
|
||||
&--active {
|
||||
background-color: rgba(255, 255, 255, 0.34);
|
||||
}
|
||||
|
||||
&-text {
|
||||
margin-right: 6rpx;
|
||||
font-size: 26rpx;
|
||||
color: #ffffff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.card {
|
||||
margin: 24rpx;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
/* 上移叠压到欢迎区上(hero 已留出 100rpx 下内边距) */
|
||||
margin: -64rpx 24rpx 24rpx;
|
||||
background-color: #ffffff;
|
||||
border-radius: 16rpx;
|
||||
border-radius: 24rpx;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 8rpx 24rpx rgba(41, 121, 255, 0.08);
|
||||
}
|
||||
|
||||
&__title {
|
||||
padding: 24rpx 32rpx 8rpx;
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
/* 段标题 + 九宫格的样式在 components/entry-sections(仅本页使用,勿在此重复定义) */
|
||||
|
||||
/* 未登录时的底部轻提示 */
|
||||
.tip {
|
||||
margin-top: 48rpx;
|
||||
font-size: 24rpx;
|
||||
color: #a8abb2;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* 加载骨架屏:形态与最终九宫格一致,减少加载后的跳动感 */
|
||||
.skeleton {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
padding: 24rpx 12rpx 8rpx;
|
||||
|
||||
&__item {
|
||||
width: 33.333%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 20rpx 6rpx 24rpx;
|
||||
}
|
||||
|
||||
&__icon {
|
||||
width: 92rpx;
|
||||
height: 92rpx;
|
||||
border-radius: 26rpx;
|
||||
background-color: #f0f2f5;
|
||||
animation: skeleton-pulse 1.4s ease-in-out infinite;
|
||||
}
|
||||
|
||||
&__text {
|
||||
width: 96rpx;
|
||||
height: 24rpx;
|
||||
margin-top: 16rpx;
|
||||
border-radius: 12rpx;
|
||||
background-color: #f0f2f5;
|
||||
animation: skeleton-pulse 1.4s ease-in-out infinite;
|
||||
}
|
||||
}
|
||||
|
||||
/* 段标题 + 九宫格的样式在 components/entry-sections(首页与「我的」共用,勿在此重复定义) */
|
||||
@keyframes skeleton-pulse {
|
||||
0% {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.loading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 56rpx 0;
|
||||
50% {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user