reset.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <cwg-page-wrapper :isLoginPage="true">
  3. <view class="reset-container">
  4. <uni-row class="content">
  5. <uni-col :span="20" :offset="2" :sm="{ span: 14, offset: 5 }">
  6. <view class="reset-title">{{ t('pages.login.resetTitle') }}</view>
  7. <view class="reset-form">
  8. <view class="form-label">{{ t('newSignup.item7') }}</view>
  9. <uni-easyinput
  10. v-model="email"
  11. :placeholder="t('forget.form')"
  12. class="custom-input"
  13. >
  14. </uni-easyinput>
  15. <view class="reset-button">
  16. <u-button block :loading="loading" @click="handleReset">{{ t('forget.forget') }}</u-button>
  17. </view>
  18. <view class="login-link">
  19. <text @click="handleLogin" class="link-text">{{ t('signin.login') }}</text>
  20. </view>
  21. </view>
  22. </uni-col>
  23. </uni-row>
  24. </view>
  25. </cwg-page-wrapper>
  26. </template>
  27. <script setup lang="ts">
  28. import { ref } from 'vue'
  29. import { useI18n } from 'vue-i18n'
  30. import useRouter from '@/hooks/useRouter'
  31. import { userApi } from '@/api/user'
  32. import config from '@/config'
  33. const { t } = useI18n()
  34. const router = useRouter()
  35. const loading = ref(false)
  36. const email = ref('')
  37. async function handleReset() {
  38. if (!email.value) {
  39. uni.showToast({ title: t('vaildate.email.empty'), icon: 'none' })
  40. return
  41. }
  42. if (!config.Pattern.Email.test(email.value)) {
  43. uni.showToast({ title: t('vaildate.email.format'), icon: 'none' })
  44. return
  45. }
  46. loading.value = true
  47. try {
  48. const res = await userApi.forgetPwd({ email: email.value })
  49. uni.showToast({ title: res.msg , icon: 'success' })
  50. setTimeout(() => { router.push('/pages/login/index') }, 1000)
  51. } catch (error: any) {
  52. uni.showToast({ title: error.message, icon: 'none' })
  53. } finally {
  54. loading.value = false
  55. }
  56. }
  57. function handleChange(value: any) {
  58. if (value.key == 'email') {
  59. email.value = value.value
  60. }
  61. }
  62. function handleLogin() {
  63. router.push('/pages/login/index')
  64. }
  65. </script>
  66. <style scoped lang="scss">
  67. @import "@/uni.scss";
  68. :deep(uni-content) {
  69. padding-left: 0 !important;
  70. }
  71. .reset-container {
  72. display: flex;
  73. flex-direction: column;
  74. align-items: center;
  75. justify-content: center;
  76. }
  77. .content {
  78. width: px2rpx(650);
  79. margin: 0 auto;
  80. }
  81. .reset-title {
  82. font-size: px2rpx(28);
  83. font-weight: bold;
  84. color: #141d22;
  85. margin-bottom: px2rpx(40);
  86. }
  87. .reset-form {
  88. width: 100%;
  89. }
  90. .form-label {
  91. font-size: px2rpx(14);
  92. color: #333;
  93. margin-bottom: px2rpx(8);
  94. }
  95. .custom-input {
  96. margin-bottom: px2rpx(40);
  97. :deep(.uni-easyinput__content) {
  98. height: px2rpx(40);
  99. border: 1px solid #dcdfe6;
  100. border-radius: px2rpx(4);
  101. }
  102. }
  103. .reset-button {
  104. margin-bottom: px2rpx(20);
  105. :deep(button) {
  106. width: 100%;
  107. height: px2rpx(44);
  108. line-height: px2rpx(44);
  109. border-radius: px2rpx(4);
  110. background-color: #fddb46; // 主题黄
  111. border: none;
  112. color: #333;
  113. font-size: px2rpx(16);
  114. font-weight: 500;
  115. margin: 0;
  116. &::after {
  117. border: none;
  118. }
  119. }
  120. :deep(u-button--loading) {
  121. opacity: 0.8;
  122. }
  123. }
  124. .login-link {
  125. text-align: center;
  126. .link-text {
  127. font-size: px2rpx(14);
  128. color: #005bbb;
  129. cursor: pointer;
  130. text-decoration: none;
  131. }
  132. }
  133. </style>