index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <view class="ezy-exam-page" :style="{backgroundImage: 'url(' + courseBjFun() + ')'}">
  3. <view class="ezy-navBar-box">
  4. <view @click="handleBack" class="nav-bar-icon"></view>
  5. <text class="nav-bar-title">单元测试</text>
  6. <view class="nav-bar-other"><text class="key-note">{{current+1}}</text>/<text>{{total}}</text></view>
  7. </view>
  8. <view class="shiti-frame-box">
  9. <w-swiper :list="list" :current="current" class="ezy-exam-swiper" @change="onSwiperChange">
  10. <template v-slot:default="{item}">
  11. <view class="body" v-if="item.mta_show">
  12. <danxuan :question="item" v-if="item.type == '1'"></danxuan>
  13. <panduan :question="item" v-if="item.type == '2'"></panduan>
  14. <tiankong :question="item" v-if="item.type == '3'" :placeholders="item.placeholders"></tiankong>
  15. <yingyuDanxuan :question="ceshiData" v-if="item.type == '4'" :placeholders="item.placeholders">
  16. </yingyuDanxuan>
  17. </view>
  18. </template>
  19. </w-swiper>
  20. <view class="exam-submit-btn" v-if="current === list.length-1" @click="handleSubmit(uniPointsRef)"></view>
  21. </view>
  22. <!-- 左右滑动 -->
  23. <view class="tip-mask-box" @click="handleCloseTishi" v-if="showTishi">
  24. <view class="exam-tip-box">左右滑动查看更多题目</view>
  25. </view>
  26. <!-- 答卷 -->
  27. <chengji ref="chengjiRef" :list="list" @back="handleBack" :cardId="cardId"></chengji>
  28. <!-- 分数弹窗 -->
  29. <uniPointsVue ref="uniPointsRef" @checkAnswer="checkAnswer" @goStudy="goStudyContinue" :isLastZhang="!!haveFlag"
  30. :studyFlag="studyFlag"></uniPointsVue>
  31. <!-- 填空 -->
  32. <FillItem :value="result" ref="popupRef" @blur="onBlur"></FillItem>
  33. <!-- 音频播放组件 -->
  34. <mtaRadio></mtaRadio>
  35. </view>
  36. </template>
  37. <script setup>
  38. import mtaRadio from '@/components/question/yingyu/mtaRadio.vue'
  39. import FillItem from "@/components/question/FillItem.vue";
  40. import wSwiper from '@/components/wSwiper/wSwiper.vue';
  41. import danxuan from "@/components/question/danxuan.vue";
  42. import panduan from "@/components/question/panduan.vue";
  43. import tiankong from "@/components/question/tiankong.vue";
  44. import yingyuDanxuan from "@/components/question/yingyu/danxuanCeshi.vue";
  45. //import yingyuDanxuan from "@/components/question/yingyu/danxuan.vue";
  46. import chengji from "@/components/chengji/chengji.vue";
  47. import uniPointsVue from '@/components/points/uni-points.vue';
  48. import * as httpUnit from "@/api/unitTest.js"
  49. import {
  50. catchError,
  51. } from "@/utils/common.js"
  52. import {
  53. useExam
  54. } from './useUnit';
  55. import {
  56. ref,
  57. reactive
  58. } from "vue";
  59. import cacheManager from "@/utils/cacheManager";
  60. import {
  61. onLoad
  62. } from "@dcloudio/uni-app"
  63. const {
  64. count,
  65. total,
  66. current,
  67. list,
  68. rightAnswer,
  69. wrongAnswer,
  70. jifen,
  71. zhangId,
  72. jieId,
  73. nianji,
  74. studyFlag,
  75. xueke,
  76. showTishi,
  77. haveFlag,
  78. activeZhang,
  79. handleSubmit,
  80. initPage,
  81. handleCloseTishi
  82. } = useExam();
  83. const cardId = Number(cacheManager.get('auth').cardId);
  84. const uniPointsRef = ref(null);
  85. const chengjiRef = ref(null);
  86. const popupRef = ref(null);
  87. const result = ref('');
  88. const curTiankong = ref(null);
  89. const ceshiData = reactive({
  90. "stId": 378,
  91. "type": 4,
  92. "name": "<p>发音:/b/ 1231[yingyu1]</p>",
  93. "result": "0",
  94. "answer": "<p>单词book发音为/bʊk/ [yingyu5]; 单词pool的发音是/puːl/ [yingyu4]。</p>",
  95. "audios": "https://ezy-app.oss-cn-beijing.aliyuncs.com/test/resource/uploadFile1a3bd1236181491b8de49e84857a9163.MP3,https://ezy-app.oss-cn-beijing.aliyuncs.com/test/resource/uploadFile16b16267eafb43b6a272b8b212049ae4.MP3,https://ezy-app.oss-cn-beijing.aliyuncs.com/test/resource/uploadFileb23646275ada46769e76a3ae0dba230e.MP3,https://ezy-app.oss-cn-beijing.aliyuncs.com/test/resource/uploadFileeff5e2bb7a6f4a0d9bc78b503ebea846.MP3,https://ezy-app.oss-cn-beijing.aliyuncs.com/test/resource/uploadFile6cbe483d691b4e5eb13401e301d62c9c.mp3",
  96. "jiangjie": null,
  97. "optList": [{
  98. "neirong": "<p>book [yingyu2]</p>",
  99. "audio":"https://ezy-app.oss-cn-beijing.aliyuncs.com/test/resource/uploadFile1a3bd1236181491b8de49e84857a9163.MP3"
  100. }, {
  101. "neirong": "<p>pool [yingyu3]</p>",
  102. "audio":"https://ezy-app.oss-cn-beijing.aliyuncs.com/test/resource/uploadFile16b16267eafb43b6a272b8b212049ae4.MP3"
  103. }]
  104. },
  105. {
  106. "stId": 379,
  107. "type": 4,
  108. "name": "<p>判断划线部分发音是否相同。</p><p><br></p><p>park [yingyu1]</p><p><br></p><p>cup [yingyu2]</p>",
  109. "result": "0",
  110. "answer": "<p>在单词park中,p发 /p/音 [yingyu3];在单词cup中,p发/p/音 [yingyu4],故发音相同。</p>",
  111. "audios": "https://ezy-app.oss-cn-beijing.aliyuncs.com/test/resource/uploadFile304fcea7440e400ca2bd0207354b2fa3.MP3,https://ezy-app.oss-cn-beijing.aliyuncs.com/test/resource/uploadFile052863fbfd074e718c63509db47f0f6c.MP3,https://ezy-app.oss-cn-beijing.aliyuncs.com/test/resource/uploadFilefee406d7614443609b450b4f260b33e5.MP3,https://ezy-app.oss-cn-beijing.aliyuncs.com/test/resource/uploadFile725a16a4dea642ccaf0129ae877b4a7c.MP3",
  112. "jiangjie": null,
  113. "optList": [{
  114. "neirong": "<p>相同</p>",
  115. "audio":"https://ezy-app.oss-cn-beijing.aliyuncs.com/test/resource/uploadFile1a3bd1236181491b8de49e84857a9163.MP3"
  116. }, {
  117. "neirong": "<p>不同</p>",
  118. "audio":"https://ezy-app.oss-cn-beijing.aliyuncs.com/test/resource/uploadFile1a3bd1236181491b8de49e84857a9163.MP3"
  119. }]
  120. }
  121. );
  122. function getPopupRef() {
  123. return popupRef.value;
  124. }
  125. onLoad(() => {
  126. uni.$on('tiankong-fillItem', (val) => {
  127. const {
  128. index,
  129. question
  130. } = val;
  131. curTiankong.value = val;
  132. result.value = question.reply[index];
  133. const dom = getPopupRef();
  134. dom && dom.showPopup();
  135. })
  136. })
  137. function onBlur({
  138. result
  139. }) {
  140. if (curTiankong.value) {
  141. uni.$emit('tiankong-setResult', {
  142. index: curTiankong.value.index,
  143. stId: curTiankong.value.question.stId,
  144. result
  145. });
  146. }
  147. const dom = getPopupRef();
  148. dom && dom.handleClear();
  149. }
  150. // 查看答案
  151. function checkAnswer() {
  152. chengjiRef.value.showPopup();
  153. }
  154. // 继续学习
  155. async function goStudyContinue() {
  156. // 设置 从单元测试 到 岛 的路由参数
  157. activeZhang.value.nextZhang ? activeZhang.value.nextZhang.zhangId : null;
  158. cacheManager.updateObject('auth', {
  159. zhangId: activeZhang.value.nextZhang.zhangId,
  160. })
  161. uni.redirectTo({
  162. url: `/pages/study/index`
  163. })
  164. }
  165. function handleBack() {
  166. // 数学
  167. uni.redirectTo({
  168. url: `/pages/study/index`
  169. })
  170. uni.$emit('back-outpage')
  171. }
  172. function onSwiperChange(index) {
  173. current.value = index;
  174. uni.$emit('swiper-change', index)
  175. }
  176. function courseBjFun() {
  177. switch (cardId) {
  178. case 1:
  179. return 'static/images/course/couse-shuxue-bj.png'
  180. break;
  181. case 2:
  182. return 'static/images/course/course-yingyu-bj.png'
  183. break;
  184. default:
  185. break;
  186. }
  187. }
  188. </script>
  189. <style lang="scss" scoped>
  190. .swiper-box {
  191. height: 200px;
  192. }
  193. .swiper-item {
  194. display: flex;
  195. flex-direction: column;
  196. justify-content: center;
  197. align-items: center;
  198. height: 200px;
  199. }
  200. </style>