|
|
@ -12,7 +12,7 @@ |
|
|
|
|
|
|
|
|
<!-- 1. 出租/流转 --> |
|
|
<!-- 1. 出租/流转 --> |
|
|
<uv-form-item label="类型" prop="type" required> |
|
|
<uv-form-item label="类型" prop="type" required> |
|
|
<uv-radio-group v-model="form.type" placement="row"> |
|
|
|
|
|
|
|
|
<uv-radio-group v-model="form.type" placement="row" @change="debounceSaveFormData"> |
|
|
<uv-radio name="rent" label="出租"></uv-radio> |
|
|
<uv-radio name="rent" label="出租"></uv-radio> |
|
|
<uv-radio name="transfer" customStyle="margin-left:30rpx;" label="流转"></uv-radio> |
|
|
<uv-radio name="transfer" customStyle="margin-left:30rpx;" label="流转"></uv-radio> |
|
|
</uv-radio-group> |
|
|
</uv-radio-group> |
|
|
@ -29,11 +29,11 @@ |
|
|
|
|
|
|
|
|
<!-- 3. 联系人和电话 --> |
|
|
<!-- 3. 联系人和电话 --> |
|
|
<uv-form-item label="联系人" prop="contactName" required> |
|
|
<uv-form-item label="联系人" prop="contactName" required> |
|
|
<uv-input v-model="form.contactName" type="text" placeholder="请输入联系人姓名" customStyle="border-radius: 5px;margin-top:5px;background-color: #f5f5f5;padding:5px 10px;"></uv-input> |
|
|
|
|
|
|
|
|
<uv-input v-model="form.contactName" type="text" placeholder="请输入联系人姓名" customStyle="border-radius: 5px;margin-top:5px;background-color: #f5f5f5;padding:5px 10px;" @input="debounceSaveFormData"></uv-input> |
|
|
</uv-form-item> |
|
|
</uv-form-item> |
|
|
|
|
|
|
|
|
<uv-form-item label="联系电话" prop="contactPhone" required> |
|
|
<uv-form-item label="联系电话" prop="contactPhone" required> |
|
|
<uv-input v-model="form.contactPhone" type="number" placeholder="请输入联系电话" customStyle="border-radius: 5px;margin-top:5px;background-color: #f5f5f5;padding:5px 10px;"></uv-input> |
|
|
|
|
|
|
|
|
<uv-input v-model="form.contactPhone" type="number" placeholder="请输入联系电话" customStyle="border-radius: 5px;margin-top:5px;background-color: #f5f5f5;padding:5px 10px;" @input="debounceSaveFormData"></uv-input> |
|
|
</uv-form-item> |
|
|
</uv-form-item> |
|
|
|
|
|
|
|
|
<!-- 4. 房屋状况 --> |
|
|
<!-- 4. 房屋状况 --> |
|
|
@ -55,7 +55,7 @@ |
|
|
<!-- 6. 产权面积 --> |
|
|
<!-- 6. 产权面积 --> |
|
|
<uv-form-item label="房屋面积" prop="houseArea" required> |
|
|
<uv-form-item label="房屋面积" prop="houseArea" required> |
|
|
<view class="input-with-unit"> |
|
|
<view class="input-with-unit"> |
|
|
<uv-input v-model="form.houseArea" type="digit" placeholder="请输入房屋面积" customStyle="border-radius: 5px;margin-top:5px;background-color: #f5f5f5;padding:5px 10px;"></uv-input> |
|
|
|
|
|
|
|
|
<uv-input v-model="form.houseArea" type="digit" placeholder="请输入房屋面积" customStyle="border-radius: 5px;margin-top:5px;background-color: #f5f5f5;padding:5px 10px;" @input="debounceSaveFormData"></uv-input> |
|
|
<text class="unit">平米</text> |
|
|
<text class="unit">平米</text> |
|
|
</view> |
|
|
</view> |
|
|
<view class="input-tip">请录入房屋证或不动产权证登记面积</view> |
|
|
<view class="input-tip">请录入房屋证或不动产权证登记面积</view> |
|
|
@ -63,7 +63,7 @@ |
|
|
|
|
|
|
|
|
<uv-form-item label="土地面积" prop="landArea" required> |
|
|
<uv-form-item label="土地面积" prop="landArea" required> |
|
|
<view class="input-with-unit"> |
|
|
<view class="input-with-unit"> |
|
|
<uv-input v-model="form.landArea" type="digit" placeholder="请输入土地面积" customStyle="border-radius: 5px;margin-top:5px;background-color: #f5f5f5;padding:5px 10px;"></uv-input> |
|
|
|
|
|
|
|
|
<uv-input v-model="form.landArea" type="digit" placeholder="请输入土地面积" customStyle="border-radius: 5px;margin-top:5px;background-color: #f5f5f5;padding:5px 10px;" @input="debounceSaveFormData"></uv-input> |
|
|
<text class="unit">平米</text> |
|
|
<text class="unit">平米</text> |
|
|
</view> |
|
|
</view> |
|
|
<view class="input-tip">请录入土地使用证或不动产权证面积</view> |
|
|
<view class="input-tip">请录入土地使用证或不动产权证面积</view> |
|
|
@ -86,7 +86,7 @@ |
|
|
<!-- 9. 价格 --> |
|
|
<!-- 9. 价格 --> |
|
|
<uv-form-item label="价格" prop="price" required> |
|
|
<uv-form-item label="价格" prop="price" required> |
|
|
<view class="price-container"> |
|
|
<view class="price-container"> |
|
|
<uv-input v-model="form.price" type="digit" placeholder="请输入价格" customStyle="border-radius: 5px;margin-top:5px;background-color: #f5f5f5;padding:5px 10px;flex:1;"></uv-input> |
|
|
|
|
|
|
|
|
<uv-input v-model="form.price" type="digit" placeholder="请输入价格" customStyle="border-radius: 5px;margin-top:5px;background-color: #f5f5f5;padding:5px 10px;flex:1;" @input="debounceSaveFormData"></uv-input> |
|
|
<text class="price-unit" v-if="form.type === 'rent'">元/年</text> |
|
|
<text class="price-unit" v-if="form.type === 'rent'">元/年</text> |
|
|
<text class="price-unit" v-else-if="form.type === 'transfer'">万元</text> |
|
|
<text class="price-unit" v-else-if="form.type === 'transfer'">万元</text> |
|
|
<text class="price-unit" v-else>元</text> |
|
|
<text class="price-unit" v-else>元</text> |
|
|
@ -109,7 +109,7 @@ |
|
|
<!-- 10. 可用菜地 --> |
|
|
<!-- 10. 可用菜地 --> |
|
|
<uv-form-item label="可用菜地" prop="vegetableGarden"> |
|
|
<uv-form-item label="可用菜地" prop="vegetableGarden"> |
|
|
<view class="input-with-unit"> |
|
|
<view class="input-with-unit"> |
|
|
<uv-input v-model="form.vegetableGarden" type="digit" placeholder="请输入菜地面积" customStyle="border-radius: 5px;margin-top:5px;background-color: #f5f5f5;padding:5px 10px;"></uv-input> |
|
|
|
|
|
|
|
|
<uv-input v-model="form.vegetableGarden" type="digit" placeholder="请输入菜地面积" customStyle="border-radius: 5px;margin-top:5px;background-color: #f5f5f5;padding:5px 10px;" @input="debounceSaveFormData"></uv-input> |
|
|
<text class="unit">平米</text> |
|
|
<text class="unit">平米</text> |
|
|
</view> |
|
|
</view> |
|
|
</uv-form-item> |
|
|
</uv-form-item> |
|
|
@ -153,6 +153,7 @@ |
|
|
customStyle="border-radius: 5px;margin-top:5px;background-color: #f5f5f5;padding:10px;" |
|
|
customStyle="border-radius: 5px;margin-top:5px;background-color: #f5f5f5;padding:10px;" |
|
|
:autoHeight="true" |
|
|
:autoHeight="true" |
|
|
:maxlength="500" |
|
|
:maxlength="500" |
|
|
|
|
|
@input="debounceSaveFormData" |
|
|
></uv-input> |
|
|
></uv-input> |
|
|
</uv-form-item> |
|
|
</uv-form-item> |
|
|
|
|
|
|
|
|
@ -172,11 +173,14 @@ |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
import { saveOrUpdateHouse, houseType } from "@/common/api.js" |
|
|
import { saveOrUpdateHouse, houseType } from "@/common/api.js" |
|
|
|
|
|
import formStorage from "@/utils/formStorage.js" |
|
|
|
|
|
|
|
|
export default { |
|
|
export default { |
|
|
data() { |
|
|
|
|
|
return { |
|
|
|
|
|
commonClass: '', // 所属分类ID |
|
|
|
|
|
|
|
|
data() { |
|
|
|
|
|
return { |
|
|
|
|
|
formKey: 'farmhouse_form', // 表单存储唯一标识 |
|
|
|
|
|
saveTimer: null, // 防抖定时器 |
|
|
|
|
|
commonClass: '', // 所属分类ID |
|
|
form: { |
|
|
form: { |
|
|
type: '', // 出租/流转 |
|
|
type: '', // 出租/流转 |
|
|
address: '', // 地址 |
|
|
address: '', // 地址 |
|
|
@ -267,8 +271,40 @@ |
|
|
|
|
|
|
|
|
// 初始化分类数据 |
|
|
// 初始化分类数据 |
|
|
this.onHouseType() |
|
|
this.onHouseType() |
|
|
|
|
|
|
|
|
|
|
|
// 恢复表单数据 |
|
|
|
|
|
this.restoreFormData() |
|
|
|
|
|
}, |
|
|
|
|
|
onUnload() { |
|
|
|
|
|
// 页面卸载时保存数据 |
|
|
|
|
|
this.saveFormData() |
|
|
|
|
|
// 清除定时器 |
|
|
|
|
|
if (this.saveTimer) { |
|
|
|
|
|
clearTimeout(this.saveTimer) |
|
|
|
|
|
} |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
|
|
|
// 恢复表单数据 |
|
|
|
|
|
restoreFormData() { |
|
|
|
|
|
const savedData = formStorage.getFormData(this.formKey) |
|
|
|
|
|
if (savedData) { |
|
|
|
|
|
// 合并保存的数据到表单 |
|
|
|
|
|
this.form = { ...this.form, ...savedData } |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 保存表单数据 |
|
|
|
|
|
saveFormData() { |
|
|
|
|
|
formStorage.saveFormData(this.formKey, this.form) |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 防抖保存表单数据 |
|
|
|
|
|
debounceSaveFormData() { |
|
|
|
|
|
clearTimeout(this.saveTimer) |
|
|
|
|
|
this.saveTimer = setTimeout(() => { |
|
|
|
|
|
this.saveFormData() |
|
|
|
|
|
}, 1000) |
|
|
|
|
|
}, |
|
|
// 获取分类数据 |
|
|
// 获取分类数据 |
|
|
onHouseType(){ |
|
|
onHouseType(){ |
|
|
let that = this |
|
|
let that = this |
|
|
@ -310,6 +346,8 @@ |
|
|
const { indexs, value } = e; |
|
|
const { indexs, value } = e; |
|
|
this.form.houseCondition = value[0]; // 修改:直接使用选择的值而不是索引 |
|
|
this.form.houseCondition = value[0]; // 修改:直接使用选择的值而不是索引 |
|
|
this.form.houseConditionName = value[0]; |
|
|
this.form.houseConditionName = value[0]; |
|
|
|
|
|
// 选择后保存表单数据 |
|
|
|
|
|
this.debounceSaveFormData() |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 分类标识选择 |
|
|
// 分类标识选择 |
|
|
@ -322,6 +360,8 @@ |
|
|
let {indexs,value,values} = e |
|
|
let {indexs,value,values} = e |
|
|
that.form.classId = that.houseTypeList[indexs[0]].id; |
|
|
that.form.classId = that.houseTypeList[indexs[0]].id; |
|
|
that.form.className = that.houseTypeList[indexs[0]].title; |
|
|
that.form.className = that.houseTypeList[indexs[0]].title; |
|
|
|
|
|
// 选择后保存表单数据 |
|
|
|
|
|
that.debounceSaveFormData() |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 产权证照片上传 |
|
|
// 产权证照片上传 |
|
|
@ -332,12 +372,16 @@ |
|
|
self.form.propertyImages.push({ |
|
|
self.form.propertyImages.push({ |
|
|
url |
|
|
url |
|
|
}) |
|
|
}) |
|
|
|
|
|
// 上传完成后保存表单数据 |
|
|
|
|
|
self.debounceSaveFormData() |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
deletePropertyPic(event) { |
|
|
deletePropertyPic(event) { |
|
|
this.form.propertyImages.splice(event.index, 1) |
|
|
this.form.propertyImages.splice(event.index, 1) |
|
|
|
|
|
// 删除后保存表单数据 |
|
|
|
|
|
this.debounceSaveFormData() |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 房屋正面照片上传 |
|
|
// 房屋正面照片上传 |
|
|
@ -348,12 +392,16 @@ |
|
|
self.form.frontImages.push({ |
|
|
self.form.frontImages.push({ |
|
|
url |
|
|
url |
|
|
}) |
|
|
}) |
|
|
|
|
|
// 上传完成后保存表单数据 |
|
|
|
|
|
self.debounceSaveFormData() |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
deleteFrontPic(event) { |
|
|
deleteFrontPic(event) { |
|
|
this.form.frontImages.splice(event.index, 1) |
|
|
this.form.frontImages.splice(event.index, 1) |
|
|
|
|
|
// 删除后保存表单数据 |
|
|
|
|
|
this.debounceSaveFormData() |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 视频上传 |
|
|
// 视频上传 |
|
|
@ -375,6 +423,8 @@ |
|
|
self.form.videos.push({ |
|
|
self.form.videos.push({ |
|
|
url |
|
|
url |
|
|
}) |
|
|
}) |
|
|
|
|
|
// 上传完成后保存表单数据 |
|
|
|
|
|
self.debounceSaveFormData() |
|
|
}) |
|
|
}) |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
console.error('视频处理失败:', error) |
|
|
console.error('视频处理失败:', error) |
|
|
@ -383,6 +433,8 @@ |
|
|
self.form.videos.push({ |
|
|
self.form.videos.push({ |
|
|
url |
|
|
url |
|
|
}) |
|
|
}) |
|
|
|
|
|
// 上传完成后保存表单数据 |
|
|
|
|
|
self.debounceSaveFormData() |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -424,6 +476,8 @@ |
|
|
|
|
|
|
|
|
deleteVideoPic(event) { |
|
|
deleteVideoPic(event) { |
|
|
this.form.videos.splice(event.index, 1) |
|
|
this.form.videos.splice(event.index, 1) |
|
|
|
|
|
// 删除后保存表单数据 |
|
|
|
|
|
this.debounceSaveFormData() |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 切换房屋亮点 |
|
|
// 切换房屋亮点 |
|
|
@ -434,6 +488,8 @@ |
|
|
} else { |
|
|
} else { |
|
|
this.form.highlights.push(item); |
|
|
this.form.highlights.push(item); |
|
|
} |
|
|
} |
|
|
|
|
|
// 选择后保存表单数据 |
|
|
|
|
|
this.debounceSaveFormData() |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 切换不利因素 |
|
|
// 切换不利因素 |
|
|
@ -444,6 +500,8 @@ |
|
|
} else { |
|
|
} else { |
|
|
this.form.disadvantages.push(item); |
|
|
this.form.disadvantages.push(item); |
|
|
} |
|
|
} |
|
|
|
|
|
// 选择后保存表单数据 |
|
|
|
|
|
this.debounceSaveFormData() |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 提交表单 |
|
|
// 提交表单 |
|
|
@ -536,18 +594,20 @@ |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// 调用统一API |
|
|
// 调用统一API |
|
|
saveOrUpdateHouse(params).then(response => { |
|
|
|
|
|
uni.hideLoading(); |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: response.message || '提交成功', |
|
|
|
|
|
icon: 'success' |
|
|
|
|
|
}); |
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
uni.redirectTo({ |
|
|
|
|
|
url: "/pages_subpack/successful-apply/index" |
|
|
|
|
|
}); |
|
|
|
|
|
}, 2000); |
|
|
|
|
|
}).catch(error => { |
|
|
|
|
|
|
|
|
saveOrUpdateHouse(params).then(response => { |
|
|
|
|
|
uni.hideLoading(); |
|
|
|
|
|
// 提交成功后清除本地存储的表单数据 |
|
|
|
|
|
formStorage.removeFormData(this.formKey); |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: response.message || '提交成功', |
|
|
|
|
|
icon: 'success' |
|
|
|
|
|
}); |
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
uni.redirectTo({ |
|
|
|
|
|
url: "/pages_subpack/successful-apply/index" |
|
|
|
|
|
}); |
|
|
|
|
|
}, 2000); |
|
|
|
|
|
}).catch(error => { |
|
|
uni.hideLoading(); |
|
|
uni.hideLoading(); |
|
|
uni.showToast({ |
|
|
uni.showToast({ |
|
|
title: error.message || '提交失败', |
|
|
title: error.message || '提交失败', |
|
|
|