review.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. <template>
  2. <view class="wrap">
  3. <u-navbar title="答题详情" :placeholder="true" bgColor="rgba(255,255,255,0.3)" leftText="返回" :autoBack="true" titleStyle="font-weight:bold;color:#7a5831"></u-navbar>
  4. <view class="main" v-if="hasLoad">
  5. <view class="process">
  6. <view class="b-state">
  7. <view class="b-count">
  8. <view class="s-tit1">答题进度</view>
  9. <view class="s-num">{{ state.session_seq }}</view>
  10. <view class="s-tit2">/{{ state.total_count }}</view>
  11. </view>
  12. <view class="b-time">
  13. <view class="s-tit">花费时间</view>
  14. <view class="s-time">{{ costTime(state.cost_time) }}</view>
  15. </view>
  16. </view>
  17. <view class="b-bar">
  18. <view class="s-percent" :style="barPercent"></view>
  19. </view>
  20. </view>
  21. <view class="answer">
  22. <view class="b-type">{{ state.type_text }}</view>
  23. <view class="b-title">
  24. <view class="s-num">{{ state.session_seq }}.</view>
  25. <text class="s-title">
  26. {{ state.title }}
  27. <text class="s-score">({{ state.score }}分)</text>
  28. </text>
  29. </view>
  30. <view class="b-options">
  31. <view class="b-item" v-for="(item, index) in state.optionList" :key="index" :class="[optionState(index)]">
  32. <view class="s-num">{{ optionNum(index) }}.</view>
  33. <view class="s-cont">{{ item.label }}</view>
  34. <view class="s-state iconfont" :class="[optionIcon(index)]"></view>
  35. </view>
  36. </view>
  37. <view class="b-result" :class="resultIcon">
  38. <view class="b-right">
  39. <view class="s-tit">正确答案:</view>
  40. <view class="s-cont">{{ trueAnswer }}</view>
  41. </view>
  42. <view class="b-mine">
  43. <view class="s-tit">已选答案:</view>
  44. <view class="s-cont">{{ userAnswer }}</view>
  45. </view>
  46. </view>
  47. <view class="b-explain" v-if="state.explain">
  48. <text>解析:{{ state.explain }}</text>
  49. </view>
  50. <view class="b-action">
  51. <view class="b-last" :class="{ disabled: disabled.hasLast }" @click="onLast">上一题</view>
  52. <view class="b-next" :class="{ disabled: disabled.hasNext }" @click="onNext">下一题</view>
  53. </view>
  54. <view class="b-home" @click="onHome">回到首页</view>
  55. </view>
  56. </view>
  57. <!-- 加载中 -->
  58. <load-more :loadingType="loadingType" :loadingText="loadingText" color="#ffffff" :top="500"></load-more>
  59. </view>
  60. </template>
  61. <script>
  62. import { getResult } from '@/service/api/examine.js';
  63. import mixinsCommon from '@/mixins/common.js';
  64. import mixinsAuth from '../../mixins/auth.js';
  65. export default {
  66. mixins: [mixinsCommon, mixinsAuth],
  67. data() {
  68. return {
  69. hasLoad: false,
  70. state: {},
  71. disabled: {
  72. hasLast: false,
  73. hasNext: false
  74. },
  75. loadingType: 1,
  76. loadingText: ''
  77. };
  78. },
  79. onLoad(options) {
  80. this.loadResult(options.record_id);
  81. },
  82. computed: {
  83. barPercent() {
  84. return 'width: ' + (this.state.session_seq * 100) / this.state.total_count + '%';
  85. },
  86. optionNum() {
  87. return (index) => {
  88. return String.fromCharCode(64 + (index + 1));
  89. };
  90. },
  91. optionState() {
  92. return (index) => {
  93. console.log('optionState', index);
  94. let optionRight = false;
  95. let optionWrong = false;
  96. if (this.state.state == 2) {
  97. if (this.state.type === 'radio' || this.state.type === 'yesorno') {
  98. if (this.state.trueAnswer.includes(index)) {
  99. optionRight = true;
  100. } else if (this.state.userAnswer.includes(index)) {
  101. optionWrong = true;
  102. }
  103. } else {
  104. if (this.state.trueAnswer.includes(index)) {
  105. optionRight = true;
  106. } else if (
  107. (this.state.userAnswer.includes(index) && !this.state.trueAnswer.includes(index)) ||
  108. (this.state.trueAnswer.includes(index) && !this.state.userAnswer.includes(index))
  109. ) {
  110. optionWrong = true;
  111. }
  112. }
  113. }
  114. let ret = '';
  115. ret += optionRight ? 'f-right' : '';
  116. ret += optionWrong ? 'f-wrong' : '';
  117. return ret;
  118. // return {
  119. // 'f-right': optionRight,
  120. // 'f-wrong': optionWrong
  121. // }
  122. };
  123. },
  124. optionIcon() {
  125. return (index) => {
  126. console.log('optionIcon', index);
  127. return this.state.userAnswer.includes(index) ? 'icon-roundcheck' : '';
  128. // return {
  129. // 'icon-roundcheck': this.state.userAnswer.includes(index),
  130. // // 'icon-roundcheckfill': this.state.trueAnswer.includes(index),
  131. // }
  132. };
  133. },
  134. resultIcon() {
  135. let ret = '';
  136. ret += this.state.result == 2 ? ' f-right' : '';
  137. ret += this.state.result == 3 ? ' f-wrong' : '';
  138. ret += this.state.result == 4 ? ' f-timeout' : '';
  139. ret += this.state.result == 5 ? ' f-timeout-end' : '';
  140. return ret;
  141. // return {
  142. // 'f-right': this.state.result == 2,
  143. // 'f-wrong': this.state.result == 3,
  144. // 'f-timeout': this.state.result == 4,
  145. // 'f-timeout-end': this.state.result == 5,
  146. // }
  147. },
  148. trueAnswer() {
  149. let options = this.state.trueAnswer.map((item) => {
  150. return String.fromCharCode(64 + (parseInt(item) + 1));
  151. });
  152. return options.join('、');
  153. },
  154. userAnswer() {
  155. let options = this.state.userAnswer.map((item) => {
  156. return String.fromCharCode(64 + (parseInt(item) + 1));
  157. });
  158. return options.join('、');
  159. }
  160. },
  161. methods: {
  162. loadResult(recordId) {
  163. if (!recordId) {
  164. this.$logic.showToast('没有更多记录');
  165. return;
  166. }
  167. getResult(recordId).then(([err, res]) => {
  168. console.log('getResult', err, res);
  169. if (!err) {
  170. this.hasLoad = true;
  171. this.loadingType = -1;
  172. this.state = res;
  173. if (!res.last_id) {
  174. this.disabled.hasLast = true;
  175. } else {
  176. this.disabled.hasLast = false;
  177. }
  178. if (!res.next_id) {
  179. this.disabled.hasNext = true;
  180. } else {
  181. this.disabled.hasNext = false;
  182. }
  183. } else {
  184. if (!this.hasLoad) {
  185. this.loadingType = 3;
  186. this.loadingText = err.data.msg || '加载失败';
  187. }
  188. }
  189. });
  190. },
  191. onLast() {
  192. this.loadResult(this.state.last_id);
  193. },
  194. onNext() {
  195. this.loadResult(this.state.next_id);
  196. },
  197. onHome() {
  198. uni.reLaunch({
  199. url: '/answer_pages/home/index'
  200. });
  201. }
  202. }
  203. };
  204. </script>
  205. <style lang="scss">
  206. // page {
  207. // padding-bottom: env(safe-area-inset-bottom);
  208. // background: #da5650;
  209. // }
  210. .wrap {
  211. background: #da5650;
  212. }
  213. .main {
  214. padding: 40upx;
  215. }
  216. .process {
  217. display: flex;
  218. flex-direction: column;
  219. .b-state {
  220. display: flex;
  221. align-items: center;
  222. justify-content: space-between;
  223. color: #fff;
  224. .b-count {
  225. display: flex;
  226. align-items: center;
  227. .s-tit1,
  228. .s-tit2 {
  229. font-size: 24upx;
  230. }
  231. .s-num {
  232. margin: 0 10upx;
  233. font-size: 32upx;
  234. }
  235. }
  236. .b-time {
  237. display: flex;
  238. align-items: center;
  239. .s-tit {
  240. font-size: 24upx;
  241. }
  242. .s-time {
  243. margin-left: 10upx;
  244. font-size: 28upx;
  245. }
  246. }
  247. }
  248. .b-bar {
  249. margin-top: 10upx;
  250. background: rgba(255, 255, 255, 0.5);
  251. width: 100%;
  252. height: 24upx;
  253. position: relative;
  254. .s-percent {
  255. position: absolute;
  256. left: 0;
  257. bottom: 0;
  258. width: 30%;
  259. height: 24upx;
  260. display: inline-block;
  261. background: #fff;
  262. }
  263. }
  264. }
  265. .answer {
  266. margin-top: 50upx;
  267. padding: 40upx;
  268. background: #fff;
  269. border-radius: 20upx;
  270. overflow: hidden;
  271. display: flex;
  272. flex-direction: column;
  273. .b-type {
  274. width: fit-content;
  275. background: #da5650;
  276. padding: 0 20upx;
  277. font-size: 28upx;
  278. color: #fff;
  279. height: 50upx;
  280. line-height: 50upx;
  281. }
  282. .b-title {
  283. margin-top: 20upx;
  284. font-size: 30upx;
  285. display: flex;
  286. .s-num {
  287. font-weight: bold;
  288. }
  289. .s-title {
  290. margin-left: 10upx;
  291. flex: 1;
  292. color: #333;
  293. }
  294. .s-score {
  295. margin-left: 20upx;
  296. color: #666;
  297. }
  298. }
  299. .b-options {
  300. margin-top: 40upx;
  301. .b-item {
  302. margin-bottom: 20upx;
  303. padding: 20upx;
  304. font-size: 28upx;
  305. display: flex;
  306. // align-items: center;
  307. background: #f7f7f7;
  308. &:last-child {
  309. margin-bottom: 0;
  310. }
  311. &.f-select {
  312. background: #ecf3fe;
  313. color: #338ada;
  314. }
  315. &.f-right {
  316. background: #ecf6f0;
  317. color: #1eab69;
  318. }
  319. &.f-wrong {
  320. background: #ffebeb;
  321. color: #d13b42;
  322. }
  323. .s-num {
  324. font-weight: bold;
  325. }
  326. .s-cont {
  327. margin-left: 10upx;
  328. flex: 1;
  329. }
  330. .s-state {
  331. margin-left: 10upx;
  332. font-size: 36upx;
  333. }
  334. }
  335. }
  336. .b-result {
  337. padding: 80upx 0;
  338. display: flex;
  339. align-items: center;
  340. justify-content: space-between;
  341. background-repeat: no-repeat;
  342. background-size: 180upx auto;
  343. background-position: center center;
  344. &.f-right {
  345. background-image: url(https://huli-app.wenlvti.net/app_static/wuyuan/static/wenwu/answer/imgs/result_right.png);
  346. }
  347. &.f-wrong {
  348. background-image: url(https://huli-app.wenlvti.net/app_static/wuyuan/static/wenwu/answer/imgs/result_wrong.png);
  349. }
  350. &.f-timeout {
  351. background-image: url(https://huli-app.wenlvti.net/app_static/wuyuan/static/wenwu/answer/imgs/result_timeout.png);
  352. }
  353. &.f-timeout-end {
  354. background-image: url(https://huli-app.wenlvti.net/app_static/wuyuan/static/wenwu/answer/imgs/result_timeout_end.png);
  355. }
  356. .b-right,
  357. .b-mine {
  358. display: flex;
  359. align-items: center;
  360. .s-tit {
  361. font-size: 26upx;
  362. color: #333;
  363. }
  364. .s-cont {
  365. margin-left: 10upx;
  366. font-weight: bold;
  367. color: #da5650;
  368. font-size: 36upx;
  369. }
  370. }
  371. }
  372. .b-explain {
  373. font-size: 28upx;
  374. color: #808080;
  375. }
  376. .b-action {
  377. margin-top: 50upx;
  378. display: flex;
  379. .b-last {
  380. flex: 1;
  381. height: 78upx;
  382. line-height: 78upx;
  383. text-align: center;
  384. color: #da5650;
  385. font-size: 32upx;
  386. border: 1upx solid #da5650;
  387. border-radius: 50upx;
  388. letter-spacing: 5upx;
  389. &.disabled {
  390. color: #da5650a3;
  391. border: 1upx solid #da5650a3;
  392. }
  393. }
  394. .b-next {
  395. margin-left: 50upx;
  396. flex: 1;
  397. height: 80upx;
  398. line-height: 80upx;
  399. text-align: center;
  400. color: #fff;
  401. font-size: 32upx;
  402. background: #da5650;
  403. border-radius: 50upx;
  404. letter-spacing: 5upx;
  405. &.disabled {
  406. background: #da5650a3;
  407. }
  408. }
  409. }
  410. .b-home {
  411. margin-top: 40upx;
  412. text-align: center;
  413. color: #808080;
  414. font-size: 28upx;
  415. }
  416. }
  417. </style>