Quellcode durchsuchen

添加二维码遮罩

kumu vor 6 Monaten
Ursprung
Commit
9308f2b79b

+ 1 - 0
src/assets/images/mini-program.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1732606154666" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4264" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M512 0a512 512 0 1 0 512 512A512 512 0 0 0 512 0z m256.717 460.186a151.962 151.962 0 0 1-87.347 65.74 83.251 83.251 0 0 1-24.474 4.096 29.082 29.082 0 0 1 0-58.163 15.667 15.667 0 0 0 6.451-1.229 91.443 91.443 0 0 0 55.91-40.96 75.264 75.264 0 0 0 11.06-39.628c0-45.978-42.496-83.866-94.31-83.866a105.267 105.267 0 0 0-51.2 13.414 81.92 81.92 0 0 0-43.725 70.452v244.224a138.445 138.445 0 0 1-72.704 120.422 159.642 159.642 0 0 1-79.77 20.48c-84.378 0-153.6-63.488-153.6-142.029a136.192 136.192 0 0 1 19.763-69.837 151.962 151.962 0 0 1 87.347-65.74 85.914 85.914 0 0 1 24.474-4.096 29.082 29.082 0 1 1 0 58.163 15.667 15.667 0 0 0-6.451 1.229 95.949 95.949 0 0 0-55.91 40.96 75.264 75.264 0 0 0-11.06 39.628c0 45.978 42.496 83.866 94.925 83.866a105.267 105.267 0 0 0 51.2-13.414 81.92 81.92 0 0 0 43.622-70.452V390.35a138.752 138.752 0 0 1 72.807-120.525 151.245 151.245 0 0 1 79.155-21.504c84.378 0 153.6 63.488 153.6 142.029a136.192 136.192 0 0 1-19.763 69.837z" fill="#00B240" p-id="4265"></path></svg>

+ 2 - 2
src/modules/report/NavBar.vue

@@ -27,10 +27,10 @@ watchEffect(() => {
   const path = route.fullPath;
   isScheme.value = path.endsWith('scheme');
   tabbar.value = isScheme.value ? [
-    { key: 'screen', label: '返回首页', icon: NavHome, select: NavHomeSelect },
+    // { key: 'screen', label: '返回首页', icon: NavHome, select: NavHomeSelect },
     { key: 'report', label: '健康报告', icon: NavScheme, select: NavSchemeSelect },
   ] : [
-    { key: 'screen', label: '返回首页', icon: NavHome, select: NavHomeSelect },
+    // { key: 'screen', label: '返回首页', icon: NavHome, select: NavHomeSelect },
     { key: 'scheme', label: '调理方案', icon: NavScheme, select: NavSchemeSelect },
     // { key: 'print', label: '打印', icon: NavPrint, select: NavPrintSelect },
     { key: 'mini', label: '小程序', icon: NavPrint, select: NavPrintSelect },

+ 52 - 3
src/modules/report/report-analyse.page.vue

@@ -6,11 +6,13 @@ import NavHomeSelect from '@/assets/images/nav-home.select.png?url';
 
 const router = useRouter();
 
-const { data, loading } = useRequest(analysisResultsMethod, {
+const { data, loading, error } = useRequest(analysisResultsMethod, {
   initialData: {
     tongue: {},
     face: {},
   },
+}).onSuccess(({ data }) => {
+  if (data?.miniProgramURL) panelOpen(data.payLock ? panelProps.anchors[1] : 100);
 }).onError(async ({ error }) => {
   await Dialog.show({
     message: error.message,
@@ -21,6 +23,22 @@ const { data, loading } = useRequest(analysisResultsMethod, {
   });
   await router.replace(`/camera`);
 });
+
+const panelHeight = ref(0);
+const panelProps = reactive({
+  anchors: [0, window.innerWidth],
+  contentDraggable: false,
+  lockScroll: true,
+
+  show: true,
+});
+const panelOpen = (min?: number) => {
+  if (panelProps.show && min) panelProps.anchors[0] = min;
+  panelHeight.value = panelProps.anchors[1];
+};
+
+const scrollable = computed(() => panelHeight.value < panelProps.anchors[1] || panelHeight.value === 0);
+
 </script>
 <template>
   <div class="report-wrapper">
@@ -38,14 +56,31 @@ const { data, loading } = useRequest(analysisResultsMethod, {
       </div>
     </div>
     <div class="page-content flex flex-col overflow-hidden">
-      <van-skeleton class="flex-auto" title :row="3" :loading>
-        <div class="flex-auto overflow-y-auto">
+      <van-skeleton class="flex-auto" v-if="!error" title :row="3" :loading>
+        <div class="flex-auto" :class="{ 'overflow-y-auto': scrollable }">
           <div class="my-6 text-primary text-2xl text-center" v-if="data.date">报告日期:{{ data.date }}</div>
           <AnalysisComponent title="舌象分析" v-bind="data.tongue"></AnalysisComponent>
           <AnalysisComponent title="面象分析" v-bind="data.face"></AnalysisComponent>
+          <div :style="{ height: panelHeight + 'px' }"><!--补偿面板打开高度--></div>
         </div>
       </van-skeleton>
     </div>
+    <van-floating-panel v-model:height="panelHeight" v-bind="panelProps">
+      <Transition>
+        <div class="panel-content">
+          <img
+            class="size-full object-contain"
+            v-if="panelHeight === panelProps.anchors[1] || panelHeight > panelProps.anchors[0] * 1.5"
+            :src="data.miniProgramURL"
+            alt="小程序码"
+          />
+          <div class="flex justify-center items-center" v-else @click="panelOpen()">
+            <img class="h-10 w-10" src="@/assets/images/mini-program.svg" alt="小程序" />
+            <span class="text-lg ml-2">小程序</span>
+          </div>
+        </div>
+      </Transition>
+    </van-floating-panel>
   </div>
 </template>
 <style scoped lang="scss">
@@ -53,6 +88,20 @@ const { data, loading } = useRequest(analysisResultsMethod, {
   .panel-content {
     padding: 0 var(--van-floating-panel-header-height) var(--van-floating-panel-header-height);
   }
+
+  .v-enter-active,
+  .v-leave-active {
+    transition: opacity 0.5s ease;
+  }
+
+  .v-enter-from,
+  .v-leave-to {
+    opacity: 0;
+  }
+}
+
+.overflow-y-auto {
+  overflow-y: auto;
 }
 </style>
 <style lang="scss">

+ 64 - 8
src/modules/report/report.page.vue

@@ -7,6 +7,8 @@ import { getReportMethod, updateReportMethod } from '@/request/api/report.api';
 import { useRouteParams }                      from '@vueuse/router';
 import { useRequest, useWatcher }              from 'alova/client';
 
+import NavHomeSelect from '@/assets/images/nav-home.select.png?url';
+
 
 const id = useRouteParams<string>('id');
 const { data, loading } = useWatcher(() => getReportMethod(id.value), [ id ], {
@@ -16,7 +18,9 @@ const { data, loading } = useWatcher(() => getReportMethod(id.value), [ id ], {
     face: {},
   },
   immediate: true,
-});
+}).onSuccess(({ data }) => {
+  if (data?.miniProgramURL) panelOpen(data.payLock ? panelProps.anchors[1] : 100);
+})
 
 const { loading: uploading, send: upload } = useRequest(() => updateReportMethod(id.value, data.value), {
   immediate: false,
@@ -54,12 +58,23 @@ async function miniProgram() {
     Notify.warning(`未获取到小程序地址,请联系管理员或重试`);
     return;
   }
-  ReportPreview = defineAsyncComponent(() => import('./ReportPreview.vue'));
-  reportPreviewProps.mode = 'img';
-  reportPreviewProps.title = '微信 扫一扫';
-  reportPreviewProps.url = url;
-  reportPreviewProps.show = true;
+  panelOpen();
 }
+
+const panelHeight = ref(0);
+const panelProps = reactive({
+  anchors: [0, window.innerWidth],
+  contentDraggable: false,
+  lockScroll: true,
+
+  show: false,
+});
+const panelOpen = (min?: number) => {
+  if (panelProps.show && min) panelProps.anchors[0] = min;
+  panelHeight.value = panelProps.anchors[1];
+};
+
+const scrollable = computed(() => panelHeight.value < panelProps.anchors[1] || panelHeight.value === 0);
 </script>
 <template>
   <div class="report-wrapper">
@@ -70,11 +85,15 @@ async function miniProgram() {
           健康分析报告
         </div>
       </div>
-      <div class="grow shrink-0 h-full min-w-16"></div>
+      <div class="grow shrink-0 h-full min-w-16">
+        <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 overflow-hidden">
       <van-skeleton class="flex-auto" title :row="3" :loading>
-        <div class="flex-auto overflow-y-auto">
+        <div class="flex-auto" :class="{ 'overflow-y-auto': scrollable }">
           <div class="my-6 text-primary text-2xl text-center">报告日期:{{ data.date }}</div>
           <div class="card m-6 text-lg">
             <div class="card__title text-primary text-3xl font-bold"></div>
@@ -167,6 +186,23 @@ async function miniProgram() {
       </van-skeleton>
       <NavBar class="flex-none" :uploading @print="print" @mini="miniProgram"></NavBar>
       <Component :is="ReportPreview" v-bind="reportPreviewProps" v-model:show="reportPreviewProps.show"></Component>
+
+      <van-floating-panel v-model:height="panelHeight" v-bind="panelProps">
+        <Transition>
+          <div class="panel-content">
+            <img
+              class="size-full object-contain"
+              v-if="panelHeight === panelProps.anchors[1] || panelHeight > panelProps.anchors[0] * 1.5"
+              :src="data.miniProgramURL"
+              alt="小程序码"
+            />
+            <div class="flex justify-center items-center" v-else @click="panelOpen()">
+              <img class="h-10 w-10" src="@/assets/images/mini-program.svg" alt="小程序" />
+              <span class="text-lg ml-2">小程序</span>
+            </div>
+          </div>
+        </Transition>
+      </van-floating-panel>
     </div>
   </div>
 </template>
@@ -182,6 +218,26 @@ async function miniProgram() {
 .text-grey {
   color: #e3e3e3;
 }
+
+.report-wrapper {
+  .panel-content {
+    padding: 0 var(--van-floating-panel-header-height) var(--van-floating-panel-header-height);
+  }
+
+  .v-enter-active,
+  .v-leave-active {
+    transition: opacity 0.5s ease;
+  }
+
+  .v-enter-from,
+  .v-leave-to {
+    opacity: 0;
+  }
+}
+
+.overflow-y-auto {
+  overflow-y: auto;
+}
 </style>
 <style lang="scss">
 .report-wrapper .card {

+ 7 - 1
src/modules/report/scheme.page.vue

@@ -5,6 +5,8 @@ import { getReportSchemeMethod } from '@/request/api/report.api';
 import { useRouteParams }        from '@vueuse/router';
 import { useWatcher }            from 'alova/client';
 
+import NavHomeSelect from '@/assets/images/nav-home.select.png?url';
+
 
 const id = useRouteParams<string>('id');
 const { data, loading } = useWatcher(() => getReportSchemeMethod(id.value), [ id ], {
@@ -23,7 +25,11 @@ const { data, loading } = useWatcher(() => getReportSchemeMethod(id.value), [ id
           调理方案
         </div>
       </div>
-      <div class="grow shrink-0 h-full min-w-16"></div>
+      <div class="grow shrink-0 h-full min-w-16">
+        <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 overflow-hidden">
       <!--{{ data }}-->

+ 3 - 1
src/request/model/report.model.ts

@@ -27,7 +27,7 @@ export function fromReportData(data: Record<string, any>) {
         [ '环境适应能力', data?.constitutionGroupAdaptability ],
       ],
     },
-    
+
     tongue: fromTongueAnalysisModel(data),
     face: fromFaceAnalysisModel(data),
 
@@ -65,6 +65,8 @@ export function fromReportData(data: Record<string, any>) {
     factorItemRadarImg: data?.factorItemRadarImg,
     reportURL: data?.reportPdfUrl,
     miniProgramURL: data?.appletImg,
+
+    payLock: data?.payLock ?? false,
   };
 }