<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">
			<view class="bimage">
				<image :src="item.soil_cover_pic || emptyImage" :key="index" :style="img_style"></image>
			</view>
			<view class="case_titleblock">
				<view class="case_title">{{item.soil_name}}</view>
			</view>
			<view class="case_title_sm" :style="info_style">{{item.soil_desc}}</view>
			<view class="price_selection">
				<view class="commodity_price">
					价格:
					<view class="commodity_price_red text-neutral" :style="price_style">￥{{ item.show_price}}</view>
					元起
				</view>
				<view @click="gobuy(item.id)" class="btn" :style="buttonstyle">选择土地</view>
			</view>
		</view>
	</view>
</template>
<script>
	import landApi from '@/api/land/index.js'
	export default {
		props: ['styles', 'datas'],
		data() {
			let siteinfo = getApp().globalData.siteinfo;
			this.landinit()
			return {
				settingFile: siteinfo,
				emptyImage: siteinfo.root_img + '/static/app/image.png',
				landid: [],
				list:[]
			}
		},
		computed: {
			/** 副标题内容 */
			title() {
				return this.datas.title || '土地';
			},
			img_style2() {
				const {
					button_size
				} = this.datas
				return `
				width:${button_size}px;
				height:${button_size}px;
				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:450rpx;
				border-top-left-radius: 10px;
				border-top-right-radius: 10px;
            `;
			},
			//按钮设置
			buttonstyle() {
				const {
					border_radius,
					button_color,
					buttontitle_color
				} = this.datas
				return `
				color:${buttontitle_color};
				font-size: 30rpx;
				display: inline-block;
				padding: 15rpx 20rpx;
				background-color:${button_color};
				border-radius:${border_radius}px;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
				margin-right:10px
				`;
			},

			//土地描述设置
			info_style() {
				const {
					info_color
				} = this.datas
				return `
				color:${info_color};
				`;
			},
			//价格设置
			price_style() {
				const {
					peice_color
				} = this.datas
				return `
				color:${peice_color};
				`;
			},
		},
		methods: {
			landinit() {
				let that = this
				let ids = []
				that.datas.goods.forEach(ele => {
					ids.push(ele.id)
				})
				let res = landApi.getlist({
					gids: ids,
					gtype: 'land',
				}).then(res => {
					if (res.status == 200) {
						that.list = res.data;
					}
				});

			},
			more() {
				uni.switchTab({
					url: '/pages/land/land'
				})
			},
			gobuy(id) {
				uni.navigateTo({
					url: '/pagesB/pages/chooseland/chooseland?landid=' + id
				})
			},
		},
	};
</script>
<style lang="less" scoped>
	.component-wrapper {
		.morebox {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 0 12px;
			margin-bottom: 15rpx;

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

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

			.bimage {
				display: flex;
				justify-content: center;
			}
		}

		.case_titleblock {
			display: flex;
			justify-content: flex-start;
			align-items: center;
			padding: 0 10px;
			.case_title {
				font-size: 36rpx;
				height: 75rpx;
				line-height: 75rpx;
				color: #000;
				white-space: nowrap;
				text-overflow: ellipsis;
				overflow: hidden;
			}
		}

		.case_title_sm {
			width: 80%;
			font-size: 30rpx;
			color: #999;
			padding: 0 10px;
			text-overflow: ellipsis;
			overflow: hidden;
			white-space: nowrap;
		}

		.price_selection {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 5rpx 10px;
			margin-bottom: 10px;
			padding-bottom: 5px;

			.commodity_price {
				display: flex;
				font-size: 30rpx;
				color: #333;

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