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

152 lines
3.4 KiB

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