login.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <div class="d1" >
  3. <img class="logo" src="../../../public/loginbg/logo.png"/>
  4. </div>
  5. <van-form style="margintop:20px ;">
  6. <van-cell-group>
  7. <van-field v-if="type==1"
  8. v-model="userName"
  9. label="用户名"
  10. placeholder="用户名"
  11. :rules="[{ required: true, message: '请填写用户名' }]"
  12. />
  13. <van-field v-if="type==1"
  14. v-model="userPwd"
  15. type="password"
  16. label="密码"
  17. placeholder="密码"
  18. :rules="[{ required: true, message: '请填写密码' }]"
  19. />
  20. <van-field v-if="type==2"
  21. v-model="phone"
  22. label="手机号码"
  23. placeholder="手机号码"
  24. :rules="[{ required: true, message: '请填写手机号码' }]"
  25. />
  26. <van-field v-if="type==2"
  27. v-model="sms"
  28. center
  29. clearable
  30. label="短信验证码"
  31. placeholder="请输入短信验证码"
  32. >
  33. <template #button>
  34. <van-button size="small" type="primary">发送验证码</van-button>
  35. </template>
  36. </van-field>
  37. </van-cell-group>
  38. <div class="changetype" @click="changetbt"> {{changet}} </div>
  39. <div style="margin: 16px;">
  40. <van-button round block type="primary" native-type="submit" @click="save" >
  41. 登录
  42. </van-button>
  43. </div>
  44. </van-form>
  45. </template>
  46. <script>
  47. import { useStore } from 'vuex';
  48. export default {
  49. data () {
  50. return {
  51. userName:"",
  52. userPwd:"",
  53. phone:"",
  54. sms:"",
  55. onSubmit:"",
  56. type:1,
  57. changet: '用户名密码登录',
  58. t1:'用户名',
  59. t2:'密码',
  60. }
  61. },
  62. methods: {
  63. save(){
  64. const inputForm ={
  65. 'username': this.userName,
  66. 'password': this.userPwd,
  67. 'code': '',
  68. 'uuid': ''
  69. }
  70. //store.commit('setUser',"asdsdasd");
  71. // login(inputForm).then(({data}) => {
  72. // this.$store.commit('setUser',data);
  73. // })
  74. // login(inputForm).then(res => {
  75. // this.$store.commit('setUser',res.data);
  76. // })
  77. this.$router.push({name:'tabAll',query: {id:'123456'}})
  78. },
  79. changetbt(){
  80. if(this.type==1){
  81. this.type=2;
  82. this.changet='手机验证码登录';
  83. this.t1="手机号码";
  84. }else{
  85. this.type=1;
  86. this.changet='用户名密码登录';
  87. this.t1="用户名";
  88. }
  89. },
  90. }
  91. };
  92. </script>
  93. <style>
  94. </style>