studentList.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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" :foot-border-top="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="class-name">{{item.studentName}}</view>
  10. </view>
  11. <view class="class-content" slot="body">
  12. <view class="class-info-text">家长姓名:{{item.fatherName}}</view>
  13. <view class="class-info-text">性别:{{item.sex}}</view>
  14. <view class="class-info-text">年龄:{{item.age}}岁</view>
  15. <view class="class-info-text">生日:{{item.birthday}}</view>
  16. <view class="class-info-text">联系方式:{{item.phone}}</view>
  17. </view>
  18. </u-card>
  19. <u-divider v-if="isOver" bg-color="transparent">没有更多了</u-divider>
  20. </scroll-view>
  21. <view class="handle-fix-box" style="height:40rpx">
  22. <u-button type="warning" shape="circle" :ripple="true" :custom-style="customStyle" @click="goToSubscribelForm()">新增学员</u-button>
  23. </view>
  24. <u-top-tips ref="uTips"></u-top-tips>
  25. </view>
  26. </template>
  27. <script>
  28. import {
  29. mapGetters
  30. } from 'vuex'
  31. const NET = require('@/utils/request')
  32. const API = require('@/config/api')
  33. export default {
  34. computed: {
  35. ...mapGetters([
  36. 'customStyle',
  37. ])
  38. },
  39. data() {
  40. return {
  41. triggered: false,
  42. isOver: false,
  43. pageIndex: 1,
  44. tableList: [],
  45. }
  46. },
  47. onLoad() {
  48. this.getTableList()
  49. },
  50. onReady() {},
  51. methods: {
  52. // 下拉刷新
  53. onRefresh() {
  54. this.triggered = true
  55. this.isOver = false
  56. this.pageIndex = 1
  57. this.tableList = []
  58. this.getTableList()
  59. },
  60. // 重置下拉刷新状态
  61. onRestore() {
  62. this.triggered = 'restore'
  63. this.triggered = false
  64. },
  65. // 懒加载
  66. handleLoadMore() {
  67. if (!this.isOver) {
  68. this.pageIndex++
  69. this.getTableList()
  70. }
  71. },
  72. // 获取列表数据
  73. getTableList() {
  74. NET.request(API.getStudentList, {
  75. page: this.pageIndex,
  76. size: 10,
  77. }, 'POST').then(res => {
  78. this.triggered = false
  79. this.tableList = this.tableList.concat(res.data.row)
  80. this.isOver = res.data.row.length != 10
  81. }).catch(error => {
  82. this.triggered = false
  83. this.$refs.uTips.show({
  84. title: error.message,
  85. type: 'warning',
  86. })
  87. })
  88. },
  89. // 跳转预定表单
  90. goToSubscribelForm() {
  91. uni.navigateTo({
  92. url: '/pagesMember/subscribelForm?id=' + this.classId
  93. });
  94. }
  95. },
  96. }
  97. </script>
  98. <style>
  99. page {
  100. width: 100%;
  101. height: 100%;
  102. background-color: #f7f7f7;
  103. }
  104. </style>
  105. <style lang="scss" scoped>
  106. @import "@/static/css/themes.scss";
  107. .content {
  108. width: 100%;
  109. float: left;
  110. .scroll-box {
  111. width: 100%;
  112. height: calc(100vh - 60px);
  113. padding-bottom: 10px;
  114. box-sizing: border-box;
  115. .class-card {
  116. .class-content {
  117. padding: 5px 15px;
  118. }
  119. .class-name {
  120. height: 20px;
  121. display: inline-block;
  122. font-weight: bold;
  123. font-size: 14px;
  124. line-height: 20px;
  125. }
  126. .class-info-text {
  127. color: #999999;
  128. margin-bottom: 5px;
  129. }
  130. }
  131. }
  132. }
  133. </style>