<template>
	<view class="zd_container">
		<nav-bar title="设置" :inner2="true" @goIn="goIn"></nav-bar>
		<view class="zd_content">
			<view class="zd_wrapper">
				<view class="setup-item">
					<view class="setup-label">服务器地址</view>
					<input type="text" class="setup-input" placeholder="请输入服务器地址" v-model="addrip">
				</view>
				<view class="setup-item">
					<view class="setup-label">ACS地址</view>
					<input type="text" class="setup-input" placeholder="请输入ACS地址" v-model="acsip">
				</view>
				<!-- <view class="setup-item">
					<view class="setup-label">刷新时间(s)</view>
					<input type="text" class="setup-input" placeholder="请输入刷新时间" v-model="setTime">
				</view> -->
			</view>
		</view>
		<view class="zd-row submit-bar">
		  <button class="zd-col-24 button-primary" @click="_submit">确认</button>
		</view>
	</view>
</template>

<script>
	import NavBar from '@/components/NavBar.vue'
	export default {
		components: {
			NavBar
		},
		data() {
			return {
				addrip: this.$store.getters.baseUrl,
				acsip: this.$store.getters.acsUrl,
				setTime: this.$store.getters.setTime / 1000
			};
		},
		methods: {
			goIn () {
				uni.redirectTo({
					url: '/pages/login/login'
				})
			},
			_submit () {
				if (this.addrip === '') {
					uni.showToast({
						title: '请填写服务器地址',
						icon: 'none'
					})
					return
				}
				if (this.acsip === '') {
					uni.showToast({
						title: '请填写ACS地址',
						icon: 'none'
					})
					return
				}
				if (this.setTime === '') {
					uni.showToast({
						title: '请填写刷新时间',
						icon: 'none'
					})
					return
				}
				// 存值
				this.$store.dispatch('setConfig',{baseUrl: this.addrip, acsUrl: this.acsip, setTime: this.setTime * 1000})
				uni.redirectTo({
					url: '/pages/login/login'
				})
			}
		}
	}
</script>

<style lang="stylus">
@import '../../common/style/mixin.styl';
.setup-item
	width 100%
	margin-bottom 40rpx
.setup-label
	_font(24rpx,40rpx,#000)
.setup-input
	_wh(100%, 80rpx)
	background #fff
	_font(28rpx,80rpx,#323232)
	padding 0 28rpx
	border 2px solid #e9ecf3
	border-radius 12rpx
</style>
