refactor: 首页改用简洁卡片布局,emoji图标
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Agent
2026-03-28 14:08:21 +00:00
parent f47f078357
commit 7140e0049f

View File

@@ -1,182 +1,130 @@
<template>
<view class="page">
<!-- 顶部欢迎 -->
<!-- 顶部欢迎 -->
<view class="header">
<view class="user-info">
<text class="greeting">{{ greeting }}</text>
<view class="user-section">
<text class="welcome">{{ greeting }}</text>
<text class="username" v-if="username">{{ username }}</text>
<text class="username" v-else>请登录</text>
</view>
<view class="logout-btn" @click="logout" v-if="isLoggedIn">
<view class="logout-btn" @click="logout" v-if="username">
<text>退出</text>
</view>
</view>
<!-- 统计概览 -->
<view class="stats-section" v-if="isAdmin || isSales">
<view class="stat-card">
<text class="stat-value">{{ stats.todayOrders }}</text>
<text class="stat-label">今日订单</text>
</view>
<view class="stat-card">
<text class="stat-value">¥{{ stats.todayAmount }}</text>
<text class="stat-label">今日销售额</text>
</view>
<view class="stat-card">
<text class="stat-value">{{ stats.totalCustomers }}</text>
<text class="stat-label">客户数</text>
</view>
</view>
<!-- 订单相关 -->
<view class="menu-section">
<!-- 订单区域 -->
<view class="section">
<text class="section-title">订单</text>
<view class="menu-grid">
<template v-if="isAdmin">
<view class="menu-item" @click="goTo('/pages/order/create')">
<view class="menu-icon" style="background: #e8f4ff;">
<text style="color: #1890ff;">📝</text>
</view>
<text class="menu-icon"></text>
<text class="menu-text">创建订单</text>
</view>
<view class="menu-item" @click="goToTab('/pages/order/list')">
<view class="menu-icon" style="background: #f6ffed;">
<text style="color: #52c41a;">📋</text>
</view>
<text class="menu-icon">📋</text>
<text class="menu-text">订单列表</text>
</view>
<view class="menu-item" @click="goTo('/pages/order/search')">
<view class="menu-icon" style="background: #fff7e6;">
<text style="color: #fa8c16;">🔍</text>
</view>
<text class="menu-icon">🔍</text>
<text class="menu-text">订单查询</text>
</view>
<view class="menu-item" @click="goTo('/pages/order/return')">
<view class="menu-icon" style="background: #fff1f0;">
<text style="color: #ff4d4f;"></text>
</view>
<text class="menu-icon"></text>
<text class="menu-text">退货</text>
</view>
</template>
<template v-else-if="isSales">
<view class="menu-item" @click="goTo('/pages/order/create')">
<view class="menu-icon" style="background: #e8f4ff;">
<text style="color: #1890ff;">📝</text>
</view>
<text class="menu-icon"></text>
<text class="menu-text">创建订单</text>
</view>
<view class="menu-item" @click="goToTab('/pages/order/list')">
<view class="menu-icon" style="background: #f6ffed;">
<text style="color: #52c41a;">📋</text>
</view>
<text class="menu-icon">📋</text>
<text class="menu-text">订单列表</text>
</view>
</template>
<template v-else-if="isCustomer">
<view class="menu-item" @click="goToTab('/pages/order/list')">
<view class="menu-icon" style="background: #f6ffed;">
<text style="color: #52c41a;">📋</text>
</view>
<text class="menu-icon">📋</text>
<text class="menu-text">我的订单</text>
</view>
</template>
</view>
</view>
<!-- 管理相关 -->
<view class="menu-section" v-if="isAdmin || isSales">
<!-- 管理区域 -->
<view class="section" v-if="isAdmin || isSales">
<text class="section-title">管理</text>
<view class="menu-grid">
<template v-if="isAdmin">
<view class="menu-item" @click="goTo('/pages/product/manage')">
<view class="menu-icon" style="background: #f9f0ff;">
<text style="color: #722ed1;">📦</text>
</view>
<text class="menu-icon">📦</text>
<text class="menu-text">商品管理</text>
</view>
<view class="menu-item" @click="goTo('/pages/category/index')">
<view class="menu-icon" style="background: #fff0f6;">
<text style="color: #eb2f96;">📂</text>
</view>
<text class="menu-icon">📂</text>
<text class="menu-text">种类管理</text>
</view>
<view class="menu-item" @click="goStock()">
<view class="menu-icon" style="background: #e6f7ff;">
<text style="color: #13c2c2;">🏭</text>
</view>
<text class="menu-icon">🏭</text>
<text class="menu-text">库存管理</text>
</view>
<view class="menu-item" @click="goTo('/pages/stock/in')">
<view class="menu-icon" style="background: #fff7e6;">
<text style="color: #fa8c16;"></text>
</view>
<text class="menu-icon"></text>
<text class="menu-text">入库</text>
</view>
<view class="menu-item" @click="goTo('/pages/stock/flow')">
<view class="menu-icon" style="background: #f6ffed;">
<text style="color: #52c41a;">📊</text>
</view>
<text class="menu-icon">📊</text>
<text class="menu-text">库存流水</text>
</view>
</template>
<template v-else-if="isSales">
<view class="menu-item" @click="goTo('/pages/product/list')">
<view class="menu-icon" style="background: #f9f0ff;">
<text style="color: #722ed1;">📦</text>
</view>
<text class="menu-icon">📦</text>
<text class="menu-text">商品浏览</text>
</view>
</template>
</view>
</view>
<!-- 商品浏览顾客 -->
<view class="menu-section" v-if="isCustomer">
<!-- 商品区域顾客 -->
<view class="section" v-if="isCustomer">
<text class="section-title">商品</text>
<view class="menu-grid">
<view class="menu-item" @click="goTo('/pages/product/list')">
<view class="menu-icon" style="background: #f9f0ff;">
<text style="color: #722ed1;">📦</text>
</view>
<text class="menu-icon">📦</text>
<text class="menu-text">商品浏览</text>
</view>
</view>
</view>
<!-- 游客登录 -->
<view class="guest-section" v-if="isGuest">
<view class="guest-card" @click="goTo('/pages/login/index')">
<text class="guest-icon">👤</text>
<view class="guest-section" v-if="!username">
<view class="guest-btn" @click="goTo('/pages/login/index')">
<text class="guest-text">点击登录</text>
<text class="guest-hint">登录后可使用更多功能</text>
</view>
</view>
</view>
</template>
<script>
import { isAdmin, isSales, isCustomer, isGuest } from '@/utils/auth'
import { isAdmin, isSales, isCustomer } from '@/utils/auth'
export default {
data() {
return {
username: '',
greeting: '',
stats: {
todayOrders: 0,
todayAmount: '0',
totalCustomers: 0
}
greeting: ''
}
},
computed: {
isAdmin() { return isAdmin() },
isSales() { return isSales() },
isCustomer() { return isCustomer() },
isGuest() { return isGuest() },
isLoggedIn() { return !isGuest() }
isCustomer() { return isCustomer() }
},
onShow() {
this.username = uni.getStorageSync('username') || '' || ''
this.username = uni.getStorageSync('username') || ''
this.setGreeting()
},
methods: {
@@ -200,7 +148,7 @@ export default {
logout() {
uni.showModal({
title: '退出登录',
content: '确定要退出登录吗?',
content: '确定要退出吗?',
success: (res) => {
if (res.confirm) {
uni.clearStorageSync()
@@ -216,147 +164,98 @@ export default {
<style>
.page {
min-height: 100vh;
background: #f7f8fa;
padding: 30rpx;
background: #f5f5f5;
padding: 20rpx;
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 30rpx;
background: #fff;
padding: 30rpx;
border-radius: 16rpx;
margin-bottom: 20rpx;
}
.user-info {
.user-section {
display: flex;
flex-direction: column;
}
.greeting {
font-size: 26rpx;
.welcome {
font-size: 24rpx;
color: #999;
}
.username {
font-size: 36rpx;
font-size: 34rpx;
font-weight: bold;
color: #333;
margin-top: 8rpx;
margin-top: 6rpx;
}
.logout-btn {
font-size: 26rpx;
color: #666;
padding: 10rpx 20rpx;
background: #f0f0f0;
border-radius: 20rpx;
padding: 12rpx 24rpx;
background: #f5f5f5;
border-radius: 30rpx;
}
.stats-section {
display: flex;
justify-content: space-between;
margin-bottom: 30rpx;
}
.stat-card {
flex: 1;
.section {
background: #fff;
border-radius: 16rpx;
padding: 24rpx;
margin: 0 8rpx;
text-align: center;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
}
.stat-value {
display: block;
font-size: 36rpx;
font-weight: bold;
color: #333;
}
.stat-label {
font-size: 22rpx;
color: #999;
margin-top: 8rpx;
}
.menu-section {
margin-bottom: 30rpx;
margin-bottom: 20rpx;
}
.section-title {
display: block;
font-size: 28rpx;
font-weight: bold;
color: #333;
margin-bottom: 20rpx;
padding-left: 10rpx;
margin-bottom: 24rpx;
padding-left: 16rpx;
border-left: 6rpx solid #1890ff;
}
.menu-grid {
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
gap: 20rpx;
}
.menu-item {
width: calc(25% - 15rpx);
width: 25%;
display: flex;
flex-direction: column;
align-items: center;
padding: 24rpx 10rpx;
background: #fff;
border-radius: 16rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
padding: 16rpx 0;
}
.menu-icon {
width: 80rpx;
height: 80rpx;
border-radius: 20rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 40rpx;
font-size: 50rpx;
margin-bottom: 12rpx;
}
.menu-text {
font-size: 22rpx;
color: #333;
font-size: 24rpx;
color: #666;
}
.guest-section {
margin-top: 100rpx;
}
.guest-card {
background: #fff;
border-radius: 24rpx;
padding: 60rpx;
margin-top: 200rpx;
display: flex;
flex-direction: column;
align-items: center;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
justify-content: center;
}
.guest-icon {
font-size: 100rpx;
margin-bottom: 30rpx;
.guest-btn {
background: #1890ff;
padding: 30rpx 80rpx;
border-radius: 50rpx;
}
.guest-text {
font-size: 32rpx;
font-weight: bold;
color: #333;
}
.guest-hint {
font-size: 24rpx;
color: #999;
margin-top: 16rpx;
color: #fff;
}
</style>