examList.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <!-- 在线考试 -->
  2. <template>
  3. <view id="examList">
  4. <scroll-view scroll-y @scrolltolower="scrollGet" class="info-max-box">
  5. <view class="for-box" v-for="(item,index) in infoList" :key="index">
  6. <view class="for-title-box">
  7. <view :class="item.level==1?'colorA':(item.level==2?'colorB':(item.level==3?'colorC':''))">{{item.level==1?'中等':(item.level==2?'较难':(item.level==3?'难':''))}}</view>
  8. <view>{{item.title}}</view>
  9. </view>
  10. <view class="for-info-box">{{item.info}}</view>
  11. <view class="for-text-box">
  12. <view>试卷总分:</view>
  13. <view>{{item.totalScore}}</view>
  14. </view>
  15. <view class="for-text-box">
  16. <view>及格分数:</view>
  17. <view>{{item.qualifyScore}}</view>
  18. </view>
  19. <view class="for-text-box">
  20. <view>考试时长:</view>
  21. <view>{{item.totalTime}}分钟</view>
  22. </view>
  23. <view class="for-button-box" @click="createPaperButton(item)">开始考试</view>
  24. </view>
  25. <view class="get-null-box" v-if="getData.nullDataType">暂无更多数据</view>
  26. </scroll-view>
  27. </view>
  28. </template>
  29. <script>
  30. import { onlineExamList,createPaper } from '@/api/index.js'
  31. export default {
  32. data() {
  33. return {
  34. infoList:[],
  35. //列表请求参数
  36. getData:{
  37. page:1,
  38. pageSize:20,
  39. getType:true,
  40. nullDataType:true,
  41. },
  42. violationId:"",
  43. }
  44. },
  45. onLoad(option) {
  46. if(option.violationId){
  47. this.violationId = option.violationId;
  48. }
  49. // this.itemData = JSON.parse(decodeURIComponent(option.item));
  50. // //修改页面title
  51. // uni.setNavigationBarTitle({
  52. // title:this.itemData.content
  53. // });
  54. // this.time(this.itemData.totalTime);
  55. // this.getPaper();
  56. },
  57. onShow(){
  58. this.clearData();
  59. this.getList();
  60. },
  61. methods: {
  62. //清除
  63. clearData(){
  64. this.infoList = [];
  65. this.getData.page = 1;
  66. this.getData.getType = true;
  67. this.getData.nullDataType = true;
  68. },
  69. //创建考卷
  70. async createPaperButton(item){
  71. let self = this;
  72. const {data} = await createPaper(item.id);
  73. if(data.code == 200){
  74. item.newPaperId = data.data;
  75. if(this.violationId){
  76. uni.navigateTo({
  77. url: '/pages_student/workbench/exam/examInfo?item='+encodeURIComponent(JSON.stringify(item))+'&violationId='+this.violationId
  78. });
  79. }else{
  80. uni.navigateTo({
  81. url: '/pages_student/workbench/exam/examInfo?item='+encodeURIComponent(JSON.stringify(item))
  82. });
  83. }
  84. }
  85. },
  86. //滚动事件
  87. scrollGet(){
  88. if(this.getData.getType){
  89. this.getData.page += 1;
  90. this.getList();
  91. }
  92. },
  93. //获取列表数据
  94. async getList(){
  95. let self = this;
  96. let obj = {
  97. pageNum:this.getData.page,
  98. pageSize:this.getData.pageSize,
  99. }
  100. if(this.violationId){
  101. obj.violationId = this.violationId;
  102. }
  103. const {data} = await onlineExamList(obj)
  104. if(data.code==200){
  105. if(self.page==1){
  106. if(data.rows.length > 0 && data.rows.length == self.getData.pageSize){
  107. self.infoList = data.rows;
  108. }else if(data.rows.length > 0 && data.rows.length != self.getData.pageSize){
  109. self.infoList = data.rows;
  110. self.getData.getType = false;
  111. self.getData.nullDataType = true;
  112. }else{
  113. self.getData.getType = false;
  114. self.getData.nullDataType = true;
  115. }
  116. }else{
  117. if(data.rows.length > 0 && data.rows.length == self.getData.pageSize){
  118. self.infoList = self.infoList.concat(data.rows)
  119. }else if(data.rows.length > 0 && data.rows.length != self.getData.pageSize){
  120. self.infoList = self.infoList.concat(data.rows);
  121. self.getData.getType = false;
  122. self.getData.nullDataType = true;
  123. }else{
  124. self.getData.getType = false;
  125. self.getData.nullDataType = true;
  126. }
  127. }
  128. }
  129. },
  130. }
  131. }
  132. </script>
  133. <style lang="stylus" scoped>
  134. #examList{
  135. height:100%;
  136. width:100%;
  137. display: flex
  138. .info-max-box{
  139. flex:1;
  140. overflow: scroll
  141. .for-box{
  142. background #fff
  143. margin-bottom:10rpx;
  144. padding:13rpx 0 25rpx;
  145. .for-title-box{
  146. margin:0 20rpx;
  147. display flex
  148. view:nth-child(1){
  149. padding:0 8rpx;
  150. line-height:28rpx;
  151. height:28rpx;
  152. margin:15rpx 18rpx 0 0;
  153. font-size:22rpx;
  154. border-radius: 4px;
  155. }
  156. view:nth-child(2){
  157. font-size:30rpx;
  158. color:#333;
  159. line-height:58rpx;
  160. }
  161. .colorA{
  162. border:1rpx solid #FFC76E;
  163. color:#FFC76E;
  164. }
  165. .colorB{
  166. border:1rpx solid #E76200;
  167. color:#E76200;
  168. }
  169. .colorC{
  170. border:1rpx solid #FF3B3B;
  171. color:#FF3B3B;
  172. }
  173. }
  174. .for-info-box{
  175. line-height:57rpx;
  176. font-size:30rpx;
  177. margin:0 20rpx;
  178. color:#999999;
  179. }
  180. .for-text-box{
  181. display flex
  182. margin:0 20rpx;
  183. view{
  184. font-size:30rpx;
  185. line-height:57rpx;
  186. }
  187. view:nth-child(1){
  188. color:#999999;
  189. }
  190. view:nth-child(2){
  191. color:#333;
  192. flex:1;
  193. }
  194. }
  195. .for-button-box{
  196. width: 420rpx;
  197. height: 80rpx;
  198. border: 2rpx solid #0183FA;
  199. border-radius: 10rpx;
  200. margin:46rpx auto 0;
  201. font-size: 22rpx;
  202. color: #0183FA;
  203. text-align center
  204. line-height:80rpx;
  205. }
  206. }
  207. .get-null-box{
  208. height:100rpx;
  209. line-height:100rpx;
  210. color:#999;
  211. text-align center
  212. }
  213. }
  214. }
  215. </style>