login.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <view class="login">
  3. <view class="login-box">
  4. <view class="login-box-title">
  5. <text>智慧停车<br />运营数据系统</text>
  6. </view>
  7. <view class="login-box-form">
  8. <view class="login-box-form-title">
  9. <text>账号密码登录</text>
  10. </view>
  11. <view class="login-box-form-box">
  12. <u--form :model="form" :rules="rules" ref="uForm">
  13. <u-form-item label="" prop="phoneNumber">
  14. <u-input v-model="form.phoneNumber" placeholder="请输入手机号" :maxlength="11" type="number"/>
  15. </u-form-item>
  16. <u-form-item label="" prop="password">
  17. <u-input v-model="form.password" placeholder="请输入密码" :password="true"/>
  18. </u-form-item>
  19. </u--form>
  20. </view>
  21. <view class="login-box-form-btn">
  22. <u-button type="primary" text="登录" :loading="loading" @click="submitLogin"></u-button>
  23. </view>
  24. <!-- <view class="login-box-form-forget">
  25. <text>忘记密码?</text>
  26. </view> -->
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. export default {
  33. data() {
  34. return {
  35. form: {
  36. phoneNumber: '',
  37. password: ''
  38. },
  39. loading: false,
  40. rules: {
  41. phoneNumber: [
  42. {
  43. required: true,
  44. message: '请输入手机号',
  45. trigger: ['change', 'blur']
  46. },
  47. {
  48. validator: (rule, value, callback) => {
  49. return uni.$u.test.mobile(value);
  50. },
  51. message: '手机号不正确',
  52. trigger: ['change', 'blur'],
  53. }
  54. ],
  55. password: {
  56. required: true,
  57. message: '请输入密码',
  58. trigger: ['change', 'blur']
  59. }
  60. }
  61. }
  62. },
  63. methods: {
  64. /**
  65. * 登录提交
  66. */
  67. submitLogin() {
  68. this.$refs.uForm.validate().then(res => {
  69. this.loading = true
  70. // uni.$u.api.loginApi(this.form).then(res => {
  71. // console.log(res)
  72. // uni.$u.route({
  73. // url: 'pages/index/index'
  74. // })
  75. // }).catch(err => {
  76. // this.loading = false
  77. // })
  78. uni.$u.route({
  79. url: 'pages/index/index'
  80. })
  81. }).catch(errors => {
  82. uni.$u.toast(errors[0].message || '必填项不能为空!')
  83. })
  84. }
  85. }
  86. }
  87. </script>
  88. <style lang="scss" scoped>
  89. @import './login.scss';
  90. </style>