<template>
	<view class="login-bg relative">
		<view class="logo-wrap"><h1>ACS</h1></view>
		<view class="login_wrap">
			<view class="login_w">
				<view class="login_tab">
					<view class="login_tab_item login_tab_active">配置</view>
				</view>
				<view class="login_cnt">
					<view class="login_card">
						<view class="zd-row card_wrap">
							<view class="zd-col-4 login_label">域名</view>
							<view class="zd-col-20">
								<input type="text" placeholder="域名地址" v-model="baseUrl" class="inputStyle">
							</view>
						</view>
						<view class="zd-row">
							<button class="primary-button" @tap="toConfig">配置</button>
						</view>
						<view class="zd-row">
							<text class="zd-col-24 san_text" @tap="isUpdate">升级版本</text>
						</view>
					</view>
				</view>
			</view>
			<view class="daoying_bg"></view>
		</view>
		<view v-if="version !== ''" class="version-name">v{{version}}</view>
		<Up-grade v-if="grade === true" @closeUpdate="closeUpdate" :androidUrl="androidUrl"></up-grade>
	</view>
</template>

<script>
	import { RSAencrypt } from '@/utils/jsencrypt.js'
	import {handLogin, pdaUpdate} from '@/utils/getData2.js'
	import permision from "@/utils/permission.js"
	import UpGrade from './upgrade.vue'
	export default {
		components: {
			UpGrade
		},
		data() {
			return {
				loginname: this.$store.getters.loginName,
				password: '',
				baseUrl: this.$store.getters.baseUrl,
				setTime: this.$store.getters.setTime / 1000,
				inputType: 'password',
				eyeOpen: true,
				drift: 0,
				disabled: false,
				jobnum: '',
				qrcode: '',
				logintype: '',
				version: '',
				versionCode: '',
				grade: false,
				androidUrl: ''
			};
		},
		methods: {
			toConfig () {
				let obj = {
					baseUrl: this.baseUrl,
					setTime: this.setTime * 1000
				}
				this.$store.dispatch('setConfig', obj)
				uni.redirectTo({
					url: '/pages/home/home'
				})
			},
			isUpdate () {
				this._pdaUpdate()
			},
			async _pdaUpdate () {
				let res = await pdaUpdate()
				if (res.code === 1) {
					this.grade = true
					this.androidUrl = res.result[0].url
					console.log(this.androidUrl)
				} else {
					uni.showToast({
						title: desc,
						icon: 'none'
					})
				}
			},
			closeUpdate () {
				this.grade = false
			}
		}
	}
</script>

<style lang="stylus" scoped>
@import '../../common/style/mixin.styl';
.login-bg
	_wh(100%, 100%)
	_bis(#fff,'../../static/images/page_bg.jpg', 100%, 100%,bottom)
.logo-wrap
	position fixed
	_wh(100%, 1.25rem)
	_bis(,'../../static/images/login_header_bg.png', 16.82rem, 100%,bottom)
	h1
		_font(.8rem, 1rem, #CF6A46,,center)
		font-family 'YouSheBiaoTiHei'
.login_wrap
	position fixed
	left 50%
	top 50%
	width 9rem
	padding .87rem .85rem .82rem .98rem
	transform translate3d(-50%, -50%, 0)
	_bis(,'../../static/images/form_bg.png', 100%, 100%,bottom)
.login_w
	_wh(100%, 100%)
	overflow hidden
.login_tab
	height 1.07rem
	margin-bottom .51rem
	_bis(,'../../static/images/login_tabs_bg.png', 100%, 100%,bottom)
.login_tab_item
	_wh(2.7rem, .73rem)
	_font(.4rem,.73rem,#99B1DD,,center)
	font-family 'YouSheBiaoTiHei'
.login_tab_active
	color #fff
	_bis(,'../../static/images/login_tab_active.png', 100%, 100%,bottom)
.login_cnt
	100%
.login_card
	width 100%
	padding 0 .41rem
.card_wrap
	margin-bottom .52rem
.login_label
	_font(.3rem, .8rem, #AFBED8,700,)
.inputStyle
	_font(.3rem, .8rem, #fff,,)
	_wh(100%, .8rem)
	background: rgba(45,88,184,0.1);
	border: 1px solid #4980BD;
	padding 0 .22rem
.inputStyle[focus]
	background: rgba(45,88,184,0.25);
	border: 1px solid #21D0F2;
	line-height .8rem
.login_icon
	position absolute
	top 5px
	right 10px
.primary-button
	_wh(3.36rem, .93rem)
	_font(.48rem,.93rem,#fff,,center)
	font-family 'YouSheBiaoTiHei'
	_bis(,'../../static/images/button.png', 100%, 100%,bottom)
.san_text
	margin-top .4rem
	_font(0.34rem,0.34rem,#fff,,center)
.drift
	transition left .3s linear
.version-name
	width 100%
	position: absolute
	bottom 3%
	_font(15px, 30px, #fff,,center)
.daoying_bg
	position: absolute
	bottom -30%
	left 0
	_wh(100%, 30%)
	_bis(,'../../static/images/daoy.png', 100%, 100%,bottom)
</style>
