<template>
	<view class="content">
		<view class="top-fixed">
			 <u-tabs
			  :scrollable="false"
			  :list="tabs"  
			  lineColor="#2583EB"
			 @change="statusChange">
			 </u-tabs>
		</view>
		<mescroll-body top="88rpx" bottom="0" ref="mescrollRef" @init="mescrollInit"    :down="downOption" :up="upOption" @down="downCallback" @up="upCallback">
		<view class="order-list">
			<view class="order-item"  v-for="(item) in dataList" @click="navTo('./inquiryOrderDetails?orderId='+item.orderId)">
				<view class="order-top"  >
					<view class="left"  >
			 
						<image class="head" mode="aspectFill" :src="item.avatar"></image>
						<view class="name">
							{{item.doctorName}}
						</view>
					</view>
					<view class="status red" v-if="item.status==1">
						未评价
					</view>
					<view class="status green" v-if="item.status==2">
						已评价
					</view>
				</view>
				<view class="order-cont">
					<view class="order-desc">咨询总结:{{item.reportSummary}}</view>
					<view class="order-time-box">
						<view class="order-time">
							<view class="time">{{item.createTime}}   </view>
						</view>
						<view class="right">
							<view class="btn green" v-if="item.status==1" @click.stop="doPing(item)">去评价</view>
							<view class="btn green"   @click.stop="showDetails(item)">查看</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		</mescroll-body>
	</view>
</template>

<script>
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	import {getDrugReportList} from '@/api/drugReport'
	export default {
		mixins: [MescrollMixin], // 使用mixin
		data() {
			return {
				tabs:[
					{
						id:0,
						name:'全部'
					},
					{
						id:1,
						name:'待评价'
					},
					{
						id:2,
						name:'已评价'
					}
					 
				],
				status:0,
				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() {
			var that=this;
			uni.$on('refreshDrugReportList', () => {
				that.mescroll.resetUpScroll()
			})
		},
		onShow() {
		},
		methods: {
			doPing(item){
				uni.navigateTo({
					url: "./drugReportPing?reportId="+item.reportId
				})
			},
			showDetails(item){
				uni.navigateTo({
					url: "./drugReportDetails?reportId="+item.reportId
				})
			},
			statusChange(item){
				this.status=item.id
				console.log(item)
				this.mescroll.resetUpScroll()
			},
			navTo(url){
				uni.navigateTo({
					url: url
				})
			},
			mescrollInit(mescroll) {
				this.mescroll = mescroll;
			},
			/*下拉刷新的回调 */
			downCallback() {
				this.mescroll.resetUpScroll()
			},
			/*上拉加载的回调*/
			upCallback(page) {   
				//联网加载数据
				var that = this;
				var data = {
					pageNum: page.num,
					pageSize: page.size
				};
				if(this.status!=0){
					data.status=this.status
				}
				getDrugReportList(data).then(res => {
					if(res.code==200){
						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 lang="scss">
	page{
		
		height: 100%;
		background: #f6f6f6;
	}
</style>
<style scoped lang="scss">
	.content{
		height: 100%;
		.top-fixed{
			width: 100%;
			position: fixed;
			top: 0;
			left: 0;
			z-index: 10;
			height: 88upx;
			background-color: #fff;
		}
		.order-list{
			width: 100%;
			padding: 15rpx;
			display: flex;
			flex-direction: column;
			align-items: flex-start;
			justify-content: flex-start;
			.order-item{
				margin-bottom: 20rpx;
				width: 100%;
				padding: 20rpx;
				box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
				background-color: #fff;
				border-radius: 15rpx;
				display: flex;
				flex-direction: column;
				align-items: flex-start;
				justify-content: flex-start;
				.order-top{
					display: flex;
					align-items: center;
					justify-content: space-between;
					width: 100%;
					padding-bottom: 15rpx;
					border-bottom: 1px solid #efefef;
					.left{
						display: flex;
						align-items: center;
						justify-content: flex-start;
						 
						image{
							width:80rpx;
							height:80rpx;
							border-radius: 50%;
						}
						.title{
							font-size: 32upx;
							font-family: PingFang SC;
							font-weight: bold;
							color: #111111;
						}
						.name{
							margin-left: 20rpx;
							font-size: 32upx;
							font-family: PingFang SC;
							font-weight: bold;
							color: #111111;
						}
						 
					}
					.status{
						font-size: 28upx;
						font-family: PingFang SC;
					}
					.red{
						
						color: #db5053;
					}
					.green{
						color: #2583EB;
					}
					 
				}
				.order-cont{
					width: 100%;
					margin-top: 20rpx;
					.order-desc{
						margin-top: 15rpx;
						font-size: 28upx;
						font-family: PingFang SC;
						// font-weight: bold;
						color: #111111;
					}
					.order-time-box{
						width: 100%;
						margin-top: 15rpx;
						display: flex;
						align-items: center;
						justify-content: space-between;
						.order-time{
							display: flex;
							align-items: center;
							justify-content: flex-start;
							.time{
								font-size: 28upx;
								font-family: PingFang SC;
								color: #9a9a9c;
							}
							.count{
								margin-left: 10rpx;
								font-size: 28upx;
								font-family: PingFang SC;
								color: #111;
							}
						}
						.right{
							display: flex;
							align-items: center;
							justify-content: flex-end;
							.btn{
								margin-left: 10rpx;
								padding: 10rpx 30rpx;
								font-size: 28rpx;
								border-radius: 30rpx;
							}
							.red{
								background-color: #2583EB;
								color: #fff;
							}
							.green{
								border: 1rpx solid #2583EB;
								color: #2583EB;
							}
						}
					}
				}
				
			}
		} 
		
	}
	 
</style>
