signStudentList.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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-checkbox-group :active-color="mainColor" shape="circle" size="56" icon-size="36">
  7. <u-card :head-border-bottom="false" :foot-border-top="false" padding="0px" margin="0" borderRadius="0" v-for="(item, index) in tableList"
  8. :key="index" class="card-box" @click="changeStatus(item)">
  9. <view class="card-content" slot="body">
  10. <view class="card-info-img">
  11. <u-avatar :src="site.url" size="100"></u-avatar>
  12. </view>
  13. <view class="card-info-text">{{item.name}}</view>
  14. <u-checkbox v-model="item.checked" @click.native.stop=""></u-checkbox>
  15. </view>
  16. </u-card>
  17. </u-checkbox-group>
  18. <u-divider v-if="isOver" bg-color="transparent">没有更多了</u-divider>
  19. </scroll-view>
  20. <view class="handle-fix-box">
  21. <u-button type="warning" shape="circle" :ripple="true" :custom-style="customStyle" @click="selectStudent()">确定</u-button>
  22. </view>
  23. <u-top-tips ref="uTips"></u-top-tips>
  24. </view>
  25. </template>
  26. <script>
  27. import {
  28. mapGetters
  29. } from 'vuex'
  30. const NET = require('@/utils/request')
  31. const API = require('@/config/api')
  32. export default {
  33. computed: {
  34. ...mapGetters([
  35. 'mainColor',
  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.getOtherSignStudentList, {
  75. page: this.pageIndex,
  76. size: 10,
  77. }, 'POST').then(res => {
  78. this.triggered = false
  79. res.data.row.forEach(site => site.checked = false)
  80. this.tableList = this.tableList.concat(res.data.row)
  81. this.isOver = res.data.row.length != 10
  82. }).catch(error => {
  83. this.triggered = false
  84. this.$refs.uTips.show({
  85. title: error.message,
  86. type: 'warning',
  87. })
  88. })
  89. },
  90. // 变更状态
  91. changeStatus(item) {
  92. item.checked = !item.checked
  93. },
  94. // 选择学员
  95. selectStudent() {
  96. uni.setStorage({
  97. key: 'signUserList',
  98. data: this.tableList.filter(site => site.checked).map(site => {
  99. return {
  100. id: site.id,
  101. name: site.name,
  102. url: site.url,
  103. hasUrl: site.hasUrl,
  104. checked: false,
  105. }
  106. })
  107. })
  108. uni.navigateBack()
  109. }
  110. },
  111. }
  112. </script>
  113. <style>
  114. page {
  115. width: 100%;
  116. height: 100%;
  117. background-color: #f7f7f7;
  118. }
  119. </style>
  120. <style lang="scss" scoped>
  121. @import "@/static/css/themes.scss";
  122. .content {
  123. width: 100%;
  124. float: left;
  125. .scroll-box {
  126. width: 100%;
  127. height: calc(100vh - 60px);
  128. .card-box {
  129. border-bottom: 1px solid #cccccc;
  130. .card-content {
  131. padding: 5px 15px;
  132. display: flex;
  133. align-items: center;
  134. .card-info-img {
  135. width: 50px;
  136. height: 50px;
  137. margin-right: 5px;
  138. display: flex;
  139. align-items: center;
  140. justify-content: center;
  141. }
  142. .card-info-text {
  143. line-height: 20px;
  144. font-size: 14px;
  145. flex: 1;
  146. }
  147. }
  148. }
  149. }
  150. }
  151. </style>