<template>
	<view>
		<view v-if="loaded || list.itemIndex < 15" class="uni-indexed-list__title-wrapper">
			<text v-if="list.items && list.items.length > 0" class="uni-indexed-list__title">{{ list.key=='*'? '热门品牌': list.key }}</text>
		</view>
		<view v-if="(loaded || list.itemIndex < 15) && list.items && list.items.length > 0"
			:class="{'uni-indexed-list__list':list.key!='*'}">
			<view v-if="list.key=='*'" class="imgList">
				<view class="imgList-bj" v-for="(item,index) in list.items" :key="index" @click="onClick(idx, index)">
					<!-- aspectFill scaleToFill-->
					<view>
						<image :src="item.img"  mode="aspectFill"/>
					</view>
				</view>
			</view>
			<template v-else>
			<view v-for="(item, index) in list.items" :key="index" class="uni-indexed-list__item" hover-class="uni-indexed-list__item--hover">
				<view class="uni-indexed-list__item-container" @click="onClick(idx, index)">
					<view class="uni-indexed-list__item-border" :class="{'uni-indexed-list__item-border--last':index===list.items.length-1}">
						<view class="imgs" style="margin-right: 20rpx;">
							<image :src="item.img" mode="aspectFill"/>
						</view>
						<view class="uni-indexed-list__item-content">
								{{ item.name }}
						</view>
					</view>
				</view>
			</view>
			</template>
		</view>
	</view>
</template>

<script>
	export default {
		name: 'UniIndexedList',
		emits:['itemClick'],
		props: {
			loaded: {
				type: Boolean,
				default: false
			},
			idx: {
				type: Number,
				default: 0
			},
			list: {
				type: Object,
				default () {
					return {}
				}
			},
			showSelect: {
				type: Boolean,
				default: false
			}
		},
		methods: {
			onClick(idx, index) {
				this.$emit("itemClick", {
					idx,
					index
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.uni-indexed-list__list {
		background-color: $uni-bg-color;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		/* border-top-style: solid; */
		border-top-width: 1px;
		border-top-color: #DEDEDE;
	}

	.uni-indexed-list__item {
		font-size: 14px;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex: 1;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		padding: 0 20rpx;
	}

	.uni-indexed-list__item-container {
		/* padding-left: 15px; */
		flex: 1;
		position: relative;
		/* #ifndef APP-NVUE */
		display: flex;
		box-sizing: border-box;
		/* #endif */
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		/* #ifdef H5 */
		cursor: pointer;
		/* #endif */
	}

	.uni-indexed-list__item-border {
		flex: 1;
		position: relative;
		/* #ifndef APP-NVUE */
		display: flex;
		box-sizing: border-box;
		/* #endif */
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		height: 50px;
		padding: 25px;
		padding-left: 0;
		/* border-bottom-style: solid; */
		border-bottom-width: 1px;
		border-bottom-color:  #DEDEDE;
		
	}

	.uni-indexed-list__item-border--last {
		border-bottom-width: 0px;
	}

	.uni-indexed-list__item-content {
		width: 470rpx;
		flex: 1;
		font-size: 30rpx;
		color: #191919;
		font-weight:600;
		font-family: -webkit-pictograph;
		margin-left: 20rpx;
		word-wrap: break-word;
	}

	.uni-indexed-list {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
	}

	.uni-indexed-list__title-wrapper {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		background-color: #f7f7f7;
		padding: 0 0 0 20rpx;
	}

	.uni-indexed-list__title {
		padding: 6px 12px;
		line-height: 24px;
		font-size: 16px;
		font-weight: 700;
		font-family: -webkit-pictograph;
	}
	.imgList{
		display: flex;
		flex-wrap: wrap;
		background: #f7f7f7;
	}
	.imgList-bj{
		flex-shrink: 0;
		width: 33.33%;
		padding: 20rpx 0 0 0;
	}
	.imgList-bj view{
		width: 207rpx;
		height: 120rpx;
		/* margin-right: 10rpx; */
		margin-left: 20rpx;
		border-radius: 20rpx;
		background: #ffffff;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.imgList-bj view image{
		width: 120rpx;
		height: 70rpx;
		display: block;
	}
	/* .imgList view:nth-child(3n) image{
		margin-right: 0;
	} */
	.imgs{
		height: 90rpx;
	}
	.imgs image{
		width: 80rpx;
		height: 80rpx;
		border-radius: 50%;
	}
</style>
