<template>
	<view class="app">
		<view class="item">
			<image :src="list.itemPictureUrl"></image>
			<view class="huanyao" v-if='list.nurseItemName'>{{list.nurseItemName}}
			</view>
			<view class="huanyao" v-else>暂无
			</view>
			<!-- <view class="pingfen">
			<u-rate :count="5" value="2"></u-rate>
		</view> -->
			<view class="servicetime">服务时长:{{list.serveDurationUnit?list.serveDurationUnit:'0'}}</view>
			<view class="price">￥{{list.nurseItemPrice==null?'0':list.nurseItemPrice}}</view>
		</view>
		<view class="Consumablespackage" v-if='list.itemConsumableList'>耗材包详情:
			<span>￥{{list.consumableTotalPrice==null?'0':list.consumableTotalPrice}}</span>
			<view class="detail" v-for='(item,index) in list.itemConsumableList' :key="index">
				·{{item.consumableDetail}}
				<span>{{item.consumableCount}}{{item.consumableUnit}}/￥{{item.consumablePrice}}</span>
			</view>
		</view>
		<view class="detailtitle">
			<view class="Introduction">服务详情:</view>
			<view class="textInfo" v-html="list.nurseItemContent">
			</view>
		</view>
		<view class="appointment" @tap.stop='goappointments(item)'>预约</view>
		<u-toast ref="uToast" />
		<u-mask :show="usershow" class='mask'>
			<view class="information">
				<image src="../../static/information.png" mode=""></image>
				<view class="title">
					请完善个人信息
				</view>
				<view class="cancel" @tap='usershow=false'>
					取消
				</view>
				<view class="determine" @tap='goinformation'>
					去完善
				</view>
			</view>
		</u-mask>
	</view>
</template>
<script>
	import {
		AppIdentification
	} from '@/api/AppIdentification/index.js'
	import baseurl from '@/api/baseurl.js'
	import {
		getAppStationItemInfo
	} from '@/api/ProjectDetails/index.js'
	export default {
		data() {
			return {
				baseurl: '',
				list: {},
				orderNo: '',
				usershow: false, //完善信息开关
				list: [], //护理站list
				timer: null,
				stationId: null,
				stationItemId: null,
				stationItemPriceId: null,
			}
		},
		onLoad(options) {
			this.stationId = options.stationId
			this.stationItemId = options.stationItemId
			this.stationItemPriceId = options.stationItemPriceId
		},
		onShow() {
			this.usershow = false
			// 耗材包详情方法调用
			this.getlist(this.stationId, this.stationItemId, this.stationItemPriceId)
		},
		methods: {
			//预约
			goappointments() {
				let that = this
				try {
					const value = uni.getStorageSync('openid');
					const value2 = uni.getStorageSync('patientId');
					if (value && value2) {
						AppIdentification(value2).then(res => {
							if (res.code == 200) {
								if (res.data.loginFlag) {
									that.usershow = false
									uni.navigateTo({
										url: `/pages/appointmenttime/appointmenttime?stationId=${this.list.stationId}&stationItemId=${this.list.stationItemId}&stationItemPriceId=${this.list.stationItemPriceId}`,
									})
								} else {
									that.usershow = true
								}
							} else if (res.code == 9999) {

							} else {
								that.$refs.uToast.show({
									title: res.msg,
									type: 'error'
								})
								if (that.timer) {
									clearTimeout(that.timer)
								}
								that.timer = setTimeout(e => {
									uni.navigateTo({
										url: '/pages/login/login'
									})
								}, 1500)
							}
						})
					} else {
						that.$refs.uToast.show({
							title: '未登录,请先登录',
							type: 'error'
						})
						if (that.timer) {
							clearTimeout(that.timer)
						}
						that.timer = setTimeout(e => {
							uni.navigateTo({
								url: '/pages/login/login'
							})
						}, 1500)
					}
				} catch (e) {
					uni.navigateTo({
						url: '/pages/login/login'
					})
				}
			},
			//跳转完善页面
			goinformation() {
				this.usershow = false
				uni.navigateTo({
					url: '/pages/information/information'
				})
			},
			// 信息
			getlist(stationId, stationItemId, stationItemPriceId) {
				getAppStationItemInfo(stationId, stationItemId, stationItemPriceId).then(res => {
					if (res.data.nurseItemContent) {
						res.data.nurseItemContent = res.data.nurseItemContent.replace(/\<img/gi,
							"<br/> <img class='richPic'")
					}
					res.data.itemPictureUrl = baseurl + res.data.itemPictureUrl
					this.list = res.data
				})
			},
		},
		//1.分享给朋友
		onShareAppMessage(res) {
			return {
				title: '泉医到家',
				path: '/pages/startup/startup',
			}
		},
		//2.分享到朋友圈
		onShareTimeline(res) {
			return {
				title: '泉医到家',
				path: '/pages/startup/startup',
			}
		},
	}
</script>

<style lang="scss">
	@import './ProjectDetails.scss';
</style>
