From a8de74cfd4cda56f935fd82e6d9a2f9acc5bb0d1 Mon Sep 17 00:00:00 2001
From: wangxiaoxian <1094175543@qq.com>
Date: Sat, 9 May 2026 17:01:20 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/renter-add/renter-add.vue | 77 +++++++++++++++------------
pages/renter-detail/renter-detail.vue | 14 ++++-
2 files changed, 55 insertions(+), 36 deletions(-)
diff --git a/pages/renter-add/renter-add.vue b/pages/renter-add/renter-add.vue
index 940d7b4..3b3ca60 100644
--- a/pages/renter-add/renter-add.vue
+++ b/pages/renter-add/renter-add.vue
@@ -23,30 +23,23 @@
- 手机号
+ 手机号
身份证号
-
- 紧急联系人
-
-
-
- 紧急电话
-
-
-
-
-
-
- 备注信息
-
-
-
- {{form.remark.length}}/200
+
+ 状态
+
+
+ 正常
+
+
+ 停用
+
+
@@ -72,9 +65,7 @@
name: '',
phone: '',
idCard: '',
- emergencyContact: '',
- emergencyPhone: '',
- remark: ''
+ status: 'active'
}
}
},
@@ -95,9 +86,7 @@
name: data.name || '',
phone: data.phone || '',
idCard: data.idCard || '',
- emergencyContact: data.emergencyContact || '',
- emergencyPhone: data.emergencyPhone || '',
- remark: data.remark || ''
+ status: data.status || 'active'
}
} catch (error) {
uni.showToast({ title: '加载失败', icon: 'none' })
@@ -105,15 +94,34 @@
uni.hideLoading()
}
},
+ validateForm() {
+ const { name, phone, idCard } = this.form
+ if (!name || !name.trim()) {
+ uni.showToast({ title: '请输入租客姓名', icon: 'none' })
+ return false
+ }
+ if (name.trim().length < 2 || name.trim().length > 50) {
+ uni.showToast({ title: '姓名长度应在2-50个字符', icon: 'none' })
+ return false
+ }
+ if (phone && phone.trim()) {
+ const phonePattern = /^1[3-9]\d{9}$/
+ if (!phonePattern.test(phone.trim())) {
+ uni.showToast({ title: '请输入正确的手机号', icon: 'none' })
+ return false
+ }
+ }
+ if (idCard && idCard.trim()) {
+ const idCardPattern = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
+ if (!idCardPattern.test(idCard.trim())) {
+ uni.showToast({ title: '请输入正确的身份证号', icon: 'none' })
+ return false
+ }
+ }
+ return true
+ },
async save() {
- if (!this.form.name.trim()) {
- uni.showToast({ title: '请输入姓名', icon: 'none' })
- return
- }
- if (!this.form.phone.trim()) {
- uni.showToast({ title: '请输入手机号', icon: 'none' })
- return
- }
+ if (!this.validateForm()) return
try {
uni.showLoading({ title: '保存中...' })
if (this.isEdit) {
@@ -172,8 +180,9 @@
.item-label { width: 180rpx; font-size: 30rpx; color: #1E293B; font-weight: 500; }
.item-label.required::after { content: '*'; color: #EF4444; margin-left: 8rpx; }
.item-input { flex: 1; font-size: 30rpx; color: #1E293B; text-align: right; }
- .remark-input { width: 100%; height: 200rpx; font-size: 30rpx; color: #1E293B; line-height: 1.6; }
- .word-count { position: absolute; right: 32rpx; bottom: 24rpx; font-size: 24rpx; color: #94A3B8; }
.delete-section { margin-top: 48rpx; }
.delete-btn { width: 100%; height: 96rpx; background: #FEE2E2; color: #EF4444; font-size: 32rpx; font-weight: 600; border-radius: 16rpx; border: none; display: flex; align-items: center; justify-content: center; }
+ .status-options { display: flex; gap: 24rpx; }
+ .status-option { padding: 16rpx 32rpx; border-radius: 12rpx; background: #F1F5F9; font-size: 28rpx; color: #64748B; }
+ .status-option.active { background: #DBEAFE; color: #2563EB; }
diff --git a/pages/renter-detail/renter-detail.vue b/pages/renter-detail/renter-detail.vue
index 6d0789f..e455573 100644
--- a/pages/renter-detail/renter-detail.vue
+++ b/pages/renter-detail/renter-detail.vue
@@ -59,7 +59,8 @@
data() {
return {
renterId: null,
- renter: null
+ renter: null,
+ isLoading: false
}
},
onLoad(options) {
@@ -69,20 +70,29 @@
}
},
onShow() {
- if (this.renterId) {
+ // 避免与 onLoad 重复加载,只在已有数据时刷新
+ if (this.renterId && this.renter) {
this.loadData()
}
},
methods: {
async loadData() {
+ if (this.isLoading) return
+ this.isLoading = true
try {
uni.showLoading({ title: '加载中...' })
const res = await renterApi.getDetail(this.renterId)
this.renter = res.data
} catch (error) {
+ // 重复请求的错误不提示
+ if (error?.message === '重复请求') {
+ console.log('重复请求被拦截')
+ return
+ }
uni.showToast({ title: '加载失败', icon: 'none' })
} finally {
uni.hideLoading()
+ this.isLoading = false
}
},
editRenter() {