school.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <view class="pageCon">
  3. <view class="top dfsb">
  4. <view @click="sectionChange(item.id)" :class="[type == item.id ? 'sel' : '', 'li']" v-for="(item, index) in school_type" :key="index">{{ item.name }}</view>
  5. </view>
  6. <view class="conwarp"><list :flag="1" :list="schoolList"></list></view>
  7. </view>
  8. </template>
  9. <script>
  10. import list from './componets/list.vue';
  11. export default {
  12. components: {
  13. list
  14. },
  15. data() {
  16. return {
  17. school_type: [],
  18. type: 0,
  19. schoolList: [
  20. // { image: '/static/img/pro/indnotice.png', name: '知识过关', path: '/pages/knowledge/knowledge' },
  21. ],
  22. page: 1,
  23. pagnum: 6
  24. };
  25. },
  26. onPullDownRefresh() {
  27. this.page = 1;
  28. this.schoolList = [];
  29. setTimeout(res => {
  30. uni.stopPullDownRefresh();
  31. }, 1000);
  32. },
  33. onLoad(opt) {
  34. this.type = opt.type || '';
  35. this.getInfoList();
  36. },
  37. onReachBottom() {
  38. if (this.status == 'nomore') return;
  39. this.status = 'loading';
  40. this.page = ++this.page;
  41. this.getInfoList();
  42. },
  43. methods: {
  44. sectionChange(index) {
  45. this.type = index;
  46. this.page = 1;
  47. this.schoolList = [];
  48. this.getInfoList();
  49. },
  50. getInfoList() {
  51. this.status = 'loadmore';
  52. this.$api
  53. .request('index/getSchoolList', {
  54. type: this.type,
  55. page: this.page,
  56. limit: this.pagnum
  57. })
  58. .then(data => {
  59. console.log(data);
  60. if (data.code == 200) {
  61. this.school_type = data.data.school_type;
  62. this.schoolList = this.schoolList.concat(data.data.list);
  63. if (data.data.list.length < this.pagnum) {
  64. this.status = 'nomore';
  65. }
  66. } else {
  67. this.$api.toast(data.msg);
  68. }
  69. });
  70. },
  71. toNext(url) {
  72. uni.navigateTo({
  73. url: url
  74. });
  75. }
  76. }
  77. };
  78. </script>
  79. <style lang="scss" scoped>
  80. .pageCon {
  81. .top {
  82. padding: 22rpx 0;
  83. background-color: #fff;
  84. justify-content: center;
  85. .li {
  86. padding: 11rpx 18rpx;
  87. border: 1px solid #666666;
  88. margin-left: -1rpx;
  89. &:first-of-type {
  90. border-radius: 8rpx 0 0 8rpx;
  91. }
  92. &:last-of-type {
  93. border-radius: 0 8rpx 8rpx 0;
  94. }
  95. }
  96. .sel {
  97. border: 1px solid #025b58;
  98. background: rgba(2, 91, 88, 0.1);
  99. color: #025b58;
  100. }
  101. }
  102. .conwarp {
  103. background: #ffffff;
  104. margin-top: 20rpx;
  105. padding: 0 30rpx;
  106. }
  107. }
  108. </style>