<template>
	<view class='container'>
		<u-navbar :placeholder="true" bgColor="#0F0F0F">
			<view slot="left" class="flex-center-center">
				<image class="w-270 h-57" src="/static/icon_sy_tab_img.png"></image>
			</view>
		</u-navbar>
		<view class="mt-40 mlr-24">
			<u-swiper :list="swiperList" circular :autoplay="true" radius="5" bgColor="#0F0F0F" height="160"></u-swiper>
		</view>
		<view class="sv-y mt-25">
			<scroll-view scroll-y>
				<view v-for="(item,index) in list" :key="index">
					<view class="flex-column mlr-24 mb-30" @click="onMdhd(item)"
						style="color: #878787;border-radius: 20rpx;">
						<image class="br-20 h-350" style="width: 100%;" :src="$config.cdnUrl+splitList(item.image)[0]">
						</image>
						<view class="flex-column fs-28 pad-10 mt-25" style="flex: 1;">
							<text class="fs-32" style="color: white;">{{item.name}}</text>
							<view class="flex ptb-15">
								<view v-for="(sonitem,index) in splitList(item.remark)" :key="index">
									<text class="fs-24 br-8 ptb-5 plr-15 mr-10"
										style="color: #FFC100;border: 1px solid #FFC100;">{{sonitem}}</text>
								</view>
							</view>
							<view class="flex" style="color:#FE42C2;align-items: flex-end;">
								<text class="fs-46">￥{{item.minSpend}}</text>
								<text class="fs-28 ml-10 mb-5">起</text>
							</view>
						</view>
					</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				timeIndex: 0,
				swiperList: [
					'https://cdn.uviewui.com/uview/swiper/swiper1.png',
					'https://cdn.uviewui.com/uview/swiper/swiper2.png',
					'https://cdn.uviewui.com/uview/swiper/swiper3.png',
				],
				list: [],

			};
		},
		onLoad() {
			this.getBannerList();
			this.getList();
		},
		methods: {
			onMdhd(item) {
				// if (!uni.getStorageSync('token')) {
				// 	this.$wskj.to('/pages/login/wechatlogin');
				// 	return
				// }
				this.$wskj.to('/pagesMain/pages/mdhd?data=' + encodeURIComponent(JSON.stringify(item)))
			},
			splitList(data) {
				if (data == null) {
					return []
				}
				return data.split(',')
			},
			getBannerList() {
				const params = {
					url: '/system/banner/list',
					method: "GET",
					data: {
						type: 2,
					}
				}
				this.$request(params).then(res => {
					this.swiperList.length = 0
					for (var i = 0; i < res.rows.length; i++) {
						this.swiperList.push(res.rows[i].image)
					}
				})
			},
			getList() {
				const params = {
					url: '/system/party/listShop',
					method: "GET",
					data: {}
				}
				this.$request(params).then(res => {
					this.list = res.rows
				})
			},

		},
	};
</script>

<style scoped>
	.container {
		width: 100%;
		height: 100%;
		background: #0F0F0F;
		display: flex;
		flex-direction: column;
	}

	.good-hot {
		margin: 25rpx;
		height: 160rpx;
	}

	/* 注意点，测试下来，设置水平滑动也要给一个固定高度 */
	.scroll-view_H {
		margin-top: 30rpx;
		width: 100%;
		white-space: nowrap;
		height: 100rpx;
		flex-direction: row;
	}

	.scroll-view_H view {
		display: inline-block;
		width: 120rpx;
		height: 100rpx;
		border-radius: 10rpx;
	}

	/* 去掉最后一个元素的 margin-right: 16rpx 设置为0 */
	/* .scroll-view_H view:last-child {
		margin-right: 0;
	} */

	.scroll-view_H .fl-item-sel {
		display: flex;
		height: 100%;
		width: 100rpx;
		flex-direction: column;
		background: #9FFF00;
		border-radius: 20rpx;
		justify-content: center;
		align-items: center;
		color: #000;
	}

	.scroll-view_H .fl-item {
		display: flex;
		height: 100%;
		width: 100rpx;
		flex-direction: column;
		border-radius: 20rpx;
		justify-content: center;
		align-items: center;
		color: #878787;
	}

	.sv-y {
		flex: 1;
		/* 自动占满剩余的空间 */
		overflow-y: auto;
		/* 允许纵向滚动 */
	}
</style>