江西小程序管理端
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.

137 lines
2.9 KiB

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