完善功能
This commit is contained in:
@ -95,7 +95,7 @@
|
||||
</view>
|
||||
|
||||
<!-- 家长基本信息2 -->
|
||||
<view class="form-card" v-if="id == 4">
|
||||
<view class="form-card" v-if="id == 3 || id == 4">
|
||||
<view class="section-title">
|
||||
家长2基本信息 <text class="required">*</text>
|
||||
</view>
|
||||
@ -124,23 +124,23 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 随行子女信息 -->
|
||||
<!-- 随行子女1信息 -->
|
||||
<view class="form-card" v-if="id == 3 || id == 4">
|
||||
<view class="section-title">
|
||||
随行子女信息 <text class="required">*</text>
|
||||
随行子女1信息 <text class="required">*</text>
|
||||
</view>
|
||||
|
||||
<view class="form-item">
|
||||
<view class="label">姓名</view>
|
||||
<input class="input" type="text" placeholder="请填写姓名" placeholder-class="placeholder-style"
|
||||
v-model="formData.child.name" />
|
||||
v-model="formData.child[0].name" />
|
||||
</view>
|
||||
|
||||
<view class="form-item">
|
||||
<view class="label">出生年月</view>
|
||||
<picker mode="date" :end="endDate" @change="onChildDateChange">
|
||||
<view class="picker-view" :class="{ 'has-value': formData.child.both }">
|
||||
<text>{{ formData.child.both || '请选择出生年月' }}</text>
|
||||
<picker mode="date" :end="endDate" @change="(e) => onChildDateChange(e, 0)">
|
||||
<view class="picker-view" :class="{ 'has-value': formData.child[0].both }">
|
||||
<text>{{ formData.child[0].both || '请选择出生年月' }}</text>
|
||||
<image src="https://xh.stnav.com/uploads/sport/icon_down.png"
|
||||
style="width: 36rpx; height: 36rpx;" mode="aspectFit"></image>
|
||||
</view>
|
||||
@ -150,7 +150,37 @@
|
||||
<view class="form-item no-border">
|
||||
<view class="label">身份证号</view>
|
||||
<input class="input" type="idcard" placeholder="请输入身份证号码" placeholder-class="placeholder-style"
|
||||
v-model="formData.child.card" />
|
||||
v-model="formData.child[0].card" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 随行子女2信息 -->
|
||||
<view class="form-card" v-if="id == 4">
|
||||
<view class="section-title">
|
||||
随行子女2信息 <text class="required">*</text>
|
||||
</view>
|
||||
|
||||
<view class="form-item">
|
||||
<view class="label">姓名</view>
|
||||
<input class="input" type="text" placeholder="请填写姓名" placeholder-class="placeholder-style"
|
||||
v-model="formData.child[1].name" />
|
||||
</view>
|
||||
|
||||
<view class="form-item">
|
||||
<view class="label">出生年月</view>
|
||||
<picker mode="date" :end="endDate" @change="(e) => onChildDateChange(e, 1)">
|
||||
<view class="picker-view" :class="{ 'has-value': formData.child[1].both }">
|
||||
<text>{{ formData.child[1].both || '请选择出生年月' }}</text>
|
||||
<image src="https://xh.stnav.com/uploads/sport/icon_down.png"
|
||||
style="width: 36rpx; height: 36rpx;" mode="aspectFit"></image>
|
||||
</view>
|
||||
</picker>
|
||||
</view>
|
||||
|
||||
<view class="form-item no-border">
|
||||
<view class="label">身份证号</view>
|
||||
<input class="input" type="idcard" placeholder="请输入身份证号码" placeholder-class="placeholder-style"
|
||||
v-model="formData.child[1].card" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@ -230,11 +260,10 @@ export default {
|
||||
{ id: 0, name: '', both: '', card: '' },
|
||||
{ id: 0, name: '', both: '', card: '' }
|
||||
],
|
||||
child: {
|
||||
name: '',
|
||||
both: '',
|
||||
card: '',
|
||||
},
|
||||
child: [
|
||||
{ id: 0, name: '', both: '', card: '' },
|
||||
{ id: 0, name: '', both: '', card: '' }
|
||||
],
|
||||
phone: '',
|
||||
group_id: 0
|
||||
},
|
||||
@ -289,27 +318,46 @@ export default {
|
||||
if (data.group_id == 3 || data.group_id == 4) {
|
||||
// 亲子卡
|
||||
if (data.parent && data.parent.length > 0) {
|
||||
self.formData.parents[0] = {
|
||||
self.$set(self.formData.parents, 0, {
|
||||
id: data.parent[0].id,
|
||||
name: data.parent[0].name,
|
||||
both: data.parent[0].both,
|
||||
card: data.parent[0].card,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (data.parent && data.parent.length > 1) {
|
||||
self.formData.parents[1] = {
|
||||
id: data.parent[0].id,
|
||||
self.$set(self.formData.parents, 1, {
|
||||
id: data.parent[1].id,
|
||||
name: data.parent[1].name,
|
||||
both: data.parent[1].both,
|
||||
card: data.parent[1].card,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
self.formData.child = {
|
||||
name: data.name,
|
||||
both: data.both,
|
||||
card: data.card,
|
||||
if (data.child && data.child.length > 0) {
|
||||
self.$set(self.formData.child, 0, {
|
||||
id: data.child[0].id,
|
||||
name: data.child[0].name,
|
||||
both: data.child[0].both,
|
||||
card: data.child[0].card,
|
||||
});
|
||||
} else {
|
||||
self.$set(self.formData.child, 0, {
|
||||
id: 0,
|
||||
name: data.name || '',
|
||||
both: data.both || '',
|
||||
card: data.card || '',
|
||||
});
|
||||
}
|
||||
|
||||
if (data.child && data.child.length > 1) {
|
||||
self.$set(self.formData.child, 1, {
|
||||
id: data.child[1].id,
|
||||
name: data.child[1].name,
|
||||
both: data.child[1].both,
|
||||
card: data.child[1].card,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -347,8 +395,8 @@ export default {
|
||||
this.formData.parents[index].both = e.detail.value;
|
||||
},
|
||||
|
||||
onChildDateChange(e) {
|
||||
this.formData.child.both = e.detail.value;
|
||||
onChildDateChange(e, index) {
|
||||
this.formData.child[index].both = e.detail.value;
|
||||
},
|
||||
|
||||
contactUs() {
|
||||
@ -424,28 +472,38 @@ export default {
|
||||
let err0 = validateCardAndAgeMatch(p0.card, p0.both, '家长1', 'adult');
|
||||
if (err0) return uni.showToast({ title: err0, icon: 'none' });
|
||||
|
||||
// id == 4 时(第二个亲子卡),还需要额外验证 parents[1] 属性
|
||||
if (self.id == 4) {
|
||||
let p1 = self.formData.parents[1];
|
||||
if (!p1 || !p1.name || !p1.both || !p1.card) {
|
||||
return uni.showToast({ title: '请填写完整家长2基本信息', icon: 'none' });
|
||||
}
|
||||
if (!regex.test(p1.card)) {
|
||||
return uni.showToast({ title: '请输入正确的家长2身份证号码', icon: 'none' });
|
||||
}
|
||||
let err1 = validateCardAndAgeMatch(p1.card, p1.both, '家长2', 'adult');
|
||||
if (err1) return uni.showToast({ title: err1, icon: 'none' });
|
||||
let p1 = self.formData.parents[1];
|
||||
if (!p1 || !p1.name || !p1.both || !p1.card) {
|
||||
return uni.showToast({ title: '请填写完整家长2基本信息', icon: 'none' });
|
||||
}
|
||||
if (!regex.test(p1.card)) {
|
||||
return uni.showToast({ title: '请输入正确的家长2身份证号码', icon: 'none' });
|
||||
}
|
||||
let err1 = validateCardAndAgeMatch(p1.card, p1.both, '家长2', 'adult');
|
||||
if (err1) return uni.showToast({ title: err1, icon: 'none' });
|
||||
|
||||
let child = self.formData.child;
|
||||
if (!child || !child.name || !child.both || !child.card) {
|
||||
return uni.showToast({ title: '请填写完整随行子女信息', icon: 'none' });
|
||||
let child0 = self.formData.child[0];
|
||||
if (!child0 || !child0.name || !child0.both || !child0.card) {
|
||||
return uni.showToast({ title: '请填写完整随行子女1信息', icon: 'none' });
|
||||
}
|
||||
if (!regex.test(child.card)) {
|
||||
return uni.showToast({ title: '请输入正确的子女身份证号码', icon: 'none' });
|
||||
if (!regex.test(child0.card)) {
|
||||
return uni.showToast({ title: '请输入正确的子女1身份证号码', icon: 'none' });
|
||||
}
|
||||
let errC0 = validateCardAndAgeMatch(child0.card, child0.both, '子女1', 'child');
|
||||
if (errC0) return uni.showToast({ title: errC0, icon: 'none' });
|
||||
|
||||
// id == 4 时(第二个亲子卡),还需要额外验证 child[1] 属性
|
||||
if (self.id == 4) {
|
||||
let child1 = self.formData.child[1];
|
||||
if (!child1 || !child1.name || !child1.both || !child1.card) {
|
||||
return uni.showToast({ title: '请填写完整随行子女2信息', icon: 'none' });
|
||||
}
|
||||
if (!regex.test(child1.card)) {
|
||||
return uni.showToast({ title: '请输入正确的子女2身份证号码', icon: 'none' });
|
||||
}
|
||||
let errC1 = validateCardAndAgeMatch(child1.card, child1.both, '子女2', 'child');
|
||||
if (errC1) return uni.showToast({ title: errC1, icon: 'none' });
|
||||
}
|
||||
let errC = validateCardAndAgeMatch(child.card, child.both, '子女', 'child');
|
||||
if (errC) return uni.showToast({ title: errC, icon: 'none' });
|
||||
}
|
||||
|
||||
// 所有场景必填联系电话
|
||||
@ -483,7 +541,10 @@ export default {
|
||||
{ name: '', both: '', card: '' },
|
||||
{ name: '', both: '', card: '' }
|
||||
],
|
||||
child: { name: '', both: '', card: '' },
|
||||
child: [
|
||||
{ name: '', both: '', card: '' },
|
||||
{ name: '', both: '', card: '' }
|
||||
],
|
||||
phone: '',
|
||||
group_id: self.id
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user