|
|
@@ -107,17 +107,8 @@
|
|
|
<view class="member-section-title">成员信息</view>
|
|
|
<view class="member-pre adfac">
|
|
|
<view class="member-pre-title"><span style="color: #F4657A;">*</span>人员类型</view>
|
|
|
- <view class="member-pre-content adfac">
|
|
|
- <view class="member-pre-content-box adfac" @click="memberInfo.personnelType=1">
|
|
|
- <image v-if="memberInfo.personnelType==1" src="https://oss.familydaf.cn/sxsnfile/20251218/ef2d43944c7e4cea8c6ebe0b4179f0fc.png"></image>
|
|
|
- <image v-else src="https://oss.familydaf.cn/sxsnfile/20251218/a27c9b23939d4d5085ff790ed4bd2d6a.png"></image>
|
|
|
- <text>成人</text>
|
|
|
- </view>
|
|
|
- <view class="member-pre-content-box adfac" @click="memberInfo.personnelType=2">
|
|
|
- <image v-if="memberInfo.personnelType==2" src="https://oss.familydaf.cn/sxsnfile/20251218/ef2d43944c7e4cea8c6ebe0b4179f0fc.png"></image>
|
|
|
- <image v-else src="https://oss.familydaf.cn/sxsnfile/20251218/a27c9b23939d4d5085ff790ed4bd2d6a.png"></image>
|
|
|
- <text>学生</text>
|
|
|
- </view>
|
|
|
+ <view class="member-pre-content">
|
|
|
+ <view style="font-size: 30rpx;color: #252525;text-align: right;">{{memberInfo.personnelType===2?'学生':'成人'}}</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="member-pre adfac">
|
|
|
@@ -195,7 +186,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup name="">
|
|
|
- import { ref, getCurrentInstance, nextTick } from 'vue'
|
|
|
+ import { ref, getCurrentInstance, nextTick, watch } from 'vue'
|
|
|
import { BaseApi2 } from '@/common/api/baseApi.js'
|
|
|
const { proxy } = getCurrentInstance()
|
|
|
import { useUserStore } from '@/common/stores/user.js';
|
|
|
@@ -230,6 +221,29 @@
|
|
|
const hasSelectedChannel = ref(false)
|
|
|
const qicShow = ref(false)
|
|
|
|
|
|
+ const calcAge = (idCard) => {
|
|
|
+ if (!idCard || !proxy.$reg.idCard(idCard)) return -1
|
|
|
+ const birthStr = idCard.substring(6, 14)
|
|
|
+ const birth = new Date(
|
|
|
+ parseInt(birthStr.substring(0, 4)),
|
|
|
+ parseInt(birthStr.substring(4, 6)) - 1,
|
|
|
+ parseInt(birthStr.substring(6, 8))
|
|
|
+ )
|
|
|
+ const today = new Date()
|
|
|
+ let age = today.getFullYear() - birth.getFullYear()
|
|
|
+ const m = today.getMonth() - birth.getMonth()
|
|
|
+ if (m < 0 || (m === 0 && today.getDate() < birth.getDate())) age--
|
|
|
+ return age
|
|
|
+ }
|
|
|
+
|
|
|
+ // 监听身份证变化,自动设置人员类型(>=18 为成人,<18 为学生)
|
|
|
+ watch(() => memberInfo.value.idCard, (val) => {
|
|
|
+ const age = calcAge(val)
|
|
|
+ if (age >= 0) {
|
|
|
+ memberInfo.value.personnelType = age >= 18 ? 1 : 2
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
const close = () => {
|
|
|
userStore.closeLoginModal();
|
|
|
}
|