diff --git a/api/modules/service.ts b/api/modules/service.ts index 6f558ab..dad6596 100644 --- a/api/modules/service.ts +++ b/api/modules/service.ts @@ -24,4 +24,13 @@ export const serviceApi = { // 查病历数据 getAidInfo: (firstAidId: string, codeList = []) => post('/firstAid/queryAidRecord', { param: { firstAidId, codeList } }), + + // 更新急救基本信息 + updateAidBase: param => post('/firstAid/update', { param }), + + // 更新急救code信息 + updateAidCode: param => post('/firstAid/saveAidRecord', { param }), + + // 查 下一个节点 + getNextNode: (firstAidId: string) => post('/firstAid/next', { param: { firstAidId } }), } diff --git a/components/CodeFormItem/CodeFormItem.vue b/components/CodeFormItem/CodeFormItem.vue index cc24cd0..d1f8fc9 100644 --- a/components/CodeFormItem/CodeFormItem.vue +++ b/components/CodeFormItem/CodeFormItem.vue @@ -2,9 +2,14 @@ - + - + + + diff --git a/components/DetailBase/DetailBase.vue b/components/DetailBase/DetailBase.vue index b07b354..3d27e54 100644 --- a/components/DetailBase/DetailBase.vue +++ b/components/DetailBase/DetailBase.vue @@ -7,17 +7,24 @@ + - + + - + + - + + - + diff --git a/hooks/useNextNode.ts b/hooks/useNextNode.ts new file mode 100644 index 0000000..14673f4 --- /dev/null +++ b/hooks/useNextNode.ts @@ -0,0 +1,54 @@ +import { computed, onUnmounted, ref } from 'vue' + +import { onUnload } from '@dcloudio/uni-app' +import { useServiceStore } from '@/store/modules/service' + +export interface INextNode { + countDownInSeconds: string + firstAidId: number + nextStepCode: string + nextStepName: string + nextStepType: string // 0 仅显示 1 弹窗询问是否进入下个环节 +} + +export function useNextNode() { + const serviceStore = useServiceStore() + const nextNode = ref(null) + const currentFirstAidId = computed(() => serviceStore.currentFirstAidId) + let timer: number + + async function getNextNode() { + if (!currentFirstAidId.value) { + uni.$u.alertError('没有急救id信息') + return + } + try { + nextNode.value = await uni.$u.api.getNextNode(currentFirstAidId.value) + } catch (error) { + nextNode.value = null + uni.$u.alertError(error) + } + } + + // 循环查下个节点 + function intervalGetNextCode() { + timer && clearInterval(timer) + timer = setInterval(() => { + getNextNode() + }, 1000) + } + + onUnmounted(() => { + console.log('on unmounted') + + timer && clearInterval(timer) + timer = 0 + }) + + onUnload(() => { + console.log('on unload') + timer && clearInterval(timer) + timer = 0 + }) + return { nextNode, getNextNode, intervalGetNextCode } +} diff --git a/pages/detail2/detail2.vue b/pages/detail2/detail2.vue index 8f6dd43..bbb08dd 100644 --- a/pages/detail2/detail2.vue +++ b/pages/detail2/detail2.vue @@ -39,8 +39,8 @@ - - NIHSS评分 + + {{ nextNode.nextStepName }} 00 : @@ -68,41 +68,37 @@ - - -