 <template>
	<view class="page">
		<u-navbar title=" " :border-bottom="false" :background="bgc" back-icon-color="#262B37" title-color='#262B37'
			title-size='36' height='46' id="navbar">
		</u-navbar>
        <view class="bj">
        	<image class="bj" src="https://api.ccttiot.com/smartmeter/img/static/uMh22gvApiiWjWXSqnNV" mode=""></image>
        </view>
        <view class="tit">
        	精选好物
        </view>
		<view class="tab">
			<view :class="tabindex == 0 ? 'active' : '' " @click="btntab('')">
				推荐
			</view>
			<view :class="tabindex == 1 ? 'active' : '' " @click="btntab(1)">
				特色美食
			</view>
			<view :class="tabindex == 2 ? 'active' : '' " @click="btntab(2)">
				农副产品
			</view>
			<view :class="tabindex == 3 ? 'active' : '' " @click="btntab(3)">
				特色干货
			</view>
		</view>
		<view class="techan">
			<view class="gundong">
				<view v-for="(item,index) in techanlist" :key="index" @click="btnsp(item,index)">
					<image :class="imgindex == index ? 'gdactive' : ''" :src="item.picture" mode="aspectFill"></image>
					<text>{{item.name}}</text>
				</view>
			</view>
		</view>
		<view class="tit">
			推荐店铺
		</view>
		<view class="dianpu">
			<view class="list" v-for="(item,index) in dplist" :key="index" @click="btndp(item)">
				<view class="lt">
					<image :src="item.picture.split(',')[0]" mode="aspectFill"></image>
				</view>
				<view class="rt">
					<view class="name">
						{{item.name}}
					</view>
					<view class="dizhi">
						<image src="https://api.ccttiot.com/smartmeter/img/static/upMvbI8C1ghy8GLhLlqT" mode=""></image> {{item.address}}
					</view>
				</view>
			</view>
		</view>
        
	</view>
</template>

<script>
	export default {
		data() {
			return {
                bgc: {
                	backgroundColor: "#fff",
                },
				tabindex:'',
				type:'',
				techanlist:[],
				id:'',
				dplist:[],
				imgindex:0
			}
		},
		onLoad() {
            this.getlist()
		},
		methods: {
			// 请求攻略列表
			getlist(){
				this.$u.get(`/app/specialty/list?pageNum=1&pageSize=999&type=${this.type}`).then((res) => {
					if(res.code == 200){
						this.techanlist = res.rows
						this.id = res.rows[0].id
						this.getdianpu()
					}
				})
			},
			// 根据特产请求店铺列表
			getdianpu(){
				this.$u.get(`/app/store/list?pageNum=1&pageSize=999&dishIds=${this.id}`).then((res) => {
					if(res.code == 200){
						this.dplist = res.rows
					}
				})
			},
			// 点击推荐店铺跳转详情
			btndp(item){
				uni.navigateTo({
					url:'/page_user/techan/techandp?id=' + item.id
				})
			},
			// 点击特产商品跳转详情
			btnsp(item,index){
				// uni.navigateTo({
				// 	url:'/page_user/techan/techansp'
				// })
				this.id = item.id
				this.imgindex = index
				this.getdianpu()
			},
			// 点击tab切换
			btntab(num){
				this.tabindex = num
				this.type = num
				this.imgindex = 0
				this.getlist()
			}
		}
	}
</script>

<style lang="less">
	::v-deep .u-icon__icon,
	::v-deep .u-title{
		padding-bottom: 22rpx !important;
	}
	.dianpu{
		margin-top: 26rpx;
		padding: 0 32rpx;
		box-sizing: border-box;
		.list{ 
			display: flex;
			border-bottom: 1px solid #D8D8D8;
			padding-bottom: 26rpx;
			margin-bottom: 26rpx;
			.lt{
				margin-right: 26rpx;
				image{
					width: 230rpx;
					height: 158rpx;
					border-radius: 10rpx;
				}
			}
			.rt{
				display: grid;
				.name{
					font-weight: 600;
					font-size: 32rpx;
					color: #3D3D3D;
				}
				.dizhi{
					display: flex;
					align-items: center;
					image{
						width: 28rpx;
						height: 28rpx;
					}
					font-size: 24rpx;
					color: #808080;
				}
			}
		}
	}
	.active{
		background: linear-gradient( 90deg, #15B37E 0%, #57E8B8 100%) !important;
		color: #fff !important;
		border: none !important;
	}
	.gdactive{
		border: 1px solid #15B37E !important;
	}
	.techan{
		margin-top: 30rpx;
		padding-left: 32rpx;
		.gundong{
			display: flex;
			overflow: scroll;
			gap: 20rpx;
			height: 290rpx;
			view{
				image{
					width: 208rpx;
					height: 208rpx;
					border-radius: 10rpx;
				}
				text{
					font-weight: 600;
					font-size: 30rpx;
					color: #3D3D3D;
					display: block;
					width: 208rpx;
					text-align: center;
					margin-top: 16rpx;
				}
			}
		}
	}
	.tab{
		box-sizing: border-box;
		font-size: 28rpx;
		color: #3D3D3D;
		display: flex;
		align-items: center;
		gap: 18rpx;
		margin-top: 20rpx;
		padding-left: 32rpx;
		view{
			border: 1px solid #808080;
			border-radius: 20rpx;
			padding: 4rpx 26rpx;
		}
	}
	.tit{
		font-weight: 600;
		font-size: 36rpx;
		color: #3D3D3D;
		margin-top: 18rpx;
		padding-left: 32rpx;
		box-sizing: border-box;
	}
	.bj{
		width: 750rpx;
		height: 420rpx;
	}
	page {
		background: #fff;
	}
</style>
