码迷,mamicode.com
首页 > 其他好文 > 详细

vue登录

时间:2018-11-24 22:29:36      阅读:281      评论:0      收藏:0      [点我收藏+]

标签:for   template   color   int   model   pwd   welcome   rem   res   

<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>


vue登录

标签:for   template   color   int   model   pwd   welcome   rem   res   

原文地址:https://www.cnblogs.com/vxianfeng/p/10013663.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!