<template>
	<view class="component-wrapper" :style="wrapper_style">
		<view v-if="datas.show_title" class="morebox">
			<view :style="title_style" class="title">{{ title }}</view>
			<view  class="title2" @click="more">查看更多
				<u-icon :style="img_style2" color="#949494" name="arrow-right" size="14"></u-icon>
			</view>
		</view>
		<view class="bigbox" v-for="(item, index) in list" @click="gobuy(item.id)">
			<view class="bigbox_top">
				<u-icon class="img" name="share" color='orangered' size="22"></u-icon>
				<view>{{item.activity_title}}</view>
			</view>
			<view class="img_box" :style="img_style">
				<view class="avtivity_state">{{item.end_time}}</view>
				<image :src="item.activity_img || emptyImage" :key="index" :style="img_style"></image>
			</view>
			<view class="case_titleblock">
				<view class="case_title">{{item.activity_title}}</view>
			</view>
			<view class="price_selection">
				<view class="commodity_price">
					<view class="commodity_price_red " :style="price_style">{{item.child_fares+'-'+item.adult_fares }}
					</view>
					元
				</view>
			</view>
			<view class="case_title_sm">{{item.start_time+'-'+item.end_time }}</view>
		</view>
	</view>
</template>
<script>
	import landApi from '@/api/land/index.js'
	export default {
		props: ['styles', 'datas'],
		data() {
			let siteinfo = getApp().globalData.siteinfo;
			this.activityinit()
			return {
				avtiveid:[],
				settingFile: siteinfo,
				emptyImage: siteinfo.root_img + '/static/app/image.png',
				list:[]
			}
		},
		computed: {
			//价格设置
			price_style() {
				const {
					price_color,
					price_size
				} = this.datas
				return `
				font-size:${price_size}px;
				color:${price_color};
				margin-right:5px;
				`;
			},
			/** 副标题内容 */
			title() {
				return this.datas.title || '活动';
			},
			img_style2() {
				return `
				width:15px;
				height:15px;
				margin:auto;
				`;
			},
			// 副标题栏样式
			title_style() {
				const {
					text_size,
					text_color,
				} = this.datas;
				return `
			    font-size: ${text_size}px;
			    color: ${text_color};
			`;
			},
			/** 样式 */
			wrapper_style() {
				if (this.datas) {
					const {
						padding_top,
						padding_bottom,
						padding_left,
						padding_right,
						bg_color
					} = this.datas;
					return `
				background-color:${bg_color};
                padding-top: ${padding_top}px;
                padding-bottom: ${padding_bottom}px;
                padding-left: ${padding_left}px;
                padding-right: ${padding_right}px;
            `;
				}
			},

			img_style() {
				return `
				width: 100%;
				height:420rpx;
				border-radius: 5px;
				margin:5px 0;
            `;
			},
		},
		methods: {
			async activityinit() {
				let that = this
				let ids = []
				that.datas.goods.forEach(ele => {
					ids.push(ele.id)
				})
				let res = landApi.getlist({
					gids: ids,
					gtype: 'activity',
				}).then(res => {
					if (res.status == 200) {
						that.list = res.data;
					}
				});
			},
			more() {
				uni.navigateTo({
					url: '/pagesB/pages/activitylist/activitylist'
				})
			},
			gobuy(id) {
				uni.navigateTo({
					url: '/pagesB/pages/activitydetails/activitydetails?id=' + id
				})
			},
		}
	};
</script>
<style lang="less" scoped>
	.component-wrapper {

		// width: 375px;
		.morebox {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 0 12px;

			.title2 {
				font-size: 28rpx;
				display: flex;
				color: #949494;
				align-items: center;
			}
		}

		.bigbox {
			padding: 10px;
			border-radius: 5px;
			margin-top: 15rpx;
			background-color: #ffffff;

			.bigbox_top {
				display: flex;
				align-items: center;

				.img {
					margin-right: 5px;
				}
			}

			.img_box {
				position: relative;

				.avtivity_state {
					position: absolute;
					color: #fff;
					right: 0;
					top: 15px;
					padding: 1px 15px;
					background-color: rgba(51, 51, 51, .7);
					border-bottom-left-radius: 5px;
					border-top-left-radius: 5px;
					z-index: 9;
				}
			}
		}

		.case_titleblock {
			display: flex;
			justify-content: flex-start;
			align-items: center;
			width: 100%;

			.case_title {
				font-size: 15px;
				height: 27px;
				line-height: 27px;
				color: #000;
				font-weight: 550;
				white-space: nowrap;
				text-overflow: ellipsis;
				overflow: hidden;
			}
		}

		.case_title_sm {
			display: flex;
			justify-content: flex-start;
			align-items: center;
			width: 80%;
			font-size: 13px;
			color: #999;
			height: 27px;
			text-overflow: ellipsis;
			overflow: hidden;
			white-space: nowrap;
		}

		.price_selection {
			display: flex;
			justify-content: space-between;
			align-items: center;
			height: 27px;

			.commodity_price {
				display: flex;
				font-size: 14px;
				color: #333;

				.commodity_price_red {
					font-weight: 800;
					color: red;
				}
			}
		}
	}
</style>
