<template>
	<!-- '遗产讲述', '达人同游'， 我要跟拍 的共同详情页面 -->
	<view class="page">
		<navbar :title="titles[type]" leftClick @leftClick="$utils.navigateBack" />
		
		<view class="info">
			<!-- 上面 -->
			<view class="top">
				<image :src="detail.roleHead" mode="aspectFill"></image>
				<view class="left">
					<view class="title">
						{{ detail.roleName }}
					</view>
					<view class="left-list">
						<view
						@click="addCollection">
							<button 
							class="share">
								<uv-icon
								name="star"
								size="50rpx"
								></uv-icon>
								收藏
							</button>
						</view>
						<view>
							<button 
							open-type="share"
							class="share">
								<uv-icon
								name="share"
								size="50rpx"
								></uv-icon>
								分享
							</button>
						</view>
						<view
						@click="$refs.contactActionSheet.open()">
							<button 
							class="share">
								<uv-icon
								name="server-man"
								size="50rpx"
								></uv-icon>
								客服
							</button>
						</view>
					</view>
				</view>
			</view>
			<!-- 下面 -->
			<view class="bottom">
				<view>
					<image src="../static/reservationDetail/1.png" mode=""></image>
					<view>
						{{ $dayjs(detail.preTime).format('YYYY-MM-DD') }}
					</view>
				</view>
				<view>
					<image src="../static/reservationDetail/2.png" mode=""></image>
					<view>
						￥{{ detail.price }}
					</view>
				</view>
				<view
				@click="toUrl(detail, type)">
					<image v-if="type == 2" src="../static/reservationDetail/3.png" mode=""></image>
					<image v-else src="../static/reservationDetail/4.png" mode=""></image>
					<view>
						预约
					</view>
				</view>
			</view>
		</view>
	
		<view class="detail">
			<view class="content">
				<view class="thumb-up">
					<uv-icon
					name="thumb-up"
					size="40rpx"
					color="#B12731"
					></uv-icon>
					
					<text>推荐度</text>  <text>{{ detail.recommend }}</text>
				</view>
				
				<view class="text">
					
					<view class="line">
						<view class="left">
							专业擅长
						</view>
						<view class="right">
							{{ detail.skill }}
						</view>
					</view>
					
					<view class="line">
						<view class="left">
							个人简介
						</view>
						<view class="right">
							{{ detail.brief }}
						</view>
					</view>
					
				</view>
			</view>
			
			<view class="video-list">
				<view class="title">
					{{ video_list_titles[type] }}
				</view>
			</view>
			<videoList ref="videoList" :roleId="id"/>
		</view>
		
		
		<contactActionSheet ref="contactActionSheet"/>
		
		<tabber/>
	</view>
</template>

<script>
	import videoList from '@/components/list/videoList.vue'
	import contactActionSheet from '@/components/base/contactActionSheet.vue'
	export default {
		components : {
			videoList,
			contactActionSheet,
		},
		data() {
			return {
				titles: ['遗产讲述', '达人同游', '我要跟拍'],
				video_list_titles: ['讲解现场', '同游现场', '跟拍现场'],
				collectType : [0, 1, 3],
				type: 0,
				id : 0,
				detail : {},
			}
		},
		onLoad(args) {
			this.type = args.type
			this.id = args.id
		},
		onShow() {
			this.$nextTick(() => {
				this.$refs.videoList.queryVideoList()
			})
			this.getData()
		},
		onPullDownRefresh(){
			this.$refs.videoList.queryVideoList()
			this.getData()
		},
		//滚动到屏幕底部
		onReachBottom() {
			this.$refs.videoList.loadMoreData()
		},
		onShareAppMessage(res) {
		    return {
		      title: this.titles[this.type],
		      desc: this.detail.roleName,
		      path: '/pages_order/service/reservationDetail?id=' + this.id
		    }
		},
		methods: {
			// 添加收藏
			addCollection(){
				this.$api('addCollection', {
					itemId : this.detail.id,
					collectionType : this.collectType[this.type],
				}, res => {
					if(res.code == 200){
						this.getData()
						
						uni.showToast({
							title: res.message,
							icon:'none'
						})
					}
				})
			},
			getData(){
				this.$api('queryRoleInfoById', {
					roleInfoId : this.id,
				}, res => {
					uni.stopPullDownRefresh()
					if(res.code == 200){
						this.detail = res.result
					}
				})
			},
			toUrl(detail, type){
				uni.navigateTo({
					url: `/pages_order/order/orderSubscribe?id=${detail.id}&payType=${parseInt(type) + 1}`
				})
			},
		}
	}
</script>

<style scoped lang="scss">
.page{
	.info{
		.top{
			display: flex;
			padding: 40rpx;
			image{
				width: 240rpx;
				height: 280rpx;
				border-radius: 20rpx;
				margin-right: 40rpx;
			}
			.left{
				.title{
					font-size: 32rpx;
					margin-top: 20rpx;
				}
				.left-list{
					display: flex;
					font-size: 26rpx;
					background-color: #fff;
					border-radius: 20rpx;
					padding: 20rpx;
					margin-top: 50rpx;
					box-shadow: 0 0 10rpx 10rpx #00000010;
					>view{
						margin: 20rpx 30rpx;
						display: flex;
						flex-direction: column;
						justify-content: center;
						align-items: center;
					}
				}
			}
		}
		.bottom{
			display: flex;
			justify-content: space-around;
			image{
				width: 80rpx;
				height: 80rpx;
				margin-bottom: 10rpx;
			}
			>view{
				background-color: #fff;
				box-shadow: 0 0 10rpx 10rpx #00000010;
				border-radius: 20rpx;
				height: 180rpx;
				width: 180rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				flex-direction: column;
				color: $uni-color;
				font-size: 28rpx;
			}
		}
	}
	.detail{
		width: 100%;
		background-color: #fff;
		.content{
			padding: 40rpx;
			.thumb-up{
				background-color: #F6F2E7;
				color: $uni-color;
				font-size: 28rpx;
				font-weight: 900;
				padding: 10rpx 25rpx;
				display: flex;
				width: fit-content;
				border-radius: 30rpx;
				text{
					margin-left: 10rpx;
				}
			}
			
			.text{
				.line{
					margin-top: 40rpx;
					display: flex;
					line-height: 50rpx;
					.left{
						width: 180rpx;
						flex-shrink: 0;
						color: $uni-color;
						font-weight: 900;
					}
				}
			}
		}
		.video-list{
			padding: 15rpx;
			.title{
				font-weight: 900;
				color: $uni-color;
				padding: 15rpx;
			}
		}
	}
}
</style>
