<template>
	<view class="zd_container">
		<nav-bar title="设置" :inner2="true" @goIn="goIn" :show1="false"></nav-bar>
		<view class="zd_content">
			<view class="zd_wrapper">
				<view class="input-wrap">
					<view class="input-label">服务器地址</view>
					<input type="text" class="setup-input" placeholder="请输入服务器地址" v-model.trim="addrip">
				</view>
			</view>
			<!-- <view class="zd_wrapper">
				<view class="input-wrap">
					<view class="input-label">刷新时间(s)</view>
					<input type="text" class="setup-input" placeholder="请输入刷新时间" v-model="setTime">
				</view>
			</view> -->
			<!-- <view class="zd_wrapper">
				<view class="input-wrap">
					<view class="input-label" style="margin-right: 20upx;">客户标签打印</view>
					<uni-data-select v-model="index" :localdata="options" @change="selectChange"></uni-data-select>
				</view>
			</view> -->
		</view>
		<view class="submit-bar">
		  <button class="submit-button" @click="_submit">确认</button>
		  <!-- <button class="submit-button" @click="_virtualprintType">查询</button> -->
		</view>
	</view>
</template>

<script>
	// import {virtualprintType} from '@/utils/getData2.js'
	import NavBar from '@/components/NavBar.vue'
	export default {
		components: {
			NavBar
		},
		data() {
			return {
				options: [],
				index: '',
				addrip: this.$store.getters.baseUrl,
				setTime: this.$store.getters.setTime / 1000
			};
		},
		created () {
			// this._virtualprintType()
		},
		methods: {
			goIn () {
				uni.redirectTo({
					url: '/pages/login/login'
				})
			},
			/** 选择器 */
			selectChange(e) {
				this.index = e
			},
			/** 打印机类型下拉框查询 */
			async _virtualprintType () {
				let res = await virtualprintType(this.addrip)
				this.options = [...res.data]
				// if (this.$store.getters.setPrintName !== '') {
				// 	this.index = this.$store.getters.setPrintName
				// }
			},
			_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, setPrintName: this.index})
				uni.redirectTo({
					url: '/pages/login/login'
				})
			}
		}
	}
</script>

<style lang="stylus">
@import '../../common/style/mixin.styl';
.input-wrap
	width 100%
	_fj()
.input-label
	wh(200rpx, 58rpx)
	_font(28rpx,58rpx,#464646)
.setup-input
	_wh(calc(100% - 200rpx), 58rpx)
	background #fff
	_font(28rpx,58rpx,#323232)
	padding 0 10rpx
</style>
