<template>
	<view style="background: #f7f8faff;">
		<view class="">
			<view class="flexB" style="margin: 24rpx; ">
				<view class="tip">
					<image src="../../static/huo.png" style="width: 32rpx; height: 32rpx;" mode=""></image>
				</view>
				<p>热门品牌</p>

			</view>
			<!-- <view class="" style="background-color: white; display: flex; flex-wrap: wrap; padding: 24rpx;">
				<view class="item" v-for="item in list">
					<image :src="item.image_url" style="width: 136rpx; height: 136rpx;" mode=""></image>
					<p>{{item.name}}</p>
				</view>
			</view> -->
		</view>
		<!-- <u-index-list :scrollTop="scrollTop">
				<view v-for="(item, index) in itemArr" :key="index">
					<u-index-item v-for="item1 in item">
					<u-index-anchor :index="item1.word" />
					<view  v-for="cell in item1.list">
							{{item1.name}}
					</view>
					</u-index-item>
				</view>
			</u-index-list> -->
		<u-index-list :index-list="indexList">
			<template v-for="(item, index) in itemArr">
				<u-index-item>
					<u-index-anchor :text="item.word"></u-index-anchor>
					<view class="list-cell" v-for="(cell, index1) in item.list" @click="backHub(cell,index1)">
						
							{{cell.name}}
						
						<!-- <view class="" v-for="item1 in cell">	
								{{item1.short_name}}
							</view> -->
					</view>
				</u-index-item>
			</template>
		</u-index-list>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				// indexList: ["A", "B", "C"],
				// 				itemArr: [
				// 					['列表A1','列表A2','列表A3'],
				// 					['列表B1','列表B2','列表B3'],
				// 					['列表C1','列表C2','列表C3']
				// 				]
				indexList: [],
				itemArr: []
			}
		},
		methods: {
			backHub(item, idx) {
				console.log(item, idx);
				//选择品牌后跳转	
				let pages = getCurrentPages(); //获取所有页面栈实例列表
				let prevPage = pages[pages.length - 2]; //上一页页面实例
				prevPage.$vm.brand_id = item.id;
				prevPage.$vm.brand_name = item.name;
				uni.navigateBack({ //uni.navigateTo跳转的返回,默认1为返回上一级
					delta: 1
				});
			}
		},
		onLoad() {
			uni.$u.http.get('/api/index/brand_list').then(res => {
				console.log(res);
				this.indexList = res.data.word;
				this.itemArr = res.data.list
			}).catch(err => {
				console.log(err);
			})
			uni.$u.http.get('/api/index/hot_brand').then(res => {
				console.log(res);
				this.list = res.data
			}).catch(err => {
				console.log(err);
			})
		}
	}
</script>

<style scoped>
	.flexB {
		display: flex;
		align-items: center;
	}

	.list-cell {
		display: flex;
		box-sizing: border-box;
		width: 100%;
		padding: 10px 24rpx;
		overflow: hidden;
		color: #323233;
		font-size: 14px;
		line-height: 24px;
		background-color: #fff;
	}

	.item {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		margin-right: 32rpx;
	}
</style>