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.

155 lines
3.4 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" @click.capture="$goPage('/pages/recordEntry/student/addStudent/searchStudent')">
  7. <searchRow placeholder="搜索学员姓名、学员手机号" :disable="true"></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="btnBorder">已选学员{{studentIds.length}}</view>
  24. <view class="btnBg" @click="studentBindCoachFn">确认学员</view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import { studentList, studentBindCoach } from '@/config/api.js'
  32. export default {
  33. data() {
  34. return {
  35. params: {
  36. pageNo: 1,
  37. pageSize: 40,
  38. schoolId: '',
  39. coachId: '',
  40. status: 1,
  41. },
  42. total: 40,
  43. list: [],
  44. status: 'loading',
  45. studentIds: []
  46. }
  47. },
  48. onLoad() {
  49. uni.$on('addSearchSudent',(ids)=>{
  50. console.log(this.studentIds)
  51. console.log('监听不到?')
  52. this.studentIds = [...new Set([...this.studentIds,...ids])]
  53. })
  54. this.params.schoolId = this.vuex_schoolId
  55. this.studentListFn()
  56. },
  57. onPullDownRefresh() {
  58. this.initList()
  59. },
  60. onReachBottom() {
  61. if(this.total>this.list.length) {
  62. this.studentListFn()
  63. }
  64. },
  65. methods: {
  66. initList() {
  67. this.params.pageNo = 1
  68. this.list = []
  69. this.studentListFn()
  70. },
  71. async studentListFn() {
  72. const {data: res} = await studentList(this.params)
  73. this.params.pageNo ++
  74. this.total = res.total
  75. this.list.push(...res.list)
  76. if(this.list.length>=this.total) this.status = 'nomore'
  77. },
  78. chooseSudent(item) {
  79. let index = this.studentIds.indexOf(item.id)
  80. if(index==-1) {
  81. this.studentIds.push(item.id)
  82. }else {
  83. this.studentIds.splice(index,1)
  84. }
  85. },
  86. async studentBindCoachFn() {
  87. if(!this.studentIds.length) return this.$u.toast('请搜索并选择学员')
  88. let obj = {
  89. "studentIds": this.studentIds,
  90. "coachId": this.vuex_coachId,
  91. // "coachName": this.vuex_
  92. }
  93. const res = await studentBindCoach(obj)
  94. if(res.code==0) {
  95. this.$u.toast('绑定学员成功')
  96. setTimeout(()=>{
  97. uni.switchTab({
  98. url: '/pages/tabbar/student/index'
  99. })
  100. },1500)
  101. }
  102. }
  103. }
  104. }
  105. </script>
  106. <style lang="scss" scoped>
  107. .btn_row {
  108. position: fixed;
  109. bottom: 0;
  110. left: 0;
  111. padding: 10rpx 28rpx;
  112. z-index: 9;
  113. width: 100%;
  114. }
  115. .searchBox {
  116. padding: 20rpx 0;
  117. }
  118. .ul {
  119. width: 100%;
  120. .li {
  121. display: flex;
  122. align-items: center;
  123. height: 108rpx;
  124. background: #FFFFFF;
  125. border-radius: 16rpx;
  126. border: 2rpx solid rgba(25,137,250,0.2);
  127. margin-bottom: 20rpx;
  128. padding: 0 20rpx;
  129. .icon {
  130. width: 32rpx;
  131. height: 32rpx;
  132. }
  133. .name {
  134. padding: 0 20rpx;
  135. }
  136. }
  137. }
  138. .btn_row {
  139. display: flex;
  140. justify-content: space-between;
  141. .btnBorder {
  142. width: 40%;
  143. }
  144. .btnBg {
  145. width: 56%;
  146. }
  147. }
  148. </style>