login.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <uv-toast ref="toast"></uv-toast>
  3. <view class="page">
  4. <uv-row justify="space-between" customStyle="margin-top: 35%" class="form">
  5. <uv-col span="10" offset="1">
  6. <uv-form labelPosition="left" :model="logininfo" :rules="rules" ref="form" >
  7. <uv-col span="10" offset="1">{{$t('telno')}}</uv-col>
  8. <uv-col span="10" offset="1">
  9. <uv-form-item prop="telno" borderBottom>
  10. <uv-input v-model.trim="logininfo.telno" border="none">
  11. </uv-input>
  12. </uv-form-item>
  13. </uv-col>
  14. <uv-col span="10" offset="1" customStyle="margin-top: 20px">{{$t('password')}}</uv-col>
  15. <uv-col span="10" offset="1">
  16. <uv-form-item prop="pw" borderBottom>
  17. <uv-input v-model.trim="logininfo.pw" :type="passwordtype" border="none">
  18. </uv-input>
  19. <template v-slot:right>
  20. <uv-icon name="eye-off-outline" color="#2979ff" size="18" v-show="!showpasswod" @click="setshowpasswod"></uv-icon>
  21. <uv-icon name="eye" color="#2979ff" size="18" v-show="showpasswod" @click="setshowpasswod"></uv-icon>
  22. </template>
  23. </uv-form-item>
  24. </uv-col>
  25. <uv-col span="10" offset="1">
  26. <uv-button type="primary" :throttleTime="throttleTime" :text="$t('login')" customStyle="margin-top: 2rem" @click="submit"></uv-button>
  27. </uv-col>
  28. </uv-form>
  29. <uv-col span="10" offset="1">
  30. <uv-button type="primary" :plain="true" :text="$t('register')" customStyle="margin-top: 20px" @click="toregister"></uv-button>
  31. </uv-col>
  32. </uv-col>
  33. </uv-row>
  34. </view>
  35. </template>
  36. <script>
  37. import {login} from "@/common/api/user.js"
  38. export default {
  39. data() {
  40. return {
  41. throttleTime:1,
  42. logininfo:{
  43. telno:'',
  44. pw:''
  45. },
  46. rules:{
  47. 'telno':[{
  48. type: 'string',
  49. required: true,
  50. message: this.$t('telno_null'),
  51. trigger: ['blur', 'change'],
  52. },{
  53. pattern: /\d{5,}/,
  54. message: this.$t('telno_error'),
  55. trigger: ['blur', 'change'],
  56. }
  57. ],
  58. 'pw': {
  59. type: 'string',
  60. required: true,
  61. message: this.$t('password_null'),
  62. trigger: ['blur', 'change']
  63. },
  64. },
  65. showpasswod:false,
  66. passwordtype:"password"
  67. }
  68. },
  69. methods: {
  70. submit(){
  71. var that = this
  72. this.$refs.form.validate().then(res => {
  73. login(this.logininfo,that)
  74. }).catch(errors => {
  75. console.log(errors)
  76. })
  77. },
  78. setshowpasswod(){
  79. this.showpasswod = !this.showpasswod
  80. if(this.showpasswod){
  81. this.passwordtype="text"
  82. }else{
  83. this.passwordtype="password"
  84. }
  85. },
  86. toregister(){
  87. uni.navigateTo({
  88. url: '/pages/register/register'
  89. });
  90. }
  91. },
  92. mounted(){
  93. uni.setNavigationBarTitle({
  94. title: this.$t('login')
  95. });
  96. this.throttleTime = getApp().globalData.throttleTime;
  97. },
  98. created() {
  99. }
  100. }
  101. </script>
  102. <style >
  103. </style>