You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

139 lines
2.9 KiB

7 months ago
7 months ago
7 months ago
  1. <template>
  2. <view class="pageBg">
  3. <view class="pageBgImg">
  4. <topNavbar title="选择学员"></topNavbar>
  5. <view class="pad">
  6. <view class="searchBox">
  7. <searchRow placeholder="搜索学员姓名、学员手机号" @searchFn="searchFn"></searchRow>
  8. </view>
  9. <view class="ul">
  10. <view class="li" v-for="(item,index) in list" :key="index" @click="chooseSudent(item)">
  11. <view class="icon">
  12. <image src="@/static/images/index/radio_cli.png" mode="" v-if="studentIds.indexOf(item.id)!=-1"></image>
  13. <image src="@/static/images/index/radio_nor.png" mode="" v-else></image>
  14. </view>
  15. <view class="name">{{item.name}}</view>
  16. </view>
  17. </view>
  18. <view style="padding-bottom: 100rpx;" v-if="list.length>6">
  19. <u-loadmore :status="status" />
  20. </view>
  21. <nodata v-if="!list.length&&status=='nomore'"></nodata>
  22. <view class="btn_row">
  23. <view class="btnBg" @click="addSearchSudent">确认学员</view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. import { studentList, studentBindCoach } from '@/config/api.js'
  31. export default {
  32. data() {
  33. return {
  34. params: {
  35. pageNo: 1,
  36. pageSize: 40,
  37. schoolId: '',
  38. coachId: '',
  39. status: 1,
  40. },
  41. total: 40,
  42. list: [],
  43. status: 'loading',
  44. studentIds: []
  45. }
  46. },
  47. onLoad() {
  48. this.params.schoolId = this.vuex_schoolId
  49. },
  50. onPullDownRefresh() {
  51. this.initList()
  52. },
  53. onReachBottom() {
  54. if(this.total>this.list.length) {
  55. this.studentListFn()
  56. }
  57. },
  58. methods: {
  59. initList() {
  60. this.params.pageNo = 1
  61. this.list = []
  62. this.studentListFn()
  63. },
  64. async studentListFn() {
  65. const {data: res} = await studentList(this.params)
  66. this.params.pageNo ++
  67. this.total = res.total
  68. this.list.push(...res.list)
  69. if(this.list.length>=this.total) this.status = 'nomore'
  70. },
  71. searchFn(val) {
  72. this.params.keyWord = val
  73. this.initList()
  74. },
  75. chooseSudent(item) {
  76. let index = this.studentIds.indexOf(item.id)
  77. if(index==-1) {
  78. this.studentIds.push(item.id)
  79. }else {
  80. this.studentIds.splice(index,1)
  81. }
  82. },
  83. addSearchSudent() {
  84. if(!this.studentIds.length) return this.$u.toast('请搜索并选择学员')
  85. uni.$emit('addSearchSudent',this.studentIds )
  86. uni.navigateBack()
  87. }
  88. }
  89. }
  90. </script>
  91. <style lang="scss" scoped>
  92. .btn_row {
  93. position: fixed;
  94. bottom: 0;
  95. left: 0;
  96. padding: 10rpx 0 40rpx 0rpx;
  97. z-index: 9;
  98. width: 100%;
  99. }
  100. .searchBox {
  101. padding: 20rpx 0;
  102. }
  103. .ul {
  104. width: 100%;
  105. .li {
  106. display: flex;
  107. align-items: center;
  108. height: 108rpx;
  109. background: #FFFFFF;
  110. border-radius: 16rpx;
  111. border: 2rpx solid rgba(25,137,250,0.2);
  112. margin-bottom: 20rpx;
  113. padding: 0 20rpx;
  114. .icon {
  115. width: 32rpx;
  116. height: 32rpx;
  117. }
  118. .name {
  119. padding: 0 20rpx;
  120. }
  121. }
  122. }
  123. .btn_row {
  124. display: flex;
  125. justify-content: center;
  126. .btnBorder {
  127. width: 40%;
  128. }
  129. .btnBg {
  130. width: 56%;
  131. }
  132. }
  133. </style>