studentList.vue 3.9 KB

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