vue登录
<template> <section class="wrap-page wrap-page-u" style="padding-top:2rem;"> <div class="us-box"> <h2>登录</h2> <div class="lItem"> <input type="number" placeholder="手机号" class="int" v-model="form.userName"/> </div> <div class="lItem"> <input type="password" placeholder="密码" class="int" v-model="form.passwd"/> <a href="#" class="green ftcode">忘记密码?</a> </div> <div class="lbot"> <input type="button" @click="doLogin" class="lbtns" value="登录"/> <router-link to="/mobile/index/register"><a class="lreg green">创建新账号</a></router-link> </div> </div> </section> </template> <script> export default { name: 'My', data () { return { msg: 'Welcome to Your Vue.js App', form: { userName: '', passwd: '', // vcode: '', }, } }, methods:{ doLogin(){ if (!this.form.userName) { this.$toast('请输入邮箱/手机号'); return; } if (!this.form.passwd) { this.$toast('请输入密码'); return; } this.$indicator.open('登录中...'); const param = { loginId: this.form.userName, userPwd: this.form.passwd, }; this.$api.get('/apis/index.php?act=login', { "act": "login" }, response => { this.$indicator.close(); this.$router.replace('/home'); },error => { this.$indicator.close(); this.$toast('error'); } ); } } } </script>
<template>
<section class="wrap-page wrap-page-u" style="padding-top:2rem;">
<div class="us-box">
<h2>登录</h2>
<div class="lItem">
<input type="number" placeholder="手机号" class="int" v-model="form.userName"/>
</div>
<div class="lItem">
<input type="password" placeholder="密码" class="int" v-model="form.passwd"/>
<a href="#" class="green ftcode">忘记密码?</a>
</div>
<div class="lbot">
<input type="button" @click="doLogin" class="lbtns" value="登录"/>
<router-link to="/mobile/index/register"><a class="lreg green">创建新账号</a></router-link>
</div>
</div>
</section>
</template>
<script>
export default {
name: 'My',
data () {
return {
msg: 'Welcome to Your Vue.js App',
form: {
userName: '',
passwd: '',
// vcode: '',
},
}
},
methods:{
doLogin(){
if (!this.form.userName) {
this.$toast('请输入邮箱/手机号');
return;
}
if (!this.form.passwd) {
this.$toast('请输入密码');
return;
}
this.$indicator.open('登录中...');
const param = {
loginId: this.form.userName,
userPwd: this.form.passwd,
};
this.$api.get('/apis/index.php?act=login', {
"act": "login"
}, response => {
this.$indicator.close();
this.$router.replace('/home');
},error => {
this.$indicator.close();
this.$toast('error');
}
);
}
}
}
</script>