<template>
|
<view class="login">
|
<!-- login -->
|
<image :src="logo" class="loginImg" mode="aspectFit" />
|
<!-- 标题 -->
|
<view class="title">
|
<view class="title1">
|
<h2>云内动力汽油机车间</h2>
|
</view>
|
<view class="title2">
|
<h3>-智能立库管理系统-</h3>
|
</view>
|
</view>
|
<u-form :model="loginForm" ref="loginRef">
|
<u-form-item label="" prop="username">
|
<u-input v-model="loginForm.username" border placeholder="请输入用户名"/>
|
<u-icon name="account" size="24"></u-icon>
|
</u-form-item>
|
<u-form-item label="" prop="password">
|
<u-input v-model="loginForm.password" type="password" border placeholder="请输入密码"/>
|
<u-icon name="lock-open" size="24"></u-icon>
|
</u-form-item>
|
</u-form>
|
<!-- 修改ip -->
|
<!-- <u-row class="setIp">
|
<u-col span="3">接口地址:</u-col>
|
<u-col :span="6">
|
<u-input v-model="ip" border placeholder="请输入ip"></u-input>
|
</u-col>
|
<u-col span="3">
|
<u-button type="primary" @click="setBaseUrl">绑定</u-button>
|
</u-col>
|
</u-row> -->
|
<!-- 登录按钮 -->
|
<u-button type="primary" class="loginBtn" @click="loginIn">登录</u-button>
|
</view>
|
</template>
|
|
<script>
|
import {login} from '../../api/login/login.js'
|
export default {
|
data() {
|
return {
|
logo:require('../../assets/logo.jpg'),
|
loginForm:{
|
username:'pda',
|
password:'123456'
|
},
|
rules: {
|
username:[
|
{required:true,message:'用户名不能为空',trigger:'blur'}
|
],
|
password:[
|
{required: true,message:'密码不能为空',trigger:'blur'}
|
]
|
},
|
//ip:'192.168.0.3',//服务地址
|
//ip:'localhost',//服务地址
|
}
|
},
|
methods: {
|
//登录
|
loginIn(){
|
this.$refs.loginRef.validate((vali) => {
|
if(vali) {
|
login(this.loginForm).then(res => {
|
//登录成功提示
|
uni.showToast({
|
duration:1000,
|
title:'登录成功',
|
icon:'success'
|
})
|
//保存当前用户的权限信息
|
uni.setStorageSync('power',res.data);
|
uni.setStorageSync('_username',res.name);
|
//跳转首页
|
uni.redirectTo({
|
url: '../index/index'
|
})
|
}).catch(()=>{})
|
}else {
|
uni.showToast({
|
title:'用户名密码不能为空'
|
})
|
}
|
})
|
},
|
// setBaseUrl(){
|
// this.$store.dispatch('setIp',this.ip);
|
// console.log(this.$store.state)
|
// }
|
},
|
onReady() {
|
//用户名密码绑定校验规则(目前非空校验)
|
this.$refs.loginRef.setRules(this.rules);
|
//this.$store.dispatch('setIp',this.ip);//注释掉,这里不需要更改ip
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.login {
|
width: 100%;
|
height: 100%;
|
overflow: hidden;
|
.loginImg {
|
display: block;
|
width: 66% !important;
|
height: 100rpx;
|
margin: 100rpx auto;
|
}
|
.title {
|
width: 85%;
|
margin: 30rpx auto;
|
h2,h3 {
|
text-align: center;
|
margin-bottom: 20rpx;
|
}
|
}
|
.u-form {
|
padding:0 100rpx;
|
.u-form-item {
|
position: relative;
|
height: 130rpx;
|
.u-input {
|
padding: 0 50rpx !important;
|
}
|
.u-form-item__message {
|
padding-left: 20rpx !important;
|
}
|
.u-icon {
|
position: absolute;
|
left: 3%;
|
top: 48rpx;
|
color: #555;
|
}
|
}
|
}
|
.loginBtn {
|
width: 70%;
|
margin: 90rpx auto;
|
}
|
.u-border-bottom:after {
|
border-bottom-width: 0;
|
}
|
.setIp {
|
width: 94%;
|
margin: 0 auto;
|
}
|
}
|
|
</style>
|