123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227 |
- <template>
- <view class="camera-container">
- <!-- 顶部标题栏 -->
- <!-- <view class="header">
- <view class="back-button" @click="back">
- <text class="iconfont icon-back"></text>
- </view>
- <view class="title">中国传统文化测试</view>
- <view class="controls">
- <text class="iconfont icon-mic"></text>
- <text class="iconfont icon-settings" @click="toggleSettings"></text>
- </view>
- </view> -->
- <!-- 主要内容区域 -->
- <view class="content">
- <!-- 数字人头像 -->
- <view class="digital-avatar">
- <web-view v-if="digitalHumanUrl" :src="digitalHumanUrl" class="digital-human-webview"></web-view>
- <image v-else src="/static/avatar.png" mode="aspectFill" class="avatar-image"></image>
- </view>
- <!-- 进度指示器 -->
- <!-- <view class="progress-container">
- <view class="progress-step" v-for="(step, index) in 3" :key="index">
- <view class="step-circle" :class="{'active': currentStep >= index+1}">{{index+1}}</view>
- <view class="step-text">{{stepTexts[index]}}</view>
- </view>
- <view class="progress-bar">
- <view class="progress-fill" :style="{width: progressWidth + '%'}"></view>
- </view>
- </view> -->
- <!-- 面试内容区域 -->
- <view class="interview-content">
- <!-- 问题编号和进度 -->
- <view class="question-number">
- <text>{{currentQuestionIndex + 1}}-{{currentQuestion.id}}/{{questions.length}}</text>
- </view>
-
- <!-- 问题和选项区域 -->
- <view class="question-area">
- <view class="question-importance">
- <text v-if="currentQuestion.isImportant">重点题</text>
- <text class="question-type">[{{currentQuestion.questionTypeName}}]</text>
- {{currentQuestion.text}}
- </view>
- <view class="options">
- <!-- 开放问题 (question_form: 0) - 显示文本输入框 -->
- <!-- {{ currentQuestion }} -->
- <view v-if="currentQuestion.questionType == 0" class="open-question-container">
-
- <textarea
- class="open-question-input"
- v-model="openQuestionAnswer"
- placeholder="请输入您的回答..."
- maxlength="500"
- ></textarea>
- <view class="word-count">{{openQuestionAnswer.length}}/500</view>
- </view>
-
- <!-- 单选题和多选题 (question_form: 1 或 2) -->
- <view
- v-else
- v-for="(option, index) in currentQuestion.options"
- :key="index"
- class="option-item"
- :class="{
- 'option-selected': currentQuestion.questionType === 1 ? selectedOption === index : selectedOptions.includes(index),
- 'option-correct': showResult && (
- currentQuestion.questionType === 1 ? index === currentQuestion.correctAnswer : currentQuestion.correctAnswers.includes(index)
- ),
- 'option-wrong': showResult && (
- currentQuestion.questionType === 1 ?
- (selectedOption === index && index !== currentQuestion.correctAnswer) :
- (selectedOptions.includes(index) && !currentQuestion.correctAnswers.includes(index))
- )
- }"
- @click="selectOption(index)">
- <!-- 选项前添加单选/多选标识 -->
- <text class="option-prefix">{{currentQuestion.questionType === 1 ? '●' : '☐'}}</text>
- <text class="option-text">{{ option.option_text || (typeof option === 'string' ? option : JSON.stringify(option)) }}</text>
- </view>
- </view>
- <!-- <view class="timer-container">
- <text class="timer-text">本题剩余时间 {{remainingTime}}</text>
- </view> -->
-
- <button class="next-button" @click="nextQuestion(option)"
- :disabled="
- (currentQuestion.questionType === 0 && openQuestionAnswer.trim() === '') ||
- (currentQuestion.questionType === 1 && selectedOption === null) ||
- (currentQuestion.questionType === 2 && selectedOptions.length === 0)
- ">
- {{showResult ? '下一题' : '提交答案'}}
- </button>
- </view>
- </view>
- </view>
- <!-- 底部控制栏 -->
- <!-- <view class="footer">
- <view class="timer">本题剩余 {{remainingTime}}</view>
- <view class="next-step">进入下一题</view>
- </view> -->
- <!-- 面试结束弹窗 -->
- <view class="interview-end-modal" v-if="showEndModal">
- <view class="modal-content">
- <view class="modal-title">测试已完成</view>
- <!-- <view class="score-display">{{score}}/{{totalQuestions}}</view>
- <view class="modal-message">您在本次测试中答了{{score}}道题目,共{{totalQuestions}}道题目。</view> -->
- <view class="modal-buttons">
- <button type="default" class="modal-button" @click="restartTest">重新测试</button>
- <button type="primary" class="modal-button" @click="back">返回首页</button>
- </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 class="loading-container" v-if="loading">
- <uni-load-more status="loading" :contentText="{contentdown: '加载中...'}" />
- <text class="loading-text">正在加载面试题目...</text>
- </view>
- <!-- 添加加载错误提示 -->
- <view class="loading-container" v-if="!loading && loadError">
- <view class="error-container">
- <text class="error-message">加载面试题目失败</text>
- <button class="retry-button" @click="fetchInterviewData">重试</button>
- </view>
- </view>
- </view>
- </template>
- <script>
- import { getInterviewList, getInterviewDetail } from '@/api/user.js';
-
- export default {
- data() {
- return {
- cameraContext: null,
- devicePosition: 'front',
- interviewStarted: true,
- showEndModal: false,
- currentQuestionIndex: 0,
- currentStep: 1,
- stepTexts: ['测试准备', '回答问题', '测试结束'],
- progressWidth: 50,
- remainingTime: '00:27',
- selectedOption: null,
- selectedOptions: [],
- showResult: false,
- isAnswerCorrect: false,
- questions: [], // 改为空数组,将通过API获取
- interviewId: null, // 存储当前面试ID
- useVideo: false,
- timerInterval: null,
- score: 0,
- totalQuestions: 0,
- interviewCompleted: false,
- digitalHumanUrl: '', // 数字人URL
- loading: true, // 添加加载状态
- loadError: false, // 添加加载错误状态
- errorMessage: '', // 添加错误消息
- answers: [], // 存储用户的所有答案
- currentQuestionDetail: null, // 当前题目详情
- isSubmitting: false, // 是否正在提交答案
- openQuestionAnswer: '', // 存储开放问题的答案
- currentAnswer: null, // 存储当前答案以便提交
- questionStartTime: null, // 存储问题开始时间
- }
- },
- computed: {
- currentQuestion() {
- console.log(this.questions[this.currentQuestionIndex]);
- return this.questions[this.currentQuestionIndex];
- }
- },
- onLoad(options) {
- // 从路由参数中获取面试ID
- if (options && options.id) {
- this.interviewId = options.id;
- this.fetchInterviewData();
- } else {
- // 如果没有ID,可以获取面试列表并使用第一个
- this.fetchInterviewList();
- }
- },
- onReady() {
- // 创建相机上下文
- this.cameraContext = uni.createCameraContext();
- // 创建AI视频上下文
- if (this.useVideo) {
- this.aiVideoContext = uni.createVideoContext('aiInterviewer');
- }
-
- // 初始化数字人
- this.initDigitalHuman();
- },
- methods: {
- // 获取面试列表
- async fetchInterviewList() {
- try {
- this.loading = true;
- const res = await getInterviewList({job_id:JSON.parse(uni.getStorageSync('selectedJob')).id});
- console.log(res);
- // 使用第一个面试
- this.interviewId = res//[0].id;
- this.fetchInterviewData(res);
- } catch (error) {
- console.error('获取面试列表失败:', error);
- this.handleLoadError('获取面试列表失败');
- }
- },
-
- // 获取面试详情数据
- async fetchInterviewData(data) {
- try {
- this.loading = true;
- // const res = await getInterviewDetail({ id: this.interviewId });
- // console.log('API返回数据:', res);
-
- // 如果返回的是问题列表
- if (data && Array.isArray(data)) {
- // 处理多个问题
- this.questions =data.map((q, index) => ({
- id: q.id || index + 1,
- text: q.question || '未知问题',
- options:q.options || [],
- correctAnswer: q.correctAnswer || 0,
- isImportant: q.is_system || false,
- explanation: q.explanation || '',
- questionType: q.question_form,
- questionTypeName: q.question_form_name || '单选题',
- correctAnswers: q.correct_answers || [],
- difficulty: q.difficulty || 1,
- difficultyName: q.difficulty_name || '初级'
- }));
- } else {
- // 处理单个问题
- this.processInterviewData(res);
- }
- console.log(this.questions);
- // 设置总题目数
- this.totalQuestions = this.questions.length;
-
- // 启动倒计时
- if (this.questions.length > 0) {
- this.startTimer();
- }
- } catch (error) {
- console.error('获取面试详情失败:', error);
- this.handleLoadError('获取面试详情失败');
- } finally {
- this.loading = false;
- }
- },
-
- // 处理面试数据
- processInterviewData(data) {
- // 清空现有问题列表
- this.questions = [];
-
- // 检查数据格式并处理
- if (data) {
- // 创建一个格式化的问题对象
- const formattedQuestion = {
- id: data.id || 1,
- text: data.question || '未知问题',
- options: data.options || [],
- correctAnswer: data.correctAnswer || 0,
- isImportant: data.is_system || false,
- explanation: data.explanation || '',
- questionType: data.question_form, // 1-单选题,2-多选题
- questionTypeName: data.question_form_name || '单选题',
- correctAnswers: data.correct_answers || [],
- difficulty: data.difficulty || 1,
- difficultyName: data.difficulty_name || '初级'
- };
-
- // 添加到问题列表
- this.questions.push(formattedQuestion);
-
- // 设置总题目数
- this.totalQuestions = this.questions.length;
-
- // 启动倒计时
- this.startTimer();
- } else {
- this.handleLoadError('面试中没有问题');
- }
- },
-
- // 处理加载错误
- handleLoadError(message) {
- this.loadError = true;
- this.loading = false;
- this.errorMessage = message || '加载失败';
- uni.showToast({
- title: message || '加载失败',
- icon: 'none',
- duration: 2000
- });
- },
-
- startTimer() {
- // 确保问题已加载
- if (this.questions.length === 0) return;
-
- // 记录开始时间
- this.questionStartTime = new Date();
-
- // 模拟倒计时
- let seconds = 30; // 每题30秒
- this.timerInterval = setInterval(() => {
- seconds--;
- if (seconds <= 0) {
- clearInterval(this.timerInterval);
- // 时间到,自动提交答案
- if (!this.showResult) {
- this.checkAnswer();
- }
- }
- const min = Math.floor(seconds / 60).toString().padStart(2, '0');
- const sec = (seconds % 60).toString().padStart(2, '0');
- this.remainingTime = `${min}:${sec}`;
- }, 1000);
- },
- resetTimer() {
- clearInterval(this.timerInterval);
- this.startTimer();
- },
- selectOption(index) {
- if (this.showResult) return; // 已显示结果时不能再选择
-
- // 判断当前题目类型
- if (this.currentQuestion.questionType === 2) { // 多选题
- // 如果已经选中,则取消选中
- const optionIndex = this.selectedOptions.indexOf(index);
- if (optionIndex > -1) {
- this.selectedOptions.splice(optionIndex, 1);
- } else {
- // 否则添加到已选中数组
- this.selectedOptions.push(index);
- }
- } else if (this.currentQuestion.questionType === 1) { // 单选题
- this.selectedOption = index;
- }
-
- this.playAiSpeaking();
- },
-
- checkAnswer() {
- clearInterval(this.timerInterval); // 停止计时
-
- // 确保当前问题存在
- if (!this.currentQuestion) {
- console.error('当前问题不存在');
- return;
- }
-
- // 根据题目类型检查答案是否正确
- if (this.currentQuestion.questionType === 0) { // 开放问题
- // 开放问题没有标准答案,可以根据需要设置为正确或待评估
- this.isAnswerCorrect = true; // 或者设置为 null 表示待评估
- } else if (this.currentQuestion.questionType === 2) { // 多选题
- const sortedSelected = [...this.selectedOptions].sort();
- const sortedCorrect = [...this.currentQuestion.correctAnswers].sort();
-
- if (sortedSelected.length !== sortedCorrect.length) {
- this.isAnswerCorrect = false;
- } else {
- this.isAnswerCorrect = sortedSelected.every((value, index) => value === sortedCorrect[index]);
- }
- } else { // 单选题
- this.isAnswerCorrect = this.selectedOption === this.currentQuestion.correctAnswer;
- }
-
- // 显示结果
- this.showResult = true;
- },
- nextQuestion(data) {
- // 如果还没有显示结果,先检查答案并提交
- if (!this.showResult) {
- this.checkAnswer();
- // 保存当前题目的答案并立即提交
- this.saveAnswer(data);
- this.submitCurrentAnswer(data).then(() => {
- // 提交成功后显示结果
- this.showResult = true;
- }).catch(error => {
- console.error('提交答案失败:', error);
- uni.showToast({
- title: '提交答案失败,请重试',
- icon: 'none'
- });
- // 即使提交失败也显示结果
- this.showResult = true;
- });
- return;
- }
-
- // 如果已经显示结果,点击"下一题"按钮时执行
- // 如果是最后一题,显示结果页面
- if (this.currentQuestionIndex >= this.questions.length - 1) {
- this.showEndModal = true;
- return;
- }
-
- // 前往下一题
- this.goToNextQuestion();
- },
- // 保存当前题目的答案
- saveAnswer() {
- let answer;
-
- if (this.currentQuestion.questionType === 0) { // 开放问题
- answer = {
- questionId: this.currentQuestion.id,
- questionType: this.currentQuestion.questionType,
- answer: this.openQuestionAnswer,
- answerDuration: this.getAnswerDuration() // 添加答题时长
- };
- } else { // 单选或多选
- answer = {
- questionId: this.currentQuestion.id,
- questionType: this.currentQuestion.questionType,
- answer: this.currentQuestion.questionType === 1 ?
- this.selectedOption : this.selectedOptions,
- answerDuration: this.getAnswerDuration() // 添加答题时长
- };
- }
-
- // 检查是否已存在该题目的答案,如果存在则更新
- const existingIndex = this.answers.findIndex(a => a.questionId === answer.questionId);
- if (existingIndex > -1) {
- this.answers[existingIndex] = answer;
- } else {
- this.answers.push(answer);
- }
-
- // 保存当前答案以便提交
- this.currentAnswer = answer;
-
- console.log('已保存答案:', this.answers);
- },
-
- // 获取答题时长(秒)
- getAnswerDuration() {
- // 这里假设每题默认30秒,根据剩余时间计算用时
- // 您可以根据实际情况调整计算逻辑
- const remainingTimeArr = this.remainingTime.split(':');
- const remainingSeconds = parseInt(remainingTimeArr[0]) * 60 + parseInt(remainingTimeArr[1]);
- return 30 - remainingSeconds; // 假设每题30秒
- },
- // 提交当前答案
- async submitCurrentAnswer() {
- if (!this.currentAnswer) return;
-
- try {
- // 显示提交中提示
- uni.showLoading({
- title: '正在提交答案...'
- });
-
- // 构建提交数据
- let answerContent = '';
-
- if (this.currentAnswer.questionType === 0) {
- // 开放题直接使用文本答案
- answerContent = this.currentAnswer.answer;
- } else if (this.currentAnswer.questionType === 1) {
- // 单选题,获取选项ID而不是索引
- const selectedIndex = this.currentAnswer.answer;
- const selectedOption = this.currentQuestion.options[selectedIndex];
- // 使用选项的ID或其他唯一标识符
- answerContent = selectedOption.id ? selectedOption.id.toString() : selectedIndex.toString();
- } else if (this.currentAnswer.questionType === 2) {
- // 多选题,将选项ID数组转为逗号分隔的字符串
- const selectedIndices = this.currentAnswer.answer;
- const selectedOptionIds = selectedIndices.map(index => {
- const option = this.currentQuestion.options[index];
- // 使用选项的ID或其他唯一标识符
- return option.id ? option.id : index;
- });
- answerContent = selectedOptionIds.join(',');
- }
-
- const submitData = {
- application_id: 1, // 或者使用其他合适的ID
- question_id: this.currentAnswer.questionId,
- answer_content: answerContent,
- answer_duration: this.currentAnswer.answerDuration || 0,
- // 如果需要tenant_id,请在这里添加
- tenant_id: 1
- };
-
- console.log('提交数据:', submitData);
-
- // 调用API提交答案
- const res = await this.$http.post('http://192.168.66.187:8083/api/job/submit_answer', submitData);
-
- console.log('提交答案响应:', res);
-
- // 隐藏加载提示
- uni.hideLoading();
-
- return res;
-
- } catch (error) {
- console.error('提交答案失败:', error);
- // 隐藏加载提示
- uni.hideLoading();
-
- // 显示错误提示
- uni.showToast({
- title: '提交答案失败,请重试',
- icon: 'none'
- });
-
- throw error;
- }
- },
-
- // 修改 goToNextQuestion 方法,添加 async 关键字
- async goToNextQuestion() {
- // 重置状态
- this.showResult = false;
- this.selectedOption = null;
- this.selectedOptions = [];
- this.openQuestionAnswer = ''; // 重置开放问题答案
-
- // 前往下一题
- this.currentQuestionIndex++;
-
- // 如果已经有下一题的详情,直接使用
- if (this.questions[this.currentQuestionIndex]) {
- // 更新进度
- this.progressWidth = (this.currentQuestionIndex + 1) / this.questions.length * 100;
-
- // 重置计时器
- this.resetTimer();
-
- // 播放AI介绍下一题
- this.playAiSpeaking();
-
- setTimeout(() => {
- this.pauseAiSpeaking();
- }, 2000);
-
- return;
- }
-
- // 否则请求下一题详情
- try {
- this.loading = true;
-
- // 假设您有一个获取单个题目详情的API
- // const res = await getQuestionDetail({
- // interviewId: this.interviewId,
- // questionIndex: this.currentQuestionIndex
- // });
-
- // 模拟API调用
- await new Promise(resolve => setTimeout(resolve, 1000));
- const res = { /* 模拟的题目数据 */ };
-
- // 处理题目数据
- if (res) {
- const formattedQuestion = {
- id: res.id || this.currentQuestionIndex + 1,
- text: res.question || '未知问题',
- options: res.options || [],
- correctAnswer: res.correctAnswer || 0,
- isImportant: res.is_system || false,
- explanation: res.explanation || '',
- questionType: res.question_form || 1,
- questionTypeName: res.question_form_name || '单选题',
- correctAnswers: res.correct_answers || [],
- difficulty: res.difficulty || 1,
- difficultyName: res.difficulty_name || '初级'
- };
-
- // 添加到问题列表
- this.questions.push(formattedQuestion);
- }
-
- } catch (error) {
- console.error('获取题目详情失败:', error);
- uni.showToast({
- title: '获取题目失败,请重试',
- icon: 'none'
- });
-
- // 出错时回到上一题
- this.currentQuestionIndex--;
-
- } finally {
- this.loading = false;
-
- // 更新进度
- this.progressWidth = (this.currentQuestionIndex + 1) / this.questions.length * 100;
-
- // 重置计时器
- this.resetTimer();
- }
- },
- toggleSettings() {
- // 打开设置面板
- uni.showToast({
- title: '设置功能开发中',
- icon: 'none'
- });
- },
- back() {
- // 清除计时器
- 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) {
- // 相机错误事件
- console.error(e.detail);
- uni.showToast({
- title: '相机启动失败,请检查权限设置',
- icon: 'none'
- });
- },
- playAiSpeaking() {
- if (this.useVideo && this.aiVideoContext) {
- this.aiVideoContext.play();
- }
-
- // 触发数字人说话动画
- if (this.digitalHumanUrl) {
- // 假设当前问题的文本作为数字人要说的内容
- const speakText = this.currentQuestion ? this.currentQuestion.text : '';
- this.interactWithDigitalHuman(speakText);
- }
- },
- pauseAiSpeaking() {
- if (this.useVideo && this.aiVideoContext) {
- this.aiVideoContext.pause();
- }
- },
-
- // 重新开始测试
- restartTest() {
- this.currentQuestionIndex = 0;
- this.score = 0;
- this.showEndModal = false;
- this.showResult = false;
- this.selectedOption = null;
- this.selectedOptions = [];
- this.resetTimer();
- },
- // 在methods中添加测试方法
- testEndScreen() {
- this.interviewCompleted = true;
- this.showEndModal = false;
- },
- // 初始化数字人
- initDigitalHuman() {
- // 移除不可用的示例URL
- // this.digitalHumanUrl = 'https://your-digital-human-service.com/avatar?id=123';
-
- // 暂时不使用数字人服务,直接使用本地图片
- this.digitalHumanUrl = '';
-
- // 如果您有实际可用的数字人服务,可以在这里设置
- // 例如:this.digitalHumanUrl = 'https://your-actual-service.com/avatar';
-
- // 或者使用本地HTML文件(如果有的话)
- // this.digitalHumanUrl = '/hybrid/html/digital-human.html';
- },
-
- // 与数字人交互的方法
- interactWithDigitalHuman(message) {
- // 如果数字人是通过web-view加载的,可以使用postMessage与其通信
- const webview = this.$mp.page.$getAppWebview().children()[0];
- if (webview) {
- webview.evalJS(`receiveMessage('${message}')`);
- }
- }
- },
- // 添加生命周期钩子,确保在组件销毁时清除计时器
- beforeDestroy() {
- if (this.timerInterval) {
- clearInterval(this.timerInterval);
- }
- }
- }
- </script>
- <style>
- .camera-container {
- position: relative;
- width: 100%;
- height: 100vh;
- background-color: #ffffff;
- display: flex;
- flex-direction: column;
- }
- .header {
- height: 90rpx;
- /* background-color: #000000; */
- display: flex;
- align-items: center;
- padding: 0 30rpx;
- /* color: #ffffff; */
- }
- .back-button {
- width: 60rpx;
- height: 60rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .title {
- flex: 1;
- text-align: center;
- font-size: 32rpx;
- font-weight: bold;
- }
- .controls {
- display: flex;
- gap: 30rpx;
- }
- .iconfont {
- font-size: 40rpx;
- }
- .content {
- flex: 1;
- display: flex;
- flex-direction: column;
- position: relative;
- padding: 50rpx 20rpx 0;
- }
- .progress-container {
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- margin-bottom: 20rpx;
- }
- .progress-step {
- display: flex;
- align-items: center;
- margin-bottom: 10rpx;
- }
- .step-circle {
- width: 40rpx;
- height: 40rpx;
- border-radius: 50%;
- background-color: #e0e0e0;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 24rpx;
- margin-right: 10rpx;
- }
- .step-circle.active {
- background-color: #ff9500;
- color: #ffffff;
- }
- .step-text {
- font-size: 24rpx;
- color: #666666;
- }
- .progress-bar {
- height: 10rpx;
- background-color: #e0e0e0;
- border-radius: 5rpx;
- overflow: hidden;
- margin-bottom: 20rpx;
- }
- .progress-fill {
- height: 100%;
- background-color: #00c853;
- transition: width 0.3s;
- }
- .interview-content {
- flex: 1;
- display: flex;
- flex-direction: column;
- }
- .video-area {
- display: flex;
- /* flex-direction: column; */
- justify-content: space-between;
- height: auto;
- margin-bottom: 20rpx;
- }
- .video-camera {
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: space-between;
- width: 65%;
- }
- .interviewer {
- background-color: #f5f5f5;
- display: flex;
- align-items: center;
- justify-content: center;
- position: relative;
- width: 48% !important;
- height: 300rpx;
- }
- .interviewer-video {
- width: 100%;
- height: 100%;
- object-fit: cover;
- }
- .interviewer-avatar {
- width: 80%;
- height: 80%;
- object-fit: contain;
- }
- .user-camera-container {
- width: 48%;
- height: 300rpx;
- border-radius: 10rpx;
- overflow: hidden;
- border: 4rpx solid #ffffff;
- box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.2);
- }
- .question-area {
- flex: 1;
- display: flex;
- flex-direction: column;
- }
- .question-number {
- font-size: 28rpx;
- color: #666;
- margin-bottom: 20rpx;
- }
-
- .question-importance {
- background-color: #f9f9f9;
- padding: 20rpx;
- border-radius: 10rpx;
- margin-bottom: 20rpx;
- font-size: 28rpx;
- color: #333;
- }
-
- .question-importance text {
- color: #ff0000;
- margin-right: 10rpx;
- }
- .options {
- display: flex;
- flex-direction: column;
- gap: 20rpx;
- margin-bottom: 30rpx;
- }
- .option-item {
- padding: 20rpx;
- background-color: #f5f5f5;
- border-radius: 10rpx;
- font-size: 28rpx;
- transition: all 0.3s;
- border: 1px solid #e0e0e0;
- }
- .option-selected {
- background-color: #e6f7ff;
- border: 1px solid #1890ff;
- }
-
- .option-correct {
- background-color: #d4f7d4;
- border: 1px solid #52c41a;
- }
-
- .option-wrong {
- background-color: #fff1f0;
- border: 1px solid #ff4d4f;
- }
- .option-text {
- color: #333;
- }
-
- .timer-container {
- text-align: center;
- margin: 20rpx 0;
- }
-
- .timer-text {
- font-size: 24rpx;
- color: #666;
- }
- .next-button {
- background-color: #6c5ce7;
- color: #ffffff;
- border-radius: 10rpx;
- font-size: 30rpx;
- margin: 20rpx auto;
- height: 80rpx;
- line-height: 80rpx;
- width: 90%;
- text-align: center;
- }
-
- .next-button[disabled] {
- background-color: #cccccc;
- color: #999999;
- }
- .footer {
- height: 100rpx;
- background-color: #000000;
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 0 30rpx;
- color: #ffffff;
- }
- .timer {
- font-size: 28rpx;
- }
- .next-step {
- font-size: 28rpx;
- }
- .interview-end-modal {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background-color: rgba(0, 0, 0, 0.5);
- display: flex;
- align-items: center;
- justify-content: center;
- z-index: 999;
- }
- .modal-content {
- width: 80%;
- background-color: #ffffff;
- border-radius: 20rpx;
- padding: 40rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- }
- .modal-title {
- font-size: 36rpx;
- font-weight: bold;
- margin-bottom: 30rpx;
- }
- .score-display {
- font-size: 48rpx;
- font-weight: bold;
- color: #6c5ce7;
- margin: 20rpx 0;
- }
-
- .modal-message {
- font-size: 28rpx;
- color: #666;
- text-align: center;
- margin-bottom: 40rpx;
- }
-
- .modal-buttons {
- display: flex;
- justify-content: space-between;
- width: 100%;
- margin-top: 20rpx;
- }
-
- .modal-button {
- width: 45%;
- }
- @keyframes speaking {
- 0% {
- opacity: 0.8;
- }
- 50% {
- opacity: 1;
- }
- 100% {
- opacity: 0.8;
- }
- }
- .speaking {
- animation: speaking 1.5s infinite;
- }
- .digital-avatar {
- width: 120rpx;
- height: 120rpx;
- z-index: 10;
- overflow: hidden;
- }
-
- .avatar-image {
- width: 120rpx;
- height: 120rpx;
- border-radius: 20rpx;
- border: 2rpx solid #e0e0e0;
- }
- .digital-human-webview {
- width: 120rpx;
- height: 120rpx;
- 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;
- }
- /* 添加加载状态样式 */
- .loading-container {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- background-color: rgba(255, 255, 255, 0.9);
- z-index: 100;
- }
-
- .loading-text {
- margin-top: 20rpx;
- font-size: 28rpx;
- color: #666;
- }
-
- .error-container {
- text-align: center;
- }
-
- .error-message {
- font-size: 28rpx;
- color: #ff4d4f;
- margin-bottom: 30rpx;
- }
-
- .retry-button {
- background-color: #6c5ce7;
- color: #ffffff;
- border-radius: 10rpx;
- font-size: 28rpx;
- padding: 10rpx 30rpx;
- }
- .question-type {
- display: inline-block;
- background-color: #6c5ce7;
- color: white;
- font-size: 24rpx;
- padding: 4rpx 10rpx;
- border-radius: 6rpx;
- margin-right: 10rpx;
- }
- /* 新增的开放问题样式 */
- .open-question-container {
- display: flex;
- flex-direction: column;
- width: 100%;
- margin-bottom: 20rpx;
- }
- .open-question-input {
- width: 100%;
- height: 300rpx;
- background-color: #f9f9f9;
- border: 1px solid #e0e0e0;
- border-radius: 10rpx;
- padding: 20rpx;
- font-size: 28rpx;
- color: #333;
- }
- .word-count {
- text-align: right;
- font-size: 24rpx;
- color: #999;
- margin-top: 10rpx;
- }
- .option-prefix {
- margin-right: 10rpx;
- color: #6c5ce7;
- font-weight: bold;
- }
- </style>
|