rentease-app/pages/renter-detail/renter-detail.vue

145 lines
6.0 KiB
Vue
Raw Permalink Normal View History

2026-04-20 06:23:11 +00:00
<template>
<view class="renter-detail-page">
<view class="custom-nav safe-area-top">
<view class="nav-content">
<view class="nav-back" @click="goBack">
<uni-icons type="left" size="20" color="#1E293B"></uni-icons>
</view>
<text class="nav-title">租客详情</text>
<view class="nav-actions">
<view class="nav-btn" @click="editRenter">
<uni-icons type="compose" size="20" color="#2563EB"></uni-icons>
</view>
</view>
</view>
</view>
<scroll-view scroll-y class="page-content" v-if="renter">
<view class="renter-header">
<view class="renter-avatar">
<text class="avatar-text">{{renter.name ? renter.name.charAt(0) : '租'}}</text>
</view>
<text class="renter-name">{{renter.name}}</text>
<view class="renter-status" :class="renter.status">
<text>{{getStatusText(renter.status)}}</text>
</view>
</view>
<view class="info-section">
<view class="section-title">联系信息</view>
<view class="info-card">
<view class="info-item">
<text class="item-label">手机号</text>
<view class="item-value">
<text>{{renter.phone || '-'}}</text>
<uni-icons v-if="renter.phone" type="phone-filled" size="18" color="#2563EB" @click="callPhone(renter.phone)"></uni-icons>
</view>
</view>
<view class="info-item">
<text class="item-label">身份证号</text>
<text class="item-value">{{renter.idCard || '-'}}</text>
</view>
</view>
</view>
<view class="action-section">
<button class="action-btn primary" @click="viewRentals">查看租约</button>
<button class="action-btn" @click="addRental">新建租约</button>
</view>
<view class="safe-area-bottom" style="height: 40rpx;"></view>
</scroll-view>
</view>
</template>
<script>
import { renterApi } from '../../api/index.js'
export default {
data() {
return {
renterId: null,
2026-05-09 09:01:20 +00:00
renter: null,
isLoading: false
2026-04-20 06:23:11 +00:00
}
},
onLoad(options) {
if (options.id) {
this.renterId = options.id
this.loadData()
}
},
onShow() {
2026-05-09 09:01:20 +00:00
// 避免与 onLoad 重复加载,只在已有数据时刷新
if (this.renterId && this.renter) {
2026-04-20 06:23:11 +00:00
this.loadData()
}
},
methods: {
async loadData() {
2026-05-09 09:01:20 +00:00
if (this.isLoading) return
this.isLoading = true
2026-04-20 06:23:11 +00:00
try {
uni.showLoading({ title: '加载中...' })
const res = await renterApi.getDetail(this.renterId)
2026-04-22 06:47:04 +00:00
this.renter = res.data
2026-04-20 06:23:11 +00:00
} catch (error) {
2026-05-09 09:01:20 +00:00
// 重复请求的错误不提示
if (error?.message === '重复请求') {
console.log('重复请求被拦截')
return
}
2026-04-20 06:23:11 +00:00
uni.showToast({ title: '加载失败', icon: 'none' })
} finally {
uni.hideLoading()
2026-05-09 09:01:20 +00:00
this.isLoading = false
2026-04-20 06:23:11 +00:00
}
},
editRenter() {
uni.navigateTo({ url: `/pages/renter-add/renter-add?id=${this.renterId}&mode=edit` })
},
viewRentals() {
uni.navigateTo({ url: `/pages/rentals/rentals?renterId=${this.renterId}` })
},
addRental() {
2026-04-22 06:47:04 +00:00
uni.switchTab({ url: `/pages/add-record/add-record?renterId=${this.renterId}` })
2026-04-20 06:23:11 +00:00
},
callPhone(phone) {
uni.makePhoneCall({ phoneNumber: phone })
},
goBack() { uni.navigateBack() },
getStatusText(status) {
2026-04-22 06:47:04 +00:00
const texts = { 'active': '正常', 'inactive': '停用' }
2026-04-20 06:23:11 +00:00
return texts[status] || '未知'
}
}
}
</script>
<style scoped>
.renter-detail-page { min-height: 100vh; background: #F8FAFC; display: flex; flex-direction: column; }
.custom-nav { background: #FFFFFF; border-bottom: 2rpx solid #F1F5F9; }
.nav-content { display: flex; align-items: center; justify-content: space-between; padding: 20rpx 32rpx; }
.nav-back { width: 60rpx; height: 60rpx; display: flex; align-items: center; justify-content: center; }
.nav-title { font-size: 36rpx; font-weight: 700; color: #1E293B; }
.nav-actions { width: 60rpx; height: 60rpx; display: flex; align-items: center; justify-content: center; }
.page-content { flex: 1; padding: 24rpx 32rpx; }
.renter-header { display: flex; flex-direction: column; align-items: center; padding: 48rpx 0; }
.renter-avatar { width: 160rpx; height: 160rpx; border-radius: 50%; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); display: flex; align-items: center; justify-content: center; margin-bottom: 24rpx; }
.avatar-text { font-size: 64rpx; font-weight: 700; color: #FFFFFF; }
.renter-name { font-size: 40rpx; font-weight: 700; color: #1E293B; margin-bottom: 16rpx; }
.renter-status { padding: 8rpx 24rpx; border-radius: 8rpx; font-size: 26rpx; }
.renter-status.active { background: #DCFCE7; color: #16A34A; }
.renter-status.inactive { background: #F1F5F9; color: #64748B; }
.info-section { margin-bottom: 32rpx; }
.section-title { font-size: 28rpx; font-weight: 600; color: #94A3B8; margin-bottom: 16rpx; padding-left: 16rpx; }
.info-card { background: #FFFFFF; border-radius: 24rpx; padding: 0 32rpx; box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.04); }
.info-item { display: flex; align-items: center; justify-content: space-between; padding: 28rpx 0; border-bottom: 2rpx solid #F8FAFC; }
.info-item:last-child { border-bottom: none; }
.item-label { font-size: 30rpx; color: #64748B; }
.item-value { display: flex; align-items: center; gap: 16rpx; font-size: 30rpx; color: #1E293B; font-weight: 500; }
.action-section { display: flex; gap: 24rpx; margin-top: 48rpx; }
.action-btn { flex: 1; height: 96rpx; background: #F1F5F9; color: #64748B; font-size: 32rpx; font-weight: 600; border-radius: 16rpx; border: none; display: flex; align-items: center; justify-content: center; }
.action-btn.primary { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #FFFFFF; }
</style>