<template>
	<view class="probability_box">
		<view>
			概率：
		</view>
		<view>
			<input type="text" v-model="rate" placeholder="请输入内容" placeholder-style="color: #999;" />
		</view>
		<view>
			<button class="mini-btn" type="primary" size="mini" @click="save()" style="height: 29px;">保存</button>
		</view>
	</view>
</template>

<script>
	import API from '@/common/js/api.js'
	export default {
		data(){
			return{
				rate:0+"%"
			}
		},
		methods:{
			init(){
				API.request('/setting/getProbability', {} , res=>{
					this.rate = res.data.rate + '%'
				})
			},
			save(){
				uni.showModal({
					title:'温馨提示',
					content:"确定要修改概率吗？",
					success:(res)=>{
						if(res.confirm){
							API.request('/setting/settingProbability',{rate: this.rate}, res=>{
								if(200==res.code){
									uni.showToast({
										title: res.msg
									})
									this.init()
								}else{
									uni.showToast({
										title: res.msg
									})
								}
								// console.log(res);
							})
						}
					}
				})
			}
		},
		created() {
			this.init()
		}
	}
</script>

<style scoped lang="scss">
	.probability_box{
		display: flex;
		justify-content: space-around;
		align-items: center;
		margin:10px 5px 5px 5px;
		input{
			width: 500rpx;
			height: 80rpx;
			border: 1px solid #eee;
			border-radius: 5px;
			padding: 0px 10px;
			box-sizing: border-box;
			color: #444;
		}
	}
</style>