<template>
	<view class="content">
		<view class="box_item" v-for="(item,index) in item_List">
			<!-- 标题 -->
			<p class="box_title">{{item.title}}</p>
			<!-- 输入 -->
			<view class="input_box">
				<p>每日可获取奖励次数:</p>
				<input :class="item.id == change_id?'input_active':''" type="number" placeholder="1"
					v-model.number="item.lin1_num" :disabled="item.id == change_id?false:true" />
			</view>
			<!-- 第二个输入 -->
			<view class="input_box">
				<p>每次可获得活跃度:</p><input type="number" :class="item.id == change_id?'input_active':''" placeholder="1"
					v-model.number="item.lin2_num" :disabled="item.id == change_id?false:true" />
			</view>
			<!-- 按钮 -->
			<view class="item_btns" v-if="change_id==item.id">
				<view class="btns_left" @click="cancel_change">
					取消
				</view>
				<view class="btns_right" @click="queding_change(item.lin1_num,item.lin2_num)">
					确认
				</view>
			</view>
			<view class="item_btn" v-else @click="changetext(index,item.id)">
				修改
			</view>

		</view>
		<!-- 等级设置的功能区域 -->
		<view class="level_shezhi">
			<h4>等级设置</h4>
			<!-- 标题区域 -->
			<view class="shezhi_box">
				<view class="left_shezhi_box">
					等级
				</view>
				<view class="center_shezhi_box">
					升级所需活跃度
				</view>
				<view class="right_shezhi_box">
				
				</view>
			</view>
			<!-- 输入区域 -->
			<view class="shezhi_box_else" v-for="(item,index) in level_List">
				<view class="left_shezhi_box">
					{{index+1}}
				</view>
				<view class="center_shezhi_box">
					<input type="text" class="inputs" :class="index == if_focus?'input_active':''" v-model="item.huoyue_num" :focus="if_focus==index?true:false" />
				</view>
				<view class="right_shezhi_box" @click="bianji_level(index)">
					<image src="../../../static/images/icon/bianji_whitea.png" v-if="if_focus!=index" id="inputs" mode=""></image>
					<image src="../../../static/images/icon/binggo.png" mode=""v-else  @click.stop="finfsh_bianji"  ></image>
				</view>
			</view>
			<!-- 增加等级区域 -->
			<view class="add_level" @click="add_levels">
				增加等级
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue'
	var item_List = ref([{
		id: 1,
		title: '每日签到',
		lin1_num: 1,
		lin1_if_dis: true,
		lin2_num: 1,
		lin1_if_dis: false
	}, {
		id: 2,
		title: '关注用户',
		lin1_num: 2,
		lin2_num: 2
	}])
	//等级列表
	var level_List = ref([{
		huoyue_num:1000
	},{
		huoyue_num:2000
	},{
		huoyue_num:3000
	}])
	var change_id = ref(-1)
	var if_focus = ref(-1)
	// 点击修改按钮
	function changetext(index, id) {
		change_id.value = id
	}
	// 点击取消修改按钮
	function cancel_change() {
		change_id.value = -1
	}

	function queding_change(l1, l2) {
		change_id.value = -1
		console.log('修改了', l1, l2);
		console.log(item_List.value);
	}
	function add_levels(){
		
		var last_level = level_List.value[level_List.value.length-1].huoyue_num
		level_List.value.push({
		huoyue_num:last_level+1000
	})
	}
	function bianji_level(index){
		console.log(index);
		if_focus.value = index
		
		
	}
	function finfsh_bianji(){
		if_focus.value=10
		console.log(if_focus.value);
	}
</script>

<style>
	page {
		background-color: #ffffff;
	}

	.content {
		padding-top: 32rpx;
	}

	.box_item {
		width: 686rpx;
		border-radius: 24rpx 24rpx 24rpx 24rpx;
		box-shadow: 0rpx 0rpx 10rpx #efefef;
		background: #ffffff;
		margin: 0 auto;
		padding: 24rpx;
		margin-top: 24rpx;
	}

	.box_title {
		font-weight: 600;
		margin-bottom: 32rpx;
	}

	.input_box {
		display: flex;
		margin-bottom: 14rpx;

		p {
			font-size: 26rpx;
			margin-right: 24rpx;
			width: 258rpx;
		}

		input {
			background-color: #F4F5F6;
			border-radius: 8rpx 8rpx 8rpx 8rpx;
			padding-left: 10rpx;
		}
	}

	.input_active {
		box-shadow: 0rpx 0rpx 0rpx 2rpx #6aa2ff;
	}

	.item_btn {
		width: 638rpx;
		height: 80rpx;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		background: #6aa2ff;
		display: flex;
		align-items: center;
		justify-content: center;
		color: #fff;
		font-weight: 600;
		margin-top: 36rpx;
	}

	.item_btns {
		display: flex;
		align-items: center;
		justify-content: space-around;
		margin-top: 36rpx;

		.btns_left {
			width: 300rpx;
			height: 80rpx;
			border-radius: 16rpx 16rpx 16rpx 16rpx;
			background: #f4f5f6;
			color: #999999;
			font-weight: 600;
			display: flex;
			align-items: center;
			justify-content: space-around;
		}

		.btns_right {
			width: 300rpx;
			height: 80rpx;
			border-radius: 16rpx 16rpx 16rpx 16rpx;
			background: #6aa2ff;
			display: flex;
			align-items: center;
			justify-content: space-around;
			color: #fff;
			font-weight: 600;
		}
	}

	.level_shezhi {
		width: 686rpx;
		height: 557rpx;
		border-radius: 24rpx 24rpx 24rpx 24rpx;
		background: #ffffff;
		box-shadow: 0rpx 0rpx 10rpx #efefef;
		margin: 48rpx auto;
		padding-top: 24rpx;

		h4 {
			text-align: center;
			font-size: 30rpx;

		}
	}

	.shezhi_box {
		width: 100%;
		margin-top: 20rpx;
		display: flex;

		.left_shezhi_box {
			width: 60rpx;
			height: 60rpx;
			font-size: 28rpx;
			margin-right: 30rpx;
			margin-left: 24rpx;
			
		}

		.center_shezhi_box {
			width: 472rpx;
			text-align: center;
			
		}
	}

	.shezhi_box_else {
		width: 100%;

		display: flex;
		margin-bottom: 20rpx;
		.left_shezhi_box {
			width: 60rpx;
			height: 60rpx;
			font-size: 28rpx;
			margin-right: 30rpx;
			box-shadow: 0rpx 0rpx 10rpx #efefef;
			display: flex;
			align-items: center;
			justify-content: center;
			font-weight: 600;
			margin-left: 24rpx;
			border-radius: 6rpx;
		}

		.center_shezhi_box {
			width: 472rpx;
			text-align: center;
			box-shadow: 0rpx 0rpx 10rpx #efefef;
			border-radius: 8rpx 8rpx 8rpx 8rpx;

			input {
				height: 100%;
				width: 100%;
				border-radius: 6rpx;
			}
		}

		.right_shezhi_box {
			width: 60rpx;
			height: 60rpx;
			border-radius: 8rpx 8rpx 8rpx 8rpx;
			background: #6aa2ff;
			margin-left: 30rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			image {
				width: 37rpx;
				height: 37rpx;
			}

		}
	}
	.add_level{
		width: 654rpx;
		height: 80rpx;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		background: #6aa2ff;
		margin-left: 24rpx;
		margin-top: 32rpx;
		color: #fff;
		font-weight: 600;
	}
</style>