reset.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <cwg-page-wrapper :isLoginPage="true">
  3. <view class="main-content">
  4. <view class="global-header-bar pc-header">
  5. <view class="header-inner">
  6. <view class="logo-placeholder"></view> <!-- 左侧可预留放logo或留空 -->
  7. <!-- 这里由于没有深色背景,传递深色文字颜色 -->
  8. <LoginHeaderGroup text-color="#141d22" icon-color="#141d22" />
  9. </view>
  10. </view>
  11. <view class="reset-container">
  12. <uni-row class="content">
  13. <uni-col :span="20" :offset="2" :sm="{ span: 14, offset: 5 }">
  14. <view class="reset-title">{{ t('pages.login.resetTitle') }}</view>
  15. <view class="reset-form">
  16. <view class="form-label">{{ t('newSignup.item7') }}</view>
  17. <uni-easyinput
  18. v-model="email"
  19. :placeholder="t('forget.form')"
  20. class="custom-input"
  21. >
  22. </uni-easyinput>
  23. <view class="reset-button">
  24. <button class="btn" block :loading="loading" @click="handleReset">{{ t('forget.forget') }}</button>
  25. </view>
  26. <view class="login-link">
  27. <text @click="handleLogin" class="link-text">{{ t('signin.login') }}</text>
  28. </view>
  29. </view>
  30. </uni-col>
  31. </uni-row>
  32. </view>
  33. </view>
  34. </cwg-page-wrapper>
  35. </template>
  36. <script setup lang="ts">
  37. import { ref } from 'vue'
  38. import { useI18n } from 'vue-i18n'
  39. import useRouter from '@/hooks/useRouter'
  40. import { userApi } from '@/api/user'
  41. import config from '@/config'
  42. import LoginHeaderGroup from './components/LoginHeaderGroup.vue'
  43. const { t } = useI18n()
  44. const router = useRouter()
  45. const loading = ref(false)
  46. const email = ref('')
  47. async function handleReset() {
  48. if (!email.value) {
  49. uni.showToast({ title: t('vaildate.email.empty'), icon: 'none' })
  50. return
  51. }
  52. if (!config.Pattern.Email.test(email.value)) {
  53. uni.showToast({ title: t('vaildate.email.format'), icon: 'none' })
  54. return
  55. }
  56. loading.value = true
  57. try {
  58. const res = await userApi.forgetPwd({ email: email.value })
  59. uni.showToast({ title: res.msg, icon: 'success' })
  60. setTimeout(() => {
  61. router.push('/pages/login/index')
  62. }, 1000)
  63. } catch (error: any) {
  64. uni.showToast({ title: error.message, icon: 'none' })
  65. } finally {
  66. loading.value = false
  67. }
  68. }
  69. function handleChange(value: any) {
  70. if (value.key == 'email') {
  71. email.value = value.value
  72. }
  73. }
  74. function handleLogin() {
  75. router.push('/pages/login/index')
  76. }
  77. </script>
  78. <style scoped lang="scss">
  79. @import "@/uni.scss";
  80. :deep(uni-content) {
  81. padding-left: 0 !important;
  82. }
  83. .main-content {
  84. display: flex;
  85. flex-direction: column;
  86. }
  87. .global-header-bar {
  88. width: 100%;
  89. height: px2rpx(60);
  90. display: flex;
  91. align-items: center;
  92. justify-content: center;
  93. flex-shrink: 0;
  94. z-index: 100;
  95. &.pc-header {
  96. background-color: transparent;
  97. border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  98. }
  99. .header-inner {
  100. width: 100%;
  101. padding: 0 5%;
  102. display: flex;
  103. justify-content: space-between; /* 两端对齐,可放logo和组件 */
  104. align-items: center;
  105. }
  106. }
  107. .mobile-header-bar {
  108. position: absolute;
  109. top: px2rpx(20);
  110. right: px2rpx(20);
  111. z-index: 10;
  112. }
  113. .reset-container {
  114. margin-top: px2rpx(20);
  115. display: flex;
  116. flex-direction: column;
  117. align-items: center;
  118. justify-content: center;
  119. }
  120. .content {
  121. width: 100%;
  122. margin: 0 auto;
  123. }
  124. .reset-title {
  125. font-size: px2rpx(28);
  126. font-weight: bold;
  127. color: #141d22;
  128. margin-bottom: px2rpx(40);
  129. }
  130. .reset-form {
  131. width: 100%;
  132. }
  133. .form-label {
  134. font-size: px2rpx(14);
  135. color: #333;
  136. margin-bottom: px2rpx(8);
  137. }
  138. .custom-input {
  139. margin-bottom: px2rpx(40);
  140. :deep(.uni-easyinput__content) {
  141. height: px2rpx(40);
  142. border: 1px solid #dcdfe6;
  143. border-radius: px2rpx(4);
  144. }
  145. }
  146. .reset-button {
  147. margin-bottom: px2rpx(20);
  148. :deep(button) {
  149. width: 100%;
  150. height: px2rpx(44);
  151. line-height: px2rpx(44);
  152. border-radius: px2rpx(4);
  153. background-color: var(--color-error); // 主题黄
  154. border: none;
  155. color: #fff;
  156. font-size: px2rpx(16);
  157. font-weight: 500;
  158. margin: 0;
  159. &::after {
  160. border: none;
  161. }
  162. }
  163. :deep(u-button--loading) {
  164. opacity: 0.8;
  165. }
  166. }
  167. .login-link {
  168. text-align: center;
  169. .link-text {
  170. font-size: px2rpx(14);
  171. color: #005bbb;
  172. cursor: pointer;
  173. text-decoration: none;
  174. }
  175. }
  176. </style>