history.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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">
  5. <view class="questions" v-if="state.items.length > 0">
  6. <view class="b-item" v-for="(item, index) in state.items" :key="index" @click="onReview(item.id)">
  7. <view class="b-main">
  8. <view class="b-title">
  9. <view class="s-num">{{ index + 1 }}.</view>
  10. <text class="s-cont">【{{ item.type_text }}】{{ item.title }}</text>
  11. </view>
  12. <view class="b-info">
  13. <view class="s-flag f-right" v-if="item.result == 2">{{ item.result_text }}</view>
  14. <view class="s-flag f-wrong" v-else-if="item.result == 3">{{ item.result_text }}</view>
  15. <view class="s-flag f-timeout" v-else-if="item.result == 4">{{ item.result_text }}</view>
  16. <view class="s-flag f-timeout-end" v-else-if="item.result == 5">{{ item.result_text }}</view>
  17. <view class="s-time">{{ costTime(item.cost_time) }}</view>
  18. </view>
  19. </view>
  20. <view class="b-more">
  21. <view class="iconfont icon-more"></view>
  22. </view>
  23. </view>
  24. </view>
  25. <!-- 加载中 -->
  26. <load-more :loadingType="loadingType" :loadingText="loadingText" color="#ffffff"></load-more>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import { getHistory } from '@/service/api/examine.js';
  32. import mixinsCommon from '@/mixins/common.js';
  33. import mixinsAuth from '../../mixins/auth.js';
  34. export default {
  35. mixins: [mixinsCommon, mixinsAuth],
  36. data() {
  37. return {
  38. state: {
  39. items: []
  40. },
  41. loadingType: 1,
  42. loadingText: ''
  43. };
  44. },
  45. onLoad(options) {
  46. this.sessionId = options.session_id;
  47. this.loadHistory(true);
  48. },
  49. onReachBottom() {
  50. if (this.loadingType !== 1 && this.loadingType !== 2) {
  51. this.loadHistory();
  52. }
  53. },
  54. methods: {
  55. loadHistory(refresh) {
  56. console.log('loadHistory', refresh);
  57. if (refresh) {
  58. this.page = 1;
  59. this.state.items = [];
  60. } else {
  61. this.page++;
  62. }
  63. this.loadingType = 1;
  64. this.loadingText = '';
  65. getHistory(this.sessionId, this.page, 10).then(([err, res]) => {
  66. console.log('getHistory', err, res);
  67. this.loadingType = -1;
  68. if (!err) {
  69. if (res.items.length > 0) {
  70. this.state.items = [...this.state.items, ...res.items];
  71. } else {
  72. this.loadingType = 2;
  73. if (this.page == 1) {
  74. this.loadingText = '暂无数据';
  75. }
  76. this.page--; // 重置分页
  77. }
  78. } else {
  79. this.loadingType = 3;
  80. }
  81. });
  82. },
  83. onReview(recordId) {
  84. uni.navigateTo({
  85. url: '/answer_pages/examine/review?record_id=' + recordId
  86. });
  87. }
  88. }
  89. };
  90. </script>
  91. <style lang="scss">
  92. // page {
  93. // padding-bottom: env(safe-area-inset-bottom);
  94. // background: #da5650;
  95. // }
  96. .wrap {
  97. background: #da5650;
  98. }
  99. .main {
  100. padding: 40upx;
  101. }
  102. .questions {
  103. .b-item {
  104. display: flex;
  105. margin-bottom: 40upx;
  106. background: #fff;
  107. border-radius: 20upx;
  108. padding: 20upx;
  109. .b-main {
  110. flex: 1;
  111. display: flex;
  112. flex-direction: column;
  113. .b-title {
  114. display: flex;
  115. .s-num {
  116. font-size: 28upx;
  117. }
  118. .s-cont {
  119. margin-left: 0upx;
  120. font-size: 28upx;
  121. }
  122. }
  123. .b-info {
  124. margin-top: 10upx;
  125. display: flex;
  126. align-items: center;
  127. justify-content: space-between;
  128. .s-flag {
  129. font-size: 24upx;
  130. padding: 0 10upx;
  131. height: 50upx;
  132. line-height: 50upx;
  133. color: #fff;
  134. border-radius: 10upx;
  135. &.f-right {
  136. background: #1eab69;
  137. }
  138. &.f-wrong {
  139. background: #d13b42;
  140. }
  141. &.f-timeout {
  142. background: #ff8d1a;
  143. }
  144. &.f-timeout-end {
  145. background: #338ada;
  146. }
  147. }
  148. .s-time {
  149. color: #da5650;
  150. font-size: 24upx;
  151. }
  152. }
  153. }
  154. .b-more {
  155. margin-left: 10upx;
  156. display: flex;
  157. align-items: center;
  158. justify-content: center;
  159. color: #e5e5e5;
  160. }
  161. }
  162. }
  163. </style>