<template>
	<div class="main">
		<div class="mainTop">
			<div>主题风格</div>
			<div class="right">
				<div class="save" @click="save">保存</div>
				<!-- <div class="cz" @click="cz">重置</div> -->
			</div>
		</div>

		<div class="ztfg">
			<div class='top'>
				<div class="item"  :class="currItem== '' ? 'on': ''" @click="clickItem('')">
					<div class="le" style="background: rgb(233, 52, 34);"></div>
					<div class="ri">红色</div>
				</div>
				<div class="item"  :class="currItem== 'blue' ? 'on': ''" @click="clickItem('blue')">
					<div class="le"></div>
					<div class="ri">天空蓝</div>
				</div>
				<div class="item" :class="currItem== 'lv' ? 'on': ''" @click="clickItem('lv')">
					<div class="le" style="background:rgb(66, 202, 77);"></div>
					<div class="ri">生鲜绿</div>
				</div>
			</div>
			<div class="mainBottom">
				<div class='item' v-show="currItem== ''">
					<img class="img"
						src="https://zysc.fjptzykj.com:3000/shangcheng/667bbed3e719df73217b10d743eb880c1719cb294b6f50a81f78f597fdbcf351.png" style="width:300px;" />
				</div>
				
				<div class='item' v-show="currItem== 'blue'">
					<img class="img"
						src="https://zysc.fjptzykj.com:3000/shangcheng/4bffe9f0cee9605262a579ee45156c9e37a16e2a24035a0e49b8a4433075f793.jpg" />
				</div>
				<div class='item' v-show="currItem== 'lv'">
					<img class="img"
						src="https://zysc.fjptzykj.com:3000/shangcheng/0d0a7ab210afb5cee674e402ca3ec197a30523687acbec2e8e5f16fb52075e9b.jpg" />
				</div>
			</div>
		</div>
	</div>
</template>
<script setup lang="ts">
	// TODO @疯狂：要不要建个 decorate 目录，然后挪进去，改成 index.vue，这样可以更明确看到是个独立界面哈，更好找
	import * as DiyTemplateApi from '@/api/mall/promotion/diy/template'
	import * as DiyPageApi from '@/api/mall/promotion/diy/page'
	import { useTagsdivStore } from '@/store/modules/tagsdiv'
	import { DiyComponentLibrary, PAGE_LIBS } from '@/components/DiyEditor/util' // 商城的 DIY 组件，在 DiyEditor 目录下
	import { toNumber } from 'lodash-es'
	const message = useMessage() // 消息弹窗
	const currItem = ref('blue');

	function clickItem(val) {
		currItem.value = val;
	}

	function cz(val) {
		currItem.value = 'blue';
	}

	function save() {
		const val = '';
		// currItem.value = val;
		if(currItem.value == 'lv'){
			setZtClass('lv')
		}else if(currItem.value == 'blue'){
			setZtClass('blue')
		}else{
			setZtClass('')
		}
		// console.log("请求接口还没有写啊！！！！快让后端提供啊")
	}
	
	// 设置主题风格
	const setZtClass = async (id) => {
		const res = await DiyTemplateApi.setDiyZtClass(id);
		console.log(res, "sssss");
		if(res || res == ''){
			message.success('保存成功')
		}
	}
	
	// 获取商品分类
	const getZtClass = async () => {
		const res = await DiyTemplateApi.getDiyZtClass();
		currItem.value = res
	}
	getZtClass()
</script>

<style lang="scss" scoped>
	.main {
		display: flex;
		flex-wrap: wrap;

		.mainTop {
			width: 100%;
			margin: 10px 10px;
			background: white;
			padding: 10px 20px;
			font-weight: 700;
			display: flex;
			justify-content: space-between;
			align-items: center;

			.right {
				display: flex;

				div {
					padding: 5px 15px;
					font-weight: 400;
					font-size: 14px;
				}

				.save {
					background: #0256FF;
					margin-right: 10px;
					color: white;
					cursor: pointer;
				}

				.cz {
					border: 1px solid #cccccc;
					cursor: pointer;
				}
			}
		}

		.ztfg {
			width: 100%;
			margin: 10px 10px;
			background: white;
			padding: 30px 30px;
			.top{
				display: flex;
				margin-bottom: 10px;
				.item{
					padding:10px 15px;
					border:1px solid #cccccc;
					border-radius:6px;
					margin-right:10px;
					display:flex;
					align-items:center;
					cursor: pointer;
					&.on{
						border:1px solid #0256ff;
					}
					.le{
						margin-right:10px;
						border-radius:6px;
						width:25px;
						height:25px;
						background:rgb(28, 165, 233);
					}
					.ti{
						
					}
				}
			}
			.mainBottom {
				
				display: flex;

				.item {
					margin-right: 20px;
					text-align: center;
					border-radius: 12px;

					// &.on {
					// 	.text {
					// 		color: #0256ff;
					// 	}

					// 	.img {
					// 		border: 2px solid #0256ff;
					// 	}
					// }

					.img {
						width: 800px;
						border-radius: 12px;
						border: 2px solid white;
					}

					.text {
						margin-top: 10px;
					}
				}
			}

		}

	}
</style>