<template>
|
|
<view class="content">
|
|
<image class="logo" src="../../static/image/login.png"></image>
|
|
<view class="text-area">
|
|
<text class="title">管理终端</text>
|
|
</view>
|
|
<view class="user">
|
|
<input type="text" placeholder="账号" v-model="username" name="username">
|
|
<input type="password" placeholder="密码" v-model="password" name="password">
|
|
</view>
|
|
<view class="btn" @tap="skip">登录</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import {httpPost} from '../../utils/requset.js';
|
|
import {getItem,setItem} from "../util/storageHelper";
|
|
export default {
|
|
data() {
|
|
return {
|
|
title: 'Hello',
|
|
username: "admin",
|
|
password: "admin123",
|
|
}
|
|
},
|
|
onLoad() {
|
|
uni.removeStorageSync('NUM', 'message');
|
|
plus.screen.lockOrientation('landscape-primary'); //强制横屏
|
|
},
|
|
methods: {
|
|
skip() {
|
|
let username = this.username;
|
|
let password = this.password;
|
|
let password1='666666';
|
|
if (username && password) {
|
|
console.log(username, password)
|
|
httpPost({
|
|
url: '/login',
|
|
data: {
|
|
username,
|
|
password
|
|
}
|
|
}).then((res) => {
|
|
console.log(res)
|
|
if (res.data.code == 200) {
|
|
console.log(res.data)
|
|
let token = res.data.token;
|
|
setItem('token1', token);
|
|
setItem('username', username);
|
|
this.goSystem();
|
|
}else if(res.data.status == 403){
|
|
httpPost({
|
|
url:'/logout',
|
|
data:{}
|
|
}).then((res)=>{
|
|
console.log(res)
|
|
})
|
|
}
|
|
}).catch((err) => {
|
|
uni.showToast({
|
|
title:'无法连接到服务',
|
|
icon:'error'
|
|
})
|
|
console.log(err)
|
|
uni.showToast({
|
|
icon:'error',
|
|
title:'连接服务器失败'
|
|
})
|
|
})
|
|
} else if (!username) {
|
|
uni.showToast({
|
|
title: "请输入用户名",
|
|
icon: "error",
|
|
duration: 1000
|
|
})
|
|
} else {
|
|
uni.showToast({
|
|
title: "请输入密码",
|
|
icon: "error",
|
|
duration: 1000
|
|
})
|
|
}
|
|
},
|
|
|
|
goSystem() {
|
|
uni.reLaunch({
|
|
url: "/pages/index/index"
|
|
})
|
|
}
|
|
},
|
|
mounted() {
|
|
|
|
}
|
|
}
|
|
</script>
|
|
<style>
|
|
.content {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
background-image: url(../../static/image/login_bg.png);
|
|
background-size: 100% 100%;
|
|
color: #fff;
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
|
|
.logo {
|
|
width: 400px;
|
|
height: 320px;
|
|
}
|
|
|
|
.text-area {
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
margin-bottom: 2%;
|
|
}
|
|
|
|
.title {
|
|
font-size: 36px;
|
|
}
|
|
|
|
.user {
|
|
width: 90%;
|
|
height: 25%;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
}
|
|
|
|
.user input {
|
|
width: 400px;
|
|
height: 50px;
|
|
border: 1rpx solid #567192;
|
|
outline: none;
|
|
padding-left: 20px;
|
|
margin: 20px 0;
|
|
}
|
|
|
|
.btn {
|
|
width: 250px;
|
|
height: 40px;
|
|
background-color: #879FBE;
|
|
color: #0A62CF;
|
|
border: 1rpx solid #567192;
|
|
outline: none;
|
|
margin: 20px 0;
|
|
border-radius: 50px;
|
|
text-align: center;
|
|
line-height: 40px;
|
|
font-size: 20px;
|
|
}
|
|
</style>
|