index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <view class="container">
  3. <!-- 设置圆角 -->
  4. <view style="padding: 10px 30px 10px 30px;">
  5. <uni-search-bar :radius="100" @input="search" placeholder="搜索课程"></uni-search-bar>
  6. </view>
  7. <view style="background: #f5f5f5">
  8. <uni-segmented-control :current="current" :values="tabs" @clickItem="changeTab" styleType="text"
  9. activeColor="#007aff">
  10. </uni-segmented-control>
  11. </view>
  12. <yf-more-list url="/api/course/course/user-paging" :params="queryParams" ref="moreList">
  13. <template v-slot:item="{ data }" >
  14. <uni-list-item :show-arrow="true" :title="data.title" :note="'类型:'+data.catId_dictText"
  15. link="navigateTo" :to="'/pages/course/detail?id='+data.id">
  16. </uni-list-item>
  17. </template>
  18. </yf-more-list>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. name: 'CourseList',
  24. props: {
  25. onlyLearn: Boolean
  26. },
  27. data() {
  28. return {
  29. current: 0,
  30. tabs: ['全部', '未学习', '学习中', '已学完'],
  31. queryParams:{
  32. title: '',
  33. learnState: "0",
  34. onlyLearn: false
  35. },
  36. breakShow: false,
  37. breakId: ''
  38. }
  39. },
  40. onPullDownRefresh() {
  41. if(this.$refs.moreList){
  42. this.$refs.moreList.initData()
  43. }
  44. },
  45. onReachBottom() {
  46. // 加载数据
  47. this.$refs.moreList.loadData()
  48. },
  49. onShow() {
  50. if(this.$refs.moreList){
  51. this.$refs.moreList.initData()
  52. }
  53. },
  54. mounted() {
  55. if(this.onlyLearn!=null){
  56. this.queryParams.onlyLearn = this.onlyLearn
  57. }
  58. },
  59. methods: {
  60. // 搜索课程
  61. search(e) {
  62. this.queryParams.title = e
  63. },
  64. // 继续考试
  65. continueExam() {
  66. uni.redirectTo({
  67. url: '/pages/exam/exam?id=' + this.breakId
  68. });
  69. },
  70. changeTab(e) {
  71. if (this.current != e.currentIndex) {
  72. this.current = e.currentIndex;
  73. }
  74. this.queryParams.learnState = e.currentIndex
  75. }
  76. }
  77. }
  78. </script>
  79. <style>
  80. .container {
  81. font-size: 14rpx;
  82. }
  83. .exam-item {
  84. display: flex;
  85. align-items: center;
  86. line-height: 25px;
  87. }
  88. .exam-item .left {
  89. text-align: left;
  90. flex-grow: 1;
  91. }
  92. .exam-item .left .desc {
  93. color: #888;
  94. }
  95. .exam-item .left .icons {
  96. font-size: 10px;
  97. display: flex;
  98. align-items: center;
  99. color: #666;
  100. }
  101. .exam-item .right {
  102. text-align: right;
  103. }
  104. .pass {
  105. color: #007AFF !important;
  106. margin-right: 5px;
  107. }
  108. .fail {
  109. color: #ff0000 !important;
  110. margin-right: 5px;
  111. }
  112. </style>