<template>
	<view v-if="isShow">
		<view class="list">
			<navigator :url="'/topic/teacherDet/teacherDet?id=' + item.id" hover-class="none" class="li ddflex" v-for="(item, index) in pageList" :key="index">
				<image :src="item.headUrl" mode="aspectFill"></image>
				<view class="fflex">
					<view class="tit">{{item.realName}}</view>
					<view class="rec-tag ddflex" v-if="item.userExtend && item.userExtend.label">
						<text class="ddflex" v-for="(it,idx) in item.userExtend.label.split(',')" :key="idx">{{it}}</text>
					</view>
					<!-- <view class="tea-bri tover" v-if="item.fieldValues && item.fieldValues.experience">{{item.fieldValues.experience}}</view> -->
					<view class="brief" v-if="item.userExtend.brief&&item.userExtend.brief!='<p><br></p>'">
						<rich-text :nodes="item.userExtend.brief"></rich-text>
					</view>
				</view>
			</navigator>
		</view>
	</view>
</template>

<script>
const req = require('../../utils/request.js');
const api = require('../../utils/api.js');
const util = require('../../utils/util.js');
const app = getApp();
import foot from "../../components/nav-bar/index";
export default {
	components: {
		foot
	},
	data() {
		return {
			isShow: false,
			opt: {},
			pageList: [],
			isLoad: true,
			form: {
				page: 1,
				limit: 10
			},
		};
	},
	onLoad(options) {
		this.opt = options;
	},
	onShow() {
		this.getPageList(true);
	},
	onReachBottom: function() {
		this.form.page++;
		this.getPageList(false);
	},

	methods: {
		splitLabel(label){
			if(!label){
				return false;
			}else{
				if (label.indexOf("，") > 0){
					return label.split('，');
				}else{
					return label.split(',');
				}
			}
		},
		getPageList(isShow){
			let that = this;
			if (!that.isLoad) return false;
			that.isLoad = false;
			let form = that.form;
			form.merchantId = this.opt.id;
			req.getRequest('/api/v3/sysUser/getDoctorV2',form,res => {
				that.isShow = true;
				if(res&&res.length > 0){
					res.map(it=>{
						if(it.userExtend.brief&&it.userExtend.brief!='<p><br></p>')
						it.userExtend.brief = '<div style="overflow: hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-line-clamp: 3;-webkit-box-orient: vertical;word-break: break-all;">' + it.userExtend.brief + '</div>'
					})
				}
				if (res && res.length == 10) {
					that.isLoad = true;
				}
				if (that.form.page > 1) {
					res = that.pageList.concat(res);
				}
				that.pageList = res;
			},isShow);
		}
	}
};
</script>

<style>
	@import "./teacher.css";
</style>
