Files
learning-system-mobile/pages/login/login.vue
2023-03-17 17:22:48 +08:00

116 lines
2.7 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view style="padding-top: 100px;">
<u-toast ref="loginToast"></u-toast>
<view style="padding: 40uxp;background-color: #FFFFFF;">
<view class="logo">
<view style="font-size: 50upx;">京东方大学堂</view>
</view>
<view class="row">
<view class="">
<u--input prefixIcon="account" placeholder="员工号" border="surround" v-model="loginName"></u--input>
</view>
</view>
<view class="row">
<view class="">
<u--input prefixIcon="lock" placeholder="密码" :password="true" type="password" border="surround" v-model="password"></u--input>
</view>
</view>
<view class="row">
<u-button @tap="submitLogin" type="primary" text="登 录"></u-button>
</view>
<view class="getpass">
<!-- <a href="#">忘记密码?</a> -->
</view>
</view>
</view>
</template>
<script>
import apiLogin from '@/api/login.js'
export default {
data() {
return {
loginName: '',//10181457
password: '',//666666
loading:false,
redirect: ''
}
},
onLoad(options) {
console.log(options,'options');
var pvArray=Object.keys(options);
this.redirect=options.returnUrl;
var params='';
pvArray.forEach(pv=>{
if(pv!='returnUrl'){
params+='&'+pv+'='+options[pv];
}
console.log(pv,'=',options[pv]);
});
},
mounted() {
//对cookies进行操作这里是写
//document.cookie = "mytest=qweqwe131231; path=/; max-age=" + 30*24*60*60;
//console.log('process.env.NODE_ENV',process.env.NODE_ENV);
//console.log('process.env.ENV_TYPE',process.env.ENV_TYPE);
},
methods: {
submitLogin(){
const params={
loginName:this.loginName,
password:this.password,
code:''
}
let $this=this;
this.$store.dispatch("Login", params).then(rs => {
$this.loading = false;
if(rs.status==200){
//console.log(rs);
//记录已登录
uni.setStorageSync("boe_new_login",1);
$this.$store.dispatch("InitData").then(res => {
//console.log(res)
//$this.$watermark.set(res.result.name + res.result.loginName);
// uni.switchTab({
// url:'/pages/index/index'
// })
if($this.redirect){
location.href=$this.redirect;
}else{
uni.switchTab({
url:'/pages/index/index'
})
}
});
}else{
console.log(rs.error);
$this.$refs.loginToast.show({message:'登录失败',type:'error'});
}
}).catch(() => {
$this.loading = false;
});
}
}
}
</script>
<style lang="scss" scoped>
page{
background-color: #FFFFFF;
}
.row{
margin: 30upx 100upx;
}
.logo{
text-align: center;
margin: 40upx;
}
.getpass{
text-align: right;
margin: 20upx 100upx;
}
</style>