<template>
	<view style="margin-bottom: 100rpx;" v-if="isShowView">
		<!-- 处方信息 -->
		<view class="prescription-info-box">
			<!-- <view class="prescription-state-title">医生/药师正在审方中，请耐心等等...</view> -->
			<view class="prescription-state-title">
				<view class="prescription-state-title" v-if="detail.state == 0">医生/药师正在审方中，请耐心等等...</view>
				<block v-if="detail.state == 1">
					<view>医生/药师已根据处方进行报价</view>
					<view class="baojia" @click="jumpUrl('mine/orderDet/orderDet?id=' + detail.orderId)">查看报价</view>
				</block>
				<view class="prescription-state-title" v-if="detail.state == 2">已驳回：{{ detail.reason }}</view>
			</view>
			<view class="prescription-data">
				<text class="prescription-tinfo">服务处方编号</text>
				<text class="prescription-dinfo">{{ detail.id }}</text>
			</view>
			<view class="prescription-data">
				<text class="prescription-tinfo">处方提交时间</text>
				<text class="prescription-dinfo">{{ detail.createDate }}</text>
			</view>
			<view class="prescription-data" v-if="detail.phone">
				<text class="prescription-tinfo">联系电话</text>
				<text class="prescription-dinfo">{{ detail.phone }}</text>
			</view>
		</view>
		<!-- 处方图 -->
		<view class="prescription-image-box">
			<view>处方图</view>
			<view>
				<image v-for="(item, index) in drugImgUrl" @click="previewImg(drugImgUrl, index)" :key="index" class="prescription-image" :src="item" mode="widthFix"></image>
			</view>
			<view class="service-item bottom-border">
				<view>是否需要代煎药</view>
				<view>{{ detail.isFrying ? '是' : '否' }}</view>
			</view>
			<view class="service-item bottom-border">
				<view>是否是孕妇</view>
				<view>{{ detail.isPregnant ? '是' : '否' }}</view>
			</view>
			<view class="service-item">
				<view>备注</view>
				<view>{{ detail.remarks }}</view>
			</view>
		</view>
		<!-- 收货地址 -->
		<view class="prescription-address-box" v-if="detail.addressDTO">
			<view>收获地址</view>
			<view class="address ddflex">
				<image class="address-icon" src="../static/images/area.png"></image>
				<view class="fflex">
					<view>{{ detail.addressDTO.address + detail.addressDTO.house }}</view>
					<view class="address-user">{{ detail.addressDTO.name }} {{ detail.addressDTO.phone }}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
const app = getApp();
const req = require('../../utils/request.js');
const api = require('../../utils/api.js');
const utils = require('../../utils/util.js');
export default {
	data() {
		return {
			isShowView: false,
			detail: '',
			drugImgUrl: [],
			id: ''
		};
	},
	components: {},
	onLoad: function(options) {
		this.id = options.id;
		this.getDetail();
	},
	onShow() {},
	methods: {
		jumpUrl(url) {
			app.globalData.navigateTo(url);
		},

		getDetail() {
			req.getRequest(
				'/api/orderdurg/getOrderDrug',
				{
					id: this.id
				},
				data => {
					this.detail = data;
					if (this.detail.drugImgUrl) {
						this.drugImgUrl = this.detail.drugImgUrl.split(',');
					}
					this.isShowView = true;
				},
				true
			);
		},

		//预览图片
		previewImg(picUrls, index) {
			//预览合同图片
			var src = picUrls[index];
			let imgs = picUrls;
			uni.previewImage({
				current: src, // 当前显示图片的http链接
				urls: imgs
			});
		}
	},
	mounted() {}
};
</script>

<style>
@import './detail.css';
</style>
