summary.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <view class="wrap">
  3. <view class="main" v-if="hasLoad">
  4. <view class="result" v-if="state.state && state.state != 1">
  5. <view class="b-summary">
  6. <view class="b-title" v-if="state.state == 2">获得成绩</view>
  7. <view class="b-title" v-else-if="state.state == 3">超时结束</view>
  8. <view class="b-score">
  9. <view class="s-num">{{state.total_score || 0}}</view>
  10. <view class="s-tit">分</view>
  11. </view>
  12. <text class="break-score" v-if="state.break_sid > 0">上次{{breakTips}},恭喜打破记录!</text>
  13. </view>
  14. <view class="b-detail">
  15. <view class="b-item" v-if="state.scenario">
  16. <view class="s-tit">答题模式</view>
  17. <view class="s-cont">{{state.scenario_text}}</view>
  18. </view>
  19. <view class="b-item">
  20. <view class="s-tit">总答题数</view>
  21. <view class="s-cont">{{state.answer_count}}道</view>
  22. </view>
  23. <view class="b-item">
  24. <view class="s-tit">答对数</view>
  25. <view class="s-cont">{{state.right_count}}道</view>
  26. </view>
  27. <view class="b-item">
  28. <view class="s-tit">答错数</view>
  29. <view class="s-cont">{{state.wrong_count}}道</view>
  30. </view>
  31. <view class="b-item" v-if="state.state == 3">
  32. <view class="s-tit">超时题数</view>
  33. <view class="s-cont f-focus">{{state.timeout_count}}道</view>
  34. </view>
  35. <view class="b-item">
  36. <view class="s-tit">答题耗时</view>
  37. <view class="s-cont f-focus">{{costTime(state.cost_time)}}</view>
  38. </view>
  39. <view class="b-item">
  40. <view class="s-tit">答题时间</view>
  41. <view class="s-cont">{{startTime}}</view>
  42. </view>
  43. </view>
  44. <view class="b-action">
  45. <view class="b-history" @click="onHistory">查看历史</view>
  46. <view class="b-home" @click="onHome">返回首页</view>
  47. </view>
  48. </view>
  49. </view>
  50. <!-- 加载中 -->
  51. <load-more :loadingType="loadingType" :loadingText="loadingText" color="#ffffff" :top="500"></load-more>
  52. </view>
  53. </template>
  54. <script>
  55. import {
  56. getSummary
  57. } from '../../service/api/examine.js'
  58. import mixinsCommon from '../../mixins/common.js'
  59. import mixinsAuth from '../../mixins/auth.js'
  60. import {
  61. formatDate
  62. } from '../../common/util.js'
  63. import { showToast } from '../../common/util.js'
  64. import LoadMore from '../../components/load-more/load-more.vue'
  65. export default {
  66. mixins: [mixinsCommon, mixinsAuth],
  67. components: {
  68. LoadMore
  69. },
  70. data() {
  71. return {
  72. hasLoad: false,
  73. session_id: 0,
  74. state: {},
  75. loadingType: 1,
  76. loadingText: '',
  77. }
  78. },
  79. onLoad(options) {
  80. switch (options.from) {
  81. case 'last':
  82. uni.setNavigationBarTitle({
  83. title: '上次答题'
  84. })
  85. break
  86. case 'max':
  87. uni.setNavigationBarTitle({
  88. title: '最好成绩'
  89. })
  90. break
  91. case 'exercise':
  92. uni.setNavigationBarTitle({
  93. title: '练习结果'
  94. })
  95. break
  96. case 'review':
  97. uni.setNavigationBarTitle({
  98. title: '复习结果'
  99. })
  100. break
  101. }
  102. this.session_id = options.session_id
  103. getSummary(options.session_id).then(([err, res]) => {
  104. console.log('getSummary', err, res)
  105. if (!err) {
  106. this.hasLoad = true
  107. this.loadingType = -1
  108. this.state = res
  109. } else {
  110. if (!this.hasLoad) {
  111. this.loadingType = 3
  112. this.loadingText = err.data.msg || '加载失败'
  113. }
  114. showToast('答题未完成').then(([err, res]) => {
  115. uni.reLaunch({
  116. url: '/pages/third/yunexamine/pages/home/index'
  117. })
  118. })
  119. }
  120. })
  121. },
  122. computed: {
  123. breakTips() {
  124. if (this.state.total_score > this.state.break_score) {
  125. return this.state.break_score + '分'
  126. } else {
  127. return this.costTime(this.state.break_time)
  128. }
  129. },
  130. startTime() {
  131. return formatDate(this.state.created_at, 'yyyy-MM-dd hh:mm:ss')
  132. }
  133. },
  134. methods: {
  135. onHistory() {
  136. uni.navigateTo({
  137. url: '/pages/third/yunexamine/pages/examine/history?session_id=' + this.session_id
  138. })
  139. },
  140. onHome() {
  141. uni.reLaunch({
  142. url: '/pages/third/yunexamine/pages/home/index'
  143. })
  144. }
  145. }
  146. }
  147. </script>
  148. <style lang="scss">
  149. page {
  150. padding-bottom: env(safe-area-inset-bottom);
  151. background: #DA5650;
  152. }
  153. .wrap {}
  154. .main {
  155. padding: 40upx;
  156. }
  157. .result {
  158. margin-top: 50upx;
  159. padding: 40upx;
  160. background: #fff;
  161. border-radius: 20upx;
  162. overflow: hidden;
  163. display: flex;
  164. flex-direction: column;
  165. .b-summary {
  166. margin-top: 20upx;
  167. font-size: 30upx;
  168. display: flex;
  169. flex-direction: column;
  170. align-items: center;
  171. .b-title {
  172. font-size: 36upx;
  173. }
  174. .b-score {
  175. margin-top: 20upx;
  176. display: flex;
  177. align-items: baseline;
  178. .s-num {
  179. color: #FF8D1A;
  180. font-weight: bold;
  181. font-size: 80upx;
  182. }
  183. .s-tit {
  184. margin-left: 10upx;
  185. font-size: 28upx;
  186. }
  187. }
  188. .break-score {
  189. margin-top: 20upx;
  190. color: #DA5650;
  191. font-size: 32upx;
  192. font-weight: bold;
  193. }
  194. }
  195. .b-detail {
  196. margin-top: 40upx;
  197. padding: 20upx;
  198. background: #F7F7F7;
  199. border-radius: 10upx;
  200. .b-item {
  201. font-size: 28upx;
  202. height: 60upx;
  203. line-height: 60upx;
  204. display: flex;
  205. align-items: center;
  206. justify-content: space-between;
  207. .s-tit {
  208. color: #808080;
  209. }
  210. .s-cont {
  211. color: #383838;
  212. }
  213. .f-focus {
  214. color: #FF8D1A;
  215. }
  216. }
  217. }
  218. .b-action {
  219. margin-top: 50upx;
  220. display: flex;
  221. .b-history {
  222. flex: 1;
  223. height: 78upx;
  224. line-height: 78upx;
  225. text-align: center;
  226. color: #DA5650;
  227. font-size: 32upx;
  228. border: 1upx solid #DA5650;
  229. border-radius: 50upx;
  230. letter-spacing: 5upx;
  231. }
  232. .b-home {
  233. margin-left: 50upx;
  234. flex: 1;
  235. height: 80upx;
  236. line-height: 80upx;
  237. text-align: center;
  238. color: #fff;
  239. font-size: 32upx;
  240. background: #DA5650;
  241. border-radius: 50upx;
  242. letter-spacing: 5upx;
  243. }
  244. }
  245. }
  246. </style>