skillTraining.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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.file?item.file: errorFile" alt="">
  11. </view>
  12. <u-line color="#e6e6e6" />
  13. <!-- 标题 -->
  14. <view class="title">
  15. {{item.name}}
  16. </view>
  17. <!-- 报名状态 -->
  18. <view class="state" :class="{
  19. state2:item.status!=1
  20. }">
  21. {{item.status==1?'开放报名':'结束报名'}}
  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. export default {
  33. data() {
  34. return {
  35. errorFile:file,
  36. list: [],
  37. recordsTotal: 0,
  38. listFrom: {
  39. pageIndex: 1,
  40. pageSize: 20,
  41. }
  42. }
  43. },
  44. onReachBottom() {
  45. if (this.list.length < this.recordsTotal) {
  46. this.myLoadmore();
  47. }
  48. },
  49. onLoad(op) {
  50. this.getList();
  51. },
  52. methods: {
  53. myLoadmore() {
  54. this.listFrom.pageIndex += 1;
  55. this.getList();
  56. },
  57. getList() {
  58. uni.showLoading({
  59. title: "加载中",
  60. mask: true,
  61. })
  62. API.trainingList({
  63. pageSize: this.listFrom.pageSize,
  64. pageIndex: this.listFrom.pageIndex,
  65. }).then((res) => {
  66. uni.hideLoading();
  67. if (this.listFrom.pageIndex == 1) {
  68. this.list = res.data.data;
  69. } else {
  70. this.list = [
  71. ...this.list,
  72. ...res.data.data
  73. ];
  74. }
  75. this.recordsTotal = res.data.recordsTotal;
  76. }).catch(error => {
  77. uni.showToast({icon: 'none',
  78. title: error,
  79. icon: "none"
  80. })
  81. })
  82. }
  83. }
  84. }
  85. </script>
  86. <style>
  87. page {
  88. background: #F0F0F2;
  89. padding-bottom: 50px;
  90. }
  91. </style>
  92. <style lang="scss" scoped>
  93. .content {
  94. margin: 24rpx 32rpx 0;
  95. background-color: #fff;
  96. padding: 24rpx;
  97. border-radius: 24rpx;
  98. .picture {
  99. width: 100%;
  100. height: 240rpx;
  101. margin-bottom: 24rpx;
  102. img {
  103. width: 100%;
  104. height: 100%;
  105. }
  106. }
  107. .title {
  108. color: rgba(16, 16, 16, 1);
  109. font-size: 32rpx;
  110. margin-top: 24rpx;
  111. }
  112. // 报名状态
  113. .state {
  114. color: rgba(0, 185, 98, 1);
  115. font-size: 24rpx;
  116. margin-top: 60rpx;
  117. }
  118. .state2 {
  119. color: rgba(153, 153, 153, 1);
  120. }
  121. }
  122. </style>