<template>
	<view class="yc_main bg_ff">
		<view class="pt80 tc fs40">用户登录 </view>
		<!-- 登录窗口 -->
		<view class="p40">
			<view class="p20">
				<u-input v-model="form.login_name" maxlength="20" prefixIcon="account" placeholder="请输入账号" border="surround" clearable></u-input>
			</view>
			<view class="p20">
				<u-input v-model="form.password" maxlength="25" prefixIcon="lock" placeholder="请输入密码" border="surround" password clearable></u-input>
			</view>
			<view class="p20">
				<u-button type="primary" text="登录" @click="login">登录</u-button>
			</view>
			<view class="p20 fs24 tc"> <text class="font_color_content">没有账号，</text><text class="font_color_primary" @click="navigateTo('reg')">立即注册</text> </view>
		</view>

		<view class="fiexd_bottom_box p20">
			<view class="test_less">test less1</view>

			<version></version>
		</view>
	</view>
</template>

<script>
let tagInfo = "[/pages/index/index.vue]";
import basePage from "@/libs/base-page.js";
import Index from "../../libs/model";
export default {
	//name: "index-me",
	mixins: [basePage],

	data() {
		return {
			form: {
				login_name: "",
				password: ""
			}
		};
	},
	onLoad() {
		this.loadData();
	},
	methods: {
		async loadData() {
			//this.initSaveData();
			let token = this._util.storage.get("token");

			if (token) {
				uni.reLaunch({
					url: "/pages/manager/index"
				});
			}
		},
		async login() {
			if (!this.form.login_name || !this.form.password) {
				this._util.message.alert("请填写用户名或密码！");
				return;
			}
			let res = await Index.login(this.form.login_name, this.form.password);
			if (res.code != 0) {
				this._util.message.alert(res.msg);
				return;
			}
			this.setToken(res.data.token);
			this.navigateTo("../manager/index");
		}
	}
};
</script>

<style lang="less" scoped>
.yc_main {
	.fiexd_bottom_box {
		.test_less {
			color: #f00;
			font-size: 40rpx;
		}
	}
}
</style>
