signStudentList.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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.list.forEach(site => site.checked = false)
  80. this.tableList = this.tableList.concat(res.data.list)
  81. this.isOver = res.data.list.length != 10
  82. }).catch(error => {
  83. this.triggered = false
  84. this.$refs.uTips.show({
  85. title: error.data.msg,
  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=>{return {
  99. id: site.id,
  100. name: site.name,
  101. url: site.url,
  102. hasUrl: site.hasUrl,
  103. checked: false,
  104. }})
  105. })
  106. uni.navigateBack()
  107. }
  108. },
  109. }
  110. </script>
  111. <style>
  112. page {
  113. width: 100%;
  114. height: 100%;
  115. background-color: #f7f7f7;
  116. }
  117. </style>
  118. <style lang="scss" scoped>
  119. @import "@/static/css/themes.scss";
  120. .content {
  121. width: 100%;
  122. float: left;
  123. .scroll-box {
  124. width: 100%;
  125. height: calc(100vh - 60px);
  126. .card-box {
  127. border-bottom: 1px solid #cccccc;
  128. .card-content {
  129. padding: 5px 15px;
  130. display: flex;
  131. align-items: center;
  132. .card-info-img {
  133. width: 50px;
  134. height: 50px;
  135. margin-right: 5px;
  136. display: flex;
  137. align-items: center;
  138. justify-content: center;
  139. }
  140. .card-info-text {
  141. line-height: 20px;
  142. font-size: 14px;
  143. flex: 1;
  144. }
  145. }
  146. }
  147. }
  148. }
  149. </style>