Files
smt-used-car-h5/pages/index/mine - 副本 (2).vue
T
2026-03-11 11:15:33 +08:00

180 lines
3.3 KiB
Vue

<template>
<view class="page">
<!-- 用户信息卡片 -->
<view class="user-card" @click="goToChanginfo">
<view class="user-info">
<image
class="avatar"
:src="userInfo.avatar_url || '/static/image/car.png'"
mode="aspectFill"
/>
<view class="user-details">
<text class="nickname">{{ userInfo.name || '未设置昵称' }}</text>
<text class="phone">{{ userInfo.mobile || '未绑定手机号' }}</text>
</view>
</view>
</view>
<!-- 功能入口 -->
<view class="menu-section">
<view class="menu-item" @tap="goToMyPublish">
<view class="menu-icon">
<u-icon name="list" size="24" color="#3F435B"></u-icon>
</view>
<text class="menu-text">我的发布</text>
<view class="menu-arrow">
<u-icon name="arrow-right" size="18" color="#999"></u-icon>
</view>
</view>
</view>
</view>
</template>
<script>
import { request } from '@/api/apiT.js'
export default {
data() {
return {
userInfo: {
avatar_url: '',
name: '',
mobile: ''
}
}
},
onLoad() {
this.getUserInfo()
},
onShow() {
// 页面显示时刷新用户信息
this.getUserInfo()
},
methods: {
// 获取用户信息
getUserInfo() {
request({
url: 'user/getInfo',
method: 'get'
}).then(res => {
if (res.data.code == 0 || res.data.code == 200) {
this.userInfo = {
avatar_url: res.data.data.avatar_url || '',
name: res.data.data.name || '',
mobile: res.data.data.mobile || ''
}
}
}).catch(() => {
// 获取失败时使用默认值
})
},
// 跳转到我的发布列表
goToMyPublish() {
uni.navigateTo({
url: '/pages/index/myPublish'
})
},
// 跳转到个人信息
goToChanginfo() {
uni.navigateTo({
url: '/pages/index/changinfo'
})
},
}
}
</script>
<style lang="scss" scoped>
.page {
min-height: 100vh;
background: #f4f6f8;
padding: 20rpx;
}
.user-card {
background: rgba(255, 255, 255, 0.95);
border-radius: 18rpx;
padding: 40rpx 30rpx;
margin-bottom: 20rpx;
box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.06);
}
.user-info {
display: flex;
align-items: center;
}
.avatar {
width: 120rpx;
height: 120rpx;
border-radius: 50%;
background: #eef2f7;
margin-right: 30rpx;
}
.user-details {
flex: 1;
display: flex;
flex-direction: column;
gap: 12rpx;
}
.nickname {
font-size: 32rpx;
font-weight: 700;
color: #111827;
}
.phone {
font-size: 26rpx;
color: #6b7280;
}
.menu-section {
background: rgba(255, 255, 255, 0.95);
border-radius: 18rpx;
overflow: hidden;
box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.06);
}
.menu-item {
display: flex;
align-items: center;
padding: 30rpx;
border-bottom: 1px solid #f0f0f0;
transition: background-color 0.2s;
}
.menu-item:last-child {
border-bottom: none;
}
.menu-item:active {
background-color: #f9fafb;
}
.menu-icon {
width: 48rpx;
height: 48rpx;
display: flex;
align-items: center;
justify-content: center;
margin-right: 24rpx;
background: #f3f4f6;
border-radius: 12rpx;
}
.menu-text {
flex: 1;
font-size: 30rpx;
color: #111827;
font-weight: 500;
}
.menu-arrow {
display: flex;
align-items: center;
justify-content: center;
}
</style>