|
|
@@ -41,6 +41,38 @@
|
|
|
<view class="age-display">{{ calculatedAge || '根据出生日期自动计算' }}</view>
|
|
|
</view>
|
|
|
|
|
|
+ <!-- 出生时辰(选填) -->
|
|
|
+ <view class="form-item">
|
|
|
+ <text class="label">出生时辰(选填)</text>
|
|
|
+ <picker :range="birthHourOptions" @change="onBirthHourChange">
|
|
|
+ <view class="picker">
|
|
|
+ {{ form.birthHourName || '请选择出生时辰' }}
|
|
|
+ </view>
|
|
|
+ </picker>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- 出生体重(选填) -->
|
|
|
+ <view class="form-item">
|
|
|
+ <text class="label">出生体重(选填,克)</text>
|
|
|
+ <input class="input" type="number" v-model="form.birthWeight" placeholder="如: 3500" maxlength="5" />
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- 出生地(选填) -->
|
|
|
+ <view class="form-item">
|
|
|
+ <text class="label">出生地(选填)</text>
|
|
|
+ <input class="input" v-model="form.birthPlace" placeholder="如: 北京市" maxlength="30" />
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- 是否剖腹产(选填) -->
|
|
|
+ <view class="form-item">
|
|
|
+ <text class="label">是否剖腹产(选填)</text>
|
|
|
+ <picker :range="cesareanOptions" range-key="label" @change="onCesareanChange">
|
|
|
+ <view class="picker">
|
|
|
+ {{ form.cesareanLabel || '请选择' }}
|
|
|
+ </view>
|
|
|
+ </picker>
|
|
|
+ </view>
|
|
|
+
|
|
|
<!-- 手机号(选填) -->
|
|
|
<view class="form-item">
|
|
|
<text class="label">手机号(选填)</text>
|
|
|
@@ -67,12 +99,23 @@ export default {
|
|
|
relationshipType: '',
|
|
|
gender: '',
|
|
|
birthday: '',
|
|
|
- phone: ''
|
|
|
+ phone: '',
|
|
|
+ birthHour: '',
|
|
|
+ birthHourName: '',
|
|
|
+ birthWeight: '',
|
|
|
+ birthPlace: '',
|
|
|
+ isCesarean: null,
|
|
|
+ cesareanLabel: ''
|
|
|
},
|
|
|
genderOptions: [
|
|
|
{ value: 'male', label: '男' },
|
|
|
{ value: 'female', label: '女' }
|
|
|
],
|
|
|
+ birthHourOptions: ['', '子时(23-1点)', '丑时(1-3点)', '寅时(3-5点)', '卯时(5-7点)', '辰时(7-9点)', '巳时(9-11点)', '午时(11-13点)', '未时(13-15点)', '申时(15-17点)', '酉时(17-19点)', '戌时(19-21点)', '亥时(21-23点)'],
|
|
|
+ cesareanOptions: [
|
|
|
+ { value: 0, label: '顺产' },
|
|
|
+ { value: 1, label: '剖腹产' }
|
|
|
+ ],
|
|
|
todayDate: ''
|
|
|
}
|
|
|
},
|
|
|
@@ -104,6 +147,21 @@ export default {
|
|
|
onBirthdayChange(e) {
|
|
|
this.form.birthday = e.detail.value
|
|
|
},
|
|
|
+ onBirthHourChange(e) {
|
|
|
+ var idx = e.detail.value
|
|
|
+ if (idx === 0) {
|
|
|
+ this.form.birthHour = ''
|
|
|
+ this.form.birthHourName = ''
|
|
|
+ } else {
|
|
|
+ this.form.birthHour = this.birthHourOptions[idx]
|
|
|
+ this.form.birthHourName = this.birthHourOptions[idx]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onCesareanChange(e) {
|
|
|
+ var idx = e.detail.value
|
|
|
+ this.form.isCesarean = this.cesareanOptions[idx].value
|
|
|
+ this.form.cesareanLabel = this.cesareanOptions[idx].label
|
|
|
+ },
|
|
|
async submit() {
|
|
|
if (!this.form.nickname || !this.form.nickname.trim()) {
|
|
|
uni.showToast({ title: '请输入成员昵称', icon: 'none' })
|
|
|
@@ -126,17 +184,66 @@ export default {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ // 根据 relationshipType 推导 generationLevel 和 peerType
|
|
|
+ var generationLevel = ''
|
|
|
+ var peerType = null
|
|
|
+ switch (this.form.relationshipType) {
|
|
|
+ case 'spouse':
|
|
|
+ generationLevel = 'peer'
|
|
|
+ peerType = 'spouse'
|
|
|
+ break
|
|
|
+ case 'sibling':
|
|
|
+ generationLevel = 'peer'
|
|
|
+ peerType = 'sibling'
|
|
|
+ break
|
|
|
+ case 'parent':
|
|
|
+ generationLevel = 'parent'
|
|
|
+ break
|
|
|
+ case 'child':
|
|
|
+ generationLevel = 'child'
|
|
|
+ break
|
|
|
+ case 'grandparent':
|
|
|
+ generationLevel = 'grandparent'
|
|
|
+ break
|
|
|
+ case 'grandchild':
|
|
|
+ generationLevel = 'grandchild'
|
|
|
+ break
|
|
|
+ case 'great_grandparent':
|
|
|
+ generationLevel = 'great_grandparent'
|
|
|
+ break
|
|
|
+ case 'great_grandchild':
|
|
|
+ generationLevel = 'great_grandchild'
|
|
|
+ break
|
|
|
+ default:
|
|
|
+ uni.showToast({ title: '无效的关系类型: ' + this.form.relationshipType, icon: 'none' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
try {
|
|
|
this.submitting = true
|
|
|
var payload = {
|
|
|
nickname: this.form.nickname.trim(),
|
|
|
relationshipType: this.form.relationshipType,
|
|
|
+ generationLevel: generationLevel,
|
|
|
+ peerType: peerType,
|
|
|
gender: this.form.gender,
|
|
|
birthday: this.form.birthday
|
|
|
}
|
|
|
if (this.form.phone) {
|
|
|
payload.phone = this.form.phone
|
|
|
}
|
|
|
+ if (this.form.birthHour) {
|
|
|
+ payload.birthHour = this.form.birthHour
|
|
|
+ }
|
|
|
+ if (this.form.birthWeight) {
|
|
|
+ payload.birthWeight = parseInt(this.form.birthWeight)
|
|
|
+ }
|
|
|
+ if (this.form.birthPlace) {
|
|
|
+ payload.birthPlace = this.form.birthPlace
|
|
|
+ }
|
|
|
+ if (this.form.isCesarean !== null && this.form.isCesarean !== undefined) {
|
|
|
+ payload.isCesarean = this.form.isCesarean
|
|
|
+ }
|
|
|
var res = await addFamilyMember(payload)
|
|
|
if (res.code === 200) {
|
|
|
uni.showToast({ title: '添加成功', icon: 'success' })
|