<template>
	<view class="content">
		<view class="top-fixed">
			 <u-tabs
			  :scrollable="false"
			  :list="tabs"  
			  lineColor="#2583EB"
			 @change="tabChange">
			 </u-tabs>
		</view>
		<mescroll-body top="88rpx" bottom="0" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
		<view class="prescribe-list">
			<view v-for="(item,index) in dataList" :key="index" class="item" @click="navTo('/pages_order/prescribeDetails?prescribeId='+item.preId)">
					<view class="ordersn-box">
						<view class="num">处方单号：{{item.pid||''}}</view>
						<view class="status-box">
							<text   class="text info" v-if="item.status==0">待开方</text>
							<text   class="text success" v-if="item.status==1">已开方</text>
							<text   class="text black" v-if="item.status==2">已拒绝</text>
						</view>
					</view>
					<view class="ask-text"  >诊断结果：{{item.tags||''}}</view>
				<!-- 	<view class="drug-list" >
						<view  class="drug-item" v-for="(subItme,index) in item.drugs" >
							<view class="drug-info"  >
								<view class="name-box ellipsis">
									<view class="tag">{{index+1}}</view>{{subItme.drugName}}
								</view>
							</view>
						</view>
					</view> -->
					<!-- <view class="ask-text">审核结果：{{item.auditReason||''}}</view> -->
					<view class="patient-text">患者：{{item.userFamilyName}} {{item.userFamilyAge}}岁 {{item.userFamilyGender==1?'男':'女'}} </view>
					<view class="ask-time" v-if="item.createTime!=null">提交时间：{{item.createTime}}</view>
					<view class="ask-time" v-if="item.createdTime!=null">开方时间：{{item.createdTime}}</view>
				</view>
		</view>
		</mescroll-body>
	</view>
</template>

<script>
	import {getPrescribeList} from '@/api/prescribe.js'
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin], 
		data() {
			return {
				status:0,
				tabs:[
					{
						id:0,
						name:'待开方'
					},
					{
						id:1,
						name:'已开方'
					},
					{
						id:2,
						name:'已拒绝'
					}
					 
				],
				mescroll:null,
				// 上拉加载的配置
				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() {
			
		},
		methods: {
			tabChange(item){
				this.status=item.id
				console.log(item)
				this.mescroll.resetUpScroll()
			},
			navTo(url){
				uni.navigateTo({
					url: url
				})
			},
			mescrollInit(mescroll) {
				this.mescroll = mescroll;
			},
			/*下拉刷新的回调 */
			downCallback(mescroll) {
				mescroll.resetUpScroll()
			},
			upCallback(page) {
				//联网加载数据
				var that = this;
				var data = {
					status:this.status,
					pageNum: page.num,
					pageSize: page.size
				};
				getPrescribeList(data).then(res => {
					if(res.code==200){
						//设置列表数据
						if (page.num == 1) {
							that.dataList = res.datas; 
						} else {
							that.dataList = that.dataList.concat(res.datas);
						}
						that.mescroll.endBySize(res.datas.length, res.total);
						
					}else{
						uni.showToast({
							icon:'none',
							title: "请求失败",
						});
						that.dataList = null;
						that.mescroll.endErr();
					}
				});
			},
			showImg(item) {
				 var imgArr = [];
				 imgArr.push(item.rpUrl)
				 //预览图片
				 uni.previewImage({
				 	urls: imgArr,
				 	current: imgArr[0]
				 });
			}
		}
	}
</script>

<style lang="scss">
	.content{
		.top-fixed{
			width: 100%;
			position: fixed;
			top: 0;
			left: 0;
			z-index: 10;
			height: 88upx;
			background-color: #fff;
		}
		.prescribe-list{
			padding: 20upx;
			.item{
				background: #FFFFFF;
				border-radius: 16upx;
				padding: 30upx;
				position: relative;
				margin-bottom: 20upx;
				.ordersn-box{
					display: flex;
					align-items: center;
					justify-content: space-between;
					padding: 0upx 0 10upx;
					.num{
						font-size: 26upx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #999999;
						line-height: 1;
					}
					.status-box{
						display: flex;
						align-items: center;
						.text{
							font-size: 28upx;
							font-family: PingFang SC;
							font-weight: 500;
							line-height: 1;
							&.success{
								color: #2583EB;
							}
							&.black{
								color: #111111;
							}
							&.info{
								color: #999999;
							}
						}
					}
				}
				.doctor-info{
					display: flex;
					align-items: center;
					.img-box{
						width: 80upx;
						height: 80upx;
						background: #E0FFF8;
						border-radius: 50%;
						overflow: hidden;
						margin-right: 20upx;
						image{
							width: 100%;
							height: 100%;
						}
					}
					.name{
						font-size: 28upx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #666666;
						line-height: 48upx;
						text{
							margin-right: 10upx;
						}
					}
				}
				.ask-text{
					margin: 24rpx 0rpx;
					font-size: 30upx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #111111;
					line-height: 42upx;
				}
				.patient-text{
					font-size: 24upx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #999999;
					margin-bottom: 15upx;
				}
				.ask-time{
					font-size: 24upx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #999999;
				}
				 
			}
		}
	}
	.drug-list{
		.drug-item{
			padding: 10upx 0;
			border-bottom: 1px soli #F0F0F0;
			display: flex;
			align-items: center;
			.drug-info{
				width: 100%;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				.name-box{
					font-size: 28upx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #111111;
					line-height: 40upx;
					.tag{
						display: inline-block;
						padding: 0 6upx;
						height: 30upx;
						background: linear-gradient(90deg, #2583EB 0%, #2EDAD4 100%);
						border-radius: 4upx;
						margin-right: 10upx;
						font-size: 22upx;
						font-family: PingFang SC;
						font-weight: bold;
						color: #FFFFFF;
						line-height: 30upx;
						float: left;
						margin-top: 7upx;
					}
				}
				 
				 
			}
		}
	}
</style>
