Quellcode durchsuchen

Merge branch 'release/2.1.0'

cc12458 vor 1 Monat
Ursprung
Commit
2eb3cb1407

+ 2 - 2
package.json

@@ -16,8 +16,8 @@
   },
   "dependencies": {
     "@alova/mock": "^2.0.7",
-    "@vueuse/core": "^11.1.0",
-    "@vueuse/router": "^11.1.0",
+    "@vueuse/core": "^13.6.0",
+    "@vueuse/router": "^13.6.0",
     "alova": "^3.0.20",
     "echarts": "^5.5.1",
     "eruda": "^3.4.0",

Datei-Diff unterdrückt, da er zu groß ist
+ 592 - 1575
pnpm-lock.yaml


BIN
src/assets/images/alcohol-0.png


BIN
src/assets/images/alcohol-1.png


+ 38 - 12
src/components/AnalysisPulseComponent.vue

@@ -10,6 +10,7 @@ import { getURLSearchParamsByUrl } from '@/tools';
 import HandLeft from '@/assets/images/pulse-hand-left.png?url';
 import HandRight from '@/assets/images/pulse-hand-right.png?url';
 import { useVisitor } from '@/stores';
+import { Toast } from '@/platform';
 
 type Props = Partial<SimplePulseModel> & { title?: string; results?: string; disabled?: boolean; simple?: boolean };
 
@@ -45,7 +46,7 @@ const stringifyUrl = (panel: 'left' | 'right', simple = false, overall = true) =
 };
 
 const { data: agent, loading, send: getPulseAgent } = useRequest(() => getPulseAgentMethod(), {
-  initialData: void 0,
+  initialData: parseUrl(report.value?.url),
   immediate: false,
 });
 
@@ -81,12 +82,13 @@ const load = async (panel: 'left' | 'right' | boolean = true, simple = false) =>
 
   if (!agent.value) {
     try {
+      if (__FORBID_AUTO_PROCESS_PULSE_AGENCY__) throw { _: `禁止从设备中获取代理地址` };
       const { promise, ...resolvers } = Promise.withResolvers<string>();
       await window.bridge.postMessage('pulse:url:get', report.value?.measureId, resolvers);
       agent.value = parseUrl(await promise);
-    } catch (e) {
-      const value = await getPulseAgent().catch(() => void 0);
-      if (!value) agent.value = parseUrl();
+    } catch (e: any) {
+      if (e._) console.info(`log: ${e._}`);
+      agent.value = await getPulseAgent().catch(() => void 0);
     }
   }
 
@@ -116,18 +118,33 @@ const load = async (panel: 'left' | 'right' | boolean = true, simple = false) =>
     }
   }
 };
+
+const panelWrapperRef = useTemplateRef('panel-wrapper-ref');
 const open = async (panel?: 'left' | 'right', scroll = true) => {
   if (disabled) return;
 
+  toast = Toast.loading(500);
   await load(panel);
-  if (scroll) getHeightAndScrollTop();
-  else {
+  if (scroll) {
+    const last = panelConfig.height;
+    getHeightAndScrollTop();
+    if (last === panelConfig.height) {
+      const el = panelWrapperRef.value?.$el?.querySelector(`.van-floating-panel__content`);
+      el.scroll({ top: 0, behavior: 'smooth' });
+      console.log(panelWrapperRef.value.$el);
+    }
+  } else {
     const height = window.innerHeight * 0.8;
     panelConfig.anchors = [0, height];
     panelConfig.height = height;
   }
 };
 
+let toast;
+function iframeLoaded() {
+  toast?.close();
+}
+
 tryOnMounted(() => {
   if (!slots.exception) load(false, simple);
   preview.clickMainPanelPreviewable = !!slots.exception;
@@ -146,7 +163,7 @@ watchPostEffect(() => {
 <template>
   <van-skeleton class="analysis" :row="5" :loading="report?.results == null" v-if="report?.results !== ''">
     <PreviewSlot v-slot="{ src }">
-      <iframe v-if="src" :src="src" :class="{ simple: !src.includes('Hand=true') }"></iframe>
+      <iframe v-if="src" :src="src" :class="{ simple: !src.includes('Hand=true') }" @load="iframeLoaded()"></iframe>
     </PreviewSlot>
     <slot>
       <div ref="card" class="card m-6 text-lg" @click="panelConfig.height = 0">
@@ -154,7 +171,7 @@ watchPostEffect(() => {
         <slot name="content" :report="report">
           <div class="card__content">
             <div v-if="report?.summaryLabel" class="flex justify-evenly">
-              <div v-if="report?.summaryLabel?.left" class="flex flex-row-reverse justify-center" @click.stop="preview.clickMainPanelPreviewable && open('left')">
+              <div v-if="report?.summaryLabel?.left" class="part flex flex-row-reverse justify-center" @click.stop="preview.clickMainPanelPreviewable && open('left')">
                 <img style="width: 100px; height: 200px" :src="HandLeft" alt="左手" />
                 <div class="flex flex-col justify-evenly translate-y-2 h-40 text-xl" :class="{ highlight: preview.showLeftPanel }">
                   <div>寸:<span style="letter-spacing: 4px">{{ report.summaryLabel.left.cun }}</span></div>
@@ -162,14 +179,16 @@ watchPostEffect(() => {
                   <div>尺:<span style="letter-spacing: 4px">{{ report.summaryLabel.left.chi }}</span>
                   </div>
                 </div>
+                <div v-if="!disabled && preview.clickMainPanelPreviewable" class="absolute bottom-2 text-primary text-sm">查看脉象详情</div>
               </div>
-              <div v-if="report?.summaryLabel?.right" class="flex justify-center" @click.stop="preview.clickMainPanelPreviewable && open('right')">
+              <div v-if="report?.summaryLabel?.right" class="part flex justify-center" @click.stop="preview.clickMainPanelPreviewable && open('right')">
                 <img style="width: 100px; height: 200px" :src="HandRight" alt="右手" />
                 <div class="flex flex-col justify-evenly translate-y-2 h-40 text-xl" :class="{ highlight: preview.showRightPanel }">
                   <div>寸:<span style="letter-spacing: 4px">{{ report.summaryLabel.right.cun }}</span></div>
                   <div>关:<span style="letter-spacing: 4px">{{ report.summaryLabel.right.guan }}</span></div>
                   <div>尺:<span style="letter-spacing: 4px">{{ report.summaryLabel.right.chi }}</span></div>
                 </div>
+                <div v-if="!disabled && preview.clickMainPanelPreviewable" class="absolute bottom-2 text-primary text-sm">查看脉象详情</div>
               </div>
             </div>
             <p v-if="report?.results" class="text-2xl text-center" @click.stop="preview.clickMainPanelPreviewable && open()">
@@ -201,7 +220,7 @@ watchPostEffect(() => {
         </div>
       </slot>
     </slot>
-    <van-floating-panel class="pulse-info-panel" :content-draggable="false" :lock-scroll="true" :anchors="panelConfig.anchors" v-model:height="panelConfig.height">
+    <van-floating-panel ref="panel-wrapper-ref" class="pulse-info-panel" :content-draggable="false" :lock-scroll="true" :anchors="panelConfig.anchors" v-model:height="panelConfig.height">
       <template #header>
         <div class="van-floating-panel__header !justify-between">
           <div></div>
@@ -209,11 +228,11 @@ watchPostEffect(() => {
           <van-icon class="pr-2" name="cross" @click="panelConfig.height = 0" />
         </div>
       </template>
-      <div class="area" :class="{ last: !preview.showRightPanel }" v-if="report?.summaryLabel?.left" v-show="preview.showLeftPanel">
+      <div class="area" :class="{ last: !preview.showRightPanel }" v-if="preview.showLeftPanel && report?.summaryLabel?.left">
         <div class="title">左手脉象: {{ report.summaryLabel.left.summary?.join('、') }}</div>
         <ReusePreview :src="preview.leftPanelUrl"></ReusePreview>
       </div>
-      <div class="area" v-if="report?.summaryLabel?.right" v-show="preview.showRightPanel">
+      <div class="area" v-if="preview.showRightPanel && report?.summaryLabel?.right">
         <div class="title">右手脉象: {{ report.summaryLabel.right.summary?.join('、') }}</div>
         <ReusePreview :src="preview.rightPanelUrl"></ReusePreview>
       </div>
@@ -222,8 +241,15 @@ watchPostEffect(() => {
 </template>
 
 <style scoped lang="scss">
+.part {
+  position: relative;
+  width: 50%;
+}
 .highlight {
   color: rgb(52 167 107 / var(--tw-text-opacity, 1));
+  & + div {
+    opacity: 0.5;
+  }
 }
 
 $h: 1660px;

+ 212 - 0
src/components/PickerDialog.vue

@@ -0,0 +1,212 @@
+<script setup lang="ts">
+import type { Option } from '@/request/model';
+import { tryOnBeforeMount, tryOnUnmounted } from '@vueuse/core';
+import type { DialogProps } from 'vant';
+
+export interface Props {
+  options: Option[];
+  title?: string;
+  multiple?: boolean;
+  /* 单选点击选项直接确定 */
+  immediate?: boolean;
+  selected?: (string | EditableOption)[];
+}
+
+type EditableOption = Option & { inputValue?: string; showLabel?: string };
+
+let cache: WeakMap<Option[], EditableOption[]>;
+const onCleanup = () => {
+  cache = new WeakMap();
+};
+
+const props = defineProps<Props>();
+const emits = defineEmits<{ closed: []; selected: [{ label: string; value: string }[]] }>();
+const show = defineModel('show', { default: false });
+
+const options = ref<EditableOption[]>([]);
+const dialog = reactive<Partial<DialogProps>>({
+  showCancelButton: true,
+});
+
+watchEffect(() => {
+  dialog.title = props.title ?? void 0;
+  dialog.showConfirmButton = props.multiple || !props.immediate;
+});
+const selectedInput = useTemplateRef<{ focus(): void; $el: HTMLInputElement; }>('input');
+const selectedOptions = ref<EditableOption>();
+const dialogConfirmHandle = (emit?: boolean) => {
+  if (selectedOptions.value && !emit) {
+    const option = selectedOptions.value;
+    if (!option.inputValue) option.inputValue = option.showLabel;
+    if (!option.inputValue || option.inputValue === option.label) return dialogCancelHandle();
+
+    selectedOptions.value.showLabel = option.inputValue;
+    selectedOptions.value.checked = true;
+    if (props.immediate) handle(selectedOptions.value, true);
+    else selectedOptions.value = void 0;
+  } else {
+    emits('selected', options.value.filter((option) => option.checked).map((option) => ({
+      label: option.showLabel ?? option.label,
+      value: option.editable ? `${option.value}:${option.showLabel ?? option.label}` : option.value,
+    })));
+    show.value = false;
+  }
+};
+const dialogCancelHandle = () => {
+  if (selectedOptions.value) {
+    dialog.showConfirmButton = props.multiple || !props.immediate;
+    delete dialog.confirmButtonText;
+    delete dialog.cancelButtonText;
+    const option = selectedOptions.value;
+    selectedOptions.value.inputValue = option.showLabel !== option.label ? option.showLabel : ``;
+    selectedOptions.value.checked = false;
+    selectedOptions.value = void 0;
+  } else {
+    show.value = false;
+  }
+};
+const dialogOpenHandle = (select?: EditableOption[]) => {
+  select ??= (props.selected?.map((option) => {
+    if (typeof option === 'string') {
+      const [value, inputValue] = option.split(':');
+      if (!value) return false;
+      option = { value, inputValue } as EditableOption;
+    }
+    return option;
+  })?.filter(Boolean) as EditableOption[]) ?? [];
+
+  const value = props.options;
+  if (!cache.has(value)) cache.set(value, value.map((item) => Object.assign({ inputValue: '', showLabel: item.label }, item)));
+  const values = cache.get(value)!;
+
+  if (select.length) for (const option of values) option.checked = false;
+  for (const item of select) {
+    if (!item) continue;
+    const option = values.find((v) => v.value === item.value);
+    if (!option) continue;
+    if (option.editable) {
+      option.inputValue = item.inputValue;
+      option.showLabel = item.inputValue ?? option.label;
+    }
+    option.checked = true;
+  }
+
+  options.value = values;
+  show.value = true;
+};
+const dialogClosedHandle = () => {
+  emits('closed');
+  selectedOptions.value = void 0;
+};
+const handle = (option: EditableOption, checked?: boolean) => {
+  if (option.disabled) return;
+
+  if (option.editable && checked == null) {
+    selectedOptions.value = option;
+    dialog.showConfirmButton = true;
+    dialog.confirmButtonText = '确认';
+    dialog.cancelButtonText = '返回';
+    return nextTick(() => {
+      /*try { selectedInput.value?.$el?.querySelector('input')?.select(); } catch (e) {}*/
+      try { selectedInput.value?.focus?.(); } catch (e) {}
+    })
+  }
+
+  checked ??= !option.checked;
+  if (checked) {
+    if (!props.multiple || option.single) for (const option of options.value) option.checked = false;
+    else {
+      const single = options.value.find((option) => option.single);
+      if (single) single.checked = false;
+    }
+  }
+
+  option.checked = checked;
+  if (props.immediate) setTimeout(() => dialogConfirmHandle(true), 100);
+};
+
+tryOnBeforeMount(() => onCleanup());
+tryOnUnmounted(() => onCleanup());
+defineExpose({ onCleanup });
+</script>
+
+<template>
+  <div>
+    <slot :handle="dialogOpenHandle"></slot>
+    <van-dialog
+      class="sub-dialog scrollable"
+      :show="show"
+      v-bind="dialog"
+      @confirm="dialogConfirmHandle"
+      @cancel="dialogCancelHandle"
+      @open="dialogOpenHandle"
+      @closed="dialogClosedHandle"
+    >
+      <template v-if="selectedOptions">
+        <van-cell-group inset class="form-wrapper">
+          <van-field ref="input" v-model="selectedOptions.inputValue" :placeholder="selectedOptions.showLabel" maxlength="10" />
+        </van-cell-group>
+      </template>
+      <template v-else>
+        <slot name="options" :options="options" :handle="handle">
+          <div class="grid grid-rows-1 grid-cols-2 gap-4 py-4 px-12">
+            <div
+              v-for="(option, index) in options"
+              :key="option.value"
+              class="sub-option flex justify-center items-center min-h-16 text-lg text-primary hover:text-white rounded-xl border border-primary hover:border-primary-400"
+              :class="{ checked: option.checked, disabled: option.disabled }"
+              @click="handle(option)"
+            >
+              <div class="p-2 text-center">{{ option.showLabel }}</div>
+            </div>
+          </div>
+        </slot>
+      </template>
+    </van-dialog>
+  </div>
+</template>
+
+<style scoped lang="scss">
+.form-wrapper {
+  .van-field {
+    margin: 0;
+    padding: 0;
+  }
+
+  :deep(.van-field__control) {
+    margin-bottom: 24px;
+    padding: 8px;
+    border: 1px solid #38ff6e;
+    border-radius: 8px;
+    text-align: center;
+  }
+}
+
+.sub-option.checked {
+  color: #fff;
+  background-color: var(--primary-color);
+}
+</style>
+<style lang="scss">
+.sub-dialog {
+  --van-dialog-width: 60vw;
+  --van-dialog-font-size: 24px;
+  --van-dialog-button-height: 60px;
+  --van-button-default-font-size: 24px;
+
+  &.scrollable {
+    max-height: 80vh;
+    display: flex;
+    flex-direction: column;
+
+    .van-dialog__header {
+      padding-bottom: var(--van-dialog-header-padding-top);
+    }
+
+    .van-dialog__content {
+      flex: auto;
+      overflow-y: auto;
+    }
+  }
+}
+</style>

+ 59 - 0
src/computable/useRouteNext.ts

@@ -0,0 +1,59 @@
+import { tryOnBeforeMount } from '@vueuse/core';
+
+import { useRequest } from 'alova/client';
+import { processMethod } from '@/request/api';
+import type { Flow, FlowRoute } from '@/request/model';
+
+import { useVisitor } from '@/stores';
+
+export interface RouteNextOption {
+  immediate: boolean;
+
+  onSuccess(flow: FlowRoute): void | Promise<void>;
+
+  onError(error: Error | { message: string }): void;
+
+  onComplete(): void;
+}
+
+export function useRouteNext(option?: Partial<RouteNextOption>) {
+  const router = useRouter();
+  const path = computed(() => router.currentRoute.value.path);
+
+  const flow = shallowRef<FlowRoute>();
+
+  const { send, loading } = useRequest(processMethod, { immediate: false }).onSuccess(({ data, args: [key] }) => {
+    flow.value = data.parse(key);
+  });
+
+  const handle = async () => {
+    try {
+      await send(path.value);
+      loading.value = true;
+      await option?.onSuccess?.(flow.value!);
+    } catch (error) {
+      flow.value = void 0;
+      option?.onError?.(<{ message: string }>error);
+    }
+    option?.onComplete?.();
+    loading.value = false;
+    return flow.value;
+  };
+
+  tryOnBeforeMount(() => {
+    if (option?.immediate) {
+      const block = () => void 0;
+      send(path.value).then(block, block);
+    }
+  });
+
+  return { handle, flow, loading };
+}
+
+export function getRoutePath(flow?: Flow) {
+  let route = flow?.route;
+  if (!route) throw { message: `[路由] 页面未找到` };
+  if (route === '/report') route += `/${useVisitor().reportId}`;
+
+  return route;
+}

+ 3 - 3
src/loader/bridge.loader.ts

@@ -1,5 +1,5 @@
-import { processMethod, scanAccountMethod } from '@/request/api';
-import router                               from '@/router';
+import { getNextProcess, scanAccountMethod } from '@/request/api';
+import router                                from '@/router';
 
 import { platformIsAIO, platformIsAIO_1 } from '@/platform';
 
@@ -46,7 +46,7 @@ export default function bridgeLoader(): DEV.Loader {
           const data = await scanAccountMethod(detail.data.code).catch(() => {});
 
           if (data) {
-            const path = data?.path ?? (route?.path === '/screen' ? await processMethod() : route?.path);
+            const path = data?.path ?? (route?.path === '/screen' ? await getNextProcess().catch(() => route?.path) : route?.path);
             const key = Date.now();
             sessionStorage.setItem(`scan_${key}`, JSON.stringify(data));
             await router.replace({ path, query: { scan: key } });

+ 151 - 0
src/modules/alcohol/alcohol.page.vue

@@ -0,0 +1,151 @@
+<script setup lang="ts">
+import { Notify } from '@/platform';
+import { tryOnBeforeMount, tryOnUnmounted, useCountdown } from '@vueuse/core';
+
+import { getAlcoholReportMethod } from '@/request/api';
+import type { Flow, FlowRoute } from '@/request/model';
+import { getRoutePath, useRouteNext } from '@/computable/useRouteNext';
+import { useRouteMeta } from '@/router/hooks/useRouteMeta';
+
+import NavHomeSelect from '@/assets/images/nav-home.select.png?url';
+import alcohol_0 from '@/assets/images/alcohol-0.png?url';
+import alcohol_1 from '@/assets/images/alcohol-1.png?url';
+
+const router = useRouter();
+const actionText = computed(() => `获取健康调理方案`);
+/* 倒计时完成动作 */
+const done = shallowRef<Flow>();
+/* 下一动作可选 */
+const next = shallowRef<Flow>();
+
+const title = useRouteMeta('title');
+const { handle, flow, loading } = useRouteNext({
+  onSuccess(flow) { return load(flow); },
+  onError(error) { Notify.warning(error.message); },
+});
+
+const { remaining, start, stop } = useCountdown(5, {
+  onComplete() { replace(done.value!); },
+  immediate: false,
+});
+const countdown = computed(() => remaining.value.toString().padStart(2, '0'));
+
+tryOnBeforeMount(() => handle());
+tryOnUnmounted(() => stop());
+
+const report = ref<Awaited<ReturnType<typeof getAlcoholReportMethod>>>();
+const tips = '建议您每日饮酒';
+const description = computed(() => report.value?.alcohol?.description
+  ?.replace?.(new RegExp(`^${tips}`), '')
+  ?.replace?.(/(\S)\s*(或)/g, '$1\n$2')
+  ?.replace?.(/(\{[^}]*})/g, "\n$1\n")
+  ?.replace?.(/(\[[^\]]*])/g, "\n$1\n")
+  ?.replace?.(/(\([^)]*\))/g, "\n$1\n")
+  ?.replace?.(/(([^)]*))/g, "\n$1\n")
+  ?.replace?.(/([((\[][^))\]]*\))/g, "\n$1\n")
+  ?? ''
+);
+
+async function load(flow: FlowRoute) {
+  stop();
+  report.value = await getAlcoholReportMethod();
+
+  done.value = flow.next.optional ? { title: '返回首页', route: '/screen' } : flow.next;
+  next.value = flow.next.optional ? flow.next : void 0;
+  start(report.value?.alcohol?.description ? 60 : 5);
+}
+
+const replace = (flow: Flow) => router.push({ path: getRoutePath(flow), replace: true });
+</script>
+<template>
+  <div>
+    <div class="page-header flex py-4 px-4">
+      <div class="grow shrink-0 h-full min-w-16"></div>
+      <div class="grow-[3] shrink mx-2 flex flex-col justify-center overflow-hidden">
+        <div class="font-bold text-3xl text-nowrap text-center tracking-wide overflow-ellipsis overflow-hidden">
+          {{ flow?.value.title ?? title }}
+        </div>
+      </div>
+      <div class="grow shrink-0 h-full min-w-16 flex items-center justify-end overflow-hidden">
+        <router-link :to="{ path: '/screen' }" replace>
+          <img class="size-8 object-scale-down" :src="NavHomeSelect" alt="返回首页" />
+        </router-link>
+      </div>
+    </div>
+    <div class="page-content flex flex-col">
+      <van-toast v-if="loading" show type="loading" message="加载中" />
+      <template v-else>
+        <header>
+          <div class="my-6 text-primary text-2xl text-center" v-if="report?.date">报告日期:{{ report.date }}</div>
+        </header>
+        <main class="flex flex-col justify-evenly">
+          <div class="report-wrapper" v-if="report">
+            <div class="card m-6 text-lg" v-if="report.alcohol?.condition">
+              <div v-if="title" class="card__title mb-3 text-primary text-2xl font-bold">您的情况为</div>
+              <div class="card__content">
+                <div class="text-center text-4xl font-bold pre" style="letter-spacing: 4px">
+                  {{ report.alcohol?.condition }}
+                </div>
+              </div>
+            </div>
+            <div class="card m-6 text-lg">
+              <div v-if="title" class="card__title mb-3 text-primary text-2xl">{{ tips }}</div>
+              <div class="card__content">
+                <div class="flex items-center justify-center min-h-32" v-if="report.alcohol?.description">
+                  <div class="text-center text-5xl font-semibold whitespace-pre" style="letter-spacing: 4px; line-height: 1.25em">
+                    {{ description }}
+                  </div>
+                  <img v-if="report.alcohol?.volume?.length" class="image-container object-scale-down" :src="alcohol_1" alt="可饮酒" />
+                </div>
+                <van-empty v-else :image="alcohol_0" image-size="160" description="暂无建议" />
+              </div>
+            </div>
+          </div>
+        </main>
+        <footer class="flex flex-col justify-center items-center gap-4">
+          <van-button v-if="next" class="decorate !text-xl" @click="replace(next)">
+            {{ next.title ?? actionText }}
+          </van-button>
+          <van-button v-if="done" class="decorate !text-xl !text-primary-400" @click="replace(done)">
+            {{ done.title ?? actionText }}
+            <template v-if="remaining">({{ countdown }}s)</template>
+          </van-button>
+        </footer>
+      </template>
+    </div>
+  </div>
+</template>
+<style scoped lang="scss">
+header {
+  flex: 1 1 10%;
+}
+
+footer {
+  flex: 1 1 30%;
+}
+
+main {
+  position: relative;
+  flex: 1 1 50%;
+}
+
+.image-container {
+  width: 30vw;
+  height: 30vw;
+  max-width: 216px;
+  max-height: 216px;
+}
+
+.card__content {
+  --van-empty-description-color: #fff;
+  --van-empty-description-margin-top: 36px;
+  --van-empty-description-font-size: 18px;
+}
+</style>
+<style scoped lang="scss">
+.report-wrapper .card {
+  padding: 24px;
+  border-radius: 24px;
+  box-shadow: inset 0 0 80px 0 #34a76b60;
+}
+</style>

+ 33 - 36
src/modules/camera/camera-result.page.vue

@@ -1,46 +1,42 @@
 <script setup lang="ts">
-import { processMethod2 } from '@/request/api';
-import { useRequest } from 'alova/client';
+import { tryOnBeforeMount, tryOnUnmounted, useCountdown } from '@vueuse/core';
 import { useRouter } from 'vue-router';
 
+import { getRoutePath, useRouteNext } from '@/computable/useRouteNext';
+import type { Flow } from '@/request/model';
+
+import { Notify } from '@/platform';
+
 defineOptions({
   name: 'CameraResult',
 });
 
-const router = useRouter();
+const actionText = computed(() => `获取健康调理方案`);
+/* 倒计时完成动作 */
+const done = shallowRef<Flow>();
+/* 下一动作可选 */
+const next = shallowRef<Flow>();
 
-const { data, loading } = useRequest(processMethod2).onSuccess(({ data }) => {
-  init(data.optional ? 10 : 5);
+const { handle, loading } = useRouteNext({
+  onSuccess(flow) {
+    done.value = flow.next.optional ? { title: '返回首页', route: '/screen' } : flow.next;
+    next.value = flow.next.optional ? flow.next : void 0;
+    start(flow.next.optional ? 10 : 5);
+  },
+  onError(error) { Notify.warning(error.message); },
 });
-const tips = computed(() => (data.value.route === '/screen' || data.value.optional ? '返回首页' : '获取健康调理方案'));
-const countdown = ref(5);
-
-let timer: ReturnType<typeof setInterval>;
 
-function done() {
-  if (!data.value.optional) next();
-  else {
-    clearInterval(timer);
-    router.replace({ path: '/screen' });
-  }
-}
-
-function next() {
-  clearInterval(timer);
-  router.replace({ path: data.value.route });
-}
+const { remaining, start, stop } = useCountdown(5, {
+  onComplete() { replace(done.value!); },
+  immediate: false,
+});
+const countdown = computed(() => remaining.value.toString().padStart(2, '0'));
 
-function init(value = 5) {
-  countdown.value = value;
-  timer = setInterval(() => {
-    const _countdown = countdown.value - 1;
-    if ( _countdown <= 0 ) { done(); } else { countdown.value = _countdown; }
-  }, 1000);
-}
+tryOnBeforeMount(() => handle());
+tryOnUnmounted(() => stop());
 
-onBeforeUnmount(() => {
-  clearInterval(timer);
-});
+const router = useRouter();
+const replace = (flow: Flow) => router.push({ path: getRoutePath(flow), replace: true });
 </script>
 <template>
   <div>
@@ -55,13 +51,14 @@ onBeforeUnmount(() => {
           <div class="text-3xl text-center my-8">完成舌面象的采集</div>
         </div>
       </main>
-      <footer class="flex flex-col items-center" style="flex: 1 1 30%">
+      <footer class="flex flex-col items-center gap-4" style="flex: 1 1 30%">
         <template v-if="!loading">
-          <van-button v-if="data.optional" class="decorate !text-xl !text-primary-400 !mb-6" :loading @click="next()">
-            {{ data.title || '获取健康调理方案' }}
+          <van-button v-if="next" class="decorate !text-xl" @click="replace(next)">
+            {{ next.title ?? actionText }}
           </van-button>
-          <van-button class="decorate !text-xl !text-primary-400" :loading @click="done()">
-            {{ tips }}({{ countdown }})
+          <van-button v-if="done" class="decorate !text-xl !text-primary-400" @click="replace(done)">
+            {{ done.title ?? actionText }}
+            <template v-if="remaining">({{ countdown }}s)</template>
           </van-button>
         </template>
       </footer>

+ 19 - 1
src/modules/camera/camera.page.vue

@@ -6,6 +6,7 @@ import { useForm, useRequest }              from 'alova/client';
 import Segmented, { type ConfigProps }      from './camera.config';
 import Camera                               from './camera.vue';
 
+import { getRoutePath, useRouteNext } from '@/computable/useRouteNext';
 import NavHomeSelect from '@/assets/images/nav-home.select.png?url';
 
 
@@ -13,13 +14,30 @@ let audio: HTMLAudioElement | void;
 
 const router = useRouter();
 
+const { flow } = useRouteNext({ immediate: true });
 const { form: dataset, loading: submitting, send: submit } = useForm(data => saveFileMethod(data), {
   initialForm: { } as Record<string, any>,
-}).onSuccess(({ data }) => router.replace(data.route)).onError(() => {
+}).onSuccess(({ data }) => replace()).onError(() => {
   handle();
   step.value = 1;
 });
 
+const replace = async () => {
+  let next = flow.value?.next;
+
+  if (next?.optional) {
+    const action = await Dialog.show({
+      title: next.title || '获取健康调理方案',
+      confirmButtonText: '好的',
+      showCancelButton: true,
+      cancelButtonText: '返回首页',
+      width: 350,
+    }).catch((err) => err)
+    if (action === 'cancel') next = { title: '返回首页', route: '/screen' };
+  }
+  return router.push({ path: getRoutePath(next), replace: true });
+}
+
 
 const step = ref(0);
 const snapshot = ref<string | void>();

+ 29 - 43
src/modules/pulse/pulse-result.page.vue

@@ -1,49 +1,41 @@
 <script setup lang="ts">
 import NavHomeSelect from '@/assets/images/nav-home.select.png?url';
 import NavNextSelect from '@/assets/images/next-step.svg?url';
-import { Dialog } from '@/platform';
+import { Dialog, Notify } from '@/platform';
 
 import { useRouteQuery } from '@vueuse/router';
-import { useRequest, useWatcher } from 'alova/client';
+import { useRequest } from 'alova/client';
 import { useRouter } from 'vue-router';
 import { getPulseMethod } from '@/request/api/pulse.api';
-import { processMethod3 } from '@/request/api';
+import type { Flow, FlowRoute } from '@/request/model';
+import { useRouteNext } from '@/computable/useRouteNext';
 
 const id = useRouteQuery<string>('id');
 
-const next = ref<{ title: string; route: string; icon?: string; }>();
-useRequest(processMethod3, { immediate: true }).onSuccess(({ data }) => {
-  if (data.next?.route === '/screen') {
-    next.value = { title: '返回首页', route: '/screen', icon: NavHomeSelect };
-  } else if (data.next) {
-    next.value = { title: data.next.title || '获取健康调理方案', route: data.next.route, icon: NavNextSelect  };
-  }
+const { handle, loading } = useRouteNext({
+  onSuccess(flow) { return load(flow); },
+  onError(error) { Notify.warning(error.message); },
 });
 
-const { data, loading, error } = useWatcher(() => getPulseMethod(id.value), [id], {
-  initialData: {
-    date: '',
-    pulse: {},
-  },
-  immediate: false,
-}).onError(async ({ error }) => {
-  await Dialog.show({
-    message: error.message,
-    theme: 'round-button',
-    showCancelButton: false,
-    confirmButtonText: '好的',
-    width: '350px',
-  });
-  //
-});
+const { data, error, send } = useRequest(getPulseMethod, { immediate: false, initialData: { date: '', pulse: {}, } });
 
-const router = useRouter();
+const back = shallowRef<Flow>();
+const next = shallowRef<Flow>();
 
-const scrollable = computed(() => true);
+async function load(flow: FlowRoute) {
+  back.value = flow.next.optional ? { title: '返回首页', route: '/screen' } : void 0;
+  next.value = flow.next.route !== '/screen' ? flow.next : void 0;
 
-function replace(path: string = '/screen') {
-  return router.replace({ path });
+  if (id.value) await send(id.value);
+  else { /* 从 Visitor 中获取 */ }
 }
+
+watch(id, (value, oldValue) => { if (value !== oldValue || value == null) handle(); }, { immediate: true });
+
+const router = useRouter();
+const replace = (flow: Flow) => router.replace(flow.route);
+
+const scrollable = computed(() => true);
 </script>
 <template>
   <div class="report-wrapper">
@@ -65,21 +57,15 @@ function replace(path: string = '/screen') {
           <AnalysisPulseComponent title="脉象分析" v-bind="data.pulse"></AnalysisPulseComponent>
         </div>
       </van-skeleton>
-      <div class="flex-none flex justify-between py-2 nav-wrapper" style="background-color: #12312c" v-if="next">
-        <div class="m-auto min-w-16 text-center hover:text-primary" @click="replace(next.route)">
-          <img v-if="next.icon" :src="next.icon" :alt="next.title" />
-          <div class="mt-2">{{ next.title }}</div>
+      <div class="flex-none flex justify-between py-2 nav-wrapper" style="background-color: #12312c" v-if="next || back">
+        <div v-if="back" class="m-auto min-w-16 text-center hover:text-primary" @click="replace(back)">
+          <img :src="NavHomeSelect" :alt="back.title" />
+          <div class="mt-2">{{ back.title }}</div>
         </div>
-        <!--        <div class="m-auto min-w-16 text-center hover:text-primary" v-if="data.scheme" @click="toggle()">
-          <img :src="NavScheme" alt="调理方案" />
-          <div class="mt-2">调理方案</div>
+        <div v-if="next" class="m-auto min-w-16 text-center hover:text-primary" @click="replace(next)">
+          <img :src="NavNextSelect" :alt="next.title" />
+          <div class="mt-2">{{ next.title ?? `获取健康调理方案` }}</div>
         </div>
-
-        <div class="m-auto min-w-16 text-center hover:text-primary" @click="print()">
-          <van-loading v-if="uploading" color="#38ff6e" style="font-size: 24px" />
-          <img v-else :src="NavPrint" alt="打印" />
-          <div class="mt-2">打印</div>
-        </div>-->
       </div>
     </div>
   </div>

+ 55 - 99
src/modules/pulse/pulse.page.vue

@@ -1,11 +1,11 @@
 <script setup lang="ts">
 import { Notify } from '@/platform';
-import { tryOnMounted, tryOnUnmounted } from '@vueuse/core';
+import { tryOnBeforeMount, tryOnUnmounted, useCountdown } from '@vueuse/core';
 
 import { useRequest } from 'alova/client';
 import { putPulseMethod } from '@/request/api/pulse.api';
-import { processMethod3 } from '@/request/api';
-import type { Flow } from '@/request/model';
+import type { Flow, FlowRoute } from '@/request/model';
+import { getRoutePath, useRouteNext } from '@/computable/useRouteNext';
 
 import { useVisitor } from '@/stores';
 
@@ -14,104 +14,65 @@ import NavHomeSelect from '@/assets/images/nav-home.select.png?url';
 const router = useRouter();
 const Visitor = useVisitor();
 
-const pending = ref(false);
 const finished = ref(false);
 const supported = ref(true);
+const actionText = computed(() => supported.value ? `获取健康调理方案` : `下一步`);
+/* 倒计时完成动作 */
+const done = shallowRef<Flow>();
+/* 下一动作可选 */
+const next = shallowRef<Flow>();
+
+const { handle, loading } = useRouteNext({
+  onSuccess(flow) { return pulse(flow); },
+  onError(error) { Notify.warning(error.message); },
+});
+
+const { remaining, start, stop } = useCountdown(5, {
+  onComplete() { replace(done.value!); },
+  immediate: false,
+});
+const countdown = computed(() => remaining.value.toString().padStart(2, '0'));
 
-async function handle() {
-  if (pending.value) return;
-  pending.value = true;
-  clearInterval(timer);
+tryOnBeforeMount(() => handle());
+tryOnUnmounted(() => stop());
 
-  const patientId = Visitor.patientId;
+async function pulse(flow: FlowRoute) {
+  stop();
+  const showReport = flow.next.route === '/pulse/result';
   try {
-    await load();
+    const patientId = Visitor.patientId;
     const result = await Bridge.pulse(patientId!!);
     await submit(patientId, result);
-  } catch (e: any) {
-    let message = e.message;
+    if (showReport) await replace(flow.next);
+    else {
+      finished.value = true;
+      done.value = flow.next.optional ? { title: '返回首页', route: '/screen' } : flow.next;
+      next.value = flow.next.optional ? flow.next : void 0;
+      start(10);
+    }
+  } catch (e) {
+    let message;
+    let countdown;
+
     if (e instanceof ReferenceError) {
       supported.value = false;
-      message = '当前环境不支持脉诊设备,请联系管理员';
-    }
-    if (!supported.value || process.value?.current?.optional) {
-      done.value = next.value?.optional
-        ? { ...next.value, countdown: 5 }
-        : {
-            title: '返回首页',
-            route: '/screen',
-            countdown: 5,
-          };
-      next.value = void 0;
-      start();
+      message = `当前环境不支持脉诊设备,请联系管理员!`;
+      countdown = 5;
     } else {
-      done.value = void 0;
-      message = '请再次测量脉诊';
+      message = `请再次测量脉诊!`;
+      countdown = 10;
     }
+    done.value = flow.value.optional && !showReport ? flow.next : { title: '返回首页', route: '/screen' };
+    start(countdown);
     Notify.warning(message);
   }
-  pending.value = false;
 }
 
-const done = shallowRef<Partial<Flow> & { countdown: number }>();
-const next = shallowRef<Partial<Flow>>();
-
-const {
-  data: process,
-  loading,
-  send: load,
-} = useRequest(processMethod3, { immediate: false }).onSuccess(({ data }) => {
-  if (data.next.route === '/screen') {
-    done.value = { title: '返回首页', route: '/screen', countdown: 30 };
-    next.value = void 0;
-  } else if (data.next.route === '/pulse/result') {
-    done.value = data.next.optional ? { title: '返回首页', route: '/screen', countdown: 10 } : void 0;
-    next.value = { title: data.next.title || '查看报告', route: data.next.route };
-  } else {
-    done.value = { title: data.next.title || '获取健康调理方案', route: data.next.route, countdown: 10 };
-    next.value = void 0;
-  }
-});
-
-const {
-  data: report,
-  loading: submitting,
-  send: submit,
-} = useRequest((id, result) => putPulseMethod(id, result), { immediate: false }).onSuccess(({ data }) => {
+const { data: report, loading: submitting, send: submit, } = useRequest((id, result) => putPulseMethod(id, result), { immediate: false }).onSuccess(({ data }) => {
   Visitor.updatePulseReport(data);
-  finished.value = true;
-  start();
 });
 
-let timer: ReturnType<typeof setInterval>;
-const countdown = ref(5);
-
-function start(value?: number) {
-  if (!done.value) {
-    if (next.value?.route === '/pulse/result') replace(next.value.route);
-    return;
-  }
-  countdown.value = value ?? done.value.countdown ?? 3;
-  timer = setInterval(() => {
-    const _countdown = countdown.value - 1;
-    if (_countdown <= 0) {
-      replace(done.value?.route);
-    } else {
-      countdown.value = _countdown;
-    }
-  }, 1000);
-}
-
-function replace(path: string = '/screen') {
-  return router.replace({ path });
-}
-
-tryOnMounted(() => {
-  setTimeout(() => handle(), 300);
-});
-tryOnUnmounted(() => {
-  clearInterval(timer);
-});
+const replace = (flow: Flow) => router.push({ path: getRoutePath(flow), replace: true });
 </script>
 <template>
   <div>
@@ -145,23 +106,18 @@ tryOnUnmounted(() => {
         </template>
       </main>
       <footer class="flex flex-col justify-center items-center">
-        <van-button
-          v-if="!pending && finished && next"
-          class="decorate !text-xl !text-primary-400"
-          @click="replace(next.route)"
-        >
-          {{ next.title }}
-        </van-button>
-        <van-button
-          v-if="!pending && done"
-          class="decorate !text-xl !text-primary-400 !mb-6"
-          @click="replace(done.route)"
-        >
-          {{ done.title }}({{ countdown }})
-        </van-button>
-        <div v-if="supported && !finished" class="van-button decorate" @click="handle()">
+        <template v-if="!loading">
+          <van-button v-if="next" class="decorate !text-xl" @click="replace(next)">
+            {{ next.title ?? actionText }}
+          </van-button>
+          <van-button v-if="done" class="decorate !text-xl !text-primary-400" @click="replace(done)">
+            {{ done.title ?? actionText }}
+            <template v-if="remaining">({{ countdown }}s)</template>
+          </van-button>
+        </template>
+        <div v-if="supported && !finished" class="van-button decorate" @click="!loading && handle()">
           <div class="van-button__content">
-            <van-loading v-if="loading || pending || submitting" />
+            <van-loading v-if="loading || submitting" />
             <span v-else class="van-button__text">连接脉诊</span>
           </div>
         </div>

+ 4 - 2
src/modules/questionnaire/page.vue

@@ -2,6 +2,7 @@
 import { Dialog, Notify, Toast } from '@/platform';
 import { questionnaireMethod } from '@/request/api';
 import type { QuestionnaireProps } from '@/request/model';
+import { getRoutePath, useRouteNext } from '@/computable/useRouteNext';
 
 import TierSelectField from './TierSelect.field.vue';
 
@@ -42,12 +43,13 @@ function handle() {
   }
 }
 
+const { loading: nextLoading, flow } = useRouteNext({ immediate: true });
 async function load() {
   const _first = first.value;
   loading.value = true;
   try {
     const { reportId, questionnaires } = await questionnaireMethod(<any>data.value);
-    if (reportId) return await router.replace(`/report/${reportId}`);
+    if (reportId) return await router.push({ path: getRoutePath(flow.value?.next!), replace: true });
     showTitle.value = _first;
     data.value = [];
     // TODO 延迟渲染
@@ -100,7 +102,7 @@ load();
             :disabled="loading"
           />
         </div>
-        <van-button class="decorate" block :loading @click="handle()">提交</van-button>
+        <van-button class="decorate" block :loading :disabled="nextLoading" @click="handle()">提交</van-button>
       </template>
       <van-toast v-else-if="first" :show="loading" type="loading" message="加载中" />
     </div>

+ 11 - 15
src/modules/report/report-analyse.page.vue

@@ -1,9 +1,11 @@
 <script setup lang="ts">
-import NavHomeSelect                               from '@/assets/images/nav-home.select.png?url';
-import { Dialog }                                  from '@/platform';
-import { getAnalysisResultsMethod, processMethod } from '@/request/api';
-import { useRequest }                              from 'alova/client';
-import { useRouter }                               from 'vue-router';
+import { useRouter } from 'vue-router';
+import { useRequest } from 'alova/client';
+import { getAnalysisResultsMethod } from '@/request/api';
+import { getRoutePath, useRouteNext } from '@/computable/useRouteNext';
+
+import { Dialog } from '@/platform';
+import NavHomeSelect from '@/assets/images/nav-home.select.png?url';
 
 
 const router = useRouter();
@@ -37,20 +39,14 @@ const panelOpen = (min?: number) => {
   panelHeight.value = panelProps.anchors[1];
 };
 
-const scrollable = computed(() => !data.value.payLock &&
-                                  panelHeight.value < panelProps.anchors[ 1 ] || panelHeight.value === 0,
-);
-
+const scrollable = computed(() => !data.value.payLock && panelHeight.value < panelProps.anchors[ 1 ] || panelHeight.value === 0);
 
-const { data: path, loading: nextLoading } = useRequest(processMethod).onSuccess((data) => {
-  console.log(data);
-});
+const { flow, loading: nextLoading } = useRouteNext({ immediate: true });
 
-const showNext = computed(() => path.value && path.value !== '/screen');
+const showNext = computed(() => flow.value?.next.route && flow.value?.next.route !== '/screen');
 
 function next() {
-  console.log(path);
-  router.replace({ path: path.value });
+  router.push({ path: getRoutePath(flow.value?.next), replace: true })
 }
 </script>
 <template>

+ 5 - 2
src/modules/report/report.page.vue

@@ -6,13 +6,14 @@ import NavScheme         from '@/assets/images/nav-scheme.png?url';
 
 import PhysiqueChart                           from '@/modules/report/PhysiqueChart.vue';
 import SyndromeChart                           from '@/modules/report/SyndromeChart.vue';
-import { Notify, Toast } from '@/platform';
+import { Notify, platformIsAIO, Toast } from '@/platform';
 import { getReportMethod, updateReportMethod } from '@/request/api';
 
 import { useRouteParams }         from '@vueuse/router';
 import { useRequest, useWatcher } from 'alova/client';
 import { useRouter }              from 'vue-router';
 
+const hidePulseExceptionTemplate = computed(() => platformIsAIO())
 
 const id = useRouteParams<string>('id');
 const { data, loading } = useWatcher(() => getReportMethod(id.value), [ id ], {
@@ -182,7 +183,9 @@ const scrollable = computed(() => !data.value.payLock &&
             </template>
             <template #exception><div><!--空占位符--></div></template>
           </AnalysisComponent>
-          <AnalysisPulseComponent title="脉象分析" v-bind="data.pulse" simple></AnalysisPulseComponent>
+          <AnalysisPulseComponent title="脉象分析" v-bind="data.pulse" simple>
+            <template #exception v-if="hidePulseExceptionTemplate"><div><!--空占位符--></div></template>
+          </AnalysisPulseComponent>
           <div class="card m-6 text-lg" v-if="data['中医证素']?.length">
             <div class="card__title mb-3 text-primary text-2xl font-bold">中医证素</div>
             <div class="card__content">

+ 136 - 65
src/pages/register.page.vue

@@ -2,39 +2,64 @@
 import NavHomeSelect from '@/assets/images/nav-home.select.png?url';
 import { Notify, Toast } from '@/platform';
 
-import {
-  getCaptchaMethod,
-  processMethod,
-  registerAccountMethod,
-  registerFieldsMethod,
-  searchAccountMethod,
-}                                     from '@/request/api';
-import type { Fields, RegisterModel } from '@/request/model';
-import { useRouteQuery }              from '@vueuse/router';
+import { getCaptchaMethod, registerAccountMethod, registerFieldsMethod, dictionariesMethod, searchAccountMethod } from '@/request/api';
+import type { Fields, Option, RegisterModel } from '@/request/model';
+import { useRouteQuery } from '@vueuse/router';
 
+import { getRoutePath, useRouteNext } from '@/computable/useRouteNext';
 import { useCaptcha, useRequest, useSerialRequest } from 'alova/client';
 
-import type { FormInstance }           from 'vant';
+import type { FormInstance } from 'vant';
 import { RadioGroup as vanRadioGroup } from 'vant';
-
-
-const { data: fields, loading } = useRequest(registerFieldsMethod);
+import PickerDialog from '@/components/PickerDialog.vue';
 
 const formRef = useTemplateRef<FormInstance>('register-form');
 const modelRef = ref<Partial<RegisterModel>>({ code: '' });
+const modelValueRef = ref<Partial<RegisterModel>>({});
+const model = computed(() => ({ ...modelRef.value, ...modelValueRef.value }));
+
+const { data: fields, loading } = useSerialRequest([dictionariesMethod, (dictionaries) => registerFieldsMethod(dictionaries)]).onSuccess(({ data }) => {
+  const sex = data.find((field) => field.name === 'sex');
+  if (sex) {
+    const unknown = (<any>sex).component?.options?.find((option: any) => option.value === '2');
+    modelRef.value.sex = unknown?.value;
+  }
+});
 
 const router = useRouter();
-const { loading: submitting, send: submit } = useSerialRequest([
-  data => registerAccountMethod(data),
-  () => processMethod(),
-], { immediate: false })
-  .onSuccess(({ data }) => {router.replace(data);})
-  .onError(({ error }) => Notify.warning(error.message));
+
+const { loading: submitting, send: submit } = useRequest(registerAccountMethod, { immediate: false }).onSuccess(({ data }) => {
+  submitting.value = true;
+  handle();
+});
+const { handle } = useRouteNext({
+  onSuccess(flow) { return router.push({ path: getRoutePath(flow.next), replace: true }).then() },
+  onError(error) { Notify.warning(error.message); },
+  onComplete() { submitting.value = false; },
+});
 
 const { loading: searching, send: search } = useRequest((data) => searchAccountMethod(data), {
   immediate: false,
 }).onSuccess(({ data }) => {
-  modelRef.value = { ...modelRef.value, ...data };
+  const modelLabel = {} as Record<string, any>;
+  const modelValue = {} as Record<string, any>;
+
+  for (const [key, value] of Object.entries(data)) {
+    const field = fields.value?.find((field) => field.name === key);
+    if (typeof value === 'string' && field?.component?.name === 'picker') {
+      const result = value.split(',').map((value) => {
+        const [v, l] = value.split(':');
+        return { value, label: l ?? (field.component as { options: Option[] })?.options?.find((option) => option.value === v)?.label ?? v };
+      });
+      modelValue[key] = result.map((t) => t.value).join(',');
+      modelLabel[key] = result.map((t) => t.label).join(',');
+    } else {
+      modelLabel[key] = value;
+    }
+  }
+
+  modelRef.value = { ...modelRef.value, ...modelLabel };
+  modelValueRef.value = { ...modelValueRef.value, ...modelValue };
 });
 
 let captchaLoaded = false;
@@ -43,11 +68,12 @@ const { loading: captchaLoading, countdown, send: getCaptcha } = useCaptcha(
   { initialCountdown: 60 },
 ).onSuccess(({ data }) => {
   captchaLoaded = true;
-  Toast.success(data ?? '获取成功')
+  Toast.success(data ?? '获取成功');
 });
 const getCaptchaHandle = async () => {
   try {
     await formRef.value?.validate('phone');
+    if ( !modelRef.value.phone ) throw { message: `请输入手机号码` };
     await getCaptcha();
     const field = fields.value.find(field => field.name === 'code');
     if ( field?.keyboard ) { field.keyboard.show = true; }
@@ -67,12 +93,12 @@ const searchHandle = async (key: 'cardno' | 'code') => {
 
 function onKeyboardBlur(field: Fields[number]) {
   if ( field?.name === 'phone' && !captchaLoaded ) { getCaptchaHandle(); }
-  if ( field?.name === 'cardno' ) { searchHandle('cardno'); }
-  if ( field?.name === 'code' ) { searchHandle('code'); }
+  if ( field?.name === 'cardno' && modelRef.value.cardno ) { searchHandle('cardno'); }
+  if ( field?.name === 'code' && modelRef.value.phone ) { searchHandle('code'); }
 }
 
 function onSubmitHandle() {
-  submit(toValue(modelRef));
+  submit(model.value);
 }
 
 function fix(key: string) {
@@ -97,6 +123,51 @@ onBeforeUnmount(() => {
     if ( key?.startsWith('scan_') ) sessionStorage.removeItem(key);
   }
 });
+
+const keyboardProps = reactive({
+  key: '',
+  props: {},
+  show: false,
+});
+
+const pickerProps = reactive({
+  key: '',
+  props: { options: [], selected: [] },
+  show: false,
+  handle(options: Option[]) {
+    const key = (this ?? pickerProps).key;
+    (modelRef.value as Record<string, any>)[key] = options.map(option => option.label).join(',');
+    (modelValueRef.value as Record<string, any>)[key] = options.map(option => option.value).join(',');
+  }
+});
+function onFieldFocus(field: any) {
+  if (field.keyboard) {
+    keyboardProps.key = field.name;
+    keyboardProps.show = true;
+    keyboardProps.props = {
+      ...field.keyboard,
+      maxlength: field.control?.maxlength ?? Number.POSITIVE_INFINITY,
+      onBlur() {
+        keyboardProps.show = false;
+        onKeyboardBlur(field);
+      },
+    }
+  } else if (field.component?.name === 'picker') {
+    pickerProps.key = field.name;
+    pickerProps.show = true;
+    pickerProps.props = {
+      ...field.component.props,
+      title: field.control.label,
+      options: field.component.options,
+      selected: (modelValueRef.value as Record<string, string>)[field.name]?.split(','),
+    }
+    return;
+  }
+}
+function onFieldBlur(field: any) {
+  keyboardProps.show = false;
+  pickerProps.show = false;
+}
 </script>
 <template>
   <div>
@@ -120,55 +191,50 @@ onBeforeUnmount(() => {
       >
         <van-cell-group :border="false">
           <template v-for="field in fields" :key="field.name">
-            <van-field v-model="modelRef[field.name]" :name="field.name" :id="field.name"
-                       :rules="field.rules" v-bind="field.control"
-                       :class="{'no-border': field.control?.border === false}"
-                       :focused="field.keyboard?.show" @focus="field.keyboard && (field.keyboard.show = true)"
-                       @blur="field.keyboard && (field.keyboard.show = false)"
-                       :readonly="field.control.readonly" @click="field.keyboard && (field.keyboard.show = true)"
-            >
-              <template #input v-if="field.component?.name === 'radio'">
-                <van-radio-group v-model="modelRef[field.name]" direction="horizontal" shape="dot">
-                  <van-radio v-for="option in field.component?.options" :key="option.value" :name="option.value">
-                    {{ option.label }}
-                  </van-radio>
-                </van-radio-group>
-              </template>
-              <template #input v-else-if="field.component?.name === 'code'">
-                <van-password-input
-                  style="width: 100%;"
-                  v-model:value="modelRef[field.name]" v-bind="(field.component as any)!.props"
-                  :focused="field.keyboard?.show" @focus="field.keyboard && (field.keyboard.show = true);fix('code')"
-                />
-              </template>
-              <template #button>
-                <div class="text-primary cursor-pointer">
-                  <template v-if="field.component?.name === 'code'">
-                    <div class="text-primary cursor-pointer" @click="getCaptchaHandle()">
-                      {{ captchaLoading ? '发送中...' : countdown > 0 ? `${ countdown }后可重发` : '获取验证码' }}
-                    </div>
-                  </template>
-                  <template v-else>{{ field.suffix }}</template>
-                </div>
-              </template>
-            </van-field>
-            <van-number-keyboard
-              v-if="field.keyboard"
-              v-model="modelRef[field.name]"
-              v-bind="field.keyboard" :maxlength="field.control.maxlength"
-              @blur="field.keyboard.show = false; onKeyboardBlur(field)"
-            />
+            <template v-if="!field.control?.hide || (typeof field.control?.hide === 'function' && !field.control.hide(model))">
+              <van-field v-model="modelRef[field.name]" :name="field.name" :id="field.name"
+                         :rules="field.rules" v-bind="field.control"
+                         :class="{'no-border': field.control?.border === false}"
+                         @focus="onFieldFocus(field)" @blur="onFieldBlur(field)"
+                         :readonly="field.control?.readonly" @click="onFieldFocus(field)"
+              >
+                <template #input v-if="field.component?.name === 'radio'">
+                  <van-radio-group v-model="modelRef[field.name]" direction="horizontal" shape="dot">
+                    <van-radio v-for="option in field.component?.options" :key="option.value" :name="option.value">
+                      {{ option.label }}
+                    </van-radio>
+                  </van-radio-group>
+                </template>
+                <template #input v-else-if="field.component?.name === 'code'">
+                  <van-password-input
+                    style="width: 100%;"
+                    v-model:value="modelRef[field.name]" v-bind="(field.component as any)!.props"
+                    :focused="field.keyboard?.show" @focus="field.keyboard && (field.keyboard.show = true);fix('code')"
+                  />
+                </template>
+                <template #button>
+                  <div class="text-primary cursor-pointer">
+                    <template v-if="field.component?.name === 'code'">
+                      <div class="text-primary cursor-pointer" @click="getCaptchaHandle()">
+                        {{ captchaLoading ? '发送中...' : countdown > 0 ? `${ countdown }后可重发` : '获取验证码' }}
+                      </div>
+                    </template>
+                    <template v-else>{{ field.suffix }}</template>
+                  </div>
+                </template>
+              </van-field>
+            </template>
           </template>
         </van-cell-group>
       </van-form>
       <div class="m-4">
         <div class="m-auto size-16 cursor-pointer">
           <van-loading v-if="submitting || loading" type="spinner" size="64" color="#38ff6e" />
-          <img v-else class="size-full"
-               src="@/assets/images/next-step.svg" alt="提交" @click="formRef?.submit()"
-          >
+          <img v-else class="size-full" src="@/assets/images/next-step.svg" alt="提交" @click="formRef?.submit()">
         </div>
       </div>
+      <van-number-keyboard v-bind="keyboardProps.props" :show="keyboardProps.show" v-model="modelRef[keyboardProps.key]"></van-number-keyboard>
+      <PickerDialog v-bind="pickerProps.props" immediate v-model:show="pickerProps.show" @selected="pickerProps.handle($event)"></PickerDialog>
     </div>
   </div>
 </template>
@@ -251,4 +317,9 @@ onBeforeUnmount(() => {
 .van-radio-group {
   height: 40px + 2px;
 }
+
+.sub-option.checked {
+  color: #fff;
+  background-color: var(--primary-color);
+}
 </style>

+ 11 - 13
src/pages/screen.page.vue

@@ -1,7 +1,8 @@
 <script setup lang="ts">
 import { Dialog, Notify } from '@/platform';
 
-import { copyrightMethod, processMethod, registerVisitorMethod } from '@/request/api';
+import { copyrightMethod, registerVisitorMethod } from '@/request/api';
+import { useRouteNext, getRoutePath } from '@/computable/useRouteNext';
 
 import { useVisitor }     from '@/stores';
 import getBubbles         from '@/tools/bubble';
@@ -25,15 +26,15 @@ const { data: copyright, send: load } = useRequest(copyrightMethod).onError(asyn
   });
   await load();
 });
-const { send: handle, loading } = useRequest(processMethod, { immediate: false })
-  .onSuccess(({ data }) => {
+
+const { handle, loading } = useRouteNext({
+  async onSuccess(flow) {
     Visitor.$reset();
-    router.push({ path: data, replace: true }).then(
-      () => { if (visitor.value) Visitor.patientId = visitor.value; },
-      () => {}
-    );
-  })
-  .onError(({ error }) => Notify.warning(error.message));
+    await router.push({ path: getRoutePath(flow.next), replace: true })
+    if (visitor.value) Visitor.patientId = visitor.value;
+  },
+  onError(error) { Notify.warning(error.message); },
+});
 
 const container = useTemplateRef<HTMLDivElement>('container');
 const { width, height } = useElementSize(container);
@@ -50,10 +51,7 @@ interface Bubble {
 }
 
 watchEffect(() => {
-  if ( width.value && height.value ) {
-    init(
-      { width: width.value, height: height.value * 0.90, container: container.value! });
-  }
+  if ( width.value && height.value ) init({ width: width.value, height: height.value * 0.90, container: container.value! });
 });
 
 function init({ width, height, container }: { width: number; height: number; container: HTMLElement }) {

+ 13 - 0
src/platform/index.ts

@@ -21,6 +21,19 @@ export function getSerialNumberSync() {
   )();
 }
 
+let getNetworkWall = async (): Promise<"exterior" | "interior"> => {
+  const controller = new AbortController();
+  setTimeout(() => controller.abort(), 1000);
+
+  const wall = await fetch(`https://wx.hzliuzhi.com/aio/`, { method: 'HEAD', mode: 'no-cors', signal: controller.signal }).then(
+    () => 'exterior' as const,
+    () => 'interior' as const,
+  );
+  return (getNetworkWall = () => Promise.resolve(wall), wall);
+};
+
+export { getNetworkWall };
+
 export * from './dialog.ui';
 export * from './notify.ui';
 export * from './toast.ui';

+ 17 - 4
src/request/api/account.api.ts

@@ -1,5 +1,6 @@
-import { cacheFor }                                                     from '@/request/api/index';
-import { type Fields, fromRegisterFields, getPath, type RegisterModel } from '@/request/model';
+import { cacheFor } from '@/request/api/index';
+import type { Dictionaries, Fields, RegisterModel } from '@/request/model';
+import { fromRegisterFields, getPath} from '@/request/model';
 import { useVisitor } from '@/stores';
 
 import HTTP from '../alova';
@@ -11,13 +12,13 @@ export function getCaptchaMethod(mobile: string) {
   });
 }
 
-export function registerFieldsMethod() {
+export function registerFieldsMethod(dictionaries?: Dictionaries) {
   return HTTP.Post<Fields, { tabletFileFields: string[] }>(`/fdhb-tablet/warrantManage/getPageSets`, void 0, {
     cacheFor, name: `variate:register_fields`,
     params: { k: 'register_fields' },
     transform(data, headers) {
       const options = data?.tabletFileFields ?? [];
-      return fromRegisterFields(options);
+      return fromRegisterFields(options, dictionaries);
     },
   });
 }
@@ -64,3 +65,15 @@ export function scanAccountMethod(key: string) {
     },
   });
 }
+
+export function dictionariesMethod() {
+  return HTTP.Get<Dictionaries | void, any>(`/fdhb-tablet/dict/getDicts`, {
+    cacheFor, name: `variate:dict`,
+    transform(data) {
+      if (!Array.isArray(data)) return void 0;
+      const dictionaries: Dictionaries = new Map();
+      for (const { dictType, items } of data) dictionaries.set(dictType, items.map((item: any) => ({label: item.dictLabel, value: item.dictValue })));
+      return dictionaries.size ? dictionaries : void 0;
+    },
+  });
+}

+ 1 - 19
src/request/api/camera.api.ts

@@ -1,7 +1,5 @@
 import HTTP              from '@/request/alova';
-import { processMethod2 } from '@/request/api/flow.api';
 import { useVisitor }    from '@/stores';
-import { Dialog } from '@/platform';
 
 
 export function uploadFileMethod(file: File) {
@@ -17,23 +15,7 @@ export function saveFileMethod(params: Record<string, string>) {
     params,
     async transform(data: string, headers) {
       Visitor.resultId = data;
-      const flow = await processMethod2();
-      let path = flow.optional
-        ? await Dialog.show({
-            title: flow.title || '获取健康调理方案',
-            confirmButtonText: '好的',
-            showCancelButton: true,
-            cancelButtonText: '返回首页',
-            width: 350,
-          }).then(
-            () => flow.route,
-            () => '/screen'
-          )
-        : flow.route;
-      return {
-        resultId: data,
-        route: { path },
-      };
+      return data;
     },
   });
 }

+ 11 - 43
src/request/api/flow.api.ts

@@ -1,5 +1,6 @@
 import { cacheFor }     from '@/request/api/index';
-import { type Flow, fromFlowData } from '@/request/model';
+import { FlowMap }      from '@/request/model';
+import type { FlowKey } from '@/request/model';
 import Router           from '@/router';
 
 import HTTP from '../alova';
@@ -18,50 +19,17 @@ export function copyrightMethod() {
 }
 
 export function processMethod() {
-  const path = unref(Router.currentRoute).path;
-  return HTTP.Post<string, { tabletProcessModules?: string[]; }>(`/fdhb-tablet/warrantManage/getPageSets`, {}, {
-    cacheFor, name: `variate:process`,
-    params: { k: 'process', p: path },
-    transform(data) {
-      const options = data.tabletProcessModules ?? [];
-      const ref = fromFlowData(options);
-      const flow = ref.get(path);
-      if ( !flow ) throw { message: `[路由] 配置异常无法解析正确路径,请联系管理员 (${ data?.tabletProcessModules?.join(' -> ') }})` };
-      return flow.route;
-    },
-  });
-}
-
-export function processMethod2() {
-  const path = unref(Router.currentRoute).path;
-  return HTTP.Post<Flow, { tabletProcessModules?: string[]; }>(`/fdhb-tablet/warrantManage/getPageSets`, {}, {
+  return HTTP.Post(`/fdhb-tablet/warrantManage/getPageSets`, void 0, {
     cacheFor, name: `variate:process`,
-    params: { k: 'process', p: path },
-    transform(data) {
-      const options = data.tabletProcessModules ?? [];
-      const ref = fromFlowData(options);
-      const flow = ref.get(path);
-      if ( !flow ) throw { message: `[路由] 配置异常无法解析正确路径,请联系管理员 (${ data?.tabletProcessModules?.join(' -> ') }})` };
-      return flow;
-    },
+    params: { k: 'process' },
+    transform(data: any, headers) { return new FlowMap(data?.tabletProcessModules ?? []); },
   });
 }
 
-
-export function processMethod3() {
-  const path = unref(Router.currentRoute).path;
-  return HTTP.Post<{ current: Flow; prev: Flow; next: Flow }, { tabletProcessModules?: string[]; }>(`/fdhb-tablet/warrantManage/getPageSets`, {}, {
-    cacheFor, name: `variate:process`,
-    params: { k: 'process', p: path },
-    transform(data) {
-      const options = data.tabletProcessModules ?? [];
-      const ref = fromFlowData(options);
-      const [key, current] = [...ref.entries()].find(([,flow]) => flow.route === path) || [];
-      const prev = [...ref.values()].find(flow => flow.route === key);
-      const next = ref.get(path);
-      if ( !next ) throw { message: `[路由] 配置异常无法解析正确路径,请联系管理员 (${ data?.tabletProcessModules?.join(' -> ') }})` };
-      return { current, prev, next } as any;
-    }
-  })
+export async function getNextProcess(path?: FlowKey) {
+  const process = await processMethod();
+  path ??= unref(Router.currentRoute).path as FlowKey;
+  const flow = process.get(path);
+  if (!flow) throw { message: `[路由] 配置异常无法解析正确路径,请联系管理员!` };
+  return flow.route;
 }
-

+ 9 - 9
src/request/api/pulse.api.ts

@@ -1,5 +1,6 @@
 import HTTP from '@/request/alova';
 import { fromAnalysisModel, type PulseAnalysisModel } from '@/request/model';
+import { getNetworkWall } from '@/platform';
 
 const getSummary = (value?: string[]) => (Array.isArray(value) && value.length ? value : void 0);
 
@@ -11,7 +12,8 @@ export function putPulseMethod(patientId: string, result: PulseAnalysisModel) {
     [];
   const data = Object.assign(result, { patientId, results: summary.join(',') });
   return HTTP.Post<PulseAnalysisModel, any>(`/fdhb-tablet/analysisManage/savePulseAnalysisReport`, data, {
-    transform() {
+    async transform() {
+      const network = await getNetworkWall();
       return {
         measureId: data.measureId,
         hand: [
@@ -21,7 +23,7 @@ export function putPulseMethod(patientId: string, result: PulseAnalysisModel) {
         summaryValue: data.summaryValue,
         summaryLabel: data.summaryLabel,
         results: data.results,
-        url: __FORBID_AUTO_PROCESS_PULSE_AGENCY__ ? void 0 : data.url,
+        url: network === 'interior' ? (console.info('log: 判定内网环境 舍弃脉诊报告 url'),void 0) : data.url,
       };
     },
   });
@@ -42,18 +44,16 @@ export function getPulseMethod(id: string) {
   });
 }
 
-/**
- * 暂未实现
- * @deprecated
- */
 export function getPulseAgentMethod() {
   return HTTP.Post(
-    `/fdhb-tablet/warrantManage/getPageSets`,
+    `/fdhb-tablet/analysisManage/getPulseSupport`,
     {},
     {
       transform(data: any) {
-        if (data?.origin == null && data?.url == null) return void 0;
-        const origin = data.origin.endsWith('/report.html') ? data.origin : `${data.origin}/taiyi/report.html`;
+        const url = data?.origin ?? data?.url;
+        if (!url) return void 0;
+
+        const origin = url.endsWith('/report.html') ? url : `${url}/taiyi/report.html`;
         return {
           appId: data.appId ?? 'hJn5D3rr',
           token: data.token,

+ 3 - 1
src/request/api/questionnaire.api.ts

@@ -1,6 +1,7 @@
 import { useVisitor } from '@/stores';
 import HTTP                                           from '../alova';
 import type { QuestionnaireStorage }                  from '../model';
+import { getAnalysisExtendFlowValue }                 from '../model';
 import { fromQuestionnaireData, toQuestionnaireData } from '../model';
 
 
@@ -11,12 +12,13 @@ export function questionnaireMethod(data = []) {
   if ( !data?.length ) { storage = { questions: [] }; }
   return HTTP.Post(
     `/fdhb-tablet/dialogueManage/dialog/${ Visitor.patientId }/${ Visitor.resultId }`,
-    { ...toQuestionnaireData (data, storage), asyncTongueResult: true },
+    { ...toQuestionnaireData (data, storage), asyncTongueResult: true, extendFlow: getAnalysisExtendFlowValue() },
     {
       meta: { ignoreException: true },
       transform(data: Record<string, any>, headers) {
         const { storage: _storage, model } = fromQuestionnaireData(data);
         storage = _storage as any;
+        if (model.reportId) Visitor.reportId = model.reportId;
         return model;
       },
     }

+ 28 - 8
src/request/api/report.api.ts

@@ -16,16 +16,22 @@ export function getAnalysisResultsMethod() {
         const date = data?.tonguefaceAnalysisReportDate;
         const miniProgramURL = data?.tonguefaceAnalysisReportAppletImg;
         data = data.nextQuestions?.find((item: any) => item.classify === 'tongue_result');
+        let message = '';
         if ( data ) {
-          const { show, force } = await miniProgramMethod();
-          return {
-            id, date, miniProgramURL: show ? miniProgramURL : void 0,
-            tongue: fromAnalysisModel('tongue', data),
-            face: fromAnalysisModel('face', data),
-            payLock: show && force,
-          };
+          const tongue = fromAnalysisModel('tongue', data);
+          const face = fromAnalysisModel('face', data);
+          if (!tongue.result && !face.result) {
+            message = data.content;
+          } else {
+            const { show, force } = await miniProgramMethod();
+            return {
+              id, date, miniProgramURL: show ? miniProgramURL : void 0,
+              tongue, face,
+              payLock: show && force,
+            };
+          }
         }
-        throw { message: `[分析结果] 照片不符合检测要求,图片不是舌头(请拍摄带有舌头的、清晰的彩色照!)` };
+        throw { message: message || `[分析结果] 照片不符合检测要求,图片不是舌头(请拍摄带有舌头的、清晰的彩色照!)` };
       },
     },
   );
@@ -49,6 +55,20 @@ export function getReportMethod(id: string) {
   });
 }
 
+export function getAlcoholReportMethod() {
+  const Visitor = useVisitor();
+  const params = { healthAnalysisReportId: Visitor.reportId, patientId: Visitor.patientId };
+  return HTTP.Get(`/fdhb-tablet/analysisManage/getHealRepDetailById`, {
+    params,
+    transform(data: Record<string, any>) {
+      return {
+        date: data?.alcoholAnalysisReportDate /*?? data?.reportTime*/,
+        alcohol: fromAnalysisModel('alcohol', data),
+      }
+    }
+  });
+}
+
 export function updateReportMethod(id: string, data: Record<string, any>) {
   const Visitor = useVisitor();
   const params = {

+ 22 - 4
src/request/model/analysis.model.ts

@@ -2,10 +2,11 @@ import { groupBy } from '@/tools';
 
 export function fromAnalysisModel(mode: 'tongue' | 'face', data: Record<string, any>): AnalysisModel;
 export function fromAnalysisModel(mode: 'pulse', data: Record<string, any>): PulseAnalysisModel;
+export function fromAnalysisModel(mode: 'alcohol', data: Record<string, any>): AlcoholAnalysisModel;
 export function fromAnalysisModel(
-  mode: 'tongue' | 'face' | 'pulse',
+  mode: 'tongue' | 'face' | 'pulse' | 'alcohol',
   data: Record<string, any>
-): AnalysisModel | PulseAnalysisModel {
+): AnalysisModel | AlcoholAnalysisModel | PulseAnalysisModel {
   let model: AnalysisModel;
   switch (mode) {
     case 'tongue':
@@ -16,9 +17,11 @@ export function fromAnalysisModel(
       break;
     case 'pulse':
       return fromPulseAnalysisModel(data);
+    case 'alcohol':
+      return fromAlcoholAnalysisModel(data?.extendFlowData);
   }
 
-  const group = groupBy<AnalysisException>(model.exception, (item) => item.cover ?? '');
+  const group = groupBy<AnalysisException>(model.exception, (item) => item.cover ?? '') ?? {};
   model.exceptionGroup = Object.entries(group).map(([key, exception]) => ({ key, exception }));
   return model;
 }
@@ -29,6 +32,12 @@ export interface PulseAnalysisModel extends Pick<Awaited<ReturnType<typeof Bridg
   url?: string;
 }
 
+export interface AlcoholAnalysisModel {
+  condition: string;
+  description: string;
+  volume: [min: number, max?: number];
+}
+
 export interface AnalysisModel {
   table: {
     columns: string[];
@@ -58,7 +67,7 @@ function fromPulseAnalysisModel(data: Record<string, any>): PulseAnalysisModel {
         value = JSON.parse(value);
       } catch (e) {}
     return typeof value === 'object' ? value : {};
-  })(data.pulse);
+  })(data.pulseReport);
 
   const getSummary = (value?: string[]) => (Array.isArray(value) && value.length ? value : void 0);
   const summary =
@@ -77,6 +86,15 @@ function fromPulseAnalysisModel(data: Record<string, any>): PulseAnalysisModel {
   };
 }
 
+function fromAlcoholAnalysisModel(data: Record<string, any>): AlcoholAnalysisModel {
+  const volume: [number, number] = data?.alcoholCapacity?.match(/(\d+)/g)?.slice(0, 2)?.filter(Boolean)?.map((v: string) => +v) ?? [];
+  return {
+    condition: data?.alcoholCondition,
+    description: data?.alcoholCapacity,
+    volume: volume.sort((a, b) => a - b),
+  };
+}
+
 function fromTongueAnalysisModel(data: Record<string, any>): AnalysisModel {
   const exception: AnalysisException[] = [];
   const fromTongueException = fromAnalysisException(exception);

+ 63 - 21
src/request/model/flow.model.ts

@@ -1,3 +1,5 @@
+const ROUTE_START = '/screen';
+
 const Routes = {
   'patient_file': /* 建档页 */ '/register',
   'tongueface_upload': /*拍照页*/ '/camera',
@@ -7,39 +9,79 @@ const Routes = {
   'health_analysis': /* 健康报告页 */ '/report',
   'pulse_upload': /* 脉诊页 */ '/pulse',
   'pulse_upload_result': /* 脉诊结果页 */ '/pulse/result',
+  'alcohol_upload_result': /* 酒精结果页 */ '/alcohol/result',
 
-  'screen': '/screen',
+  'screen': ROUTE_START,
 } as const;
+const analysisFlowMap = new Map<FlowKey, string>([
+  ['/alcohol/result', 'alcohol'],
+]);
+const ANALYSIS_EXTEND_FLOW = 'ANALYSIS_EXTEND_FLOW';
+
+export type FlowKey = (typeof Routes)[keyof typeof Routes];
 
 export interface Flow {
-  route: string;
+  route: FlowKey;
   title?: string;
   optional?: boolean;
 }
 
-export function fromFlowData(options: string[]): Map<string, Flow> {
-  const ref = new Map<string, Flow>();
-  const length = options.length;
+export type FlowRoute = { next: Flow; prev: Flow | null; value: Flow };
+
+export class FlowMap extends Map<FlowKey, Flow> {
+  private readonly string: string = '';
+
+  constructor(options: string[]) {
+    super();
+    this.string = options.join('->');
 
-  // 修正虚拟路由
-  const k1 = 'tongueface_upload';
-  const k2 = 'tongueface_upload_result';
-  if ( !options.includes(k2) && options[ length - 1 ] === k1 ) options.push(k2);
+    const length = options.length;
+    if (length === 0) return;
 
-  options.unshift('/screen');
-  options.push('screen');
+    // 修正虚拟路由
+    const k1 = 'tongueface_upload';
+    const k2 = 'tongueface_upload_result';
+    if ( !options.includes(k2) && options[ length - 1 ] === k1 ) options.push(k2);
 
-  for ( let i = 1; i < options.length; i++ ) {
-    const path = options[i];
-    const optional = path.includes('?');
-    const [name, title] = path.split('?');
-    const route = (options[i] = getPath(name));
-    ref.set(options[i - 1], { route, optional, title, });
+    options.unshift(ROUTE_START);
+    options.push('screen?返回首页');
+
+    const analysisFlowSet = new Set<string>();
+    for ( let i = 1; i < options.length; i++ ) {
+      const path = options[i];
+      const optional = path.endsWith('?');
+      const [name, title] = path.split('?');
+      const route = (options[i] = getPath(name));
+      this.set(<FlowKey>options[i - 1], { route, optional, title: title || void 0});
+      if (analysisFlowMap.has(route)) analysisFlowSet.add(analysisFlowMap.get(route)!);
+    }
+    sessionStorage.setItem(ANALYSIS_EXTEND_FLOW, Array.from(analysisFlowSet).filter(Boolean).join(','));
   }
-  return ref;
-}
 
+  parse(key: FlowKey): FlowRoute {
+    const next = this.get(key);
+    if (!next) throw { message: `[路由] 配置异常无法解析正确路径,请联系管理员! (${this})` };
+
+    if (key === ROUTE_START) return { next, prev: null, value: { route: '/screen', optional: false, title: '' } };
+
+    const keys = [...this.keys()];
+    const values = [...this.values()];
 
-export function getPath(value?: string) {
-  return Routes[ value as keyof typeof Routes ];
+    const v = values.findIndex((flow) => flow.route === key);
+    const k = values.findIndex((flow) => flow.route === keys[v]);
+
+    return { next, prev: values[k], value: values[v] };
+  }
+
+  toString(): string {
+    return this.string || `未配置路由`;
+  }
 }
+
+export function getPath(value?: string): FlowKey {
+  return Routes[value as keyof typeof Routes];
+}
+
+export function getAnalysisExtendFlowValue(key = ANALYSIS_EXTEND_FLOW) {
+  return sessionStorage.getItem(key) || ''
+}

+ 50 - 12
src/request/model/register.model.ts

@@ -2,6 +2,9 @@ import { toCamelCase } from '@/tools';
 
 import type { FieldRule, NumberKeyboardProps, PasswordInputProps } from 'vant';
 
+export type Option = { label: string; value: string; checked?: boolean;  disabled?: boolean; editable?: boolean; single?: boolean; }
+export type Dictionaries = Map<string, Option[]>;
+
 
 export interface RegisterModel {
   cardno: string;
@@ -13,6 +16,8 @@ export interface RegisterModel {
   height: number;
   weight: number;
   isEasyAllergy: boolean;
+  womenSpecialPeriod: string;
+  job: string;
 }
 
 export interface Field {
@@ -20,10 +25,13 @@ export interface Field {
     label: string; placeholder?: string;
     type?: string; min?: number; max?: number; minlength?: number; maxlength?: number;
     clearable?: boolean; border?: boolean; readonly?: boolean;
+    hide?: boolean | ((model: Record<string, any>) => boolean);
   };
-  component?: |
-    { name: 'radio', options: { label: string; value: string; }[] } |
-    { name: 'code', props?: Partial<PasswordInputProps> };
+  component?:
+    | { name: 'picker', options: Option[] , props?: Partial<{ multiple: boolean; }> }
+    | { name: 'radio', options: Option[] }
+    | { name: 'code', props?: Partial<PasswordInputProps> }
+  ;
   keyboard?: { show: boolean; } & Partial<NumberKeyboardProps>;
   suffix?: string;
   rules: FieldRule[];
@@ -67,10 +75,28 @@ const Fields: Record<FieldKey, Field> = {
     control: { label: '性别', border: false },
     component: {
       name: 'radio' as const,
-      options: [
-        { label: '男', value: '0' },
-        { label: '女', value: '1' },
-      ],
+      options: 'sys_user_sex' as unknown as any,
+    },
+    rules: [],
+  },
+  womenSpecialPeriod: {
+    control: {
+      label: '女性特殊期', readonly: true,
+      hide(model) { return model?.sex !== '1'; },
+    },
+    component: {
+      name: 'picker' as const,
+      options: 'women_special_period' as unknown as any,
+      props: { multiple: false },
+    },
+    rules: [],
+  },
+  job: {
+    control: { label: '职业', readonly: true },
+    component: {
+      name: 'picker' as const,
+      options: 'job' as unknown as any,
+      props: { multiple: false },
     },
     rules: [],
   },
@@ -78,10 +104,7 @@ const Fields: Record<FieldKey, Field> = {
     control: { label: '容易过敏', border: false },
     component: {
       name: 'radio' as const,
-      options: [
-        { label: '是', value: 'Y' },
-        { label: '否', value: 'N' },
-      ],
+      options: 'sys_yes_no' as unknown as any,
     },
     rules: [],
   },
@@ -141,7 +164,21 @@ const Fields: Record<FieldKey, Field> = {
   },
 };
 
-export function fromRegisterFields(options: string[]): Fields {
+export function fromRegisterFields(options: string[], dictionaries?: Dictionaries): Fields {
+  dictionaries ??= new Map([
+    ['sys_yes_no', [{ label: '是', value: 'Y' }, { label: '否', value: 'N' }]],
+    ['sys_user_sex', [{ label: '男', value: '0' }, { label: '女', value: '1' }]]
+  ]);
+
+  const getOptions = (options?: Option[] | string): Option[] => {
+    if (options == null) options = [];
+    if (typeof options === 'string') options = dictionaries?.get(options) ?? [];
+    return options.map((option) => Object.assign({
+      editable: option.label === `其他`,
+      single: option.label === `无`,
+    } ,option));
+  };
+
   // 修正 phone,code
   const k1 = 'phone';
   const k2 = 'code';
@@ -158,6 +195,7 @@ export function fromRegisterFields(options: string[]): Fields {
       control: { label: name, type: 'text' },
       rules: [],
     };
+    if ((field.component as any)?.options) (field.component as any) = { ...field.component, options: getOptions((field.component as any).options) }
     if ( values[ 1 ] === 'required' ) field.rules.push({ required: true, message: field.control.placeholder ?? '请补充完整' });
     return { ...field, name } as Fields[number];
   });

+ 1 - 1
src/router/hooks/useRouteMeta.ts

@@ -9,7 +9,7 @@ export interface ReactiveRouteOptionsWithTransform<V, R> {
 }
 
 export function useRouteMeta<T extends RouteMeta = RouteMeta, K = T>(
-  name: string,
+  name: keyof T,
   defaultValue?: MaybeRefOrGetter,
   options: ReactiveRouteOptionsWithTransform<T, K> = {},
 ): Ref<K> {

+ 1 - 0
src/router/index.ts

@@ -11,6 +11,7 @@ const router = createRouter({
     { path: '/camera', component: () => import('@/modules/camera/camera.page.vue'), meta: { title: '拍摄' } },
     { path: '/camera/result', component: () => import('@/modules/camera/camera-result.page.vue'), meta: { title: '拍摄完成' } },
     { path: '/questionnaire', component: () => import('@/modules/questionnaire/page.vue'), meta: { title: '问卷' } },
+    { path: '/alcohol/result', component: () => import('@/modules/alcohol/alcohol.page.vue'), meta: { title: '黄酒建议' } },
     { path: '/report/analysis', component: () => import('@/modules/report/report-analyse.page.vue'), meta: { title: '舌面象分析报告' } },
     { path: '/report/:id/scheme', component: () => import('@/modules/report/scheme.page.vue'), meta: { title: '调理方案' } },
     { path: '/report/:id', component: () => import('@/modules/report/report.page.vue'), meta: { title: '健康分析报告' } },

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.