questionDetail.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <!-- 章节练习答题页-->
  3. <view :class="{'yejian': if_theme_dark}">
  4. <!--#ifdef APP-PLUS-->
  5. <view class="lz-status_bar">
  6. <view class="lz-top_view"></view>
  7. </view>
  8. <!--#endif-->
  9. <!-- #ifndef MP-WEIXIN -->
  10. <view class="kaoshi-head">
  11. <view class="kaoshi-head-top">
  12. <view class="kaoshi-head-left">
  13. <view class="iconfont icon-zuojiantou" @tap="$navigateBack"></view>
  14. </view>
  15. <view class="kaoshi-head-m">题目搜索</view>
  16. <view class="kaoshi-head-right"></view>
  17. </view>
  18. </view>
  19. <!--#endif-->
  20. <view style="height: 10px;"></view>
  21. <view class="questionBankAnswer" v-if="current_timu && current_timu.id">
  22. <view class="questionBankAnswer-tx">
  23. {{ current_timu.type == 1 ? "单选题" : current_timu.type == 2 ? "多选题" : current_timu.type == 3 ?'判断题' : current_timu.type == 4 ?'填空题' : current_timu.type == 5 ?'简答题' : '' }}
  24. </view>
  25. </view>
  26. <view class="questionBankAnswer-content" v-if="current_timu && current_timu.answers">
  27. <question-title :node="current_timu.question_name"></question-title>
  28. <block v-for="(item, index) in current_timu.answers" :key="index">
  29. <question-option :ref="'questionOption_' + index" :type="type" :item="item" :index="index"
  30. :current_timu="current_timu" :timu_index="timu_order - 1" @post_answer_req="post_answer_req"
  31. @set_sub_button_style="set_sub_button_style"></question-option>
  32. </block>
  33. <template v-if="current_timu.type == 4">
  34. <view style="height: 12px;"></view>
  35. </template>
  36. <template v-else-if="current_timu.type == 5">
  37. <view style="height: 12px;"></view>
  38. </template>
  39. </view>
  40. <question-answer ref="questionAnswer" v-if="current_timu" :timu_order="timu_order" :current_timu="current_timu">
  41. </question-answer>
  42. <view style="height: 50px;"></view>
  43. </view>
  44. </template>
  45. <script>
  46. import {
  47. mapState
  48. } from 'vuex';
  49. export default {
  50. data() {
  51. return {
  52. type: '', //from_type 1:章节练习 2:历年真题
  53. // 当前题目
  54. current_timu: {},
  55. show_change_moshi: false,
  56. if_theme_dark: false, // 黑夜模式
  57. // 上次答到第几题
  58. timu_order: 1,
  59. };
  60. },
  61. computed: {
  62. ...mapState(['subject', 'userinfo']),
  63. static_media() {
  64. return {
  65. img01: this.$myConfig.localMedia + '/static/img/dui.png',
  66. }
  67. },
  68. },
  69. onLoad(opts) {
  70. this.id = opts.id
  71. this.type = opts.from_type
  72. this.get_timu_info();
  73. },
  74. methods: {
  75. // 获取当前题目
  76. async get_timu_info() {
  77. let res = await this.$myHttp.post({
  78. url: this.$myHttp.urlMap.timu_details,
  79. data: {
  80. id: this.id
  81. },
  82. needLogin: true
  83. });
  84. if (res.code == 1) {
  85. if (res.data != []) {
  86. let timu = this.set_right_flg(res.data);
  87. this.current_timu = timu;
  88. this.setAnswerStyle(this.current_timu)
  89. } else {
  90. this.current_timu = null;
  91. }
  92. }
  93. },
  94. //单选多选判断,选项正确错误
  95. setAnswerStyle(timu) {
  96. this.$nextTick(() => {
  97. timu.answers.forEach((item, index) => {
  98. this.$refs['questionOption_' + index][0].setAnswerStyle({});
  99. })
  100. })
  101. },
  102. // 设置正确答案的标记
  103. set_right_flg(timu) {
  104. if (timu) {
  105. timu.post_status = 0;
  106. if (timu.answers) {
  107. for (let i = 0, leng = timu.answers.length; i < leng; i++) {
  108. if (timu.right_answer.toString().toLowerCase().replace(/\s/g, '').indexOf(timu.answers[i]
  109. .answer_code.toString().toLowerCase().replace(/\s/g, '')) !== -1) {
  110. timu.answers[i]['right_flg'] = true
  111. }
  112. }
  113. }
  114. }
  115. return timu
  116. },
  117. }
  118. };
  119. </script>
  120. <style>
  121. /*====sl修改样式开始====*/
  122. @import "~@/static/css/tiku.css";
  123. </style>