yangg 2 ヶ月 前
コミット
dab55e32b9

+ 114 - 7
pages/camera/camera.vue

@@ -84,6 +84,19 @@
 				</view>
 			</view>
 		</view>
+
+		<!-- AI面试结束页面 -->
+		<view class="interview-complete-screen" v-if="interviewCompleted">
+			<view class="digital-avatar-large">
+				<image src="/static/avatar.png" mode="aspectFill" class="avatar-image-large"></image>
+			</view>
+			<view class="complete-message">AI面试已结束</view>
+			<view class="complete-description">本次面试的全部环节已结束。非常感谢您的参与。</view>
+			<button class="complete-button" @click="back">我知道了</button>
+		</view>
+
+		<!-- 在模板中添加一个测试按钮(开发时使用,发布前删除) -->
+		<!-- <button @click="testEndScreen" style="position: absolute; top: 10px; right: 10px; z-index: 9999;">测试结束页</button> -->
 	</view>
 </template>
 
@@ -146,7 +159,8 @@
 				useVideo: false,
 				timerInterval: null,
 				score: 0,
-				totalQuestions: 0
+				totalQuestions: 0,
+				interviewCompleted: false
 			}
 		},
 		computed: {
@@ -214,7 +228,15 @@
 					this.score++;
 				}
 				
-				// 直接进入下一题,不显示结果
+				// 检查是否是最后一题
+				if (this.currentQuestionIndex === this.questions.length - 1) {
+					// 显示AI面试结束页面
+					this.showEndModal = false;
+					this.interviewCompleted = true;
+					return;
+				}
+				
+				// 不是最后一题,进入下一题
 				this.goToNextQuestion();
 			},
 
@@ -237,8 +259,14 @@
 				
 				// 检查是否已完成所有题目
 				if (this.currentQuestionIndex >= this.questions.length) {
-					// 显示测试结束弹窗
-					this.showEndModal = true;
+					// 显示AI面试结束页面,确保弹窗不显示
+					this.showEndModal = false;
+					this.interviewCompleted = true;
+					
+					// 确保清除计时器
+					if (this.timerInterval) {
+						clearInterval(this.timerInterval);
+					}
 					return;
 				}
 				
@@ -265,9 +293,31 @@
 			},
 
 			back() {
-				// 返回上一页
-				clearInterval(this.timerInterval); // 确保清除计时器
-				uni.navigateBack();
+				// 清除计时器
+				if (this.timerInterval) {
+					clearInterval(this.timerInterval);
+				}
+				
+				// 尝试返回上一页,如果失败则跳转到首页
+				try {
+					const pages = getCurrentPages();
+					if (pages.length > 1) {
+						uni.reLaunch({
+							url: '/pages/index/index'
+						});
+					} else {
+						// 如果当前是第一页,则跳转到首页
+						uni.reLaunch({
+							url: '/pages/index/index'
+						});
+					}
+				} catch (e) {
+					console.error('导航错误:', e);
+					// 出错时也跳转到首页
+					uni.reLaunch({
+						url: '/pages/index/index'
+					});
+				}
 			},
 
 			error(e) {
@@ -299,6 +349,12 @@
 				this.showResult = false;
 				this.selectedOption = null;
 				this.resetTimer();
+			},
+
+			// 在methods中添加测试方法
+			testEndScreen() {
+				this.interviewCompleted = true;
+				this.showEndModal = false;
 			}
 		},
 		// 添加生命周期钩子,确保在组件销毁时清除计时器
@@ -656,4 +712,55 @@
 		border-radius: 20rpx;
 		border: 2rpx solid #e0e0e0;
 	}
+
+	.interview-complete-screen {
+		position: fixed;
+		top: 0;
+		left: 0;
+		right: 0;
+		bottom: 0;
+		background-color: #f0f5ff;
+		display: flex;
+		flex-direction: column;
+		align-items: center;
+		justify-content: center;
+		z-index: 1000;
+		padding: 40rpx;
+	}
+
+	.digital-avatar-large {
+		width: 200rpx;
+		height: 200rpx;
+		margin-bottom: 60rpx;
+	}
+
+	.avatar-image-large {
+		width: 100%;
+		height: 100%;
+		border-radius: 30rpx;
+	}
+
+	.complete-message {
+		font-size: 40rpx;
+		font-weight: bold;
+		color: #333;
+		margin-bottom: 30rpx;
+	}
+
+	.complete-description {
+		font-size: 28rpx;
+		color: #666;
+		text-align: center;
+		margin-bottom: 80rpx;
+		line-height: 1.5;
+	}
+
+	.complete-button {
+		background-color: #6c5ce7;
+		color: #ffffff;
+		border-radius: 10rpx;
+		font-size: 32rpx;
+		padding: 20rpx 60rpx;
+		margin-top: 40rpx;
+	}
 </style>

+ 42 - 4
unpackage/dist/dev/mp-weixin/pages/camera/camera.js

@@ -60,7 +60,8 @@ const _sfc_main = {
       useVideo: false,
       timerInterval: null,
       score: 0,
-      totalQuestions: 0
+      totalQuestions: 0,
+      interviewCompleted: false
     };
   },
   computed: {
@@ -112,6 +113,11 @@ const _sfc_main = {
       if (this.isAnswerCorrect) {
         this.score++;
       }
+      if (this.currentQuestionIndex === this.questions.length - 1) {
+        this.showEndModal = false;
+        this.interviewCompleted = true;
+        return;
+      }
       this.goToNextQuestion();
     },
     nextQuestion() {
@@ -126,7 +132,11 @@ const _sfc_main = {
       this.selectedOption = null;
       this.currentQuestionIndex++;
       if (this.currentQuestionIndex >= this.questions.length) {
-        this.showEndModal = true;
+        this.showEndModal = false;
+        this.interviewCompleted = true;
+        if (this.timerInterval) {
+          clearInterval(this.timerInterval);
+        }
         return;
       }
       this.resetTimer();
@@ -143,8 +153,26 @@ const _sfc_main = {
       });
     },
     back() {
-      clearInterval(this.timerInterval);
-      common_vendor.index.navigateBack();
+      if (this.timerInterval) {
+        clearInterval(this.timerInterval);
+      }
+      try {
+        const pages = getCurrentPages();
+        if (pages.length > 1) {
+          common_vendor.index.reLaunch({
+            url: "/pages/index/index"
+          });
+        } else {
+          common_vendor.index.reLaunch({
+            url: "/pages/index/index"
+          });
+        }
+      } catch (e) {
+        console.error("导航错误:", e);
+        common_vendor.index.reLaunch({
+          url: "/pages/index/index"
+        });
+      }
     },
     error(e) {
       console.error(e.detail);
@@ -171,6 +199,11 @@ const _sfc_main = {
       this.showResult = false;
       this.selectedOption = null;
       this.resetTimer();
+    },
+    // 在methods中添加测试方法
+    testEndScreen() {
+      this.interviewCompleted = true;
+      this.showEndModal = false;
     }
   },
   // 添加生命周期钩子,确保在组件销毁时清除计时器
@@ -210,6 +243,11 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
     o: common_vendor.t($data.totalQuestions),
     p: common_vendor.o((...args) => $options.restartTest && $options.restartTest(...args)),
     q: common_vendor.o((...args) => $options.back && $options.back(...args))
+  } : {}, {
+    r: $data.interviewCompleted
+  }, $data.interviewCompleted ? {
+    s: common_assets._imports_0,
+    t: common_vendor.o((...args) => $options.back && $options.back(...args))
   } : {});
 }
 const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);

+ 1 - 1
unpackage/dist/dev/mp-weixin/pages/camera/camera.wxml

@@ -1 +1 @@
-<view class="camera-container"><view class="content"><view class="digital-avatar"><image src="{{a}}" mode="aspectFill" class="avatar-image"></image></view><view class="interview-content"><view class="question-number"><text>{{b}}-{{c}}/{{d}}</text></view><view class="question-area"><view class="question-importance"><text wx:if="{{e}}">重点题</text> {{f}}</view><view class="options"><view wx:for="{{g}}" wx:for-item="option" wx:key="b" class="{{['option-item', option.c && 'option-selected', option.d && 'option-correct', option.e && 'option-wrong']}}" bindtap="{{option.f}}"><text class="option-text">{{option.a}}</text></view></view><view class="timer-container"><text class="timer-text">本题剩余时间 {{h}}</text></view><button class="next-button" bindtap="{{i}}" disabled="{{j}}"> 下一题 </button></view></view></view><view wx:if="{{k}}" class="interview-end-modal"><view class="modal-content"><view class="modal-title">测试已完成</view><view class="score-display">{{l}}/{{m}}</view><view class="modal-message">您在本次中国传统文化测试中答对了{{n}}道题目,共{{o}}道题目。</view><view class="modal-buttons"><button type="default" class="modal-button" bindtap="{{p}}">重新测试</button><button type="primary" class="modal-button" bindtap="{{q}}">返回首页</button></view></view></view></view>
+<view class="camera-container"><view class="content"><view class="digital-avatar"><image src="{{a}}" mode="aspectFill" class="avatar-image"></image></view><view class="interview-content"><view class="question-number"><text>{{b}}-{{c}}/{{d}}</text></view><view class="question-area"><view class="question-importance"><text wx:if="{{e}}">重点题</text> {{f}}</view><view class="options"><view wx:for="{{g}}" wx:for-item="option" wx:key="b" class="{{['option-item', option.c && 'option-selected', option.d && 'option-correct', option.e && 'option-wrong']}}" bindtap="{{option.f}}"><text class="option-text">{{option.a}}</text></view></view><view class="timer-container"><text class="timer-text">本题剩余时间 {{h}}</text></view><button class="next-button" bindtap="{{i}}" disabled="{{j}}"> 下一题 </button></view></view></view><view wx:if="{{k}}" class="interview-end-modal"><view class="modal-content"><view class="modal-title">测试已完成</view><view class="score-display">{{l}}/{{m}}</view><view class="modal-message">您在本次中国传统文化测试中答对了{{n}}道题目,共{{o}}道题目。</view><view class="modal-buttons"><button type="default" class="modal-button" bindtap="{{p}}">重新测试</button><button type="primary" class="modal-button" bindtap="{{q}}">返回首页</button></view></view></view><view wx:if="{{r}}" class="interview-complete-screen"><view class="digital-avatar-large"><image src="{{s}}" mode="aspectFill" class="avatar-image-large"></image></view><view class="complete-message">AI面试已结束</view><view class="complete-description">本次面试的全部环节已结束。非常感谢您的参与。</view><button class="complete-button" bindtap="{{t}}">我知道了</button></view></view>

+ 45 - 0
unpackage/dist/dev/mp-weixin/pages/camera/camera.wxss

@@ -294,3 +294,48 @@
 		border-radius: 20rpx;
 		border: 2rpx solid #e0e0e0;
 }
+.interview-complete-screen {
+		position: fixed;
+		top: 0;
+		left: 0;
+		right: 0;
+		bottom: 0;
+		background-color: #f0f5ff;
+		display: flex;
+		flex-direction: column;
+		align-items: center;
+		justify-content: center;
+		z-index: 1000;
+		padding: 40rpx;
+}
+.digital-avatar-large {
+		width: 200rpx;
+		height: 200rpx;
+		margin-bottom: 60rpx;
+}
+.avatar-image-large {
+		width: 100%;
+		height: 100%;
+		border-radius: 30rpx;
+}
+.complete-message {
+		font-size: 40rpx;
+		font-weight: bold;
+		color: #333;
+		margin-bottom: 30rpx;
+}
+.complete-description {
+		font-size: 28rpx;
+		color: #666;
+		text-align: center;
+		margin-bottom: 80rpx;
+		line-height: 1.5;
+}
+.complete-button {
+		background-color: #6c5ce7;
+		color: #ffffff;
+		border-radius: 10rpx;
+		font-size: 32rpx;
+		padding: 20rpx 60rpx;
+		margin-top: 40rpx;
+}