account-login.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <!-- 账号密码登录 accountLogin -->
  2. <template>
  3. <view>
  4. <!-- 表单项 -->
  5. <u-form
  6. ref="accountLoginRef"
  7. labelWidth="140"
  8. labelAlign="left"
  9. labelPosition="top"
  10. >
  11. <u-form-item prop="loginName" label="账号">
  12. <view class="input-line">
  13. <u-input
  14. placeholder="请输入账号"
  15. v-model="model.loginName"
  16. border="none"
  17. ></u-input>
  18. </view>
  19. </u-form-item>
  20. <u-form-item prop="password" label="密码">
  21. <view class="input-line">
  22. <u-input
  23. type="password"
  24. placeholder="请输入密码"
  25. v-model="model.password"
  26. border="none"
  27. ></u-input>
  28. </view>
  29. </u-form-item>
  30. </u-form>
  31. </view>
  32. </template>
  33. <script>
  34. import {login} from '@/common/request/apis/login'
  35. import md5 from '@/common/request/md5.js'
  36. export default{
  37. data() {
  38. return {
  39. model:{
  40. loginName:'',
  41. password:''
  42. },
  43. }
  44. },
  45. methods:{
  46. accountLoginSubmit() {
  47. if(!this.model.loginName){
  48. return uni.$u.toast("请输入账号");
  49. }
  50. if(!this.model.password) {
  51. return uni.$u.toast("请输入密码");
  52. }
  53. let params = {
  54. ...this.model,
  55. password: md5(this.model.password)
  56. }
  57. login(params)
  58. .then(res=>{
  59. if(res.code == 200) {
  60. let userInfo = {
  61. token:res.data.token,
  62. ...res.data.user
  63. }
  64. this.$store.dispatch('userLogin',userInfo)
  65. }
  66. })
  67. }
  68. }
  69. }
  70. </script>
  71. <style lang="scss" scoped>
  72. // @import "../index.scss";
  73. .input-line {
  74. display: flex;
  75. align-items: center;
  76. width: 100%;
  77. background-color: #f5f7fb;
  78. border-radius: 16rpx;
  79. padding-left: 30rpx;
  80. height: 88rpx;
  81. box-sizing: border-box;
  82. }
  83. </style>