<template>
	<view class="content">


		<!-- 		<view class="search-user flex-y-center ">
			<view class="search-content flex-y-center">
				<icon type="search" size="18" />
				<input confirm-type="search" v-model="seTval" @confirm="confirm" @input="getSearch" class="flex-grow-1"
					type="text" placeholder-style="font-size:26rpx" placeholder="请输入关键词" />
				<view class="flex-center" style="margin-left: 10rpx;" @click.stop="onDel" v-if="seTval">
					<icon type="clear" size="18" />
				</view>
			</view>
			<view class="search-btn" @click="search">
				搜索
			</view>
		</view>
		<view class="header-hg100"></view> -->


		<view class="list">
			<view @click="detail(item.id,item.admin_id)" class="item" v-for="(item,index) in list" :key="index">
				<view class="top flex flex-y-center box-pack-between" style="padding: 20rpx 0;">
					<view class="name">{{item.type ==1?'位置':'商品'}} </view>
					<view class="flex-y-center">
						<view class="delBtns flex-center" style="background:#1E9FFF;" @click.stop="menuBtns(0,item.id)">
							编辑 </view>
						<view class="delBtns flex-center" style="background: #FF5722;"
							@click.stop="menuBtns(1,item.id)">删除</view>
					</view>
				</view>

				<view class="content flex flex-y-center box-pack-between" hover-class="nav-hover">
					<view class="cell flex flex-y-center">
						<view class="title">预约金额：</view>
						<view class="desc">{{item.money}}</view>
					</view>
				</view>

				<view class="content flex flex-y-center box-pack-between" hover-class="nav-hover">
					<view class="cell flex flex-y-center">
						<view class="title">创建时间：</view>
						<view class="desc">{{item.create_time}}</view>
					</view>
				</view>
			</view>
			<block v-if='list.length<=0'>
				<no-none></no-none>
			</block>
		</view>

		<view class="header-hg100"></view>

		<view class="footer-bar">
			<view class="content flex flex-center">
				<navigator :url="`./yyedit?titaleType=1`" class="btn">+新增预约</navigator>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				type: 2,
				seTval: '',
				page: 1,
				list: [],
				admin_id: '',
				store_id: '',
				is_bottom: false,
				keywords: "",
			}
		},

		onLoad(e) {
			this.type = e.type;
			this.admin_id = uni.getStorageSync("admin_id");
			this.store_id = uni.getStorageSync("store_id");
			this.list = [];
			this.getData(1)
		},

		onShow() {
			// this.list = [];
			// this.getData(1)
		},
		
		onPullDownRefresh(){
			this.list = [];
			this.getData(1)
			console.log('下拉刷新')
		},

		onReachBottom() {
			if (!this.is_bottom) {
				this.getData(this.page + 1)
			}
		},

		methods: {
			//操作按钮
			menuBtns(e, id) {
				const that = this;
				let type = e; //0是编辑1是删除
				if (type == 0) {
					uni.navigateTo({
						url: `./yyedit?id=${id}&titaleType=2`
					})
				} else {
					uni.showModal({
						title: '提示',
						content: '确认要删除吗?',
						success: (res) => {
							if (res.confirm) {
								this.request({
									url: 'Smdcshop/delete_yy',
									data: {
										id: id,
									},
								}).then(res => {
									console.log(res, "res")
									if (res.code === 200 || res.code === "200") {
										uni.showToast({
											title: "删除成功",
											icon: "none",
										})
										setTimeout(() => {
											this.getData(1)
										}, 2000)
									}
								}).catch((res) => {
									uni.showToast({
										title: res.message,
										icon: "none",
									})
								});


							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});
				}
			},


			// getSearch(e) {
			// 	if (!e.detail.value) {
			// 		this.list = [];
			// 		this.keywords = "";
			// 		this.getData(1);
			// 	}
			// 	this.keywords = e.detail.value;
			// },

			// onDel() {
			// 	this.seTval = '';
			// 	this.list = [];
			// 	this.keywords = "";
			// 	this.getData(1);
			// },

			// confirm(e) {
			// 	this.list = [];
			// 	this.keywords = e.detail.value;
			// 	this.getData(1);
			// },

			// search(e) {
			// 	this.list = [];
			// 	this.getData(1);
			// },

			detail(id) {
				uni.navigateTo({
					url: `./yyDetail?id=${id}`
				})
			},



			getData(page) {
				if (page == 1) {
					this.list = []
					this.page = 1
					this.is_bottom = false
				}
				this.request({
					url: 'Smdcshop/yylist',
					data: {
						// admin_id: this.admin_id,
						page,
						// serch: this.keywords,
						limit: 10,
						store_id: this.store_id,
					}
				}).then(res => {
					if (res.code == 200 && res.data.length) {
						this.list = this.list.concat(res.data)
						this.page = page;
						uni.stopPullDownRefresh()
					} else {
						this.is_bottom = true
					}
				})
			}
		}
	}
</script>

<style>
	@import url("../static/css/common.css");

	page {
		background: #F9F9F9;
	}

	.search-user {
		z-index: 999;
		position: fixed;
		left: 0;
		width: 100%;
		height: 100rpx;
		background: #FFFFFF;
		margin-left: 15rpx;
	}

	.search-user .search-content {
		width: 83%;
		height: 70rpx;
		background: #F1F1F1;
		border-radius: 100rpx;
		padding: 0 20rpx;

	}

	.search-user .search-content icon {
		margin-right: 10rpx;
	}

	.search-user .search-btn {
		margin-left: 20rpx;
		font-size: 28rpx;
	}

	.header-hg100 {
		height: 100rpx;
	}


	.list {
		padding: 30rpx 25rpx;
	}

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

	.list .item .top {
		border-bottom: 1rpx solid #f5f5f5;
		padding: 10rpx 0;
	}

	.list .item .top .name {
		font-size: 34rpx;
		font-weight: bold;
	}

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

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

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

	.list .item .content .cell .title {
		color: #99A0AD;
	}




	.delBtns {
		width: 100rpx;
		height: 44rpx;
		font-size: 24rpx;
		margin-right: 25rpx;
		color: #fff;
		border-radius: 15rpx;
	}
</style>
