<template>
	<view class="content">
		<view class="cont">
			<view class="ping-box">
				<view class="title-box">
					<view class="left">
						<view class="title">患者评价({{total}})</view>
					</view>
				</view>
				<mescroll-body top="88rpx" bottom="0" ref="mescrollRef" @init="mescrollInit"    :down="downOption" :up="upOption" @down="downCallback" @up="upCallback">
				
				<view class="ping-list">
					<view class="ping-item" v-for="(item) in dataList">
					 	<view class="left">
							<image :src="item.avatar==null?'https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/my_heads_icon.png':item.avatar"></image>
						</view>
						<view class="right">
							<view class="user-name-box">
								<view class="user-name">
									{{item.nickName}}
								</view>
								<view class="ping-star">
									<u-rate activeColor="#ffc603" count="5" readonly v-model="item.pingStar"></u-rate>
								</view>
							</view>
							<view class="ping-cont">
								{{item.pingContent}}
							</view>
							<view class="ping-time">
								{{item.pingTime}}
							</view>
						</view>
					</view>
				</view>
				</mescroll-body>
			</view>
		</view>
	</view>
</template>
<script>
	import {getDoctorPingList} from '@/api/doctor.js'
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin], // 使用mixin
		data() {
			return {
				total:0,
				doctorId:null,
				mescroll:null,
				downOption: {   //下拉刷新
				 	use:true,
					auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
				},
				upOption: {
					onScroll:false,
					use: true, // 是否启用上拉加载; 默认true
					page: {
						pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
						size: 10 // 每页数据的数量,默认10
					},
					noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
					textNoMore:"已经到底了",
					empty: {
						icon:'https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/empty_icon.png',
						tip: '暂无数据'
					}
				},
				dataList: []
			}
		},
		onLoad(options) {
			this.doctorId=options.doctorId;
		},
		methods: {
			mescrollInit(mescroll) {
				this.mescroll = mescroll;
			},
			/*下拉刷新的回调 */
			downCallback() {
				this.mescroll.resetUpScroll()
			},
			/*上拉加载的回调*/
			upCallback(page) {   
				//联网加载数据
				var that = this;
				var data = {
					doctorId: this.doctorId,
					pageNum: page.num,
					pageSize: page.size
				};
				getDoctorPingList(data).then(res => {
					if(res.code==200){
						this.total=res.data.total;
						if (page.num == 1) {
							that.dataList = res.data.list; 
							
						} else {
							that.dataList = that.dataList.concat(res.data.list);
							 
						}
						that.mescroll.endBySize(res.data.list.length, res.data.total);
						
					}else{
						uni.showToast({
							icon:'none',
							title: "请求失败",
						});
						that.dataList = null;
						that.mescroll.endErr();
					}
				});
			},
		}
	}
</script>
<style scoped lang="scss">
	.content{
		height: 100%;
		position: relative;
		.cont{
			width: 100%;
			display: flex;
			flex-direction: column;
			.ping-box{
				.title-box{
					padding: 0rpx 20rpx;
					position: fixed;
					line-height: 88rpx;
					display: flex;
					flex-direction: row;
					align-items: center;
					justify-content: space-between;
					.left{
						display: flex;
						align-items: center;
						justify-content: center;
						.title{
							font-size: 32upx;
							font-family: PingFang SC;
							font-weight: bold;
							color: #111111;
						}
						// .line{
						// 	margin-right: 15rpx;
						// 	height: 30rpx;
						// 	width: 6rpx;
						// 	background-color: #2583EB;
							
						// }
					}
					.more{
						display: flex;
						align-items: center;
						justify-content: center;
						font-size: 28upx;
						font-family: PingFang SC;
						color: #9a9a9c;
						image{
							margin-left: 10rpx;
							width: 30rpx;
							height:30rpx;
						}
					}
					
					 
				}
				.ping-list{
					display: flex;
					flex-direction: column;
					align-items: flex-start;
					justify-content: flex-start;
					padding: 20rpx;
					.ping-item{
						margin-bottom: 15rpx;
						padding: 15rpx;
						box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
						background-color: #fff;
						border-radius: 15rpx;
						width: 100%;
						display: flex;
						align-items: flex-start;
						justify-content: flex-start;
						&:last-child{
							margin-bottom: 0rpx;
						}
						.left{
							image{
								width:80rpx;
								height:80rpx;
								border-radius: 50%;
							}
						}
						.right{
							width: 100%;
							margin-left: 15rpx;
							.user-name-box{
								display: flex;
								align-items: center;
								justify-content: space-between;
								font-size: 28upx;
								font-family: PingFang SC;
								font-weight: bold;
								color: #111111;
							}
							.ping-cont{
								margin-top: 10rpx;
								font-size: 28upx;
								font-family: PingFang SC;
								color: #9a9a9c;
							}
							.ping-time{
								margin-top: 10rpx;
								font-size: 28upx;
								font-family: PingFang SC;
								color: #9a9a9c;
							}
							 
						}
					}
				}
			}
		}
	}
	 
</style>
