<template>
	<view class="onecontent flex-between">
		<view class="onecontentleft">
			现有<text style="color: #FC851E;font-size: 24rpx;">
				{{bannervo.coupons==null?116:bannervo.coupons}}人
			</text>
			已免单
		</view>
		<view class="onecontentright flex-start">
			<view class="onecontentrightimage">
				<view class="swiperPanel" @touchstart="startMove" @touchend="endMove">
					<view class="swiperItem" v-for="(item, index) in bannervo.counponsInfo" :key="index"
						:style="{transform: itemStyle[index].transform, zIndex: itemStyle[index].zIndex, opacity: itemStyle[index].opacity}">
						<view class="children">
							<image class="pic" :src="item.logo"></image>
						</view>
					</view>
				</view>
			</view>
			<view class="onecontentrighttext">
				<swiper class="swiper" circular :autoplay="true" :vertical='true' :interval="2000">
					<swiper-item class="swiperitem" v-for="(item,index) in bannervo.counponsInfo" :key="index">
						{{item.name}}已省{{item.money}}元钱
					</swiper-item>
				</swiper>
			</view>
		</view>
		<!-- 小内切圆 -->
		<view class="after"></view>
	</view>
</template>

<script>
	import customSwiper from '@/components/blackmonth-swiper/index'
	export default {
		components: {
			customSwiper
		},
		data() {
			return {
				isScroll: false,
				minCount: 0,
				fontColor: 'black',
				timersetInterval: '0', //定时器
				slideNote: {
					x: 0,
					y: 0
				},
				screenWidth: 0
			};
		},
		props: {
			bannervo: {
				type: Object,
				default () {
					return {
						counponsInfo: []
					}
				}
			},
			itemStyle: {
				type: Array,
				default () {
					return []
				}
			},
			title: {
				type: String,
				default: '每日特价'
			},
			timersetnteritem: {
				type: String,
				default: '0'
			}
		},
		watch: {
			timersetnteritem(newVal, oldVal) {
				// console.log(newVal, oldVal)
				if (newVal == 1) {
					clearTimeout(this.timersetInterval);
					this.timersetInterval = null;
				} else {
					this.timersetIntervalnewVal()
				}
			}
		},

		mounted() {
			this.timersetIntervalnewVal()
		},
		methods: {
			timersetIntervalnewVal() {
				this.timersetInterval = setInterval(() => {
					this.endMove()
				}, 2000);
			},
			startMove(e) {
				this.slideNote.x = e.changedTouches[0] ? e.changedTouches[0].pageX : 0;
				this.slideNote.y = e.changedTouches[0] ? e.changedTouches[0].pageY : 0;
			},
			endMove(e) {
				// this.itemStyless = []
				var newList = JSON.parse(JSON.stringify(this.itemStyle))
				// console.log(newList)
				// if ((e.changedTouches[0].pageX - this.slideNote.x) < 0) {
				// 向左滑动
				var last = [newList.pop()]
				newList = last.concat(newList)
				// } else {
				// 向右滑动
				// newList.push(newList[0])
				// newList.splice(0, 1)
				// }
				this.$emit('changeValue', newList);

				this.$forceUpdate();
			}
		}
	};
</script>

<style scoped lang="scss">
	.onecontent {
		position: relative;
		margin-top: -34rpx;
		padding: 14rpx 28rpx 44rpx 28rpx;
		width: 100%;
		background: linear-gradient(92deg, #FCECAA 0%, #fff 100%);
		border-radius: 40rpx 0rpx 0rpx 0rpx;

		.onecontentleft {
			font-family: Source Han Sans CN, Source Han Sans CN;
			font-weight: 700;
			font-size: 24rpx;
			color: #333333;
			display: flex;
			align-items: center;
			justify-content: center;

			text {
				color: #FC851E;
			}
		}



		.onecontentright {
			font-family: Source Han Sans CN, Source Han Sans CN;
			font-weight: 400;
			font-size: 24rpx;
			color: #333333;
			display: flex;
			align-items: center;
			justify-content: center;

			.onecontentrightimage {
				width: 65rpx;
				position: relative;
				overflow: hidden;
				height: 28rpx;
				margin-right: 10rpx;

				.swiperPanel {
					height: 28rpx;
					width: 100rpx;
					overflow: hidden;
					position: relative;

					.swiperItem {
						height: 100%;
						width: 100%;
						position: absolute;
						top: 0;
						left: 0;
						transition: all .5s;

						/* 定义一个动画关键帧 */


						.children {
							height: 100%;
							width: 25%;
							// margin: 2rpx auto;


							/* 应用动画，设置动画时长、循环次数和速度曲线 */
							.pic {
								height: 100%;
								width: 100%;
								border-radius: 50%;
								// box-shadow: 0 0 10px #333;
							}
						}

					}
				}

				.onecontentrightimageabsolute {
					width: 100%;
					left: 0;
					top: 0;
					position: absolute;
					z-index: 9;
					height: 28rpx;
				}


				.onecontentrightimageabsolutetow {
					width: 100%;
					left: 14rpx;
					top: 0;
					position: absolute;
					z-index: 10;
				}

				// .onecontentrightswiper {
				// 	border: 50%;
				// 	width: 28rpx;
				// 	height: 28rpx;
				// 	background: red;
				// }
			}

			.onecontentrighttext {
				width: 232rpx;

				.swiper {
					height: 28rpx;
					// width: 232rpx;

					.swiperitem {
						width: 100rpx;
						font-family: Source Han Sans CN, Source Han Sans CN;
						font-weight: 400;
						font-size: 20rpx;
						color: #333333;
						overflow: hidden; //超出的文本隐藏
						text-overflow: ellipsis; //溢出用省略号显示
						white-space: nowrap; //溢出不换行
					}
				}
			}

		}

		.after {
			position: absolute;
			top: -40rpx;
			right: 0;
			width: 40rpx;
			height: 40rpx;
			line-height: 40rpx;
			text-align: center;
			background-image: radial-gradient(160rpx at 0px 0px, rgba(0, 0, 0, 0) 40rpx, #fff 40rpx);
		}
	}
</style>