register.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <view class="container">
  3. <view class="unp-header">
  4. <view class="unp-logo">
  5. <u-avatar size="80" icon="github-circle-fill" fontSize="80"></u-avatar>
  6. </view>
  7. </view>
  8. <view class="unp-box">
  9. <u--form class="unp-form" labelPosition="left" :model="formData" :rules="rules" ref="form">
  10. <u-form-item label="账号" prop="username" borderBottom ref="item-username">
  11. <u-input type="text" maxlength="20" v-model="formData.username" clearable placeholder="账号由数字和字母组成" border="none" @change="handleUsernameChange"></u-input>
  12. </u-form-item>
  13. <u-gap height="20"></u-gap>
  14. <u-form-item label="密码" prop="password" borderBottom ref="item-password">
  15. <u-input :type="inputType" maxlength="20" v-model="formData.password" placeholder="密码由数字、字母和符号组成" border="none" @change="handlePasswordChange">
  16. <template slot="suffix">
  17. <u-icon v-if="inputType === 'password'" size="20" color="#666666" name="eye-fill" @click="inputType = 'text'"></u-icon>
  18. <u-icon v-if="inputType === 'text'" size="20" color="#666666" name="eye-off" @click="inputType = 'password'"></u-icon>
  19. </template>
  20. </u-input>
  21. </u-form-item>
  22. <view class="lk-group">
  23. <!-- 占位 -->
  24. </view>
  25. <u-button type="success" text="注册账号" customStyle="margin-top: 50px" @click="handleSubmit"></u-button>
  26. <u-gap height="20"></u-gap>
  27. <u-button type="info" text="返回" @click="navigateBack()"></u-button>
  28. </u--form>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. export default {
  34. data() {
  35. return {
  36. inputType: 'password',
  37. formData: {
  38. username: '',
  39. password: ''
  40. },
  41. rules: {
  42. username: {
  43. type: 'string',
  44. max: 20,
  45. required: true,
  46. message: '请输入您的账号',
  47. trigger: ['blur', 'change']
  48. },
  49. password: {
  50. type: 'string',
  51. max: 20,
  52. required: true,
  53. message: '请输入您的密码',
  54. trigger: ['blur', 'change']
  55. }
  56. }
  57. }
  58. },
  59. onLoad() {},
  60. methods: {
  61. handleUsernameChange(e) {
  62. let str = uni.$u.trim(e, 'all')
  63. this.$nextTick(() => {
  64. this.formData.username = str
  65. })
  66. },
  67. handlePasswordChange(e) {
  68. let str = uni.$u.trim(e, 'all')
  69. this.$nextTick(() => {
  70. this.formData.password = str
  71. })
  72. },
  73. handleSubmit() {
  74. this.$refs.form
  75. .validate()
  76. .then(res => {
  77. uni.$u.toast('点击了注册账号')
  78. })
  79. .catch(err => {})
  80. },
  81. navigateBack() {
  82. uni.navigateBack()
  83. }
  84. }
  85. }
  86. </script>
  87. <style lang="scss" scoped>
  88. .unp-header {
  89. height: 400rpx;
  90. @include flex-center;
  91. .unp-logo {
  92. @include flex-center;
  93. }
  94. }
  95. .unp-box {
  96. @include flex-center;
  97. .unp-form {
  98. width: 560rpx;
  99. }
  100. }
  101. .lk-group {
  102. @include flex-space-between;
  103. height: 40rpx;
  104. margin-top: 40rpx;
  105. font-size: 12rpx;
  106. color: $u-primary;
  107. text-decoration: $u-primary;
  108. }
  109. </style>