skillTraining.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <view>
  3. <u-navbar back-text="技能培训" back-icon-size="28" back-icon-color="#ffffff"
  4. :background="{backgroundColor: '#2795FD',}" :back-text-style="{color: '#ffffff'}"></u-navbar>
  5. <view class="content" v-for="(item,i) in list"
  6. :key="i" @click="gotoUrl('pages/packages/skillTraining/trainingRegistration?id='+item.id)" >
  7. <!-- 图片 -->
  8. <view class="picture">
  9. <img
  10. :src=" item.thumbnailImage?item.thumbnailImage: errorFile" alt="">
  11. </view>
  12. <u-line color="#e6e6e6" />
  13. <!-- 标题 -->
  14. <view class="title">
  15. {{item.title}}
  16. </view>
  17. <!-- 报名状态 -->
  18. <view class="state" :class="{
  19. state2:getStatus(item)
  20. }">
  21. {{getStatus(item)?'结束报名':'开放报名'}} <span v-if="item.endTime" style="float: right;" >结束时间:{{item.endTime}}</span>
  22. </view>
  23. </view>
  24. <u-divider v-if="list.length==recordsTotal"
  25. :isnone="list.length==0" nonetext="没有找到相关内容"
  26. bg-color="#F0F0F0" margin-top="20" border-color="#CFD2D5">已经到底了</u-divider>
  27. </view>
  28. </template>
  29. <script>
  30. var file=require("@/assets/img/traniningPicture.png")
  31. import * as API from '@/apis/pagejs/packages.js'
  32. import { newDate } from '../../../apis/utils';
  33. export default {
  34. data() {
  35. return {
  36. errorFile:file,
  37. list: [],
  38. recordsTotal: 0,
  39. listFrom: {
  40. pageIndex: 1,
  41. pageSize: 20,
  42. }
  43. }
  44. },
  45. onReachBottom() {
  46. if (this.list.length < this.recordsTotal) {
  47. this.myLoadmore();
  48. }
  49. },
  50. onLoad(op) {
  51. this.getList();
  52. },
  53. methods: {
  54. getStatus(item){
  55. if(item.endTime){
  56. return new Date()>new Date(item.endTime)
  57. }
  58. return true
  59. },
  60. myLoadmore() {
  61. this.listFrom.pageIndex += 1;
  62. this.getList();
  63. },
  64. getList() {
  65. uni.showLoading({
  66. title: "加载中",
  67. mask: true,
  68. })
  69. API.trainingList({
  70. pageSize: this.listFrom.pageSize,
  71. pageIndex: this.listFrom.pageIndex,
  72. }).then((res) => {
  73. uni.hideLoading();
  74. if (this.listFrom.pageIndex == 1) {
  75. this.list = res.data.data;
  76. } else {
  77. this.list = [
  78. ...this.list,
  79. ...res.data.data
  80. ];
  81. }
  82. this.recordsTotal = res.data.recordsTotal;
  83. }).catch(error => {
  84. uni.showToast({icon: 'none',
  85. title: error,
  86. icon: "none"
  87. })
  88. })
  89. }
  90. }
  91. }
  92. </script>
  93. <style>
  94. page {
  95. background: #F0F0F2;
  96. padding-bottom: 50px;
  97. }
  98. </style>
  99. <style lang="scss" scoped>
  100. .content {
  101. margin: 24rpx 32rpx 0;
  102. background-color: #fff;
  103. padding: 24rpx;
  104. border-radius: 24rpx;
  105. .picture {
  106. width: 100%;
  107. height: 240rpx;
  108. margin-bottom: 24rpx;
  109. img {
  110. width: 100%;
  111. height: 100%;
  112. }
  113. }
  114. .title {
  115. color: rgba(16, 16, 16, 1);
  116. font-size: 32rpx;
  117. margin-top: 24rpx;
  118. }
  119. // 报名状态
  120. .state {
  121. color: rgba(0, 185, 98, 1);
  122. font-size: 24rpx;
  123. margin-top: 30rpx;
  124. }
  125. .state2 {
  126. color: rgba(153, 153, 153, 1);
  127. }
  128. }
  129. </style>