<template>
	<view class="goods">
		<view class="goods-hd">
			<view class="item">
				<view class="a">分类名称</view>
				<view class="b">
					<input v-model="name" type="text" placeholder="请输入分类名称">
				</view>
			</view>
			<view class="items">
				<view class="a" style="justify-content: space-between;">状态<u-switch v-model="checked" active-color="#55BD6A" ></u-switch></view>
				<view class="b">
					用户端是否显示
				</view>
			</view>
			<view class="items">
				<view class="a">排序<text>*</text><view class="input"><input v-model="sort" type="text" placeholder="数字越小越靠前"/></view></view>
				<view class="d">1</view>
			</view>
		</view>
		<view class="goods-fd">
			<view class="btn" @click="toSubmit()">确认</view>
		</view>
		
	</view>
</template>

<script>
	import * as ArticleApi from '@/api/article'
	export default {
		data() {
			return {
				isShow: false,
				sort: "",
				name: "",
				tabMIndex: -1,
				list: [],
				checked: true,
				clickFlag: true,
			};
		},
		methods: {
			//提交修改
			async toSubmit(){
				if(!this.name){
					uni.showToast({
						icon: "none",
						title: "分类名称不能为空！"
					})
					return ;
				}
				if(this.clickFlag == false){
					return ;
				}
				this.clickFlag = false
				const { status, message } = await ArticleApi.articleCatAdd({
					name: this.name,
					img_id: this.img_id,
					status: this.checked ?1:0,
					sort: this.sort,
				});
				if(status == 200){
					this.clickFlag = true
					uni.showToast({
						title: "提交成功"
					})
					uni.$emit("reloadClasssify",{msg:'页面更新'})
					setTimeout(()=>{
						uni.navigateBack({
							delta: 1
						})
					},2000)
				}else{
					this.clickFlag = true
					uni.showToast({
						icon: "none",
						title: message
					})
				}
			},
			
		}
	}
</script>

<style lang="scss" scoped>
.goods{
	padding: 0 0 130rpx;
	overflow: hidden;
	&-hd{
		background-color: #fff;
		padding: 0 25rpx 0;
		overflow: hidden;
		margin-bottom: 20rpx;
		.item{
			padding: 20rpx 30rpx;
			line-height: 50rpx;
			font-size: 28rpx;
			color: #212121;
			display: flex;
			align-items: center;
			justify-content: space-between;
			border-bottom: 1px solid #F7F7F7;
			.a{
				text{
					color: #F34A40;
					margin-left: 5rpx;
				}
			}		
			.b{	
				font-size: 28rpx;
				color: #212121;
				display: flex;
				align-items: center;
				justify-content: flex-end;
				flex: 1;
				input{
					font-size: 28rpx;
					color: #212121;
					flex: 1;
					line-height: 50rpx;
					font-size: 28rpx;
					color: #212121;
					text-align: right;
					margin-right: 10rpx;
				}
				.select{
					width: 100%;
					display: flex;
					align-items: center;
					color: #C7C7C7;
					justify-content: flex-end;
					&-on{
						color: #212121;
					}
				}
			}
		}
		.items{
				padding: 20rpx 30rpx;
				line-height: 50rpx;
				font-size: 28rpx;
				color: #212121;
				border-bottom: 1px solid #F7F7F7;
				position: relative;
				.a{
					flex: 1;
					display: flex;
					align-items: center;
					input{
						flex: 1;
						font-size: 26rpx;
						color: #212121;
						line-height: 50rpx;
						margin-left: 20rpx;
					}
					text{
						color: #F34A40;
						margin-left: 5rpx;
					}
					.select{
						flex: 1;
					}
					.tip{
						margin-left: 15rpx;
						font-size: 24rpx;
						font-weight: 500;
						color: #9F9F9F;
					}
				}
				.b{
					padding-top: 10rpx;
					font-size: 24rpx;
					font-weight: 400;
					color: #C7C7C7;
				}
				.d{
					position: absolute;
					right: 20rpx;
					top: 20rpx;
					z-index: 2;
					font-size: 28rpx;
					font-weight: 400;
					color: #212121;
				}
				.c{
					padding-top: 20rpx;
					overflow: hidden;
					.slot-btn{
						width: 180rpx;
						height: 180rpx;
						background: #F6F6F6;
						border-radius: 10rpx;
						border: 1px solid #C0C0C0;
						text-align: center;
						font-size: 28rpx;
						font-weight: 500;
						color: #6D6D6D;
						.l{
							line-height: 30rpx;
						}
						image{
							width: 50rpx;
							height: 50rpx;
							display: block;
							margin: 0 auto;
							margin-top: 30rpx;
						}
					}
				}
			}
		
	}	
	&-fd{
		width: 100%;
		position: fixed;
		left: 0;
		bottom: 0;
		padding: 30rpx;
		z-index: 99;
		background-color: #fafafa;
		box-sizing: border-box;
		.btn{
			width: 630rpx;
			line-height: 88rpx;
			background: #F34A40;
			border-radius: 88rpx;
			text-align: center;
			font-size: 28rpx;
			font-weight: 500;
			color: #FFFFFF;
			margin: 0 auto;
		}
	}
	&-classify{
		width: 100%;
		overflow: hidden;
		&-hd{
			padding: 30rpx 60rpx;
			position: relative;
			font-size: 32rpx;
			font-weight: 500;
			color: #303030;
			text-align: center;
			.a{
				display: flex;
				align-items: center;
				font-size: 28rpx;
				font-weight: 500;
				color: #FF624F;
				position: absolute;
				top: 30rpx;
				left: 40rpx;
				z-index: 2;
			}
		}
		&-bd{
			overflow: hidden;
			display: flex;
			align-items: flex-start;
			.l{
				width: 210rpx;
				height: 560rpx;
				background-color: #F7F8FA;
				.item{
					text-overflow: ellipsis;
					overflow: hidden;
					height: 70rpx;
					font-size: 28rpx;
					font-weight: 400;
					color: #303030;
					white-space: nowrap;
					line-height: 70rpx;
					padding-left: 30rpx;
					box-sizing: border-box;
					&-on{
						background-color: #fff;
						font-weight: 500;
					}
				}
			}
			.m{
				width: 100%;
				text-align: center;
				max-height: 560rpx;
				.item{
					text-overflow: ellipsis;
					overflow: hidden;
					height: 70rpx;
					font-size: 28rpx;
					font-weight: 400;
					color: #303030;
					white-space: nowrap;
					line-height: 70rpx;
					padding-left: 80rpx;
					text-align: left;
					box-sizing: border-box;
					&-on{
						color: #FF624F;
					}
				}
			}
			.r{
				width: 540rpx;
				height: 560rpx;
				.item{
					text-overflow: ellipsis;
					overflow: hidden;
					height: 70rpx;
					font-size: 28rpx;
					font-weight: 400;
					color: #303030;
					white-space: nowrap;
					line-height: 70rpx;
					padding-left: 80rpx;
					box-sizing: border-box;
					&-on{
						color: #FF624F;
					}
				}
			}
		}
	}
}
</style>
