summary.vue 5.4 KB

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