|
@@ -1,8 +1,7 @@
|
|
|
<script setup lang="ts">
|
|
|
-import { processMethod } from '@/request/api';
|
|
|
-import { useRequest } from 'alova/client';
|
|
|
-import { useRouter } from 'vue-router';
|
|
|
-
|
|
|
+import { processMethod2 } from '@/request/api';
|
|
|
+import { useRequest } from 'alova/client';
|
|
|
+import { useRouter } from 'vue-router';
|
|
|
|
|
|
defineOptions({
|
|
|
name: 'CameraResult',
|
|
@@ -10,18 +9,29 @@ defineOptions({
|
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
|
-const { data, loading } = useRequest(processMethod).onSuccess(() => {init(); });
|
|
|
-const tips = computed(() => data.value === '/screen' ? '返回首页' : '下一步');
|
|
|
+const { data, loading } = useRequest(processMethod2).onSuccess(({ data }) => {
|
|
|
+ init(data.optional ? 10 : 5);
|
|
|
+});
|
|
|
+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 });
|
|
|
+ router.replace({ path: data.value.route });
|
|
|
}
|
|
|
|
|
|
-function init() {
|
|
|
+function init(value = 5) {
|
|
|
+ countdown.value = value;
|
|
|
timer = setInterval(() => {
|
|
|
const _countdown = countdown.value - 1;
|
|
|
if ( _countdown <= 0 ) { done(); } else { countdown.value = _countdown; }
|
|
@@ -45,10 +55,15 @@ onBeforeUnmount(() => {
|
|
|
<div class="text-3xl text-center my-8">完成舌面象的采集</div>
|
|
|
</div>
|
|
|
</main>
|
|
|
- <footer class="flex justify-evenly items-start" style="flex: 1 1 30%">
|
|
|
- <van-button class="decorate !text-xl !text-primary-400" :loading @click="done()">
|
|
|
- {{ tips }}({{ countdown }})
|
|
|
- </van-button>
|
|
|
+ <footer class="flex flex-col items-center" 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>
|
|
|
+ <van-button class="decorate !text-xl !text-primary-400" :loading @click="done()">
|
|
|
+ {{ tips }}({{ countdown }})
|
|
|
+ </van-button>
|
|
|
+ </template>
|
|
|
</footer>
|
|
|
</div>
|
|
|
</div>
|