完善套餐购买、人脸拍照功能

This commit is contained in:
wangxiaowei
2026-04-11 18:33:23 +08:00
parent 2a95c0e176
commit be1ce34a74
6 changed files with 390 additions and 27 deletions

View File

@ -3,7 +3,7 @@
<navbar title="完善信息" bg="#F6F7F8"></navbar>
<view class="container" style="padding-top: 20px;">
<!-- 基本信息 -->
<!-- 青年卡-基本信息 -->
<view class="form-card" v-if="id == 1">
<view class="section-title">
基本信息 <text class="required">*</text>
@ -33,6 +33,37 @@
</view>
</view>
<!-- 成人卡-基本信息 -->
<view class="form-card" v-if="id == 2">
<view class="section-title">
基本信息 <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.adult.name" />
</view>
<view class="form-item">
<view class="label">出生年月</view>
<picker mode="date" :end="endDate" @change="onAdultDateChange">
<view class="picker-view" :class="{ 'has-value': formData.adult.both }">
<text>{{ formData.adult.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.adult.card" />
</view>
</view>
<!-- 家长1基本信息 -->
<view class="form-card" v-if="id == 3 || id == 4">
<view class="section-title">
@ -185,15 +216,20 @@ export default {
showSuccessPopup: false,
comboType: 'adult', // 套餐类型adult(成人卡) youth(青年卡) family(亲子卡)
formData: {
parents: [
{ name: '', both: '', card: '' },
{ name: '', both: '', card: '' }
],
youth: {
name: '',
both: '',
card: '',
},
adult: {
name: '',
both: '',
card: '',
},
parents: [
{ name: '', both: '', card: '' },
{ name: '', both: '', card: '' }
],
child: {
name: '',
both: '',
@ -214,6 +250,10 @@ export default {
methods: {
onYouthDateChange(e) {
this.formData.youth.both = e.detail.value;
},
onAdultDateChange(e) {
this.formData.adult.both = e.detail.value;
},
onParentDateChange(e, index) {
@ -230,6 +270,7 @@ export default {
submitForm() {
let self = this;
const regex = /^[1-9]\d{5}(18|19|20)?\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dXx]$/;
// id == 1 验证 youth 属性
if (self.id == 1) {
@ -237,6 +278,21 @@ export default {
if (!youth || !youth.name || !youth.both || !youth.card) {
return uni.showToast({ title: '请填写完整基本信息', icon: 'none' });
}
if (!regex.test(youth.card)) {
return uni.showToast({ title: '请输入正确的身份证号码', icon: 'none' });
}
}
// 成人卡
if (self.id == 2) {
// 购买成人卡时,需要验证 adult 属性
let adult = self.formData.adult;
if (!adult || !adult.name || !adult.both || !adult.card) {
return uni.showToast({ title: '请填写完整基本信息', icon: 'none' });
}
if (!regex.test(adult.card)) {
return uni.showToast({ title: '请输入正确的身份证号码', icon: 'none' });
}
}
// id == 3(第一个亲子卡) 或 4 时,验证 parents[0] 和 child 属性
@ -245,18 +301,27 @@ export default {
if (!p0 || !p0.name || !p0.both || !p0.card) {
return uni.showToast({ title: '请填写完整家长1基本信息', icon: 'none' });
}
if (!regex.test(p0.card)) {
return uni.showToast({ title: '请输入正确的家长1身份证号码', 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 child = self.formData.child;
if (!child || !child.name || !child.both || !child.card) {
return uni.showToast({ title: '请填写完整随行子女信息', 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(child.card)) {
return uni.showToast({ title: '请输入正确的子女身份证号码', icon: 'none' });
}
}
@ -276,8 +341,9 @@ export default {
let submitData = {
...self.formData,
parents: JSON.stringify(self.formData.parents),
youth: JSON.stringify(self.formData.youth),
adult: JSON.stringify(self.formData.adult),
parents: JSON.stringify(self.formData.parents),
child: JSON.stringify(self.formData.child)
};
@ -288,11 +354,12 @@ export default {
uni.hideLoading();
if (result.code) {
self.formData = {
youth: { name: '', both: '', card: '' },
adult: { name: '', both: '', card: '' },
parents: [
{ name: '', both: '', card: '' },
{ name: '', both: '', card: '' }
],
youth: { name: '', both: '', card: '' },
child: { name: '', both: '', card: '' },
phone: '',
group_id: self.id