<template>
	<view class="content">
		<view class="input-wrap">
			<view class="input-label">服务器地址：</view>
			<input type="text" class="setup-input" v-model="addrip">
		</view>
		<view class="input-wrap">
			<view class="input-label">刷新时间(s)：</view>
			<input type="text" class="setup-input" v-model="setTime">
		</view>
		<view class="submit-bar">
		  <button class="submit-button" @click="_submit">确认</button>
		</view>
	</view>
</template>

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

<style lang="stylus">
@import '../../common/style/mixin.styl';
.input-wrap
	_wh(100%, 126rpx)
	padding-top 40rpx
	_fj()
.input-label
	wh(200rpx, 86rpx)
	_font(28rpx,86rpx,#464646)
.setup-input
	_wh(calc(100% - 200rpx), 86rpx)
	background #fff
	_font(28rpx,86rpx,#323232)
	text-indent: 16rpx;
</style>
