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.
 
 
 

140 lines
2.9 KiB

<template>
<view class="pageBg">
<view class="pageBgImg">
<topNavbar title="选择学员"></topNavbar>
<view class="pad">
<view class="searchBox">
<searchRow placeholder="搜索学员姓名、学员手机号" @searchFn="searchFn"></searchRow>
</view>
<view class="ul">
<view class="li" v-for="(item,index) in list" :key="index" @click="chooseSudent(item)">
<view class="icon">
<image src="@/static/images/index/radio_cli.png" mode="" v-if="studentIds.indexOf(item.id)!=-1"></image>
<image src="@/static/images/index/radio_nor.png" mode="" v-else></image>
</view>
<view class="name">{{item.name}}</view>
</view>
</view>
<view style="padding-bottom: 100rpx;" v-if="list.length>6">
<u-loadmore :status="status" />
</view>
<nodata v-if="!list.length&&status=='nomore'"></nodata>
<view class="btn_row">
<view class="btnBg" @click="addSearchSudent">确认学员</view>
</view>
</view>
</view>
</view>
</template>
<script>
import { studentList, studentBindCoach } from '@/config/api.js'
export default {
data() {
return {
params: {
pageNo: 1,
pageSize: 40,
schoolId: '',
coachId: '',
status: 1,
},
total: 40,
list: [],
status: 'loading',
studentIds: []
}
},
onLoad() {
this.params.schoolId = this.vuex_schoolId
},
onPullDownRefresh() {
this.initList()
},
onReachBottom() {
if(this.total>this.list.length) {
this.studentListFn()
}
},
methods: {
initList() {
this.params.pageNo = 1
this.list = []
this.studentListFn()
},
async studentListFn() {
const {data: res} = await studentList(this.params)
this.params.pageNo ++
this.total = res.total
this.list.push(...res.list)
if(this.list.length>=this.total) this.status = 'nomore'
},
searchFn(val) {
this.params.keyWord = val
this.initList()
},
chooseSudent(item) {
let index = this.studentIds.indexOf(item.id)
if(index==-1) {
this.studentIds.push(item.id)
}else {
this.studentIds.splice(index,1)
}
},
addSearchSudent() {
if(!this.studentIds.length) return this.$u.toast('请搜索并选择学员')
uni.$emit('addSearchSudent',this.studentIds )
uni.navigateBack()
}
}
}
</script>
<style lang="scss" scoped>
.btn_row {
position: fixed;
bottom: 0;
left: 0;
padding: 10rpx 0 40rpx 0rpx;
z-index: 9;
width: 100%;
}
.searchBox {
padding: 20rpx 0;
}
.ul {
width: 100%;
.li {
display: flex;
align-items: center;
height: 108rpx;
background: #FFFFFF;
border-radius: 16rpx;
border: 2rpx solid rgba(25,137,250,0.2);
margin-bottom: 20rpx;
padding: 0 20rpx;
.icon {
width: 32rpx;
height: 32rpx;
}
.name {
padding: 0 20rpx;
}
}
}
.btn_row {
display: flex;
justify-content: center;
.btnBorder {
width: 40%;
}
.btnBg {
width: 56%;
}
}
</style>