diff --git a/src/pages/cal/dq.vue b/src/pages/cal/dq.vue index b8e3905..9828ac0 100644 --- a/src/pages/cal/dq.vue +++ b/src/pages/cal/dq.vue @@ -1,29 +1,29 @@ - + 开始计算 - + - + - + - + - + - + @@ -182,15 +182,22 @@ const handleCal = () => { "正在生成最终评分..." ]; - let textIndex = 0; - const textInterval = setInterval(() => { - loadingText.value = loadingTexts[textIndex]; - textIndex = (textIndex + 1) % loadingTexts.length; - }, 800); - - // 模拟API调用延迟 - setTimeout(() => { - http.postForm("/cal/", formData).then(res => { +let textIndex = 0; +const minLoadingTime = 5000; // 最小加载时间 5秒 +const startTime = Date.now(); // 记录开始时间 + +const textInterval = setInterval(() => { + loadingText.value = loadingTexts[textIndex]; + textIndex = (textIndex + 1) % loadingTexts.length; +}, 800); + +// 模拟API调用延迟 +setTimeout(() => { + http.postForm("/cal/", formData).then(res => { + const elapsedTime = Date.now() - startTime; // 已过去的时间 + const remainingTime = Math.max(0, minLoadingTime - elapsedTime); // 还需要等待的时间 + + setTimeout(() => { clearInterval(textInterval); calLoading.value = false; score.value = res.total_score; @@ -200,14 +207,19 @@ const handleCal = () => { showAnimation.value = false; showResult.value = true; }, 500); - - }).catch(e => { + }, remainingTime); + + }).catch(e => { + const elapsedTime = Date.now() - startTime; + const remainingTime = Math.max(0, minLoadingTime - elapsedTime); + + setTimeout(() => { clearInterval(textInterval); calLoading.value = false; showAnimation.value = false; - alert('计算失败,请重试'); - }); - }, 3000); // 模拟网络延迟 + }, remainingTime); + }); +}, 3000); // 模拟网络延迟 } diff --git a/src/pages/cal/index.vue b/src/pages/cal/index.vue index 0b3eba8..7e2ae42 100644 --- a/src/pages/cal/index.vue +++ b/src/pages/cal/index.vue @@ -5,14 +5,46 @@ 转型金融贷前计算器 - - + + + + + {{ currentIndicator?.name }} + 当前值: {{ currentIndicator?.currentValue }}/{{ currentIndicator?.max }} + + {{ getIndicatorDescription(currentIndicator?.name) }} + + + + + + + + + 项目碳排放量 + 企业分值区间 + 企业/项目等级 + + + + + {{ item.pf }} + {{ item.score }} + {{ item.level }} + + + + @@ -25,9 +57,10 @@ + + \ No newline at end of file
当前值: {{ currentIndicator?.currentValue }}/{{ currentIndicator?.max }}