wrongTitle.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. <template>
  2. <view class="content" :class="{night:nightFlag}">
  3. <view class="top-box">
  4. <view class="icon"></view>
  5. <selectSwitch class='btn' @change="changeSwitch" :defaultSwitch='kemu==1' :switchList="['科一题目','科四题目']" checked_bj_color='#E31818' />
  6. <van-icon class='set' name="/static/imgs/sz.png" size='20' @click='show=true' />
  7. </view>
  8. <van-popup :show="show" @close="show=false" position="bottom">
  9. <van-cell title="背题模式" clickable :data-index="index" @click="answerflag=!answerflag">
  10. <van-switch slot="right-icon" :checked="answerflag" size="24px" active-color="#16CC16" />
  11. <!-- <selectSwitch slot="right-icon" @change="changeSwitch" :switchList="['答题模式','背题模式']" checked_bj_color='#E31818' /> -->
  12. </van-cell>
  13. <van-cell title="答对跳转下一题 " clickable :data-index="index" @click="answerjump=!answerjump">
  14. <van-switch slot="right-icon" :checked="answerjump" size="24px" active-color="#16CC16" />
  15. </van-cell>
  16. <!-- <van-cell title="答错展示题目解析" clickable :data-index="index" @click="checked=!checked">
  17. <van-switch slot="right-icon" :checked="checked" size="24px" active-color="#16CC16" />
  18. </van-cell> -->
  19. <van-cell title="错误震动提醒" clickable :data-index="index" @click="checked=!checked">
  20. <van-switch slot="right-icon" :checked="checked" size="24px" active-color="#16CC16" />
  21. </van-cell>
  22. <van-cell title="夜间模式" clickable :data-index="index" @click="nightFlag=!nightFlag">
  23. <van-switch slot="right-icon" :checked="nightFlag" size="24px" active-color="#16CC16" />
  24. </van-cell>
  25. <!-- <van-cell title="字体选择" clickable :data-index="index" @click="checked=!checked">
  26. <van-switch slot="right-icon" :checked="checked" size="24px" active-color="#16CC16" />
  27. </van-cell> -->
  28. </van-popup>
  29. <van-skeleton class='skeleton' avatar row="6" :row-width="['100%','40%','70%','70%','70%','70%']" avatar-shape='square'
  30. :loading="loading">
  31. <swiper class="swiper-box" :current="swiperIndex" @change="swiperChange" circular>
  32. <swiper-item v-for="(itembox,indexbox) in questionList" :key='indexbox'>
  33. <view class="swiper-item">
  34. <view class="topic-box">
  35. <view class="topic-right">
  36. <view class="topic-top">
  37. <view class="topic-left">
  38. <text class="topic-type">{{questionType(itembox.type)}}</text>
  39. <van-icon name="star-o" size='20' />
  40. </view>
  41. <!-- <rich-text class="topic-tit" :nodes="itembox.id+'、'+itembox.question"></rich-text> -->
  42. <view class="topic-tit" v-html="itembox.id+'、'+itembox.question"></view>
  43. </view>
  44. <video v-if="itembox.videoUrl" class="topic-img" :muted='true' :loop='true' :autoplay='true' :controls='false'
  45. :src="encodeURI(itembox.mediaUrl)"></video>
  46. <image v-if="itembox.sinaimg" class="topic-img" :src="itembox.mediaUrl" mode="aspectFit"></image>
  47. <view class="topic-opt" v-if='itembox.type==2'>
  48. <van-radio-group :value="userAnswer[itembox.id]">
  49. <van-cell-group>
  50. <van-cell :class='{answer:(itembox.answerTrue.includes(index+1) && (answerflag || completeAnswer[itembox.id]))}'
  51. v-for="(item,index) in choiceList" :key="index" :title="itembox[item]" v-show='itembox[item]' clickable
  52. :data-index="index+1" @click="singleToggle($event,itembox)">
  53. <van-icon v-if="(itembox.answerTrue.includes(index+1) && (answerflag || completeAnswer[itembox.id]))" slot="icon"
  54. name="/static/imgs/true.png" size='20' />
  55. <van-radio slot="right-icon" :ref="`checkboxes${itembox.id}`" checked-color="#1464cc" :name="index+1" />
  56. </van-cell>
  57. </van-cell-group>
  58. </van-radio-group>
  59. <!-- <button @click="submit(itembox)" class="submit" type="default" v-show="!(answerflag || completeAnswer[itembox.id])">提交答案</button> -->
  60. </view>
  61. <view class="topic-opt" v-if='itembox.type==1'>
  62. <van-radio-group :value="userAnswer[itembox.id]">
  63. <van-cell-group>
  64. <van-cell :class='{answer:(itembox.answerTrue.includes(index+1) && (answerflag || completeAnswer[itembox.id]))}'
  65. v-for="(item,index) in 2" :key="index" :title="index?'错误':'正确'" clickable :data-index="index+1" @click="singleToggle($event,itembox)">
  66. <van-icon v-if="(itembox.answerTrue.includes(index+1) && (answerflag || completeAnswer[itembox.id]))" slot="icon"
  67. name="/static/imgs/true.png" size='20' />
  68. <van-radio slot="right-icon" :ref="`checkboxes${itembox.id}`" checked-color="#1464cc" :name="index+1" />
  69. </van-cell>
  70. </van-cell-group>
  71. </van-radio-group>
  72. <!-- <button @click="submit(itembox)" class="submit" type="default" v-show="!(answerflag || completeAnswer[itembox.id])">提交答案</button> -->
  73. </view>
  74. <view class="topic-opt" v-else-if='itembox.type==3'>
  75. <van-checkbox-group :value="userAnswer[itembox.id]" @change="onChange($event,itembox)">
  76. <van-cell-group>
  77. <van-cell :class='{answer:(itembox.answerTrue.includes(index+1) && (answerflag || completeAnswer[itembox.id]))}'
  78. v-for="(item,index) in choiceList" :key="index" :title="itembox[item]" v-show='itembox[item]' clickable
  79. @click='toggle($event,itembox)' :data-index="index">
  80. <van-icon v-if="(itembox.answerTrue.includes(index+1) && (answerflag || completeAnswer[itembox.id]))" slot="icon"
  81. name="/static/imgs/true.png" size='20' />
  82. <van-checkbox shape="square" catch:tap="noop" slot="right-icon" :ref="`checkboxes${itembox.id}`"
  83. checked-color="#1464cc" :name="index+1" />
  84. </van-cell>
  85. </van-cell-group>
  86. </van-checkbox-group>
  87. <button @click="submit(itembox)" class="submit" type="default" v-show="!(answerflag || completeAnswer[itembox.id])">提交答案</button>
  88. </view>
  89. </view>
  90. </view>
  91. <view v-show="answerflag || completeAnswer[itembox.id]">
  92. <view class="flag">
  93. <text v-if="itembox.type==2" class="result">正确答案: {{itembox[choiceList[itembox.answerTrue-1]]}}</text>
  94. <text v-else-if="itembox.type==1" class="result">正确答案: {{itembox.answerTrue==1?'正确':'错误'}}</text>
  95. <text v-else-if="itembox.type==3" class="result">正确答案: {{itembox.answerTrue.split('').map((key)=>{
  96. return itembox[choiceList[key-1]]
  97. })}}</text>
  98. </view>
  99. <view class="parsing">
  100. <view class="item-titBox">
  101. <text class="item-tit">题目解析</text>
  102. </view>
  103. <view class="parsing-text">
  104. <text class="item-tit">{{itembox.explain1 ? itembox.explain1 : "无"}}</text>
  105. </view>
  106. </view>
  107. </view>
  108. </view>
  109. </swiper-item>
  110. </swiper>
  111. </van-skeleton>
  112. </view>
  113. </template>
  114. <script>
  115. import selectSwitch from "@/components/xuan-switch/xuan-switch.vue";
  116. import {
  117. questionErrorList
  118. } from "@/api/answer.js"
  119. export default {
  120. components: {
  121. selectSwitch
  122. },
  123. data() {
  124. return {
  125. loading: true,
  126. answerflag: false,
  127. answerjump: true,
  128. nightFlag: false,
  129. kemu: uni.getStorageSync('kemu') || 1,
  130. completeAnswer: {},
  131. show: false,
  132. checked: true,
  133. radio: null,
  134. result: [],
  135. userAnswer: {},
  136. questionList: {},
  137. choiceList: ['an1', 'an2', 'an3', 'an4', 'an5', 'an6', 'an7'],
  138. swiperIndex: 0,
  139. shakeIndex: 0,
  140. pageNum: 1,
  141. shake: 0,
  142. }
  143. },
  144. watch: {
  145. kemu(val) {
  146. uni.setStorageSync('kemu', val)
  147. this.pageNum = 1
  148. this.listInit()
  149. }
  150. },
  151. mounted() {
  152. this.listInit()
  153. },
  154. methods: {
  155. async listInit() {
  156. this.loading=true
  157. await questionErrorList({
  158. pageNum: this.pageNum,
  159. pageSize: 20,
  160. kemu: this.kemu
  161. }).then((res) => {
  162. if (res.rows.length == 0) {
  163. res.rows[0] = {
  164. question: "暂无错题"
  165. }
  166. }
  167. this.questionList = res.rows
  168. this.$nextTick(() => {
  169. this.loading = false
  170. })
  171. })
  172. },
  173. questionType(index) {
  174. switch (index) {
  175. case 1:
  176. return '判断';
  177. case 2:
  178. return '单选';
  179. case 3:
  180. return '多选';
  181. }
  182. },
  183. swiperChange(e) {
  184. let aShake = e.detail.current - this.shakeIndex
  185. this.shake += aShake ** 2 != 1 ? -aShake / Math.abs(aShake) : aShake;
  186. this.swiperIndex = e.detail.current
  187. this.shakeIndex = e.detail.current
  188. if (e.detail.current % 10 == 0) {
  189. if (Math.abs(this.shake) < 10) {
  190. this.shake = 0
  191. return
  192. }
  193. this.pageNum += 1;
  194. questionList({
  195. pageNum: this.pageNum + 1,
  196. pageSize: 10,
  197. kemu: this.kemu
  198. }).then((res) => {
  199. this.shake = 0
  200. if (e.detail.current == 20) {
  201. this.questionList = res.rows.concat(this.questionList.slice(10))
  202. }
  203. if (e.detail.current == 10) {
  204. this.questionList = this.questionList.slice(0, 20).concat(res.rows)
  205. }
  206. if (e.detail.current == 0) {
  207. this.questionList = this.questionList.slice(0, 10).concat(res.rows).concat(this.questionList.slice(20))
  208. }
  209. })
  210. }
  211. },
  212. onChange(event, itembox) {
  213. if (this.completeAnswer[itembox.id] || this.answerflag) {
  214. return
  215. }
  216. this.$set(this.userAnswer, itembox.id, event.detail)
  217. },
  218. singleToggle(event, itembox) {
  219. if (this.completeAnswer[itembox.id] || this.answerflag) {
  220. return
  221. }
  222. const {
  223. index
  224. } = event.currentTarget.dataset;
  225. this.$set(this.userAnswer, itembox.id, index)
  226. setTimeout(() => {
  227. this.submit(itembox)
  228. }, 0)
  229. },
  230. toggle(event, itembox) {
  231. const {
  232. index
  233. } = event.currentTarget.dataset;
  234. const checkbox = this.$refs[`checkboxes${itembox.id}`][index];
  235. checkbox.toggle();
  236. },
  237. noop() {},
  238. submit(itembox) {
  239. this.$set(this.completeAnswer, itembox.id, true)
  240. let flag = (this.userAnswer[itembox.id] + '').split(',').sort().join('') == itembox.answerTrue.split('').sort().join(
  241. '')
  242. if (flag) {
  243. wx.vibrateShort();
  244. if (this.answerjump) {
  245. let index = this.swiperIndex
  246. this.swiperIndex = ++index % this.questionList.length
  247. }
  248. } else {
  249. wx.vibrateLong();
  250. }
  251. },
  252. changeSwitch(e) {
  253. if (e) {
  254. this.kemu = 1
  255. } else {
  256. this.kemu = 4
  257. }
  258. }
  259. }
  260. }
  261. </script>
  262. <style lang="scss" scoped>
  263. /deep/ .answer .van-cell {
  264. background-color: #16CC16 !important;
  265. color: #ffffff;
  266. }
  267. /deep/ .van-cell {
  268. // background-color: #16CC16 !important;
  269. margin: 10rpx;
  270. border-radius: 20rpx;
  271. }
  272. .content {
  273. width: 100%;
  274. height: 100vh;
  275. background-color: #FFFFFF;
  276. }
  277. .skeleton {
  278. // margin: 0rpx 20rpx;
  279. }
  280. .swiper-box {
  281. height: calc(100vh - 120rpx);
  282. margin: 0rpx 20rpx;
  283. swiper-item {
  284. overflow: auto;
  285. }
  286. }
  287. .top-box {
  288. height: 60rpx;
  289. padding: 30rpx;
  290. display: flex;
  291. justify-content: space-between;
  292. align-items: center;
  293. .icon {
  294. width: 60rpx;
  295. }
  296. .btn {}
  297. .set {
  298. color: red;
  299. }
  300. }
  301. .topic-box {
  302. // padding: 20rpx;
  303. display: flex;
  304. justify-content: center;
  305. // border: 2px solid red;
  306. .topic-top {
  307. display: flex;
  308. // border: 2px solid red;
  309. padding: 10rpx;
  310. .topic-left {
  311. display: flex;
  312. flex-direction: column;
  313. .topic-type {
  314. background: #E31818;
  315. border-radius: 10rpx;
  316. // border: 2px solid red;
  317. color: #FFFFFF;
  318. width: 66rpx;
  319. height: 30rpx;
  320. display: flex;
  321. justify-content: center;
  322. align-items: center;
  323. border-radius: 15px 15px 0px 15px;
  324. padding: 10rpx;
  325. margin-bottom: 18rpx;
  326. }
  327. }
  328. .topic-tit {
  329. padding: 10rpx;
  330. }
  331. }
  332. .topic-right {
  333. flex: 1;
  334. display: flex;
  335. flex-direction: column;
  336. padding: 0 10rpx;
  337. .topic-img {
  338. padding: 10rpx;
  339. margin: auto;
  340. width: 500rpx;
  341. height: 250rpx;
  342. // border: 2px solid red;
  343. }
  344. .topic-opt {
  345. // border: 2px solid red;
  346. padding: 30rpx 5rpx;
  347. .submit {
  348. margin: auto;
  349. margin-top: 150rpx;
  350. height: 80rpx;
  351. background: linear-gradient(90deg, #E31818, #ED3E24, #ED4F24);
  352. border-radius: 35rpx;
  353. display: flex;
  354. justify-content: center;
  355. align-items: center;
  356. color: #FFFFFF;
  357. }
  358. }
  359. }
  360. }
  361. .flag {
  362. // border: 2px solid red;
  363. padding: 30rpx 5rpx;
  364. display: flex;
  365. justify-content: center;
  366. .result {
  367. display: inline-block;
  368. background-color: #16CC16;
  369. // border: 2px solid red;
  370. width: 690rpx;
  371. // height: 70rpx;
  372. padding: 20rpx;
  373. display: flex;
  374. align-items: center;
  375. justify-content: center;
  376. border-radius: 20rpx;
  377. color: #ffffff;
  378. }
  379. }
  380. .item-titBox {
  381. display: flex;
  382. justify-content: space-between;
  383. align-items: center;
  384. padding: 20rpx;
  385. border-bottom: 1rpx solid #e8e8e8;
  386. .item-tit {
  387. border-left: 8rpx solid #E31818;
  388. font-size: 30rpx;
  389. // line-height: 38rpx;
  390. padding: 0 11rpx;
  391. }
  392. }
  393. .parsing-text {
  394. padding: 30rpx;
  395. // border: 2px solid red;
  396. }
  397. </style>