detail.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <view :class="{'yejian': if_theme_dark}">
  3. <!--#ifdef APP-PLUS-->
  4. <view class="lz-status_bar">
  5. <view class="lz-top_view"></view>
  6. </view>
  7. <!--#endif-->
  8. <view class="kaoshi-head">
  9. <view class="kaoshi-head-top">
  10. <view class="kaoshi-head-left" @tap="$navigateBack">
  11. <view class="iconfont icon-zuojiantou"></view>
  12. </view>
  13. <view class="kaoshi-head-m">
  14. 错题详情
  15. </view>
  16. <view class="kaoshi-head-right">
  17. <view class="iconfont iconfont icon-shezhi1" @tap="show_change_moshi=true"></view>
  18. </view>
  19. </view>
  20. </view>
  21. <view scroll-y style="height: 100%;">
  22. <view style="height: 10px;"></view>
  23. <view class="questionBankAnswer" v-if="current_timu && current_timu.id">
  24. <question-type :current_timu="current_timu" :timu_order="timu_order" :total_num="total_num">
  25. </question-type>
  26. </view>
  27. <view class="questionBankAnswer-content" v-if="current_timu && current_timu.answers">
  28. <question-title :node="current_timu.question_name"></question-title>
  29. <block v-for="(item, index) in current_timu.answers" :key="index">
  30. <question-option :ref="'questionOption_' + index" :type="type" :item="item" :index="index"
  31. :current_timu="current_timu" :timu_index="timu_order - 1" @post_answer_req="post_answer_req"
  32. @set_sub_button_style="set_sub_button_style"></question-option>
  33. </block>
  34. <template v-if="current_timu.type == 4">
  35. <view style="height: 12px;"></view>
  36. </template>
  37. <template v-else-if="current_timu.type == 5">
  38. <view style="height: 12px;"></view>
  39. </template>
  40. <question-pre-next v-if="timu_list.length > 0" :total_num="total_num" :timu_order="timu_order"
  41. :timu_list="timu_list" @choice_timu_by_id="choice_timu_by_id" @tap_handler="tap_handler"
  42. class="questionBankAnswer-contentbtnbox"></question-pre-next>
  43. </view>
  44. <question-answer ref="questionAnswer" v-if="current_timu" :timu_order="timu_order"
  45. :current_timu="current_timu" :timu_list="timu_list"></question-answer>
  46. <view style="height: 50px;"></view>
  47. </view>
  48. <view class="order-pay">
  49. <question-remove class="questionBankAnswer-bottom-flex" @removeError="removeError"></question-remove>
  50. <question-fav class="questionBankAnswer-bottom-flex" :current_timu="current_timu" @collect_opt="collect_opt"
  51. :type="type"></question-fav>
  52. <question-note class="questionBankAnswer-bottom-flex" :current_timu="current_timu"></question-note>
  53. <question-jiucuo class="questionBankAnswer-bottom-flex" :current_timu="current_timu"></question-jiucuo>
  54. <question-answer-sheet class="questionBankAnswer-bottom-flex"
  55. @show_choice_timu_list="show_choice_timu_list = true"></question-answer-sheet>
  56. </view>
  57. <question-answer-sheet-1 :show_remove="false" @removeError="removeError" :current_timu="current_timu"
  58. :type="type" @collect_opt="collect_opt" v-if="show_choice_timu_list"
  59. @show_choice_timu_list="show_choice_timu_list = false" :timu_order="timu_order" :timu_list="timu_list"
  60. :total_num="total_num" @choice_timu_by_id="choice_timu_by_id"></question-answer-sheet-1>
  61. <question-set :show_change_moshi="show_change_moshi" :if_theme_dark="if_theme_dark"
  62. @set_if_theme_dark="set_if_theme_dark" @hide_change_moshi="show_change_moshi = false"></question-set>
  63. </view>
  64. </template>
  65. <script>
  66. import {
  67. mapState
  68. } from 'vuex';
  69. export default {
  70. data() {
  71. return {
  72. type: 0, //1 章节练习错题 2 历年真题错题
  73. total_num: 0,
  74. // 当前题目
  75. current_timu: {},
  76. // 页面参数
  77. pages_params: {},
  78. // 显示答题卡
  79. show_choice_timu_list: false,
  80. // 答题卡
  81. timu_list: [],
  82. // 字号大小
  83. show_change_moshi: false,
  84. if_theme_dark: false, // 黑夜模式
  85. // 错题每次都从第一题开始
  86. timu_order: 1,
  87. };
  88. },
  89. computed: {
  90. ...mapState(['subject', 'userinfo']),
  91. static_media() {
  92. return {
  93. img01: this.$myConfig.localMedia + '/static/img/dui.png',
  94. }
  95. },
  96. },
  97. onLoad(opts) {
  98. this.pages_params = opts;
  99. this.type = this.pages_params.from_type
  100. this.get_timu_list();
  101. },
  102. onReady() {},
  103. methods: {
  104. // 移除错题
  105. async removeError() {
  106. let url = ''
  107. // 1:章节练习 2:历年真题
  108. if (this.type == 1) {
  109. // 1:章节练习
  110. url = this.$myHttp.urlMap.unit_remove_error
  111. } else if (this.type == 2) {
  112. // 2:历年真题
  113. url = this.$myHttp.urlMap.library_remove_error
  114. }
  115. let res = await this.$myHttp.post({
  116. url: url,
  117. data: {
  118. id: this.current_timu.id
  119. },
  120. needLogin: true
  121. });
  122. if (res.code == 1) {
  123. uni.showToast({
  124. icon: 'none',
  125. title: '操作成功'
  126. });
  127. }
  128. },
  129. // 获取答题卡
  130. async get_timu_list() {
  131. let url = '';
  132. let data = {};
  133. if (this.type == '1') {
  134. data['unit_id'] = this.pages_params.id;
  135. url = this.$myHttp.urlMap.unit_errorCard;
  136. } else if (this.type == '2') {
  137. data['library_id'] = this.pages_params.id;
  138. url = this.$myHttp.urlMap.library_errorCard;
  139. }
  140. let res = await this.$myHttp.post({
  141. url: url,
  142. data: data,
  143. needLogin: true
  144. });
  145. //2020年2月1日修改——本次答题对错记录
  146. if (res.code == 1) {
  147. this.timu_list = res.data;
  148. this.total_num = this.timu_list.length;
  149. for (let i = 0, leng = this.timu_list.length; i < leng; i++) {
  150. //将所有题目状态设置为未答
  151. this.$set(this.timu_list[i], 'state', 3)
  152. }
  153. //获取第一题详情
  154. this.get_timu_info();
  155. }
  156. },
  157. // 根据答题卡获取题目
  158. choice_timu_by_id(index) {
  159. this.timu_order = index + 1
  160. uni.pageScrollTo({
  161. scrollTop: 0,
  162. duration: 200
  163. });
  164. this.get_timu_info()
  165. },
  166. // 获取当前题目
  167. async get_timu_info() {
  168. let id = this.timu_list[this.timu_order - 1].id;
  169. let res = await this.$myHttp.post({
  170. url: this.$myHttp.urlMap.timu_details,
  171. data: {
  172. id: id
  173. },
  174. needLogin: true
  175. });
  176. if (res.code == 1) {
  177. if (res.data != []) {
  178. let timu = this.set_right_flg(res.data);
  179. this.current_timu = timu;
  180. this.setAnswerStyle(this.current_timu)
  181. } else {
  182. this.current_timu = null;
  183. }
  184. } else {
  185. uni.showToast({
  186. title: res.msg,
  187. icon: 'none'
  188. })
  189. }
  190. },
  191. //单选多选判断,选项正确错误
  192. setAnswerStyle(timu) {
  193. this.$nextTick(() => {
  194. timu.answers.forEach((item, index) => {
  195. this.$refs['questionOption_' + index][0].setAnswerStyle(this.copy_user_answer);
  196. })
  197. })
  198. },
  199. // 设置正确答案的标记
  200. set_right_flg(timu) {
  201. if (timu) {
  202. if (timu.answers) {
  203. for (let i = 0, leng = timu.answers.length; i < leng; i++) {
  204. if (timu.right_answer.toString().toLowerCase().replace(/\s/g, '').indexOf(timu.answers[i]
  205. .answer_code.toString().toLowerCase().replace(/\s/g, '')) !== -1) {
  206. timu.answers[i]['right_flg'] = true
  207. }
  208. }
  209. }
  210. }
  211. return timu
  212. },
  213. // 收藏
  214. collect_opt(type) {
  215. this.$set(this.current_timu, 'is_fav', type)
  216. },
  217. // 设置是否黑夜模式
  218. set_if_theme_dark(data) {
  219. this.if_theme_dark = data
  220. },
  221. tap_handler(type) {
  222. uni.navigateBack();
  223. }
  224. }
  225. };
  226. </script>
  227. <style>
  228. @import "~@/static/css/tiku.css";
  229. </style>