|
@@ -164,6 +164,33 @@ const store = new Vuex.Store({
|
|
|
},
|
|
},
|
|
|
updateChildren({ commit }, children) {
|
|
updateChildren({ commit }, children) {
|
|
|
commit('setChildren', children)
|
|
commit('setChildren', children)
|
|
|
|
|
+ },
|
|
|
|
|
+ // 切换孩子前检查家庭中是否有孩子成员
|
|
|
|
|
+ switchToChildWithCheck({ commit }, { childId, members }) {
|
|
|
|
|
+ var hasChildren = members && members.some(function(m) {
|
|
|
|
|
+ return m.effectiveRole === 'child'
|
|
|
|
|
+ })
|
|
|
|
|
+ if (!hasChildren) {
|
|
|
|
|
+ uni.showToast({ title: '家庭中暂无孩子', icon: 'none' })
|
|
|
|
|
+ return false
|
|
|
|
|
+ }
|
|
|
|
|
+ commit('switchToChild', childId)
|
|
|
|
|
+ return true
|
|
|
|
|
+ },
|
|
|
|
|
+ // 切换到家庭成员前检查(仅 child 角色需要前置检查)
|
|
|
|
|
+ switchToMemberWithCheck({ commit }, payload) {
|
|
|
|
|
+ if (payload.effectiveRole === 'child') {
|
|
|
|
|
+ var members = payload.members || []
|
|
|
|
|
+ var hasChildren = members.some(function(m) {
|
|
|
|
|
+ return m.effectiveRole === 'child'
|
|
|
|
|
+ })
|
|
|
|
|
+ if (!hasChildren) {
|
|
|
|
|
+ uni.showToast({ title: '家庭中暂无孩子', icon: 'none' })
|
|
|
|
|
+ return false
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ commit('switchToMember', payload)
|
|
|
|
|
+ return true
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
,
|
|
,
|