表单校验1.0
This commit is contained in:
parent
deaa972edb
commit
05504a293d
|
|
@ -136,7 +136,10 @@ export default {
|
|||
|
||||
// 地址输入
|
||||
onAddressInput(e) {
|
||||
this.$emit('address-input', e.detail.value)
|
||||
const value = e.detail.value
|
||||
this.addressValue = value
|
||||
this.$emit('input', value)
|
||||
this.$emit('address-input', value)
|
||||
},
|
||||
|
||||
// 点击地图图标,自动获取定位并打开地图
|
||||
|
|
@ -242,6 +245,7 @@ export default {
|
|||
}
|
||||
|
||||
this.addressValue = this.currentLocation.address
|
||||
this.$emit('input', this.currentLocation.address)
|
||||
this.$emit('use-location', this.currentLocation)
|
||||
|
||||
uni.showToast({
|
||||
|
|
|
|||
|
|
@ -50,13 +50,18 @@
|
|||
@location-error="onLocationError"
|
||||
@use-location="onUseLocation"
|
||||
@map-opened="onMapOpened"
|
||||
|
||||
@input="onAddressInput"
|
||||
/>
|
||||
|
||||
<!-- 详细位置 -->
|
||||
<view class="form-item">
|
||||
<text class="field-label">详细位置</text>
|
||||
<input v-model="formData.detailAddress" class="field-input" placeholder="例:6栋201室" />
|
||||
<input
|
||||
v-model="formData.detailAddress"
|
||||
class="field-input"
|
||||
placeholder="例:6栋201室"
|
||||
@input="onDetailAddressInput"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 租赁设备 -->
|
||||
|
|
@ -149,18 +154,24 @@ export default {
|
|||
const nameValid = this.formData.name.trim().length > 0
|
||||
const phoneValid = this.formData.phone.trim().length > 0
|
||||
const addressValid = this.formData.address.trim().length > 0
|
||||
const detailAddressValid = this.formData.detailAddress.trim().length > 0
|
||||
const equipmentSelected = !!this.formData.equipmentId
|
||||
const packageSelected = !!this.formData.periodId
|
||||
const amountValid = parseFloat(this.totalAmount) > 0
|
||||
|
||||
const canPayResult = nameValid && phoneValid && addressValid &&
|
||||
const canPayResult = nameValid && phoneValid && addressValid && detailAddressValid &&
|
||||
equipmentSelected && packageSelected && amountValid
|
||||
|
||||
// 实时调试信息
|
||||
console.log('🔍 canPay 实时检查:', {
|
||||
nameValid,
|
||||
phoneValid,
|
||||
addressValid,
|
||||
addressValid: addressValid,
|
||||
addressValue: `"${this.formData.address}"`,
|
||||
addressLength: this.formData.address.length,
|
||||
detailAddressValid: detailAddressValid,
|
||||
detailAddressValue: `"${this.formData.detailAddress}"`,
|
||||
detailAddressLength: this.formData.detailAddress.length,
|
||||
equipmentSelected,
|
||||
packageSelected,
|
||||
amountValid,
|
||||
|
|
@ -181,6 +192,9 @@ export default {
|
|||
'formData.address'() {
|
||||
console.log('🔍 地址变化:', this.formData.address)
|
||||
},
|
||||
'formData.detailAddress'() {
|
||||
console.log('🔍 详细位置变化:', this.formData.detailAddress)
|
||||
},
|
||||
'formData.equipmentId'() {
|
||||
console.log('🔍 设备ID变化:', this.formData.equipmentId)
|
||||
},
|
||||
|
|
@ -218,6 +232,14 @@ export default {
|
|||
methods: {
|
||||
|
||||
|
||||
// 地址输入处理
|
||||
onAddressInput(value) {
|
||||
console.log('🔍 地址输入变化:', value)
|
||||
console.log('🔍 地址输入前 formData.address:', this.formData.address)
|
||||
this.formData.address = value
|
||||
console.log('🔍 地址输入后 formData.address:', this.formData.address)
|
||||
},
|
||||
|
||||
// 地图组件事件处理
|
||||
onLocationSuccess(location) {
|
||||
console.log('位置获取成功:', location)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user