register.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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.validate().then(res => {
  75. uni.$u.toast('点击了注册账号')
  76. })
  77. },
  78. navigateBack() {
  79. uni.navigateBack()
  80. }
  81. }
  82. }
  83. </script>
  84. <style lang="scss" scoped>
  85. .unp-header {
  86. height: 400rpx;
  87. @include flex-center;
  88. .unp-logo {
  89. @include flex-center;
  90. }
  91. }
  92. .unp-box {
  93. @include flex-center;
  94. .unp-form {
  95. width: 560rpx;
  96. }
  97. }
  98. .lk-group {
  99. @include flex-space-between;
  100. height: 40rpx;
  101. margin-top: 40rpx;
  102. font-size: 12rpx;
  103. color: $u-primary;
  104. text-decoration: $u-primary;
  105. }
  106. </style>