优化
This commit is contained in:
134
pages/mine/index copy.vue
Normal file
134
pages/mine/index copy.vue
Normal file
@@ -0,0 +1,134 @@
|
||||
<template>
|
||||
<view class="mine-container">
|
||||
<!--顶部个人信息栏-->
|
||||
<view class="header-section">
|
||||
<view class="header-box">
|
||||
<view class="header-info">
|
||||
<view v-if="!userName" class="cu-avatar">
|
||||
<image :src="userAvatar" mode="widthFix"></image>
|
||||
</view>
|
||||
<image v-else :src="userAvatar" class="cu-avatar" mode="widthFix"></image>
|
||||
<view v-if="!userName" class="login-tip">
|
||||
点击登录
|
||||
</view>
|
||||
<view v-else @click="handleToInfo" class="user-info">
|
||||
<view class="u_title">
|
||||
用户名:{{ userName }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view @click="handleToInfo" class="header-info">
|
||||
<text>个人信息</text>
|
||||
<uv-icon name="arrow-right" color="#FFFFFF"></uv-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<uv-list>
|
||||
<uv-list-item title="关于我们" border></uv-list-item>
|
||||
<uv-list-item title="退出登录" border></uv-list-item>
|
||||
</uv-list>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import userAvatar from "@/static/tabbar/mine.png"
|
||||
|
||||
|
||||
// 从store获取用户信息
|
||||
const userName = ref("")
|
||||
|
||||
|
||||
const handleLogout = () => {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定注销并退出系统吗?',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
store.dispatch('LogOut').then(() => {
|
||||
uni.reLaunch({ url: '/pages/index' })
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
page {
|
||||
background-color: #f5f6f7;
|
||||
}
|
||||
|
||||
|
||||
.header-section {
|
||||
padding: 30rpx 30rpx 90px 30rpx;
|
||||
background-color: #199793;
|
||||
color: white;
|
||||
|
||||
.header-box {
|
||||
padding: 30rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
.header-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
.login-tip {
|
||||
font-size: 18px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.cu-avatar {
|
||||
width: 128rpx;
|
||||
height: 128rpx;
|
||||
border-radius: 50%;
|
||||
background-color: #FFFFFF;
|
||||
|
||||
image {
|
||||
width: 98rpx;
|
||||
height: 98rpx;
|
||||
margin: 15rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.user-info {
|
||||
margin-left: 15px;
|
||||
|
||||
.u_title {
|
||||
font-size: 18px;
|
||||
line-height: 30px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.content-section {
|
||||
position: relative;
|
||||
top: -50px;
|
||||
|
||||
.mine-actions {
|
||||
margin: 15px 15px;
|
||||
padding: 20px 0px;
|
||||
border-radius: 8px;
|
||||
background-color: white;
|
||||
|
||||
.action-item {
|
||||
.icon {
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
.text {
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
margin: 8px 0px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
291
pages/mine/index.vue
Normal file
291
pages/mine/index.vue
Normal file
@@ -0,0 +1,291 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<!-- 头部个人信息 -->
|
||||
<view class="header">
|
||||
<view class="avatar-container" @tap="goLogin">
|
||||
<view class="avatar">
|
||||
<image
|
||||
src="../../static/image/user.png"
|
||||
mode="scaleToFill"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
<view class="user-info" @tap="goLogin">
|
||||
<text class="username">{{ userInfo.username }}</text>
|
||||
<text class="user-role">{{ userInfo.role }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 统计信息栏 -->
|
||||
<!-- <view class="stats-bar">
|
||||
<view class="stat-item" v-for="(item, index) in statsData" :key="index">
|
||||
<text class="stat-number">{{ item.number }}</text>
|
||||
<text class="stat-label">{{ item.label }}</text>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
<!-- 菜单区域 -->
|
||||
<view class="menu-section">
|
||||
<!-- 账户信息组 -->
|
||||
<!-- <view class="menu-group">
|
||||
<view class="menu-item" v-for="(item, index) in accountMenus" :key="index" @tap="handleMenu(item)">
|
||||
<text class="menu-icon">{{ item.icon }}</text>
|
||||
<text class="menu-text">{{ item.text }}</text>
|
||||
<uv-icon name="arrow-right" color="#999999"></uv-icon>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
<!-- 工作相关组 -->
|
||||
<view class="menu-group">
|
||||
<view class="menu-item" v-for="(item, index) in workMenus" :key="index" @tap="handleMenu(item)">
|
||||
<image :src="item.icon" mode="scaleToFill" />
|
||||
<text class="menu-text">{{ item.text }}</text>
|
||||
<!-- absolute :offset="['15%','43%']" -->
|
||||
<uv-badge type="error" max="100" :value="item.num" v-show="item.num"></uv-badge>
|
||||
<uv-icon name="arrow-right" color="#999999"></uv-icon>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 系统相关组 -->
|
||||
<!-- <view class="menu-group">
|
||||
<view class="menu-item" v-for="(item, index) in systemMenus" :key="index" @tap="handleMenu(item)">
|
||||
<text class="menu-icon">{{ item.icon }}</text>
|
||||
<text class="menu-text">{{ item.text }}</text>
|
||||
<uv-icon name="arrow-right" color="#999999"></uv-icon>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
<view class="btn" v-show="uni.getStorageSync('token')">
|
||||
<uv-button text="退 出 登 录" size="large" style="width: 100%;" type="error" @tap="logOut"></uv-button>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive } from 'vue'
|
||||
import { taskCount } from '../../api/inventory'
|
||||
import { userLogout } from '../../api/login'
|
||||
import { auditCount } from "@/api/mine"
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import myTask from "../../static/iconfont/myTask.svg"
|
||||
import print from "../../static/iconfont/print.svg"
|
||||
|
||||
// 用户信息
|
||||
const userInfo = reactive({
|
||||
username: '请登录',
|
||||
role: ''
|
||||
})
|
||||
|
||||
const goLogin = () => {
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login',
|
||||
})
|
||||
}
|
||||
|
||||
// 统计数据
|
||||
const statsData = reactive([
|
||||
{ number: '128', label: '今日入库' },
|
||||
{ number: '89', label: '今日出库' },
|
||||
{ number: '98%', label: '任务完成' }
|
||||
])
|
||||
|
||||
|
||||
// 工作相关菜单
|
||||
const workMenus = reactive([
|
||||
{ icon: myTask, text: '我的任务', type: 'task' },
|
||||
// { icon: myTask, text: '待审核', type: 'audit' },
|
||||
{ icon: print, text: '打印调试', type: 'print' },
|
||||
{ icon: print, text: '签字调试', type: 'signature' }
|
||||
])
|
||||
|
||||
const getCount = () => {
|
||||
taskCount().then(res => {
|
||||
workMenus[0].num = res.data
|
||||
})
|
||||
// let obj = {
|
||||
// approverId: uni.getStorageSync('user').userId
|
||||
// }
|
||||
// auditCount(obj).then(res => {
|
||||
// // console.log('审核数量', res.data)
|
||||
// workMenus[1].num = res.data
|
||||
// })
|
||||
}
|
||||
|
||||
|
||||
onShow(() => {
|
||||
if (uni.getStorageSync('token')) {
|
||||
userInfo.username = uni.getStorageSync('user').userName
|
||||
userInfo.role = uni.getStorageSync('user').roles[0].roleName
|
||||
getCount()
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
// 处理菜单点击
|
||||
const handleMenu = (item) => {
|
||||
console.log('菜单点击:', item.type)
|
||||
// 根据类型处理不同的跳转逻辑
|
||||
if (item.type == "task") {
|
||||
uni.navigateTo({
|
||||
url: `/pagesInventory/inventoryTask?type=all`
|
||||
})
|
||||
} else if (item.type == "audit") {
|
||||
uni.navigateTo({
|
||||
url: `/pagesMine/audit`
|
||||
})
|
||||
} else if (item.type == "print") {
|
||||
uni.navigateTo({
|
||||
url: `/pagesMine/print`
|
||||
})
|
||||
} else if (item.type == "signature") {
|
||||
uni.navigateTo({
|
||||
url: `/pagesMine/signPreview`
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const logOut = () => {
|
||||
userLogout().then(res => {
|
||||
uni.clearStorage()
|
||||
uni.navigateTo({
|
||||
url: `/pages/login/login`
|
||||
})
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.container {
|
||||
min-height: 100vh;
|
||||
background-color: #f7f7f7;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.header {
|
||||
background: linear-gradient(135deg, #199793, #07807b);
|
||||
padding: 60rpx 40rpx;
|
||||
color: #ffffff;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.avatar-container {
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 160rpx;
|
||||
height: 160rpx;
|
||||
border-radius: 50%;
|
||||
background: #ffffff;
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.2);
|
||||
image {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.user-info {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.username {
|
||||
font-size: 40rpx;
|
||||
font-weight: 600;
|
||||
margin-bottom: 10rpx;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.user-role {
|
||||
font-size: 28rpx;
|
||||
opacity: 0.9;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.stats-bar {
|
||||
background: #ffffff;
|
||||
padding: 30rpx;
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.stat-number {
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
color: #199793;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 24rpx;
|
||||
color: #666666;
|
||||
margin-top: 10rpx;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.menu-section {
|
||||
padding: 30rpx 30rpx 100rpx;
|
||||
}
|
||||
|
||||
.menu-group {
|
||||
background: #ffffff;
|
||||
border-radius: 20rpx;
|
||||
margin-bottom: 30rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.menu-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 30rpx;
|
||||
border-bottom: 2rpx solid #f0f0f0;
|
||||
|
||||
image {
|
||||
width: 34rpx;
|
||||
height: 34rpx;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.menu-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.menu-icon {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
margin-right: 30rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 40rpx;
|
||||
}
|
||||
|
||||
.menu-text {
|
||||
flex: 1;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
|
||||
.menu-arrow {
|
||||
color: #999999;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.btn {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
padding: 0 30rpx;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user