<template>
	<view class="component-wrapper" :style="wrapper_style">
		<view 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 :style="box_style" class="reinitem" v-for="(item, index) in list" @click="gobuy(item.id)">
			
			<view class="imgren">
				<view class="leticon">认</view>
				<image :src="item.pic || emptyImage" :key="index" :style="img_style" mode="aspectFill" class="renitem_thu">
			</view>
			
			</image>
			<view class="rightiation_bar">
				<view class="rightiation_bar_p1">{{ item.name }}</view>
				<view class="rightiation_bar_p2">收获：{{ item.bonusway }}</view>
				<view class="rightiation_bar_p3">
					<view class="right_text_p1">已售:</view>
					<view class="right_text_p2 text-primary">{{ item.sells }}</view>
					<view class="right_text_p1">剩余:</view>
					<view class="right_text_p2 text-primary">{{ item.num }}</view>
				</view>
				<progress :activeColor="primary" :percent="item.rgbl" stroke-width="3" />
				<view class="rightiation_bar_p3" :show-percent="false"
					style="justify-content: space-between;margin: 15rpx 0 0 0">
					<view class="right_buton_p1 text-neutral">￥{{ item.copies_price }}</view>
					<view class="right_buton_p2 bg-primary " :style="buttonstyle">进行中</view>
				</view>
			</view>
			<!-- <view class="uliline2"></view> -->

		</view>
	</view>
</template>
<script>
	import landApi from '@/api/land/index.js'
	export default {
		props: ['styles', 'datas'],
		data() {
			let siteinfo = getApp().globalData.siteinfo;
			this.adoptinit();
			return {
				primary: this.$theme.primary,
				settingFile: siteinfo,
				emptyImage: siteinfo.root_img + '/static/app/image.png',
				adoptid: [],
				list: []
			}
		},
		computed: {
			/** 副标题内容 */
			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() {
				const {
					picture_border,
				} = this.datas;
				return `
				width: 220rpx;
				height: 220rpx;
            `;
			},
			box_style() {
				const {
					picture_border,
				} = this.datas;
				return `
				overflow: hidden;
            `;
			},
			leftbox_right() {
				const {
					bg_color
				} = this.datas;
				return `
				overflow: hidden;
				background-color:${bg_color};
            `;
			},
			//按钮设置
			buttonstyle() {
				const {
					border_radius,
					button_color,
					buttontitle_color
				} = this.datas
				return `
				color:${buttontitle_color};
				background-color:${button_color};
				border-radius:${border_radius}px;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
				`
			},

			//价格设置
			price_style() {
				const {
					price_color
				} = this.datas
				return `
				color:${price_color};
				font-weight: 600;
				`;
			},
			//已售设置
			soldout_style() {
				const {
					soldout_color
				} = this.datas
				return `
				color:${soldout_color};
				`;
			},
			//剩余设置
			residue_style() {
				const {
					residue_color
				} = this.datas
				return `
				color:${residue_color};
				`;
			},
		},
		methods: {
			adoptinit() {
				let that = this
				let ids = []
				that.datas.goods.forEach(ele => {
					ids.push(ele.id)
				})
				let res = landApi.getlist({
					gids: ids,
					gtype: 'renyang',
				}).then(res => {
					if (res.status == 200) {
						that.list = res.data;
					}
				});
			},
			more() {
				uni.switchTab({
					url: '/pages/index/adoplist/adoplist'
				})
			},
			gobuy(id) {
				uni.navigateTo({
					url: '/pagesA/pages/adopt/adopt?id=' + id
				})
			},
		}
	};
</script>
<style lang="less" scoped>
	.component-wrapper {
		.morebox {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 0 12px;
			margin-bottom: 15px;

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

		.reinitem {
			display: flex;
			justify-content: left;
			align-items: flex-start;
			margin: 25rpx 0 0 0;
			.imgren{
				position: relative;
			}
		}
		.leticon {
			background-color: #ff8000;
			position: absolute;
			left: 0;
			top: 0;
			padding: 15rpx 15rpx 20rpx 15rpx;
			border-radius: 0 0 35rpx 35rpx;
			color: #ffffff;
			z-index: 9;
		}
		.renitem_thu {
			width: 220rpx;
			height: 220rpx;
		}

		.rightiation_bar {
			margin-left: 20rpx;
			width: 100%;
		}

		.rightiation_bar_p1 {
			color: #000;
			line-height: 38rpx;
			font-size: 28rpx;
			overflow:hidden; 
			text-overflow:ellipsis;
			display:-webkit-box; 
			-webkit-box-orient:vertical;
			-webkit-line-clamp:1; 
		}

		.rightiation_bar_p2 {
			font-size: 24rpx;
			color: #434343;
			margin: 15rpx 0;
		}

		.rightiation_bar_p3 {
			display: flex;
			justify-content: flex-start;
			margin: 15rpx 0;
			align-items: center;
		}

		.right_text_p1 {
			color: #999;
			font-size: 22rpx;
		}

		.right_text_p2 {
			font-size: 24rpx;
			margin-right: 25rpx;
		}

		.right_buton_p1 {
			font-size: 32rpx;
			font-weight: 600;
		}

		.right_buton_p2 {
			color: #fff;
			border-radius: 30rpx;
			font-size: 26rpx;
			padding: 16rpx 30rpx;
		}
	}
</style>
