register.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <!--
  2. * @Author: PoJun
  3. * @Date: 2023-09-28 10:38:11
  4. * @LastEditors: PoJun
  5. * @LastEditTime: 2023-12-25 16:35:22
  6. * @Message: 账号注册
  7. -->
  8. <template>
  9. <view class="register">
  10. <uv-alert type="primary" description="账号注册成功后将自动跳转登录界面" center></uv-alert>
  11. <view class="register-cont">
  12. <kirin-form ref="form" :list="list"></kirin-form>
  13. <view class="uv-m-t-30">
  14. <uv-button
  15. type="primary"
  16. text="注册"
  17. @click="save"
  18. :disabled="checkboxValue.length == 0"
  19. shape="circle"
  20. ></uv-button>
  21. </view>
  22. </view>
  23. <view class="register-agree uv-font-26">
  24. <view>
  25. <uv-checkbox-group v-model="checkboxValue">
  26. <uv-checkbox name="agree"></uv-checkbox>
  27. </uv-checkbox-group>
  28. </view>
  29. <view>我已仔细阅读并同意</view>
  30. <view class="register-agree-text" @tap="check('service')">《服务协议》</view>
  31. <view class="register-agree-text" @tap="check('privacy')">《隐私协议》</view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import { registerUsername } from "@/config/http.js";
  37. import { registerFormList } from "./constant";
  38. export default {
  39. data() {
  40. return {
  41. list: registerFormList,
  42. checkboxValue: [],
  43. };
  44. },
  45. onLoad() {},
  46. methods: {
  47. async save() {
  48. const formData = this.$refs.form.getFormData();
  49. if (!formData) {
  50. return;
  51. }
  52. if (formData.rePassword != formData.credentials) {
  53. uni.$uv.toast("两次输入密码不一致");
  54. return;
  55. }
  56. if (formData.rePassword.length < 6) {
  57. uni.$uv.toast("密码长度不能低于6位数");
  58. return;
  59. }
  60. uni.showLoading({ mask: true });
  61. await registerUsername(formData);
  62. try {
  63. await uni.$uv.sleep(500);
  64. uni.$uv.route({ type: "back" });
  65. } finally {
  66. uni.hideLoading();
  67. }
  68. },
  69. check(type) {
  70. uni.$uv.route({
  71. url: "/subpkg/agreement/index",
  72. params: { type },
  73. });
  74. },
  75. },
  76. };
  77. </script>
  78. <style lang="scss">
  79. .register {
  80. height: calc(100vh - var(--status-bar-height) - 44px);
  81. /* #ifdef APP-PLUS */
  82. height: 100vh;
  83. /* #endif */
  84. display: flex;
  85. flex-direction: column;
  86. &-cont {
  87. flex: 1;
  88. padding: 10rpx 25rpx;
  89. }
  90. &-agree {
  91. padding: 100rpx 0;
  92. display: flex;
  93. flex-direction: row;
  94. justify-content: center;
  95. &-text {
  96. color: $uv-primary;
  97. }
  98. }
  99. }
  100. </style>