<template>
	<view>
		<view class="addcategory">
			<view class="cell_input jus-b ali-c">
				<view class="lablename">基础距离:</view>
				<view class="inputboxs ">
					<input type="number" class="input" value="" v-model="distance" placeholder-class='hahatext' placeholder="请设置基础距离" />
				</view>
			</view>
			<view class="mints">
				*注：基础距离单位为公里
			</view>
			<view class="cell_input jus-b ali-c">
				<view class="lablename">起步费用:</view>
				<view class="inputboxs ">
					<input type="number" class="input" value="" v-model="basics_price" placeholder-class='hahatext' placeholder="请输入起步费用" />
				</view>
			</view>
			<view class="mints">
				*注：起步费用单位为元
			</view>
			<view class="cell_input jus-b ali-c">
				<view class="lablename">每公里增加费用:</view>
				<view class="inputboxs ">
					<input type="number" class="input" value="" v-model="single_price" placeholder-class='hahatext' placeholder="请输入每公里增加费用" />
				</view>
			</view>
			<view class="mints">
				*注：每公里增加费用单位为 公里/元
			</view>
			<view v-if="false">
				<view class="cell_input jus-b ali-c">
					<view class="lablename">是否凌晨配送:</view>
					<view class="inputboxs ">
						<view class="lablename" v-model="dawn"></view>
					</view>
				</view>
				<view class="cell_input jus-b ali-c">
					<view class="lablename">基础距离:</view>
					<view class="inputboxs ">
						<input type="number" class="input" value="" v-model="dawn_distance" placeholder-class='hahatext' placeholder="请设置基础距离" />
					</view>
				</view>
				<view class="cell_input jus-b ali-c">
					<view class="lablename">起步费用:</view>
					<view class="inputboxs ">
						<input type="number" class="input" value="" v-model="dawn_basics_priceP" placeholder-class='hahatext' placeholder="请输入起步费用" />
					</view>
				</view>
				<view class="cell_input jus-b ali-c">
					<view class="lablename">每公里增加费用:</view>
					<view class="inputboxs ">
						<input type="number" class="input" value="" v-model="dawn_single_price" placeholder-class='hahatext' placeholder="请输入每公里增加费用" />
					</view>
				</view>
			</view>
			<view class="cell_input jus-b ali-c">
				<view class="lablename">餐盒费分配:</view>
				<view class="inputboxs ">
					<input type="number" class="input" value="" v-model="meals_fee_price" placeholder-class='hahatext' placeholder="请输入" />
				</view>
			</view>
			<view class="mints">
				*注：餐盒费分配单位为 元
			</view>

			<view class="cell_input jus-b ali-c">
				<view class="lablename">起步配送费:</view>
				<view class="inputboxs ">
					<input type="number" class="input" value="" v-model="nitial_delivery_fee" placeholder-class='hahatext' placeholder="请输入" />
				</view>
			</view>
			<view class="mints">
				*注：起步配送费单位为 元
			</view>


			<view class="submitbtns" @tap="setShop">确认</view>

		</view>
	</view>
</template>

<script>
	import {
		setShopDeliveryPrice,
		getShopDeliveryPrice
	} from "@/utils/api/api.js"
	export default {
		data() {
			return {
				distance: '', //基础距离
				basics_price: '', //基础距离起步费用
				single_price: '', //每公里增加费用
				dawn: 2, // 是否设置凌晨参数
				dawn_distance: 0, //凌晨基础距离
				dawn_basics_priceP: 0, //凌晨基础距离起步费用
				dawn_single_price: 0, //凌晨每公里增加费用
				meals_fee_price: '', //餐盒费分配
				nitial_delivery_fee: '', //起步配送费
			}
		},
		onLoad() {

			this.getShopDeliveryPriceFun();
		},
		methods: {
			setShop() {
				this.setShopDeliveryPriceFun();

			},
			async setShopDeliveryPriceFun() {
				// if(this.distance==''){
				// 	this.$api.msg('基础距离不能为空')
				// 	return false
				// }
				// if(this.basics_price==''){
				// 	this.$api.msg('基础距离起步费用不能为空')
				// 	return false
				// }
				// if(this.single_price==''){
				// 	this.$api.msg('每公里增加费用不能为空')
				// 	return false
				// }
				// if(this.meals_fee_price==''){
				// 	this.$api.msg('餐盒费分配不能为空')
				// 	return false
				// }
				// if(this.nitial_delivery_fee==''){
				// 	this.$api.msg('起步配送费不能为空')
				// 	return false
				// }
				let res = await setShopDeliveryPrice({
					distance: this.distance,
					basics_price: this.basics_price,
					single_price: this.single_price,
					dawn: this.dawn,
					dawn_distance: this.dawn_distance,
					dawn_basics_priceP: this.dawn_basics_priceP,
					dawn_single_price: this.dawn_single_price,
					meals_fee_price: this.meals_fee_price,
					nitial_delivery_fee: this.nitial_delivery_fee,
				})
				if (res.code == 0) {
					uni.showModal({
						title: '提示',
						content: res.msg,
					})
					setTimeout(() => {
						uni.switchTab({
							url: '/pages/index/index',
						});
					}, 600)

				}

			},

			// 获取

			async getShopDeliveryPriceFun() {
				let res = await getShopDeliveryPrice({})
				if (res.code == 0) {
					this.distance = res.data.distance,
						this.basics_price = res.data.basics_price,
						this.single_price = res.data.single_price,
						this.dawn = res.data.dawn,
						this.dawn_distance = res.data.dawn_distance,
						this.dawn_basics_priceP = res.data.dawn_basics_priceP,
						this.dawn_single_price = res.data.dawn_single_price,
						this.meals_fee_price = res.data.meals_fee_price,
						this.nitial_delivery_fee = res.data.nitial_delivery_fee
				}

			}



		}
	}
</script>

<style lang="scss">
	.addcategory {
		margin: 20upx 24upx;
		padding: 20upx;
		padding-top: 70upx;
		background-color: #FFFFFF;
		border-radius: 14upx;

		.mints {
			margin-left: 40%;
			margin-bottom: 30upx;
			color: #ff6900;
			font-size: 20upx;
			font-weight: 500;
		}

		.hahatext {
			font-size: 28upx;
		}

		.cell_input {
			margin-bottom: 10upx;
			height: 80upx;
			line-height: 80upx;

			.lablename {
				height: 80upx;
				line-height: 80upx;
				margin-right: 20upx;
			}

			.inputboxs {
				width: 60%;
				border: 1px solid rgb(241, 241, 241);
			}

			.inputboxs .input {
				padding: 20upx;
				height: 80upx;
				line-height: 80upx;
			}
		}

		.submitbtns {
			margin-top: 60upx;
			background: $base_color;
			color: #FFFFFF;
			font-size: 32upx;
			border-radius: 12upx;
			height: 88upx;
			line-height: 88upx;
			text-align: center;
		}
	}
</style>
