优化首页、我的样式

This commit is contained in:
zhouyanli
2026-05-20 15:31:10 +08:00
parent 99c36c0d83
commit 6f10ac22db
4 changed files with 492 additions and 554 deletions

View File

@@ -1,236 +1,179 @@
<template>
<view class="contentStyle" style="">
<view class="content-style">
<view class="status-bar" :style="{ height: statusBarHeight + 'px' }"></view>
<uni-nav-bar title="我的" backgroundColor="transparent" :border="false"> </uni-nav-bar>
<uni-nav-bar title="我的" backgroundColor="transparent" :border="false" />
<scroll-view class="page" scroll-y>
<view class="topBox">
<view class="name">
<image :src="avatar" class="img" />
<span style="padding: 5rpx 5rpx; display: flex; flex-direction: column; line-height: 60rpx">
<span style="font-size: 36rpx; font-weight: 600">
{{ loginName }}
</span>
<span style="font-size: 26rpx; color: #666666">
{{ phoneNum }}
</span>
</span>
<view class="user-card">
<image :src="avatar || defaultAvatar" class="avatar" />
<view class="user-info">
<text class="user-name">{{ loginName }}</text>
<text class="user-phone">{{ phoneNum }}</text>
</view>
</view>
<view class="contentBox">
<div class="page-container">
<view class="list-container">
<view class="list-item" v-for="(item, index) in list" :key="index" @click="onItemClick(item)">
<image :src="item.icon" class="item-icon" />
<view class="item-content">
<text class="item-title">{{ item.title }}</text>
</view>
<view class="item-arrow"></view>
<!-- <image src="https://wuyeadmin.bugtc.com/images/propertyImgs/arrow-right.png" class="arrow-icon" /> -->
</view>
</view>
</div>
<view class="list-container">
<view
class="list-item"
v-for="(item, index) in list"
:key="index"
@click="onItemClick(item)"
>
<image :src="item.icon" class="item-icon" />
<text class="item-title">{{ item.title }}</text>
<view class="item-arrow"></view>
</view>
</view>
</scroll-view>
</view>
</template>
<script setup>
import {
ref
} from 'vue'
import {
onShow
} from '@dcloudio/uni-app'
import {
getSettingInfo
} from '../../api/api.js'
import { ref } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { getSettingInfo } from '../../api/api.js'
const list = ref([{
icon: 'https://wuyeadmin.bugtc.com/images/imgs/shangbao.png',
title: '上报记录'
},
{
icon: 'https://wuyeadmin.bugtc.com/images/imgs/xunjian.png',
title: '巡检记录'
},
{
icon: 'https://wuyeadmin.bugtc.com/images/imgs/xunjian.png',
title: '仪表换新'
},
{
icon: 'https://wuyeadmin.bugtc.com/images/propertyImgs/setting.png',
title: '设置'
const defaultAvatar = 'https://wuyeadmin.bugtc.com/images/imgs/default-avatar.png'
const list = ref([
{ icon: 'https://wuyeadmin.bugtc.com/images/imgs/shangbao.png', title: '上报记录' },
{ icon: 'https://wuyeadmin.bugtc.com/images/imgs/xunjian.png', title: '巡检记录' },
{ icon: 'https://wuyeadmin.bugtc.com/images/imgs/xunjian.png', title: '仪表换新' },
{ icon: 'https://wuyeadmin.bugtc.com/images/propertyImgs/setting.png', title: '设置' }
])
const loginName = ref('')
const phoneNum = ref('')
const avatar = ref('')
const statusBarHeight = ref(uni.getSystemInfoSync().statusBarHeight || 0)
const fetchUserInfo = () => {
getSettingInfo().then(res => {
if (res.code === 200 && res.data) {
loginName.value = res.data.nickName || ''
phoneNum.value = res.data.phonenumber || ''
avatar.value = res.data.avatar || ''
}
])
const loginName = ref('')
const phoneNum = ref('')
const avatar = ref('')
const statusBarHeight = ref(uni.getSystemInfoSync().statusBarHeight || 0)
// 获取管家信息
const fetchUserInfo = () => {
getSettingInfo().then(res => {
if (res.code === 200 && res.data) {
loginName.value = res.data.nickName || ''
phoneNum.value = res.data.phonenumber || ''
avatar.value = res.data.avatar
}
}).catch(err => {
uni.showToast({
title: err.msg || '获取失败',
icon: 'none'
})
})
}
onShow(() => {
fetchUserInfo()
}).catch(err => {
uni.showToast({ title: err.msg || '获取失败', icon: 'none' })
})
}
// --方法----
const goToDetail = () => {
uni.navigateTo({
url: '/pageSubPack/notice-list/noticeListDetails'
})
onShow(() => {
fetchUserInfo()
})
const onItemClick = item => {
const routes = {
'上报记录': '/pageSubPack/report-record/report-record',
'巡检记录': '/pageSubPack/inspection/inspection_record',
'仪表换新': '/pageSubPack/instrument/replacement_record',
'设置': '/pageSubPack/setting/setting'
}
// 返回
const onItemClick = item => {
if (item.title == '上报记录') {
uni.navigateTo({
url: '/pageSubPack/report-record/report-record'
})
} else if (item.title == '巡检记录') {
uni.navigateTo({
url: '/pageSubPack/inspection/inspection_record'
})
} else if (item.title == '仪表换新') {
uni.navigateTo({
url: '/pageSubPack/instrument/replacement_record'
})
} else if (item.title == '设置') {
uni.redirectTo({
url: '/pageSubPack/setting/setting'
})
}
const url = routes[item.title]
if (!url) return
if (item.title === '设置') {
uni.redirectTo({ url })
} else {
uni.navigateTo({ url })
}
}
</script>
<style lang="scss" scoped>
.contentStyle {
display: flex;
flex-direction: column;
min-height: 100vh;
background: linear-gradient(to left bottom, #e2efff 0%, #f9f9f9 50%);
.content-style {
display: flex;
flex-direction: column;
min-height: 100vh;
background: linear-gradient(to left bottom, #e2efff 0%, #f9f9f9 50%);
}
.status-bar {
width: 100%;
flex-shrink: 0;
}
:deep(.uni-nav-bar-text) {
font-size: 32rpx !important;
}
.page {
flex: 1;
padding: 0 40rpx;
box-sizing: border-box;
}
.user-card {
display: flex;
align-items: center;
padding: 40rpx 0;
}
.avatar {
width: 120rpx;
height: 120rpx;
margin-right: 20rpx;
border-radius: 50%;
background-color: #eee;
flex-shrink: 0;
}
.user-info {
display: flex;
flex-direction: column;
gap: 8rpx;
}
.user-name {
font-size: 36rpx;
font-weight: 600;
color: #333;
line-height: 1.4;
}
.user-phone {
font-size: 26rpx;
color: #666;
line-height: 1.4;
}
.list-container {
margin-top: 20rpx;
}
.list-item {
display: flex;
align-items: center;
padding: 24rpx 0;
// border-bottom: 1rpx solid #f0f0f0;
&:last-child {
border-bottom: none;
}
.topBox {
width: 100%;
padding: 20rpx 0px;
position: relative;
// background-color: #1A75FF;
&:active {
opacity: 0.7;
}
}
.titleBox {
width: 100%;
.item-icon {
width: 84rpx;
height: 84rpx;
flex-shrink: 0;
}
position: relative;
.item-title {
flex: 1;
font-size: 32rpx;
font-weight: 400;
margin-left: 20rpx;
}
.title {
font-size: 36rpx;
line-height: 80rpx;
text-align: center;
font-weight: 500;
}
.settingImg {
width: 48rpx;
height: 48rpx;
top: 16rpx;
right: 0px;
}
}
.img {
width: 60px;
height: 60px;
margin-right: 10rpx;
border-radius: 50%;
}
.name {
bottom: 30rpx;
left: 30rpx;
display: flex;
align-items: center;
}
.contentBox {
position: relative;
}
.status-bar {
width: 100vw;
// height: 46px;
height: var(--status-bar-height);
flex-shrink: 0;
}
::v-deep .uni-nav-bar-text{
font-size: 32rpx !important;
}
.list-item {
display: flex;
align-items: center;
/* background: #fff; */
padding: 20rpx 6rpx;
border-radius: 8rpx;
/* border-bottom:2rpx solid #f2f2f2; */
/* margin-bottom: 10rpx; */
}
.item-icon {
width: 84rpx;
height: 84rpx;
/* margin-right: 20rpx; */
}
.item-content {
flex: 1;
display: flex;
flex-direction: row;
align-items: center;
}
.item-title {
font-size: 32rpx;
/* color: #333; */
font-weight: 400;
margin: 10rpx 20rpx;
/* margin-bottom: 6rpx; */
}
.item-desc {
font-size: 24rpx;
color: #b5b5b5;
white-space: nowrap;
/* 强制不换行 */
overflow: hidden;
/* 超出隐藏 */
text-overflow: ellipsis;
}
.item-arrow {
width: 16rpx;
height: 16rpx;
border-right: 3rpx solid #999999;
border-bottom: 3rpx solid #999999;
transform: rotate(-45deg);
margin-right: 10rpx;
}
.page {
flex: 1;
overflow-y: auto;
padding: 0px 40rpx;
box-sizing: border-box;
}
.item-arrow {
width: 16rpx;
height: 16rpx;
border-right: 3rpx solid #999;
border-bottom: 3rpx solid #999;
transform: rotate(-45deg);
margin-right: 10rpx;
flex-shrink: 0;
}
</style>