RegisterPage.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <ion-page>
  3. <ion-header>
  4. <ion-toolbar>
  5. <ion-buttons slot="start">
  6. <ion-back-button text="" default-href="#" @click="$router.back()"></ion-back-button>
  7. </ion-buttons>
  8. </ion-toolbar>
  9. </ion-header>
  10. <ion-content :fullscreen="true" class="login">
  11. <img src="@/assets/png-denglu-bg.png" class="top-bg !absolute w-full h-[200px] top-0 left-0 !z-0" alt="" />
  12. <div class="login-content h-full">
  13. <div class="text-white text-[26px] AlimamaShuHeiTi">Hi,歡迎來到走馬短劇</div>
  14. <!-- 可以使用 CellGroup 作为容器 -->
  15. <van-form @submit="onSubmit">
  16. <van-cell-group :border="false">
  17. <van-field
  18. label-align="top"
  19. clearable
  20. v-model="form.email"
  21. :rules="[
  22. {
  23. required: true,
  24. pattern: /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,
  25. message: '请输入正确内容'
  26. }
  27. ]"
  28. :label="$t('login.email')"
  29. :placeholder="$t('login.emailPla')"
  30. >
  31. <template #left-icon>
  32. <img class="left-icon" src="@/assets/login_icon_zhanghao.png" alt="" />
  33. </template>
  34. <template #label>
  35. <div class="text-white text-[14px]">{{ $t('login.email') }}</div>
  36. </template>
  37. </van-field>
  38. <van-field
  39. label-align="top"
  40. clearable
  41. v-model="form.username"
  42. :label="$t('login.username')"
  43. :placeholder="$t('login.usernamePla')"
  44. :rules="[
  45. {
  46. required: true,
  47. message: $t('login.usernamePla')
  48. }
  49. ]"
  50. >
  51. <template #left-icon>
  52. <img class="left-icon" src="@/assets/login_icon_zhanghao.png" alt="" />
  53. </template>
  54. <template #label>
  55. <div class="text-white text-[14px]">{{ $t('login.username') }}</div>
  56. </template>
  57. </van-field>
  58. <van-field
  59. label-align="top"
  60. type="password"
  61. clearable
  62. v-model="form.password"
  63. :label="$t('login.password')"
  64. :placeholder="$t('login.passwordPla')"
  65. :rules="[
  66. {
  67. required: true,
  68. message: $t('login.passwordPla')
  69. }
  70. ]"
  71. >
  72. <template #left-icon>
  73. <img class="left-icon" src="@/assets/login_icon_mima.png" alt="" />
  74. </template>
  75. <template #label>
  76. <div class="text-white text-[14px]">{{ $t('login.password') }}</div>
  77. </template>
  78. </van-field>
  79. <van-field
  80. label-align="top"
  81. type="password"
  82. clearable
  83. v-model="form.password2"
  84. label="密碼"
  85. :placeholder="$t('login.password2Pla')"
  86. :rules="[
  87. {
  88. validator,
  89. message: '两次密码输入不一致'
  90. }
  91. ]"
  92. >
  93. <template #left-icon>
  94. <img class="left-icon" src="@/assets/login_icon_mima.png" alt="" />
  95. </template>
  96. <template #label>
  97. <div class="text-white text-[14px]">{{ $t('login.password2') }}</div>
  98. </template>
  99. </van-field>
  100. <!-- <div @click="loginCode = !loginCode" class="text-[#61657A] text-right text-xs underline pt-[10px]">
  101. {{ loginCode ? '密碼登录' : '验证码登录' }}
  102. </div> -->
  103. <div class="btn py-[64px] px-[17px]">
  104. <van-button type="primary" class="AlimamaShuHeiTi" block round native-type="submit"
  105. >注册</van-button
  106. >
  107. <div class="text-[#61657A] text-sm mt-[20px] text-center" @click="goLogin">
  108. 已有帳號,立即登入
  109. </div>
  110. </div>
  111. </van-cell-group>
  112. </van-form>
  113. <div class="rule flex justify-center van-safe-area-bottom">
  114. <van-checkbox v-model="checked">點擊同意注册協定</van-checkbox>
  115. </div>
  116. </div>
  117. </ion-content>
  118. </ion-page>
  119. </template>
  120. <script setup>
  121. import { ref } from 'vue'
  122. import { http } from '@/plugins/http'
  123. import { useUserStore } from '../stores/user'
  124. import { showNotify } from 'vant'
  125. import { useRouter } from 'vue-router'
  126. import { useI18n } from 'vue-i18n'
  127. import { showLoadingToast, closeToast } from 'vant'
  128. import toast from '@/utils/toast'
  129. const form = ref({
  130. email: '',
  131. username: '',
  132. password: '',
  133. password2: '',
  134. invitor: localStorage.getItem('invitor') || ''
  135. })
  136. const checked = ref(false)
  137. const loginCode = ref(false)
  138. function validator(val) {
  139. return form.value.password === val
  140. }
  141. const router = useRouter()
  142. function goLogin() {
  143. router.back()
  144. }
  145. const { t } = useI18n()
  146. const { register } = useUserStore()
  147. showLoadingToast({
  148. message: t('loading'),
  149. forbidClick: true
  150. })
  151. function onSubmit() {
  152. register(form.value.email, form.value.username, form.value.password, form.value.invitor).then(res => {
  153. closeToast()
  154. toast.success(t('login.register'))
  155. router.go(-2)
  156. })
  157. }
  158. </script>
  159. <style lang="less" scoped>
  160. .login {
  161. .login-content {
  162. position: relative;
  163. z-index: 1;
  164. padding: 30px;
  165. }
  166. }
  167. .van-cell-group {
  168. --van-cell-group-background: transparent;
  169. --van-cell-background: transparent;
  170. --van-cell-border-color: #4d61657a;
  171. --van-field-placeholder-text-color: #61657a;
  172. :deep(.van-field__label--top) {
  173. margin-bottom: 14px;
  174. }
  175. :ddep(.van-cell__value) {
  176. line-height: 44px;
  177. }
  178. .van-cell {
  179. --van-cell-value-color: #fff;
  180. --van-cell-font-size: 14px;
  181. --van-field-input-text-color: #fff;
  182. --van-field-clear-icon-color: #404455;
  183. padding: 40px 0 0;
  184. &::after {
  185. left: 0;
  186. right: 0;
  187. }
  188. }
  189. .left-icon {
  190. width: 24px;
  191. height: 24px;
  192. }
  193. }
  194. .rule {
  195. // position: fixed;
  196. // bottom: 30px;
  197. // left: 50%;
  198. // transform: translateX(-50%);
  199. .van-checkbox {
  200. --van-checkbox-size: 16px;
  201. --van-checkbox-border-color: #61657a;
  202. --van-checkbox-label-color: #61657a;
  203. font-size: 12px;
  204. }
  205. }
  206. </style>