<template>
	<view @touchend='touchend' @touchmove='touchmove' @touchstart='onChange'
		style="display: flex;flex-direction: column;flex-wrap: wrap;z-index: 9999999999999999999999999 !important;"
		:style="{height:isShow.switchBar?`calc(${styles.height}rpx + ${styles.move}rpx )`: ` calc( ${styles.move}rpx + 150rpx)` }"
		:class="styles.open? 'serviceStation_body' :'seleServiceStation_body' ">
		<view @click="switchBar" class="switchBar"></view>
		<view style="flex: 1; overflow: hidden; width: 100%; ">
			<view style="" class="information">
				<view class="information_left">
					<image class="ser_img" :src="details.siteImages" mode="widthFix"></image>
					<view
						style="width: calc(100% - 80rpx);display: flex; flex-direction: column;justify-content: space-between;"
						class="serviceStation_text black_color">
						<view class="ovf">{{details.siteName}}</view>
						<view style=" " class="ovf samall_text hui_color">{{details.address}}</view>
					</view>
				</view>
				<view class="information_right">
					<uni-icons type="paperplane-filled" size="20"></uni-icons>
					<view class="samall_text hui_color">
						{{ Number(details.juli/1000).toFixed(2) }}km
					</view>
				</view>
			</view>

			<view class="oli_swiper">
				<view class="oli_swiper_title">
					<view :style="{borderBottom: seleIndex==index? '#FF6700 solid 3px':''}" @click="seletitle(index)"
						v-for="(item,index) in details.oilSiteChannelDetailsVos" class="oli_swiper_title_item">
						{{item.channelCode|channelCode}}</view>
					<!-- <view :style="{transform:`translateX( calc(${seleIndex} * 100%) )`,width:`calc(100% / ${details.oilSiteChannelDetailsVos.length})`}"  class="tiao"></view> -->
				</view>
				<swiper class="swiper" next-margin='480rpx' :duration="500">
					<swiper-item
						v-for="(item,index) in (details.oilSiteChannelDetailsVos[seleIndex].oilSitePriceDetailsVos==null?[]:details.oilSiteChannelDetailsVos[seleIndex].oilSitePriceDetailsVos)"
						:key='index'>
						<view class="swiper-item">
							<view class="swiper-item_oliType bag_text black_color">{{item.oilProductCode}}</view>
							<view class="bag_text hu_color " style="text-align: start;">
								{{moneyIntercept(item.sitePrice)}}/L
							</view>
							<view class="samall_text hui_color" style="text-align: end;text-decoration: line-through;">
								{{ moneyIntercept(item.oilSitePrice) }}/L
							</view>
						</view>
					</swiper-item>
				</swiper>
			</view>

			<view class="serviceStation_footer">
				<view @click="Navigation" style="background-color: #8B583E;" class="serviceStation_footer_butten">导航
				</view>
				<view @click="jump" style="background-color: #FF6700;" class="serviceStation_footer_butten">详情</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				touchData: null,
				styles: {
					height: 700,
					moveY: 0,
					Y: 0,
					move: 0,
					open: false
				},
				seleIndex: 0,
				isShow: {
					switchBar: true
				}
			}
		},
		created() {
			console.log(this.details, '***');
			this.$emit('dragMap', this.details, false)
		},
		mounted() {},
		props: {
			details: {
				type: Object,
				default: () => {
					return null
				}
			}
		},
		filters: {
			channelCode(e) {
				switch (e) {
					case 'XOIL':
						return '星油'
					case 'WJY':
						return '万金油'
					case 'LV':
						return '其他'
					case 'TY':
						return '团油'
					case 'YDJY':
						return '一点加油（壳牌）'
				}
			}
		},
		watch: {},
		methods: {
			jump() {
				let obj = {
					siteId: this.details.id,
					// siteCode: this.details.siteCode,
					// siteChannel: this.details.siteChannel,
					longitude: this.details.longitude,
					latitude: this.details.latitude,
				}
				let itemS = JSON.stringify(obj)
				console.log(itemS, this.details, '************');
				// return
				uni.navigateTo({
					url: `../stationDetail/stationDetail?item=${itemS}&&types=map`
				})
			},
			Navigation() {
				console.log('组件导航')
				this.$emit('openMapApp')
			},
			touchcancel(e) {
				console.log(this.styles.yd, 'touchcancel滑动距离')
				console.log(e, 'touchcancel')
			},
			//监听鼠标滑动
			touchmove(e) {
				if (this.isShow.switchBar && this.styles.Y - e.changedTouches[0].clientY > 0) return
				this.styles.moveY = e.changedTouches[0].clientY;
				this.styles.move = this.styles.Y - this.styles.moveY;
				console.log(this.styles.moveY)
			},
			//开始滑动
			onChange(e) {
				this.$emit('dragMap', this.details, false)
				// 这一行为记录滑动位置代码 this.styles.Y = e.changedTouches[0].clientY + this.styles.move;
				console.log('禁用');
				this.styles.open = true;
				this.styles.Y = e.changedTouches[0].clientY;
				console.log('onChange')
			},
			// 滑动完成
			touchend(e) {
				this.styles.open = false;
				if (this.styles.move > 0) {
					this.isShow.switchBar = true
				} else if (this.styles.move < 0) {
					this.isShow.switchBar = false
				}
				this.styles.move = 0;
				console.log('touchend')
				setTimeout(() => {
					this.$emit('dragMap', this.details, true)
				}, 500)
			},
			vtouchmove(e) {
				this.styles.height -= 3;
				console.log(e, this.styles.height, 'vtouchmove')
			},
			seletitle(e) {
				this.seleIndex = e
			},
			switchBar() {
				this.isShow.switchBar = !this.isShow.switchBar
				console.log(this.isShow.switchBar)
			}
		}
	}
</script>

<style scoped>
	.an {
		align-items: flex-end;
	}

	.flex {
		display: flex;
	}

	.ac {
		align-items: center;
	}

	.ser_img {
		width: 80rpx;
		/* height: 80rpx; */
		margin-right: 15rpx;
	}

	.serviceStation_footer_butten {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 240rpx;
		height: 80rpx;
		color: #FFFFFF;
		border-radius: 50px;
	}

	.serviceStation_footer {
		display: flex;
		justify-content: center;
		gap: 26rpx;
		/* position: absolute;
		bottom: 40rpx; */
		width: 100%;
		margin-top: 20rpx;
	}

	.bag_text {
		font-size: 36rpx;
	}

	.swiper-item_oliType {
		position: absolute;
		right: -10rpx;
		top: -10rpx;
	}

	.swiper-item {
		width: 200rpx !important;
		background: #F0F0F0;
		border-radius: 10px;
		height: 140rpx;
		/* padding: 32rpx; */
		position: relative;
		margin-top: 10rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		gap: 10rpx;
		padding: 0 40rpx;
	}

	.hu_color {
		color: #FF6700;
	}

	.swiper {
		width: 100%;
		height: 150rpx;
	}

	.oli_swiper {
		margin-top: 40rpx;
	}

	.oli_swiper_title_item {
		/* flex: 1; */
		text-align: center;
		font-size: 28rpx;
		/* width: min-intrinsic; */
		padding-bottom: 5px;
	}

	.tiao {
		background-color: #FF6700;
		border-radius: 10px;
		height: 5rpx;
		position: absolute;
		bottom: 0;
		left: 0;
		transition: all .3s;
		transform: scaleX(100%);
	}

	.oli_swiper_title {
		/*
		border-bottom: #FF6700 solid;
		width: max-content;
		margin: 0 auto;
		*/
		padding-bottom: 10rpx;
		margin-bottom: 40rpx;
		display: flex;
		justify-content: center;
		gap: 20rpx;
		flex-wrap: nowrap;
		overflow: hidden;
		position: relative;
	}

	.black_color {
		color: #666666;
	}

	.hui_color {
		color: #BBBBBB;
	}

	.samall_text {
		font-size: 24rpx;
	}

	.serviceStation_text {
		font-size: 28rpx;
	}

	.ovf {
		width: 100%;
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
	}

	.information_right {
		width: 94rpx;
		display: flex;
		flex-direction: column;
		gap: 10rpx;
		justify-content: space-between;
		align-items: center;
	}

	.information_left {
		flex: 1;
		overflow: hidden;
		display: flex;
		/* flex-direction: column;
		justify-content: space-between; */
	}

	.information {
		display: flex;
		padding: 0 30rpx;
		gap: 20rpx;
		margin-top: 30rpx;
		overflow: hidden;
		max-height: 90rpx;
	}

	.switchBar {
		width: 160rpx;
		height: 10rpx;
		background: #F0F0F0;
		border-radius: 10px;
		margin: 0 auto;
	}

	.seleServiceStation_body {
		height: 700rpx;
		width: 750rpx;
		background: #FFFFFF;
		border-radius: 20px 20px 0px 0px;
		padding: 16rpx;
		transition: all .3s;
	}

	.serviceStation_body {
		height: 700rpx;
		width: 750rpx;
		background: #FFFFFF;
		border-radius: 20px 20px 0px 0px;
		padding: 16rpx;
		transition: all .3s;
	}
</style>
