<template>
	<view class="container">
		<form @submit="onSubmit">
			<view class="page-block">
				<view class="content">
					<view class="cell flex flex-y-center box-pack-between">
						<view class="title-block required">
							<text>品牌信息</text>
						</view>
						<view class="desc">
							<input type="text"  name="brand_name" class="input-box" placeholder="请输入品牌信息"
								placeholder-class="desc-placeholder">
						</view>
					</view>

					<view class="cell flex flex-y-center box-pack-between">
						<view class="title-block required">
							<text>优惠券总金额</text>
						</view>
						<view class="desc">
							<input type="number" name="total_amount"  class="input-box" placeholder="请输入优惠券总金额"
								placeholder-class="desc-placeholder">
						</view>
					</view>
					
					
					<view class="cell flex flex-y-center box-pack-between">
						<view class="title-block required">
							<text>使用门槛</text>
						</view>
						<view class="desc">
							<input type="number" name="floor_amount"  class="input-box" placeholder="请输入使用门槛"
								placeholder-class="desc-placeholder">
						</view>
					</view>
					
					
					<view class="cell  flex-y-center  box-pack-between">
						<view class="title-block required">发放时间</view>
						
						<view class="timeSelete flex-y-center">
							
							<picker mode="date" :start="startDate" :end="endDate"
								@change="bindDateChangeStart1">
								<view class="uni-input">{{startDates}}</view>
							</picker>
							<view class="timeSelete-left">
								至
							</view>	
							<picker mode="date" :start="startDate" :end="endDate"
								@change="bindDateChangeStart2">
								<view class="uni-input">{{endDates}}</view>
							</picker>
						</view>
					</view>
					
					<view class="cell  flex-y-center box-pack-between">
						<view class="title-block required">有效时间</view>
						
						<view class="timeSelete flex-y-center">
							
							<picker mode="date" :start="startDate" :end="endDate"
								@change="bindDateChangeStart3">
								<view class="uni-input">{{startDates2}}</view>
							</picker>
						 <view class="timeSelete-left">
						 	至
						 </view>	
							<picker mode="date" :start="startDate" :end="endDate"
								@change="bindDateChangeStart4">
								<view class="uni-input">{{endDates2}}</view>
							</picker>
						</view>
					</view>

				</view>
			
			</view>

			<view class="footer-bar">
				<view class="content flex flex-center" style="background: none;">
					<!-- <view class="btn">立即添加</view> -->
					<button class="btn" hover-class="none" form-type="submit">
						立即添加
					</button>
				</view>
			</view>
		</form>



	</view>
</template>

<script>
	export default {
		data() {
			return {
				tableTypeList: ['大桌', '中桌', '小桌'],
				tableType: "",
				store_id:"",
				info:{},
				
				startDate:'2020-10-1',
				endDate:'2080-10-1',
				
				startDates:"开始时间",
				endDates:"结束时间",
				
				startDates2:"开始时间",
				endDates2:"结束时间",
			}
		},
		onLoad(e) {
		
			this.store_id=uni.getStorageSync("store_id");

		},
		methods: {
			
			// 开始时间
			bindDateChangeStart1(e) {
				this.startDates = e.target.value;
			},
			//结束时间
			bindDateChangeStart2(e) {
				this.endDates = e.target.value;
			},
			// 开始时间
			bindDateChangeStart3(e) {
				this.startDates2 = e.target.value;
			},
			//结束时间
			bindDateChangeStart4(e) {
				this.endDates2 = e.target.value;
			},
			
			onSubmit(e) {
				let params = {
					admin_id:uni.getStorageSync("admin_id"),
					id:0,
					brand_name: e.detail.value.brand_name,
					total_amount:e.detail.value.total_amount,
					floor_amount:e.detail.value.floor_amount,
					
					publish_start_time:this.startDates,
					publish_end_time:this.endDates,

					expire_start_time:this.startDates2,

					expire_end_time:this.endDates2,
						
				},url;

				
				
				if (params.name == "") {
					uni.showToast({
						title: "请输入名称",
						icon: 'none'
					})
					return false
				}
				this.request({
					url:"Smdcshop/add_alipaycoupon",
					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;
	}
	.timeSelete-left{
		margin: 0 20rpx;
	}
	.timeSelete {
		font-size: 28rpx;
	}
	.desc{
		text-align: right;
	}
</style>
