<template>
	<view class="submit">
		
		<view class=""
		@click="$refs.contactActionSheet.open()"
		v-if="!article">
			<button
			class="share">
				<uv-icon 
				size="40rpx"
				name="chat"></uv-icon>
				<!-- star-fill -->
				<view class="">
					客服
				</view>
			</button>
		</view>
		
		<view class=""
		@click="addCollection">
			<button
			class="share">
				<uv-icon size="40rpx" color="#FF4340"
				v-if="collectonFlag" 
				name="star-fill"></uv-icon>
				<uv-icon
				name="star"
				v-else
				size="40rpx"
				></uv-icon>
				<!-- star-fill -->
				<view class="">
					收藏
				</view>
			</button>
		</view>
		
		<view class=""
		@click="openLocation(detail)"
		v-if="article">
			<button
			class="share">
				<image src="/static/image/tourGuide/f.png" 
				style="width: 40rpx;height: 40rpx;"
				mode=""></image>
				<!-- star-fill -->
				<view class="">
					导航
				</view>
			</button>
		</view>
		
		<view class=""
		v-if="!article">
			<button
			open-type="share"
			class="share">
				<uv-icon
				size="40rpx"
				name="share-square"></uv-icon>
				<view class="">
					分享
				</view>
			</button>
		</view>
		
		<view class="btn"
		v-if="isPay"
		@click="$emit('submit')">
			{{ submiitTitle }}
		</view>
		
		
		<contactActionSheet ref="contactActionSheet"/>
	</view>
</template>

<script>
	import contactActionSheet from '@/components/base/contactActionSheet.vue'
	export default {
		components : {
			contactActionSheet,
		},
		name:"submit",
		props : {
			submiitTitle : {
				default : '立即购买',
				type : String,
			},
			article : {
				default : false
			},
			detail : {
				default : {}
			},
			collectType : {
			},
			isPay : {
				default : true,
			},
			collectonFlag : {
			}
		},
		data() {
			return {
				
			}
		},
		methods: {
			// 添加收藏
			addCollection(){
				this.$api('addCollection', {
					itemId : this.detail.id,
					collectionType : this.collectType,
				}, res => {
					if(res.code == 200){
						
						this.$emit('getData')
						
						uni.showToast({
							title: res.message,
							icon:'none'
						})
					}
				})
			},
			openLocation(n){
				uni.openLocation({
					latitude: n.experienceLatitude,
					longitude: n.experienceLongitude,
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
.submit{
	position: fixed;
	bottom: 0;
	left: 0;
	width: 100vw;
	background-color: #fff;
	height: 100rpx;
	display: flex;
	justify-content: center;
	align-items: center;
	font-size: 24rpx;
	.btn{
		background: $uni-color;
		width: 600rpx;
		height: 80rpx;
		color: #fff;
		border-radius: 40rpx;
		font-size: 28rpx;
	}
	view{
		width: 100rpx;
		margin: 0 10rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
	}
}
</style>
