<template>
	<view class=" goods">
		<view class="u-flex u-font-24 u-col-center u-row-between u-p-b-16 border-bottom">
			<view class="u-flex u-col-center">
				<view class="u-font-24">
					<text>排序</text>
					<text class="u-m-l-12">{{data.sort}}</text>
				</view>
				<view class="u-flex u-m-l-16 " @click="editSort">
					<image src="/pageGoodsGroup/static/image/icon-edit.svg" class="icon-edit" mode=""></image>
				</view>
			</view>
			<view class="u-flex">
				<view class="u-m-r-14 color-999">是否启用</view>
				<up-switch :activeValue="1" :inactiveValue="0" v-model="isShow" @change="isShowChange" :size="18"></up-switch>
			</view>
		</view>
		<view class="u-m-t-24 u-p-l-54 ">
			<view class="u-flex-1 u-flex u-col-top">
				<view class="color-666 no-wrap">分组名</view>
				<view class="color-333 u-m-l-60">{{data.name}}</view>
				<view class="u-flex u-m-l-16 " @click="editName">
					<image src="/pageGoodsGroup/static/image/icon-edit.svg" class="icon-edit" mode=""></image>
				</view>
			</view>
			<view class="u-flex u-m-t-24">
				<view class="color-666">售卖时间</view>
				<view class="color-main u-m-l-32" v-if="data.saleStartTime&&data.saleEndTime">
					<text>{{data.saleStartTime}}</text>
					<text>-</text>
					<text>{{data.saleEndTime}}</text>
				</view>
			</view>
		</view>

		<view class="u-m-t-24 u-flex u-row-right">
			<view class="btn-default btn" @click="del">删除</view>
			<view class="btn-primary btn u-m-l-38" @click="toEdit">编辑</view>
		</view>

	</view>
</template>

<script setup>
	import {
		computed,
		ref,
		watchEffect
	} from 'vue';
	import mySwitch from '@/components/my-components/my-switch.vue'
	import go from '@/commons/utils/go.js';
	import {
		ColorMain
	} from '@/commons/color.js'

	const emits = defineEmits(['changeClick','edit', 'editName','editSort', 'del', 'isShowChange'])

	const props = defineProps({
		index: {
			type: Number
		},
		data: {
			type: Object,
			default: () => {
				return {
					isShow:true
				}
			}
		},
	})

	let isShow = ref(props.data.isShow)

	function isShowChange() {
		console.log(isShow.value);
		emits('isShowChange', {
			...props.data,
			isShow: isShow.value
		})
	}

	let isSellNone = ref(true)
	isSellNone.value = props.isSellNone

	function isSellNoneChange() {
		console.log(isSellNone.value);
		console.log('isSellNoneChange');
	}

	let checked = ref(false)

	function radioClick() {
		console.log(props.index);
		emits('radioClick', props.index)
	}

	function changeClick() {
		emits('changeClick', props.index)
	}

	function useTypeClick() {
		emits('useTypeClick', props.index)
	}
	function del() {
		emits('del', props.index)
	}
	function editName() {
		emits('editName', props.index)
	}
	//携带参数type edit跳转到商品添加页面，编辑与添加同一页面，根据type值来判断
	function editSort() {
		emits('editSort', props.index)
	}
	function toEdit() {
		emits('edit', props.index)
		// uni.setStorageSync('cateItem', props.data)
		// go.to('PAGES_CATEGORY_EDIT', {
		// 	type: 'edit',
		// })
	}
</script>

<style lang="scss" scoped>
	$imgSize: 126rpx;
	$price-color: #F02C45;

	.btn {
		padding: 6rpx 28rpx;
		border-radius: 100rpx;
		font-size: 24rpx;
		border: 1px solid transparent;
	}

	.btn-primary {
		border-color: $my-main-color;
		color: $my-main-color;
	}

	.btn-default {
		border-color: #999;
		color: #999;
	}

	.price {
		color: $price-color;
	}

	.h-100 {
		height: $imgSize;
	}

	.img {
		width: $imgSize;
		height: $imgSize;
	}

	.icon-arrow-right {
		width: 32rpx;
		height: 32rpx;
	}

	.stock {
		padding-right: 46rpx;
		position: relative;
	}

	.icon-edit {
		width: 24rpx;
		height: 24rpx;
	}

	.stock::after {
		content: '';
		position: absolute;
		right: 10rpx;
		top: 50%;
		transform: translateY(-50%);
		display: block;
		width: 16rpx;
		border: 2rpx solid #333333;
	}

	.goods {
		border-radius: 10rpx 10rpx 10rpx 10rpx;
		background-color: #fff;
		padding: 32rpx 28rpx 32rpx 28rpx;
		font-size: 28rpx;

		.skus {
			background: #F9F9F9;
			border-radius: 14rpx 14rpx 14rpx 14rpx;
			padding: 28rpx 42rpx;

			.sku {
				color: #000;
				font-weight: 700;
				padding: 6rpx 40rpx;
			}

			.skds {
				gap: 10rpx 50rpx;
			}

			.skd {
				padding: 14rpx 40rpx;
				background: #F0F2F5;
				border-radius: 4rpx;
				position: relative;
				color: #666;
				overflow: hidden;

				.tag {
					position: absolute;
					right: 0;
					top: 0;
					font-size: 12rpx;
					right: 0;
					padding: 2rpx 4rpx;
					border-radius: 0rpx 4rpx 4rpx 4rpx;
				}

				.tag-primary {
					background-color: $my-main-color;
					color: #fff;
				}
			}


		}
	}
</style>