You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

588 lines
15 KiB

4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
1 month ago
4 months ago
4 months ago
1 month ago
1 month ago
1 month ago
4 months ago
1 month ago
1 month ago
1 month ago
4 months ago
3 months ago
1 month ago
3 months ago
1 month ago
4 months ago
1 month ago
4 months ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
4 weeks ago
1 month ago
4 weeks ago
1 month ago
1 month ago
4 months ago
1 month ago
1 month ago
4 weeks ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
4 months ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
4 weeks ago
1 month ago
1 month ago
1 month ago
1 month ago
3 weeks ago
1 month ago
1 month ago
4 months ago
4 weeks ago
4 months ago
4 months ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
4 months ago
1 month ago
1 month ago
4 months ago
4 months ago
4 months ago
4 months ago
3 months ago
1 month ago
3 months ago
1 month ago
3 months ago
4 months ago
4 months ago
1 month ago
4 months ago
1 month ago
4 months ago
1 month ago
4 months ago
1 month ago
4 months ago
1 month ago
4 months ago
1 month ago
4 months ago
1 month ago
4 months ago
1 month ago
4 months ago
4 months ago
4 months ago
1 month ago
4 months ago
  1. <template>
  2. <view class="content">
  3. <up-navbar leftText=" " title="" :safeAreaInsetTop="false" :autoBack="true">
  4. <template #center>
  5. <view class="u-nav-slot flex">
  6. <view class="btn" @click="changeNav(1)" :class="{active: currentNav==1}">答题模式</view>
  7. <view class="btn" @click="changeNav(2)" :class="{active: currentNav==2}">背题模式</view>
  8. </view>
  9. </template>
  10. </up-navbar>
  11. <view class="con padding">
  12. <view class="h1_row">
  13. <text class="tag" :class="{red: questionBank.types==2, blue: questionBank.types==3}">{{types[questionBank.types-1]}}</text>
  14. <text class="h1" @click="speak(questionBank.title)">{{ questionBank.title}}</text>
  15. </view>
  16. <view class="imgBox" style="width: 100%;padding: 0 0 30rpx 0;" v-if="questionBank.img">
  17. <image :src="questionBank.img" mode="widthFix"></image>
  18. </view>
  19. <view class="option">
  20. <view v-for="(item,index) in questionBank.optionArr" @click="chooseOption(item)">
  21. <!-- 多选题 -->
  22. <view class="optionItem flex" v-if="questionBank.types ==2&& (!curOption.answer||curOption.answer==questionBank.answer)">
  23. <up-icon name="checkmark-circle-fill" color="#55ff7f" size="20" v-if="curOption.ans?.includes(item.key)"></up-icon>
  24. <view class="icon" v-else></view>
  25. <view class="text"><text >{{item.key}}</text> {{item.text}}</view>
  26. </view>
  27. <!-- 正常答案 -->
  28. <view class="optionItem flex" v-else >
  29. <view class="icon" v-if="!curOption.key&&questionBank.types !=2"></view>
  30. <up-icon name="checkmark-circle-fill" color="#55ff7f" size="20" v-else-if="questionBank.answer.includes(item.key)"></up-icon>
  31. <up-icon name="close-circle-fill" color="#ff0000" size="20" v-else></up-icon>
  32. <view class="text"><text v-if="questionBank.types!=3">{{item.key}}</text> {{item.text}}</view>
  33. </view>
  34. <!-- ans -->
  35. </view>
  36. </view>
  37. <view class="answerCss flex" v-if="curOption.answer&&questionBank.answer!=curOption.answer">
  38. <view class="ans">正确答案是
  39. <text v-if="questionBank.types==3" >{{ questionBank.answer=='false'?'错误':'正确' }}</text>
  40. <text v-else >{{ questionBank.answer }}</text>
  41. </view>
  42. <view class="ans">您的答案是
  43. <text v-if="questionBank.types==3" class="red">{{ curOption.answer=='false'?'错误':'正确' }}</text>
  44. <text v-else class="red">{{ curOption.answer }}</text>
  45. </view>
  46. </view>
  47. <view class="btn_row flex-b">
  48. <!-- @click="$goPage('/pages/exercises/lastPage/lastPage')" -->
  49. <button class="btn border" @click="debounce(nextQuestion(-1), 500)" :class="{disable: currentIndex==1}" :disabled="currentIndex==1">上一题</button>
  50. <button class="btn bg" @click="debounce(nextQuestion(1), 500)" :class="{disable: currentIndex>=quesIdList.length}" :disabled="currentIndex>=quesIdList.length">下一题</button>
  51. </view>
  52. <view class="analysis" v-if="currentNav==2||(curOption.answer&&curOption.answer!=questionBank.answer)">
  53. <view class="tit">题目解析</view>
  54. <view class="txt">{{ questionBank.resolving }}</view>
  55. </view>
  56. </view>
  57. <view class="bottomBar">
  58. <view class="ul">
  59. <view class="li">
  60. <view class="icon" style="color: #55ff7f;">{{ yesNum }}</view>
  61. <view class="text">答对</view>
  62. </view>
  63. <view class="li">
  64. <view class="icon" style="color: #ff0000;">{{ noNum }}</view>
  65. <view class="text">答错</view>
  66. </view>
  67. <view class="li">
  68. <view class="icon">{{currentIndex}}/<text style="color: #999; font-size: 24rpx;">{{quesIdList.length}}</text></view>
  69. <view class="text">题目</view>
  70. </view>
  71. <view class="li" @click="showCommt=true">
  72. <view class="icon">
  73. <image src="@/static/images/theory/fankui.png" mode=""></image>
  74. </view>
  75. <view class="text">反馈</view>
  76. </view>
  77. <view class="li" @click="openPopup">
  78. <view class="icon">
  79. <image src="@/static/images/theory/dtk.png" mode=""></image>
  80. </view>
  81. <view class="text">答题卡</view>
  82. </view>
  83. <view class="li" @click="questionWrongColleFn">
  84. <view class="icon">
  85. <image src="@/static/images/theory/scActive.png" mode="" v-if="questionBank.isCollect=='1'"></image>
  86. <image src="@/static/images/theory/sc.png" mode="" v-else></image>
  87. </view>
  88. <view class="text">收藏</view>
  89. </view>
  90. </view>
  91. </view>
  92. <up-popup :show="show" @close="closePopup" @open="openPopup" mode="bottom" round="20" closeable>
  93. <view class="popupCon">
  94. <view class="h3">答题卡</view>
  95. <view class="ulRow">
  96. <view class="ul">
  97. <view class="li">
  98. <view class="icon" style="color: #55ff7f;">{{ yesNum }}</view>
  99. <view class="text">答对</view>
  100. </view>
  101. <view class="li">
  102. <view class="icon" style="color: #ff0000;">{{ noNum }}</view>
  103. <view class="text">答错</view>
  104. </view>
  105. <view class="li" style="margin-left: auto;">
  106. <view class="icon">{{currentIndex}}/<text style="color: #999; font-size: 24rpx;">{{quesIdList.length}}</text></view>
  107. <view class="text">题目</view>
  108. </view>
  109. </view>
  110. </view>
  111. <view class="ul2">
  112. <view class="li2" v-for="(item,index) in quesIdList" :key="index" @click="quesIdListClick(item,index)">
  113. <view class="num" :class="{active: index+1==currentIndex}">{{ index+1 }}</view>
  114. </view>
  115. </view>
  116. </view>
  117. </up-popup>
  118. <up-popup :show="showCommt" @close="showCommtClose" mode="bottom" round="20rpx" closeable>
  119. <view class="commtCon" style="padding: 30rpx">
  120. <up-textarea v-model.trim="contentStr" placeholder="请输入反馈内容" style="margin-top: 50rpx;" maxlength="300"></up-textarea>
  121. <up-button text="提 交" style="margin-top: 20rpx;" type="primary" @click="submitCommt"></up-button>
  122. </view>
  123. </up-popup>
  124. </view>
  125. </template>
  126. <script setup>
  127. function speak(text) {
  128. const speech = new SpeechSynthesisUtterance(text); // 创建语音消息
  129. window.speechSynthesis.speak(speech); // 播报消息
  130. }
  131. import { startQuestionApi, submitAnswerResultApi, getQuestionApi, questionCommentAdd, questionWrongColle} from '@/config/api.js'
  132. import { debounce } from '@/uni_modules/uview-plus';
  133. import {
  134. ref,
  135. reactive
  136. } from 'vue';
  137. const currentNav = ref('1')
  138. const types = ref([
  139. '单选题',
  140. '多选题',
  141. '判断题'
  142. ])
  143. const yesNum = ref(0)
  144. const noNum = ref(0)
  145. import carStore from '@/store/modules/car.js'
  146. let usecarStore = carStore()
  147. import {
  148. onLoad,
  149. onReady
  150. } from "@dcloudio/uni-app"
  151. // 1:单选题,2:多选题,3:判断题
  152. function changeNav(val) {
  153. console.log(window)
  154. if(currentNav.value == val) return
  155. currentNav.value = val
  156. }
  157. function goEmam() {
  158. uni.navigateTo({
  159. // url: '/pages/exercises/exam/exam',
  160. // url: '/pages/exercises/beforeExam/beforeExam',
  161. // url: '/pages/exercises/examResults/examResults',
  162. // url: '/pages/exercises/wrongQuestion/wrongQuestion',
  163. // url: '/pages/exercises/theoryStudy/theoryStudy',
  164. url: '/pages/vip/vipEntry/vipEntry'
  165. })
  166. }
  167. function changeTabbar(val) {
  168. console.log(val)
  169. }
  170. const show = ref(false)
  171. function closePopup() {
  172. show.value = false
  173. }
  174. function openPopup() {
  175. show.value = true
  176. }
  177. let showCommt = ref(false)
  178. let contentStr = ref('')
  179. function showCommtClose() {
  180. showCommt.value = false
  181. contentStr.value = ''
  182. }
  183. // 提交反馈
  184. async function submitCommt() {
  185. if(!contentStr.value) return uni.$u.toast('请输入内容')
  186. let obj = {
  187. content: contentStr.value,
  188. questionId: questionBank.value.id
  189. }
  190. const res = await questionCommentAdd(obj)
  191. if(res.errorcode==0) {
  192. uni.$u.toast('提交成功,感谢您的反馈')
  193. showCommt.value = false
  194. }
  195. }
  196. // 请求数据
  197. const questionBank = ref({})
  198. let quesIdList = ref([])
  199. let currentIndex = ref(1)
  200. async function startQuestionFn() {
  201. try{
  202. uni.showLoading({
  203. title: '正在加载...'
  204. })
  205. let obj = {
  206. carType: usecarStore.carInfo.carType,
  207. stepType: usecarStore.carInfo.stepType,
  208. volume: usecarStore.carInfo.volume,
  209. types: usecarStore.carInfo.types,
  210. sift: usecarStore.carInfo.sift,
  211. contentType: usecarStore.carInfo.contentType,
  212. knowType: usecarStore.carInfo.knowType,
  213. chapter: usecarStore.carInfo.chapter,
  214. }
  215. const {data: res} = await startQuestionApi(obj)
  216. uni.hideLoading()
  217. questionBank.value = res.questionBank
  218. initOptionArr()
  219. quesIdList.value = res.quesIdList
  220. }catch(e){
  221. uni.hideLoading()
  222. }
  223. }
  224. startQuestionFn()
  225. function initOptionArr() {
  226. questionBank.value.optionArr = []
  227. let abcd = [
  228. 'a',
  229. 'b',
  230. 'c',
  231. 'd',
  232. 'e',
  233. 'f'
  234. ]
  235. abcd.forEach((k,i)=>{
  236. let option = 'option'+k
  237. if(questionBank.value[option]) {
  238. let obj = {
  239. key: k.toLocaleUpperCase(),
  240. text: questionBank.value[option],
  241. index: i+1
  242. }
  243. questionBank.value.optionArr.push(obj)
  244. // console.log(questionBank.value.optionArr)
  245. }
  246. })
  247. // 如果是判断题
  248. if(questionBank.value.types==3) {
  249. questionBank.value.optionArr[0].key = 'true'
  250. questionBank.value.optionArr[1].key = 'false'
  251. }
  252. }
  253. // 下一题
  254. async function nextQuestion(num) {
  255. // 如果是多选题,什么时候不直接请求下一题,是多选题 ,并且有答案,答错了,并且不是next
  256. if(questionBank.value.types==2 && curOption.value.ans) {
  257. // 如果没有请求就请求一下
  258. if(!curOption.value.answer) {
  259. curOption.value.answer = curOption.value.ans
  260. await submitAnswerResultFn()
  261. }
  262. // 如果答案不一样,并且是第一次请求
  263. if(questionBank.value.answer != curOption.value.ans&&curOption.value.isNext != 'next') {
  264. curOption.value.isNext = 'next'
  265. return false
  266. }
  267. }
  268. curOption.value = {}
  269. currentIndex.value = currentIndex.value + num
  270. getQuestionFn()
  271. }
  272. // 请求下一题
  273. async function getQuestionFn() {
  274. console.log(currentIndex.value)
  275. let questionId = quesIdList.value[currentIndex.value-1]
  276. let obj = {
  277. "carType": usecarStore.carInfo.carType,
  278. "questionId": questionId,
  279. "sort": currentIndex.value,
  280. "stepType": usecarStore.carInfo.stepType,
  281. 'tempId': questionBank.value.questionDoTemp.id
  282. }
  283. const {data: res} = await getQuestionApi(obj)
  284. questionBank.value = res
  285. curOption.value.isNext = ''
  286. initOptionArr()
  287. }
  288. async function quesIdListClick(id, index) {
  289. curOption.value = {}
  290. currentIndex.value = index + 1
  291. getQuestionFn()
  292. show.value = false
  293. }
  294. // 选择答案
  295. const curOption = ref({})
  296. async function chooseOption(item) {
  297. // console.log(item)
  298. if(curOption.value.answer) return
  299. if(questionBank.value.types != 2) {
  300. item.answer = item.key
  301. curOption.value = item
  302. submitAnswerResultFn()
  303. }else if(questionBank.value.types == 2){
  304. if(!curOption.value.ans) curOption.value.ans = ''
  305. if(curOption.value.ans.includes(item.key)) {
  306. curOption.value.ans = curOption.value.ans.replace(item.key, '')
  307. return
  308. }
  309. curOption.value.ans = (curOption.value.ans + item.key).split('').sort().join('')
  310. // console.log(curOption.value.ans)
  311. }
  312. }
  313. // 提交请求
  314. async function submitAnswerResultFn() {
  315. let obj = {
  316. answer: curOption.value.answer,
  317. carType: 'car',
  318. questionId: questionBank.value.id,
  319. result: '0',
  320. stepType: 1,
  321. tempId: questionBank.value.questionDoTemp.id
  322. }
  323. const res = await submitAnswerResultApi(obj)
  324. if(res.errorcode!=0) return
  325. if(curOption.value.answer==questionBank.value.answer) {
  326. console.log('答对了')
  327. curOption.value = {}
  328. yesNum.value ++
  329. nextQuestion(1)
  330. }else {
  331. noNum.value ++
  332. }
  333. // console.log(res)
  334. }
  335. async function questionWrongColleFn() {
  336. let isAdd = questionBank.value.isCollect==1?'0':'1'
  337. const obj = {
  338. "carType": usecarStore.carInfo.carType,
  339. "isAdd": isAdd,
  340. "questionId": questionBank.value.id,
  341. "stepType": usecarStore.carInfo.stepType
  342. }
  343. const res = await questionWrongColle(obj)
  344. questionBank.value.isCollect = isAdd
  345. console.log(questionBank.value.isCollect)
  346. }
  347. </script>
  348. <style lang="scss" scoped>
  349. image {display: block;width: 100%;height: 100%;}
  350. .bottomBar {
  351. position: fixed;
  352. bottom: 0;
  353. left: 0;
  354. width: 100%;
  355. height: 98rpx;
  356. background: #FFFFFF;
  357. border-top: 1rpx solid #F4F4F4;
  358. }
  359. .ul {
  360. display: flex;
  361. justify-content: space-between;
  362. height: 100%;
  363. align-items: center;
  364. .li {
  365. width: 16.6%;
  366. display: flex;
  367. flex-direction: column;
  368. align-items: center;
  369. justify-content: center;
  370. .icon {
  371. font-size: 30rpx;
  372. height: 30rpx;
  373. line-height: 30rpx;
  374. image {
  375. display: block;
  376. margin-top: 4rpx;
  377. width: 26rpx;
  378. height: 26rpx;
  379. }
  380. }
  381. .text {
  382. font-weight: 500;
  383. font-size: 24rpx;
  384. color: #999999;
  385. margin-top: 10rpx;
  386. }
  387. }
  388. }
  389. .content {
  390. padding: 120rpx 0;
  391. min-height: 100vh;
  392. .u-nav-slot {
  393. width: 306rpx;
  394. height: 54rpx;
  395. border-radius: 10rpx;
  396. border: 1px solid #333333;
  397. display: flex;
  398. .btn {
  399. font-size: 24rpx;
  400. color: #333333;
  401. flex: 1;
  402. text-align: center;
  403. line-height: 54rpx;
  404. &.active {
  405. background-color: #333333;
  406. color: #fff;
  407. }
  408. }
  409. }
  410. .btn_row {
  411. padding: 60rpx 0 30rpx 0;
  412. .btn {
  413. width: 44%;
  414. height: 76rpx;
  415. border-radius: 38rpx;
  416. border: 1rpx solid $themC;
  417. line-height: 76rpx;
  418. text-align: center;
  419. font-size: 28rpx;
  420. color: $themC;
  421. &.disable {
  422. opacity: 0.4;
  423. }
  424. &.bg {
  425. background: #3776FF;
  426. border-radius: 38rpx;
  427. color: #fff;
  428. }
  429. }
  430. }
  431. .con {
  432. .h1_row {
  433. margin-bottom: 50rpx;
  434. .tag {
  435. display: inline-block;
  436. // width: 66px;
  437. height: 36rpx;
  438. line-height: 36rpx;
  439. padding: 4rpx 6rpx;
  440. background: #63C168;
  441. border-radius: 6rpx;
  442. margin-top: -2rpx;
  443. margin-right: 16rpx;
  444. font-size: 28rpx;
  445. color: #fff;
  446. &.blue {
  447. background: #3776FF;
  448. }
  449. &.red {
  450. background: orangered;
  451. }
  452. }
  453. text.h1 {
  454. font-size: 36rpx;
  455. }
  456. }
  457. .option {
  458. width: 100%;
  459. .optionItem {
  460. margin-bottom: 50rpx;
  461. align-items: center;
  462. .icon {
  463. width: 36rpx;
  464. height:36rpx;
  465. border-radius: 50%;
  466. border: 1rpx solid #999;
  467. }
  468. .text {
  469. font-size: 32rpx;
  470. margin-left: 16rpx;
  471. }
  472. }
  473. }
  474. .answerCss {
  475. height: 90rpx;
  476. background: #F4F4F4;
  477. padding: 30rpx;
  478. margin-top: 20rpx;
  479. justify-content: space-around;
  480. .ans {
  481. font-size: 30rpx;
  482. text {
  483. &.red {
  484. color: red;
  485. }
  486. }
  487. }
  488. }
  489. .analysis {
  490. margin-top: 60rpx;
  491. .tit {
  492. font-weight: 700;
  493. font-size: 32rpx;
  494. position: relative;
  495. padding-left: 30rpx;
  496. &::after {
  497. content: '';
  498. position: absolute;
  499. left: 0;
  500. top: 8rpx;
  501. width: 6rpx;
  502. height: 30rpx;
  503. background: linear-gradient(0deg, #43EA80 0%, #38F8D4 100%);
  504. border-radius: 3rpx;
  505. }
  506. }
  507. .txt {
  508. margin-top: 39rpx;
  509. font-size: 32rpx;
  510. color: #333333;
  511. }
  512. }
  513. }
  514. }
  515. .popupCon {
  516. width: 100%;
  517. height: calc(100vh - 200rpx);
  518. .h3 {
  519. height: 88rpx;
  520. border-bottom: 1px solid #F4F4F4;
  521. line-height: 88rpx;
  522. font-size: 30rpx;
  523. padding: 0rpx 0 0 30rpx;
  524. }
  525. .ulRow {
  526. height: 100rpx;
  527. padding: 30rpx 0;
  528. }
  529. .ul2 {
  530. display: flex;
  531. flex-wrap: wrap;
  532. padding: 30rpx 10rpx;
  533. height: calc(100vh - 388rpx);
  534. overflow-y: auto;
  535. .li2 {
  536. width: 16.6%;
  537. margin-bottom: 20rpx;
  538. .num {
  539. width: 100rpx;
  540. height: 100rpx;
  541. border-radius: 50%;
  542. margin: auto;
  543. background: #F6F7FA;
  544. font-size: 32rpx;
  545. line-height: 100rpx;
  546. text-align: center;
  547. &.active {
  548. border: 1px solid #63C168;
  549. background: rgba(99,193,104,0.1);
  550. color: #63C168;
  551. }
  552. }
  553. }
  554. }
  555. }
  556. </style>