<template>
	<view class="container">
		<view class="content">

			<view class="cell flex flex-y-center">
				<view class="title-block requsired">
					<text>是否开启外卖:</text>
				</view>
				<view class="desc">
					<view class="flex-center">
						<view class="checklist-box " @click="choicepay(item.type)" v-for="(item,index) of integral_arr"
							:key='index' :class="is_integral==item.type?'actt':''">
							<view class="radio__inner" :class="is_integral==item.type?'act_border':''">
								<view :class="is_integral==item.type?'is-default-checked':''"
									class="radio__inner-icon radio__inner-icon ">
								</view>
							</view>
							<text class="checklist-text">{{item.name}}</text>
						</view>
					</view>
				</view>
			</view>

			<view class="cell flex flex-y-center">
				<view class="title-block requsired">
					<text>是否开启堂食:</text>
				</view>
				<view class="desc">
					<view class="flex-center">
						<view class="checklist-box " @click="choicepayTs(item.type)"
							v-for="(item,index) of integral_arr_add" :key='index'
							:class="is_integral_add==item.type?'actt':''">
							<view class="radio__inner" :class="is_integral_add==item.type?'act_border':''">
								<view :class="is_integral_add==item.type?'is-default-checked':''"
									class="radio__inner-icon radio__inner-icon ">
								</view>
							</view>
							<text class="checklist-text">{{item.name}}</text>
						</view>
					</view>
				</view>
			</view>

		</view>

		<view class="footer-bar" @click="onSubmit">
			<view class="content flex flex-center" style="background: none;">
				<button class="btn" hover-class="none" form-type="submit">
					提交
				</button>
			</view>
		</view>


	</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				integral_arr: [{
					type: 1,
					name: "开启",
				}, {
					type: 2,
					name: "关闭",
				}, ],
				is_integral: 1,

				integral_arr_add: [{
					type: 1,
					name: "开启",
				}, {
					type: 2,
					name: "关闭",
				}, ],
				is_integral_add: 1,
				store_id: '',
				obj:{},
				id:'',
			}
		},
		onLoad(e) {
			this.store_id = uni.getStorageSync("store_id");
			this.less()
		},
		methods: {
			
			less(){
				let params = {
					store_id:this.store_id,
				}
				this.request({
					url: "xcx/siteConfigFind",
					data: params
				}).then(res => {
					if (res.code == 200||res.code == '200') {
						this.id=res.data.id;
						this.is_integral=res.data.outside==1?1:2;
					    this.is_integral_add=res.data.canteen==1?1:2;
					}
				}).catch((res) => {
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				});
			},
			
			choicepay(index) {
				this.is_integral = index;
			},
			
			choicepayTs(index) {
				this.is_integral_add = index;
			},
			
			onSubmit(e) {
				let params = {
					outside: this.is_integral == 1 ? 1 : 5,
					canteen: this.is_integral_add == 1 ? 1 :5,
					store_id:this.store_id,
					id:this.id,
				}
				this.request({
					url: "xcx/siteConfigFind",
					data: params
				}).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>
	@import url("./static/css/common.css");

	page {
		background-color: #F4F5F7;
	}

	page .content {
		background-color: #F4F5F7;
		padding: 0;
	}

	page .content .cell {
		background-color: #FFF;
		padding: 25rpx;
	}

	.title-block {
		margin-right: 20rpx;
	}

	.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;
	}

	.act_border {
		border: 1rpx solid #007aff;
	}
</style>
