<template>
	<view>
		<view class="cell ">
			<view class="title-block">
				<text> 首页弹窗开关</text>
			</view>
			<view class="desc">
				<view class="desc-content" v-for="(item,index) of zt_list" :key='index'>
					<view class="checklist-box" @click="choicezt(index)" :class="is_zt==index?'actt':''">
						<view class="radio__inner" :class="is_zt==index?'act_border':''">
							<view :class="is_zt==index?'is-default-checked':''"
								class="radio__inner-icon radio__inner-icon ">
							</view>
						</view>
						<text class="checklist-text">{{item}}</text>
					</view>
				</view>
			</view>
		</view>
		
		<view class="title-block" v-if="is_zt==2">
			<navigator :url="`../../../saomaDiancan/couponList/couponList?store_id=${store_id}`" class="navURL ">
				优惠券：点击跳转设置首页优惠券 
			</navigator>
		</view>

		<view class="cell">
			<view class="title-block">
				<text>弹窗时间</text>
			</view>
			<view class="desc">
				<view class="" style="display: inline-block;" v-for="(item,index) of day_list" :key='index'>
					<view class="checklist-box" @click="choiceDay(index)" :class="is_day==index?'actt':''">
						<view class="radio__inner" :class="is_day==index?'act_border':''">
							<view :class="is_day==index?'is-default-checked':''"
								class="radio__inner-icon radio__inner-icon ">
							</view>
						</view>
						<text class="checklist-text">{{item}}</text>
					</view>
				</view>
			</view>
		</view>
		<view class="sub-btn" @click="submit">
			提交
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				zt_list: ["关闭", "语音播报", "优惠劵", "轮播图"],
				is_zt: 0,
				day_list: ["每天一次", "每天每次"],
				is_day: 0,
				id:'',store_id:'',
			}
		},
		onLoad() {
			this.store_id=uni.getStorageSync("store_id");
			this.index_set_info();
		},
		methods: {

			index_set_info() {
				this.request({
					url: "Smdcshop/index_set_info",
					data: {
						admin_id: uni.getStorageSync("admin_id"),
					}
				}).then(res => {
					if (res.code == 200) {
						this.is_zt = res.data.is_pop;
						this.is_day = res.data.pop_day-1;
						this.id=res.data.id;
					}
				}).catch((res) => {
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				});
			},

			choicezt(e) {
				this.is_zt = e;
			},

			choiceDay(e) {
				this.is_day = e;
			},

			submit() {
				//is_pop 0关闭弹窗 1语音播报弹窗，2优惠券弹窗，3轮播图弹窗， 
				//pop_day 1每天一次   2每天
				this.request({
					url: "Smdcshop/index_set",
					data: {
						admin_id: uni.getStorageSync("admin_id"),
						is_pop: this.is_zt,
						pop_day: this.is_day + 1,
						id:this.id,
					}
				}).then(res => {
					if (res.code == 200) {
						uni.showToast({
							title: res.message,
							icon: 'none'
						}) 
						setTimeout(() => {
							uni.navigateBack()
						}, 2000)
					}
				}).catch((res) => {
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				});
			},
		}
	}
</script>

<style>
	page {
		background-color: #F1F1F1;
	}
	.navURL{
		font-size: 28rpx;
		color: red;
	}
	.desc {
		padding: 20rpx 25rpx;
		background-color: #FFFFFF;
		border-bottom: 1rpx solid #F1F1F1;
		width: 690rpx;
		margin: 0 auto;
		border-radius: 12rpx;
	}

	.desc-content {
		display: inline-block;
	}

	.title-block {
		font-size: 28rpx;
		padding: 20rpx 30rpx;
		color: #999999;
	}

	page .act_border {
		border: 1rpx solid #007AFF;
	}

	.checklist-box {

		display: -webkit-box;
		display: -webkit-flex;
		display: flex;

		-webkit-box-orient: horizontal;
		-webkit-box-direction: normal;
		-webkit-flex-direction: row;
		flex-direction: row;
		-webkit-box-align: center;
		-webkit-align-items: center;
		align-items: center;
		margin: 5px 0;
		margin-right: 22px;
	}

	.radio__inner {
		-webkit-flex-shrink: 0;
		flex-shrink: 0;

		display: -webkit-box;
		display: -webkit-flex;
		display: flex;

		-webkit-box-pack: center;
		-webkit-justify-content: center;
		justify-content: center;
		-webkit-box-align: center;
		-webkit-align-items: center;
		align-items: center;
		position: relative;
		border: 1px solid #DCDFE6;
		border-radius: 2px;
		box-sizing: border-box;
		width: 16px;
		height: 16px;
		border-radius: 16px;
		background-color: #fff;
		z-index: 1;
		-webkit-transition: border-color .3s;
		transition: border-color .3s;
	}

	.radio__inner-icon {
		width: 8px;
		height: 8px;
		border-radius: 10px;
		opacity: 0;
		-webkit-transition: -webkit-transform .3s;
		transition: -webkit-transform .3s;
		transition: transform .3s;
		transition: transform .3s, -webkit-transform .3s;
	}

	.is-default-checked {
		opacity: 1;
		background-color: #007aff;
		-webkit-transform: rotate(45deg) scaleY(1);
		transform: rotate(45deg) scaleY(1);
	}

	.checklist-text {
		font-size: 28rpx;
		margin-left: 5px;
		-webkit-transition: color 0.2s;
		transition: color 0.2s;
		color: #000;
	}

	.sub-btn {
		width: 690rpx;
		height: 100rpx;
		background: -webkit-linear-gradient(135deg, #3387ff 2%, #569bff 99%);
		background: linear-gradient(315deg, #3387ff 2%, #569bff 99%);
		border-radius: 8rpx;
		box-shadow: 0px 0px 8rpx 0px rgba(51, 135, 255, 0.20);
		text-align: center;
		line-height: 100rpx;
		color: #fff;
		font-size: 36rpx;
		font-weight: bold;
		margin: 0 auto;
		margin-top: 30px;
	}
</style>
