mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-09 02:46:46 +08:00
116 lines
2.7 KiB
Vue
116 lines
2.7 KiB
Vue
<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>
|