<template name="navbars">
	<view>
		<view class="navbars-content clearfix">
			<view class="nav-item" v-for="(item,index) in navList" :key="index" @click="NavToDetailPage(item,index)">
				<view class="icon">
					<image class="icon-image" :src="item.icon" mode="widthFix"></image>
					<!-- <image class="icon-new" src="../../../static/temp/icon-new.png" mode="widthFix" v-if="index === 7"></image> -->
				</view>
				<view class="name">{{ item.name }}</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		name:"navbars",
		props:{
			list:{
				type:Array
			}
		},
		data() {
			return{
				current:100,
				navList:[
					{icon:'http://static-b.caimei365.com/app/img/icon/icon-nav1.png'},
					{icon:'http://static-b.caimei365.com/app/img/icon/icon-nav2.png'},
					{icon:'http://static-b.caimei365.com/app/img/icon/icon-nav3.png'},
					{icon:'http://static-b.caimei365.com/app/img/icon/icon-nav4.png'},
					{icon:'http://static-b.caimei365.com/app/img/icon/icon-nav5.png'},
					{icon:'http://static-b.caimei365.com/app/img/icon/icon-nav6.png'},
					{icon:'http://static-b.caimei365.com/app/img/icon/icon-nav7.png'},
					{icon:'http://static-b.caimei365.com/app/img/icon/icon-nav8.png'},
				]
			}
		},
		created(){
			this.initData(this.list)
		},
		computed: {
	
		},
		methods:{
			initData(list){
				this.navList = this.ReturnNewNavList(this.navList,list)
			},
			ReturnNewNavList(listA,listB){
				let NewArray = []
				listA.map((item,index)=>{
					for (let i = 0; i < listB.length; i++) {
						if(index == i){
							NewArray.push(Object.assign(item,listB[i]))
						}
					}
				});
				return NewArray
			},
			NavToDetailPage(item,index) {//跳转
				console.log(index)
				/**
				 * 页面跳转类型
				 * 0、1、2、二级页面,
				 * 3、5、6、7、嵌h5页面
				 * 4、二手商品列表
				 **/
				 const typeMap = {
					0:`/pages/goods/goods-secondary?linkId=${item.id}`,
					1:`/pages/goods/goods-secondary?linkId=${item.id}`,
					2:`/pages/goods/goods-secondary?linkId=${item.id}`,
					3:`/h5/pages/article/page?linkType=${index}`,
					4:`/second/pages/product/product-list`,
					5:`/h5/pages/article/page?linkType=${index}`,
					6:`/h5/pages/article/page?linkType=${index}`,
					7:`/h5/pages/article/page?linkType=${index}`,
				 }
				 const url = typeMap[index];
				 console.log(url)
				 this.$api.navigateTo(url)
			}
		}
	}
</script>

<style lang="scss">
	.navbars-content{
		width: 100%;
		height: auto;
		box-sizing: border-box;
		padding: 0 24rpx;
		margin-top: 30rpx;
		.nav-item{
			width: 164rpx;
			height: auto;
			float: left;
			margin-bottom: 30rpx;
			margin-right: 15.3rpx;
			&:nth-child(4){
				margin-right: 0;
			}
			&:nth-child(8){
				margin-right: 0;
			}
			.icon{
				width: 130rpx;
				height: 130rpx;
				margin: 0 auto;
				position: relative;
				.icon-image{
					width: 130rpx;
					height: 130rpx;
					display: block;
				}
				.icon-new{
					width: 44rpx;
					height: 22rpx;
					display: block;
					position: absolute;
					right: 0;
					top: 20rpx;
				}
			}
			.name{
				width: 100%;
				height: 40rpx;
				line-height: 40rpx;
				text-align: center;
				font-size: $font-size-28;
				color: #666666;
			}
			.nav-cell-main{
				width: 100%;
				height: auto;
				position: absolute;
				right: 0;
				.nav-cell{
					width: 164rpx;
					height: auto;
					float: left;
					margin-bottom: 30rpx;
					margin-right: 15.3rpx;
					&:nth-child(4){
						margin-right: 0;
					}
					&:nth-child(8){
						margin-right: 0;
					}
					.icon{
						width: 130rpx;
						height: 130rpx;
						margin: 0 auto;
						position: relative;
						.icon-image{
							width: 130rpx;
							height: 130rpx;
							display: block;
						}
						.icon-new{
							width: 44rpx;
							height: 22rpx;
							display: block;
							position: absolute;
							right: 0;
							top: 20rpx;
						}
					}
					.name{
						width: 100%;
						height: 40rpx;
						line-height: 40rpx;
						text-align: center;
						font-size: $font-size-28;
						color: #666666;
					}
				}
			}
		}
	}
</style>
