<template>
	<view class="postDetail">
		<navbar leftClick @leftClick="$utils.navigateBack" title="详情" />

		<view class="works">
			
			<userHeadItem :item="detail"/>
			
			<daynamicInfo :item="detail"/>
			
			<view class="bottom">
				<view class="browse">
					{{ detail.isBrowse }}浏览
				</view>
				<view class="browse">
					{{ detail.isComment }}条评论
				</view>
				
				<!-- <view class="Leavingamessage"
				@click="openLocation(detail.latitude, detail.longitude)"
				v-if="detail.latitude && detail.longitude">
					<uv-icon size="40rpx" name="map"></uv-icon>
					导航
				</view> -->
				
				<callPhone
				style="margin-left: auto;"
				:phone="item.phone" 
				:sexName="item.sex"/>
			</view>
		</view>

	
		<commentList 
		@getData="getData"
		:list="list"
		:params="params"
		/>

		
	</view>
</template>

<script>
	import mixinsSex from '@/mixins/sex.js'
	import mixinsList from '@/mixins/list.js'
	import commentList from '../components/list/comment/commentList.vue'
	import userHeadItem from '@/components/list/dynamic/userHeadItem.vue'
	import daynamicInfo from '@/components/list/dynamic/daynamicInfo.vue'
	export default {
		mixins: [mixinsSex, mixinsList],
		components: {
			commentList,
			userHeadItem,
			daynamicInfo,
		},
		data() {
			return {
				detail: {},
				mixinsListApi : 'getCommentPage',
				params : {
					type : '0',
					orderId : '',
					name : '',
				},
				id : 0,
			}
		},
		onLoad(options) {
			// this.$route.query的参数
			console.log(options)
			this.id = options.id
			this.queryParams.type = this.params.type
			this.queryParams.orderId = options.id
			
			this.params.orderId = options.id
		},
		onShareAppMessage(res) {
			return {
				title: this.detail.title,
				path: '/pages_order/post/postDetail?id=' + this.id
			}
		},
		onPullDownRefresh() {
			this.getDetail()
		},
		onShow() {
			this.getDetail()
		},
		onShareAppMessage(res) {
			// return {
			//   title: this.item.title,
			//   desc: this.item.content && this.item.content.slice(0, 30),
			//   path: '/pages/publish/postDetail?id=' + this.id
			// }
		},
		methods: {
			getDetail() {
				this.$api('getPostDetail', {
					id: this.id
				}, res => {
					uni.stopPullDownRefresh()
					if (res.code == 200) {
						
						this.params.name = res.result.userName

						this.detail = res.result
					}
				})
			},
			callPhone(){
				uni.makePhoneCall({
					phoneNumber: this.detail.phone,
					success() {
						console.log('安卓拨打成功');
					},
					fail() {
						console.log('安卓拨打失败');
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.postDetail {
		padding-bottom: env(safe-area-inset-bottom);
		.works {
			background-color: #fff;
			padding: 40rpx;
			border-radius: 20rpx;

			.bottom {
				display: flex;
				margin-top: 20rpx;
				font-size: 24rpx;

				.browse {
					margin: 0rpx 30rpx;
					color: rgb(132, 132, 132);
				}

				.Leavingamessage {
					margin-left: auto;
					display: flex;
					align-items: center;
				}
				
				.phone{
					background-color: rgba($uni-color, 0.2);
					color: $uni-color;
					padding: 8rpx 16rpx;
					border-radius: 10rpx;
					margin-left: auto;
					image{
						width: 20rpx;
						height: 20rpx;
					}
				}
			}
		}
		
	}
</style>