<template>
	<view class="boxconstant">
		<view class="boxconstantbox"
			style="border-radius: 18px 18px 0 0;padding:32rpx 24rpx 0 24rpx;border-bottom: 2rpx solid #E5E5E5;">
			<view class="boxconstantbox_one">
				充值设置
			</view>
			<view class="boxconstantbox_tow">
				<text>用户消费结账时，成功充值成功</text>
				<input class="text" v-model="form.rechargeTimes"></input>
				<text>倍的金额本单即可享受免单</text>
			</view>
		</view>
		<view class="boxconstantbox" style="padding:32rpx 24rpx 0 24rpx; border-radius: 0 0  18px 18px;">
			<view class="boxconstantbox_one">
				充值门槛
			</view>
			<view class="boxconstantbox_tow">
				<text>订单支付金额需满</text>
				<input class="text" v-model="form.rechargeThreshold"></input>
				<text> 元，才能使用</text>
			</view>
		</view>
		<view class="oneboxconstant">
			<view class="oneboxconstant_one">
				功能启用
			</view>
			<up-switch v-model="form.enable" size="18"></up-switch>
		</view>
		<view class="boxconstantbox"
			style="margin-top:24rpx; padding:32rpx 24rpx 0 24rpx; border-radius: 0 0  18px 18px;">
			<view class="boxconstantbox_one">
				充值说明
			</view>
			<view class="boxconstantbox_tow">
				<up-textarea v-model="form.rechargeDesc" placeholder="请输入内容"></up-textarea>
			</view>
		</view>
		<view class="save" @click="editlist">
			保存
		</view>

	</view>
</template>

<script setup>
	import {
		onLoad,
		onShow,
	} from '@dcloudio/uni-app';
	import {
		computed,
		reactive,
		ref,
		watch
	} from 'vue';

	import {
		get,
		edit
	} from '@/http/yskApi/bwc.js'

	const form = reactive({
		id: '',
		enable: '',
		rechargeTimes: '',
		rechargeThreshold: '',
		withCoupon: '',
		withPoints: '',
		rechargeDesc: '',
		useTypeList: [],
		childShopIdList: '',
	});
	
	const getlist = async () => {
		let res = await get()
		console.log(res)
		Object.assign(form, res)
	}
	const editlist = async () => {
		let res = await edit(form)
		uni.showToast({
			title: '保存成功'
		})
		Object.assign(form, res)
		setTimeout(()=>{
			uni.navigateBack()
		},1500)
	}
	onShow(() => {
		getlist()
	})
</script>

<style lang="scss" scoped>
	page {
		background: #F9F9F9;
	}

	.boxconstant {
		padding: 32rpx 28rpx;

		.boxconstantbox {
			padding: 32rpx 24rpx;
			width: 100%;
			background: #FFFFFF;

			.boxconstantbox_one {
				font-family: Source Han Sans CN, Source Han Sans CN;
				font-weight: bold;
				font-size: 28rpx;
				color: #333333;
			}

			.boxconstantbox_tow {
				display: flex;
				justify-content: flex-start;
				align-items: center;
				flex-wrap: wrap;
				padding-bottom: 24rpx;
				font-family: Source Han Sans CN, Source Han Sans CN;
				font-weight: 400;
				font-size: 28rpx;
				color: #333333;
				box-sizing: border-box;

				.text {
					margin: 0 12rpx;
					width: 118rpx;
					height: 48rpx;
					background: #FFFFFF;
					border-radius: 8rpx 8rpx 8rpx 8rpx;
					border: 2rpx solid #E5E5E5;
				}
			}
		}

		.oneboxconstant {
			margin-top: 32rpx;
			width: 100%;
			background: #FFFFFF;
			border-radius: 12rpx 12rpx 12rpx 12rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			flex-wrap: wrap;
			padding: 32rpx 24rpx;

			.oneboxconstant_one {
				font-family: Source Han Sans CN, Source Han Sans CN;
				font-weight: 500;
				font-size: 28rpx;
				color: #333333;
			}

		}

		.save {
			margin: 100rpx auto 50rpx auto;
			width: 530rpx;
			height: 80rpx;
			background: #318AFE;
			border-radius: 56rpx 56rpx 56rpx 56rpx;
			font-family: Source Han Sans CN, Source Han Sans CN;
			font-weight: 500;
			font-size: 32rpx;
			color: #FFFFFF;
			line-height: 80rpx;
			text-align: center;
		}
	}
</style>