subscribeList.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <view class="content">
  3. <scroll-view scroll-y class="scroll-box" @scrolltolower="handleLoadMore" :refresher-enabled="true"
  4. :refresher-triggered="triggered" :refresher-threshold="100" refresher-background="white" @refresherrefresh="onRefresh"
  5. @refresherrestore="onRestore">
  6. <u-card :head-border-bottom="false" padding="0px" margin="10px" borderRadius="40" v-for="(item, index) in tableList"
  7. :key="index" class="class-card">
  8. <view class="class-content" slot="head" style="padding-top: 10px;">
  9. <view class="student-name">{{item.studentName}}</view>
  10. <view class="class-name">{{item.name}}</view>
  11. </view>
  12. <view class="class-content" slot="body">
  13. <view class="class-info-text">
  14. <u-icon name="clock"></u-icon>
  15. {{item.classStartDate}}&nbsp;&nbsp;{{item.classStartHours}}
  16. </view>
  17. <view class="class-info-text">
  18. <u-icon name="map"></u-icon>
  19. {{item.address}}
  20. </view>
  21. </view>
  22. <view class="class-foot" slot="foot">
  23. <u-button type="default" shape="circle" :ripple="true" :custom-style="handleDefaultCustomStyle" size="mini"
  24. :hair-line="false" plain>已预约</u-button>
  25. </view>
  26. </u-card>
  27. <u-divider v-if="isOver" bg-color="transparent">没有更多了</u-divider>
  28. </scroll-view>
  29. <u-top-tips ref="uTips"></u-top-tips>
  30. </view>
  31. </template>
  32. <script>
  33. import {
  34. mapGetters
  35. } from 'vuex'
  36. const NET = require('@/utils/request')
  37. const API = require('@/config/api')
  38. export default {
  39. computed: {
  40. ...mapGetters([
  41. 'handleDefaultCustomStyle',
  42. ])
  43. },
  44. data() {
  45. return {
  46. triggered: false,
  47. isOver: false,
  48. pageIndex: 1,
  49. tableList: [],
  50. }
  51. },
  52. onLoad() {
  53. this.getTableList()
  54. },
  55. onReady() {},
  56. methods: {
  57. // 下拉刷新
  58. onRefresh() {
  59. this.triggered = true
  60. this.isOver = false
  61. this.pageIndex = 1
  62. this.tableList = []
  63. this.getTableList()
  64. },
  65. // 重置下拉刷新状态
  66. onRestore() {
  67. this.triggered = 'restore'
  68. this.triggered = false
  69. },
  70. // 懒加载
  71. handleLoadMore() {
  72. if (!this.isOver) {
  73. this.pageIndex++
  74. this.getTableList()
  75. }
  76. },
  77. // 获取列表数据
  78. getTableList() {
  79. NET.request(API.getSubscribeList, {
  80. page: this.pageIndex,
  81. size: 10,
  82. }, 'POST').then(res => {
  83. this.triggered = false
  84. this.tableList = this.tableList.concat(res.data.row)
  85. this.isOver = res.data.row.length != 10
  86. }).catch(error => {
  87. this.triggered = false
  88. this.$refs.uTips.show({
  89. title: error.message,
  90. type: 'warning',
  91. })
  92. })
  93. }
  94. },
  95. }
  96. </script>
  97. <style>
  98. page {
  99. width: 100%;
  100. height: 100%;
  101. background-color: #f7f7f7;
  102. }
  103. </style>
  104. <style lang="scss" scoped>
  105. @import "@/static/css/themes.scss";
  106. .content {
  107. width: 100%;
  108. float: left;
  109. .scroll-box {
  110. width: 100%;
  111. height: 100vh;
  112. padding-bottom: 10px;
  113. box-sizing: border-box;
  114. .class-card {
  115. .class-content {
  116. padding: 5px 15px;
  117. }
  118. .student-name {
  119. height: 20px;
  120. display: inline-block;
  121. padding: 0 10px;
  122. margin-right: 5px;
  123. background-color: $mainColor;
  124. border-radius: 10px;
  125. line-height: 20px;
  126. color: #FFFFFF;
  127. }
  128. .class-name {
  129. height: 20px;
  130. display: inline-block;
  131. font-weight: bold;
  132. font-size: 14px;
  133. line-height: 20px;
  134. }
  135. .class-info-text {
  136. color: #999999;
  137. margin-bottom: 5px;
  138. /deep/.u-icon {
  139. margin-right: 5px;
  140. font-size: 14px;
  141. color: #000000;
  142. }
  143. }
  144. }
  145. .class-foot {
  146. padding: 10px 15px;
  147. text-align: right;
  148. }
  149. }
  150. }
  151. </style>