|
|
@@ -47,22 +47,22 @@
|
|
|
<input class="input" v-model="form.idCard" placeholder="请输入身份证号" maxlength="18" />
|
|
|
</view>
|
|
|
|
|
|
- <!-- 扣分开关 -->
|
|
|
- <view class="form-item">
|
|
|
+ <!-- 扣分开关(仅 children 系统支持) -->
|
|
|
+ <view class="form-item" v-if="!isFamilyMember">
|
|
|
<text class="label">扣分开关</text>
|
|
|
<switch :checked="form.penaltyEnabled === 1" @change="onPenaltyChange" color="#F97316" />
|
|
|
<text class="hint">开启后,超时未完成任务将扣减积分</text>
|
|
|
</view>
|
|
|
|
|
|
- <!-- 对家庭成员可见 -->
|
|
|
- <view class="form-item">
|
|
|
+ <!-- 对家庭成员可见(仅 children 系统支持) -->
|
|
|
+ <view class="form-item" v-if="!isFamilyMember">
|
|
|
<text class="label">对家庭成员可见</text>
|
|
|
<switch :checked="form.showToFamily !== 0" @change="onShowToFamilyChange" color="#5B9BD5" />
|
|
|
<text class="hint">关闭后,其他家庭成员将看不到此孩子</text>
|
|
|
</view>
|
|
|
|
|
|
- <!-- 主题风格 -->
|
|
|
- <view class="form-item">
|
|
|
+ <!-- 主题风格(仅 children 系统支持) -->
|
|
|
+ <view class="form-item" v-if="!isFamilyMember">
|
|
|
<text class="label">主题风格</text>
|
|
|
<picker :range="themes" range-key="label" @change="onThemeChange">
|
|
|
<view class="picker">
|
|
|
@@ -77,12 +77,14 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getChildren, updateChild } from '../../utils/api.js'
|
|
|
+import { getChildren, updateChild, updateFamilyMember } from '../../utils/api.js'
|
|
|
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
childId: '',
|
|
|
+ memberId: '',
|
|
|
+ isFamilyMember: false,
|
|
|
submitting: false,
|
|
|
form: {
|
|
|
nickname: '',
|
|
|
@@ -133,12 +135,19 @@ export default {
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
this.childId = options.childId || ''
|
|
|
- if (!this.childId) {
|
|
|
+ this.memberId = options.memberId || ''
|
|
|
+ if (!this.childId && !this.memberId) {
|
|
|
uni.showToast({ title: '参数错误', icon: 'none' })
|
|
|
setTimeout(() => uni.navigateBack(), 1500)
|
|
|
return
|
|
|
}
|
|
|
- this.loadChildData()
|
|
|
+ // 优先按 childId 从 children 系统加载,找不到则按 memberId 从 family-member 系统加载
|
|
|
+ if (this.childId) {
|
|
|
+ this.loadChildData()
|
|
|
+ } else {
|
|
|
+ this.isFamilyMember = true
|
|
|
+ this.loadFamilyMemberData(options)
|
|
|
+ }
|
|
|
},
|
|
|
methods: {
|
|
|
async loadChildData() {
|
|
|
@@ -158,12 +167,24 @@ export default {
|
|
|
showToFamily: child.showToFamily !== 0 ? 1 : 0,
|
|
|
theme: child.theme || 'default'
|
|
|
}
|
|
|
+ } else {
|
|
|
+ // children 系统找不到,尝试作为 family member 加载
|
|
|
+ this.isFamilyMember = true
|
|
|
+ this.memberId = this.childId
|
|
|
+ this.childId = ''
|
|
|
}
|
|
|
} catch (e) {
|
|
|
console.error('加载孩子数据失败', e)
|
|
|
uni.showToast({ title: '加载失败', icon: 'none' })
|
|
|
}
|
|
|
},
|
|
|
+ loadFamilyMemberData(options) {
|
|
|
+ // 从 URL 参数中填充基本信息(family member 系统字段有限)
|
|
|
+ this.form.nickname = options.nickname ? decodeURIComponent(options.nickname) : ''
|
|
|
+ this.form.gender = options.gender || ''
|
|
|
+ this.form.phone = options.phone || ''
|
|
|
+ this.form.birthday = options.birthday || ''
|
|
|
+ },
|
|
|
onBirthdayChange(e) {
|
|
|
this.form.birthday = e.detail.value
|
|
|
// 根据出生日期自动计算年龄
|
|
|
@@ -204,17 +225,27 @@ export default {
|
|
|
|
|
|
this.submitting = true
|
|
|
try {
|
|
|
- await updateChild(this.childId, {
|
|
|
- nickname: this.form.nickname,
|
|
|
- birthday: this.form.birthday,
|
|
|
- gender: this.form.gender,
|
|
|
- age: this.form.age,
|
|
|
- phone: this.form.phone,
|
|
|
- idCard: this.form.idCard,
|
|
|
- penaltyEnabled: this.form.penaltyEnabled,
|
|
|
- showToFamily: this.form.showToFamily,
|
|
|
- theme: this.form.theme
|
|
|
- })
|
|
|
+ if (this.isFamilyMember) {
|
|
|
+ await updateFamilyMember({
|
|
|
+ memberId: this.memberId,
|
|
|
+ nickname: this.form.nickname,
|
|
|
+ birthday: this.form.birthday,
|
|
|
+ gender: this.form.gender,
|
|
|
+ phone: this.form.phone
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ await updateChild(this.childId, {
|
|
|
+ nickname: this.form.nickname,
|
|
|
+ birthday: this.form.birthday,
|
|
|
+ gender: this.form.gender,
|
|
|
+ age: this.form.age,
|
|
|
+ phone: this.form.phone,
|
|
|
+ idCard: this.form.idCard,
|
|
|
+ penaltyEnabled: this.form.penaltyEnabled,
|
|
|
+ showToFamily: this.form.showToFamily,
|
|
|
+ theme: this.form.theme
|
|
|
+ })
|
|
|
+ }
|
|
|
uni.showToast({ title: '保存成功', icon: 'success' })
|
|
|
setTimeout(() => uni.navigateBack(), 1500)
|
|
|
} catch (e) {
|