<template>
	<view class="container">
		<view class="list">
			<view @click="detail(item.id)" class="item" style="border-left:none;padding: 0 30rpx;" v-for="(item,index) in list" :key="index">
				<view class="top flex flex-y-center box-pack-between">
					<view class="flex-y-center">
						<view class="name">{{item.name}}</view>
					</view>
					
					<view class="flex-y-center">
						<view class="ft26" style="color: #FF5722;margin-right: 20rpx;">
							{{item.type==1?'小程序':item.type==2?'内部':item.type==3?'外链':item.type==4?'会员授权弹窗':''}}
						</view>
						<view class="del" @click.stop="del(item.id)">删除</view>
					</view>
					
				</view>
				<view class="content flex flex-y-center" hover-class="nav-hover">
					<image  mode="aspectFit"  class="content-icon" :src="URL+item.thumb"></image>
				</view>
			</view>
			<view class="no-more">没有更多内容了~</view>
		</view>
		<view class="footer-bar">
			<view class="content flex flex-center">
				<navigator url="./add" class="btn">+新增弹窗轮播图</navigator>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				store_id: "",
				list: [],
				page: 1,
				is_bottom: false,
				URL:getApp().globalData.URL
			}
		},

		onLoad(options) {
			this.store_id = options.store_id
		},

		onShow() {
			this.getData()
		},

		// onReachBottom() {
		// 	if (!this.is_bottom) {
		// 		this.getData(this.page + 1)
		// 	}
		// },
		methods: {
			detail(id) {
				uni.navigateTo({
					url: `./add?id=${id}`
				})
			},
			del(id) {
				uni.showModal({
					title: '提示',
					content: '是否要删除？',
					showCancel: true,
					cancelText: '取消',
					confirmText: '确定',
					success: res => {
						if (res.confirm) {
							this.request({
								url: 'Smdcshop/index_banner_delect',
								data: {
									id: id,
								},
							}).then(res => {
								console.log(res, "res")
								if (res.code === 200 || res.code === "200") {
									uni.showToast({
										title: "删除成功",
										icon: "none",
									})
									setTimeout(() => {
										this.getData()
									}, 2000)
								}
							}).catch((res) => {
								uni.showToast({
									title: res.message,
									icon: "none",
								})
							});
						}
					},
					fail: () => {},
					complete: () => {}
				});
			},
			getData() {
				// if (page == 1) {
				// 	this.list = []
				// 	this.page = 1
				// 	this.is_bottom = false
				// }
				this.request({
					url: 'Smdcshop/index_banner_data',
					data: {
						// page,
						// limit: 10,
						admin_id: uni.getStorageSync("admin_id")
					}
				}).then(res => {
					if (res.code == 200) {
						this.list = res.data
					}
				})
			}

		}
	}
</script>

<style>
	
	/* @import url("../../static/css/comm"); */
	
	.content-icon {
		width: 100%;
		height: 400rpx;
	}

	.del {
		height: 44rpx;
		line-height: 44rpx;
		padding: 0 15rpx;
		font-size: 24rpx;
		background-color: #FF5722;
		/* margin-right: 25rpx; */
		color: #fff;
		border-radius: 4rpx;
	}

	page {
		background-color: #F4F5F7;
	}

	.list {
		padding: 30rpx 25rpx;
	}

	.list .item {
		border-radius: 8rpx;
		overflow: hidden;
		padding-left: 30rpx;
		border-left: 8rpx solid #247EFF;
		background-color: #fff;
		margin-bottom: 30rpx;
	}

	.list .item .top {
		/* height: 80rpx; */
		border-bottom: 1rpx solid #f5f5f5;
		padding: 20rpx 0;
	}

	.list .item .top .name {
		font-size: 30rpx;
		/* line-height: 80rpx; */
		font-weight: bold;
		max-width: 389rpx;
	}

	.list .item .top .type-btn {
		zoom: 0.7;
		margin-right: 25rpx;
	}

	.list .item .content {
		padding: 20rpx 0 24rpx;
	}

	.list .item .content .cell {
		flex: none;
		width: 50%;
		box-sizing: border-box;
		padding-right: 30rpx;
		font-size: 26rpx;
		line-height: 37rpx;
		color: #666;
	}

	.list .item .content .cell .title {
		color: #99A0AD;
	}
	
		/*  */
	.footer-bar {
			height: 160rpx;
			/*兼容 IOS<11.2*/
			padding-bottom: constant(safe-area-inset-bottom);
			/*兼容 IOS>11.2*/
			padding-bottom: env(safe-area-inset-bottom);
			box-sizing: content-box;
	}
	.footer-bar .content {
			width: 100%;
			height: 160rpx;
			background-color: #fff;
			position: fixed;
			left: 0;
			bottom: 0;
			z-index: 100;
			/*兼容 IOS<11.2*/
			padding-bottom: constant(safe-area-inset-bottom);
			/*兼容 IOS>11.2*/
			padding-bottom: env(safe-area-inset-bottom);
			box-sizing: content-box;
			box-shadow: 0 -5rpx 10rpx #eee;
	}
	.footer-bar .content .btn {
			width: 700rpx;
			height: 100rpx;
			background: linear-gradient(315deg, #3387ff 2%, #569bff 99%);
			border-radius: 8rpx;
			box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(51, 135, 255, 0.20);
			text-align: center;
			line-height: 100rpx;
			font-size: 36rpx;
			font-weight: 500;
			color: #fff;
	}
	.footer-bar .content .detail-btn {
			width: 50%;
			height: 40rpx;
	}
	.footer-bar .content .detail-btn .btn-icon {
			flex: none;
			display: block;
			width: 32rpx;
			height: 32rpx;
			margin-right: 8rpx;
	}
</style>
