login.vue 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <view class="login">
  3. <view class="login-box">
  4. <view class="login-box-title">
  5. <view>智慧停车</view>
  6. <view>运营数据系统</view>
  7. </view>
  8. <view class="login-box-form">
  9. <view class="login-box-form-box">
  10. <u--form :model="form" :rules="rules" ref="uForm">
  11. <u-form-item label="" prop="phoneNumber">
  12. <u--input v-model="form.phoneNumber"
  13. :prefixIcon="require('@/static/icons/job-number-icon.svg')" placeholder="请输入工号"
  14. :maxlength="11" type="number" border="none" class="custom-input"
  15. :prefixIconStyle="{ marginRight: '10px' }" fontSize="14px" color="#ffffff" placeholderStyle="color: #fff"/>
  16. </u-form-item>
  17. <u-form-item label="" prop="password">
  18. <u--input v-model="form.password" :prefixIcon="require('@/static/icons/password-icon.svg')"
  19. placeholder="请输入密码" :password="true" border="none" class="custom-input"
  20. :prefixIconStyle="{ marginRight: '10px' }" fontSize="14px" color="#ffffff" placeholderStyle="color: #fff"/>
  21. </u-form-item>
  22. </u--form>
  23. </view>
  24. <view class="login-box-form-btn">
  25. <u-button class="login-btn" type="primary" text="登录" :loading="loading" @click="submitLogin">
  26. </u-button>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. export default {
  34. data() {
  35. return {
  36. form: {
  37. phoneNumber: '',
  38. password: ''
  39. },
  40. loading: false,
  41. rules: {
  42. phoneNumber: {
  43. required: true,
  44. message: '请输入工号',
  45. trigger: ['change', 'blur']
  46. },
  47. password: {
  48. required: true,
  49. message: '请输入密码',
  50. trigger: ['change', 'blur']
  51. }
  52. }
  53. }
  54. },
  55. methods: {
  56. /**
  57. * 登录提交
  58. */
  59. submitLogin() {
  60. this.$refs.uForm.validate().then(res => {
  61. this.loading = true
  62. // uni.$u.api.loginApi(this.form).then(res => {
  63. // console.log(res)
  64. // uni.$u.route({
  65. // url: 'pages/index/index'
  66. // })
  67. // }).catch(err => {
  68. // this.loading = false
  69. // })
  70. uni.$u.route({
  71. url: 'pages/index/index'
  72. })
  73. }).catch(errors => {
  74. uni.$u.toast(errors[0].message || '必填项不能为空!')
  75. })
  76. }
  77. }
  78. }
  79. </script>
  80. <style lang="scss">
  81. page {
  82. height: 100vh;
  83. background: linear-gradient(183deg, #2D82FB 0%, #1558F8 100%);
  84. }
  85. </style>
  86. <style lang="scss" scoped>
  87. @import './login.scss';
  88. </style>