|
|
@@ -1,108 +1,155 @@
|
|
|
<template>
|
|
|
- <cwg-page-wrapper>
|
|
|
- <view class="reset-container">
|
|
|
- <view class="reset-form">
|
|
|
- <cwg-input v-model:value="email" type="text" fkey="email" label="邮箱" :clearable="true"
|
|
|
- placeholder="请输入邮箱" :rules="[
|
|
|
- { required: true, message: '请输入邮箱' },
|
|
|
- { pattern: config.Pattern.Email, message: '请输入正确的邮箱格式' },
|
|
|
- ]" @change="handleChange">
|
|
|
- <template #left-icon1>
|
|
|
- <cwg-icon name="email-outline" :size="20" color="#000" />
|
|
|
- </template>
|
|
|
- </cwg-input>
|
|
|
- <view class="reset-button cwg-button">
|
|
|
- <u-button type="primary" block :loading="loading" @click="handleReset">{{ t('forget.forget')
|
|
|
- }}</u-button>
|
|
|
- </view>
|
|
|
- <view class="login-link">
|
|
|
- {{ t('signin.forget') }}<text @click="handleLogin">{{ t('newSignin.item7') }}</text>
|
|
|
- </view>
|
|
|
+ <cwg-page-wrapper :isLoginPage="true">
|
|
|
+ <view class="reset-container">
|
|
|
+ <uni-row class="content">
|
|
|
+ <uni-col :span="20" :offset="2" :sm="{ span: 14, offset: 5 }">
|
|
|
+ <view class="reset-title">{{ t('pages.login.resetTitle') }}</view>
|
|
|
+ <view class="reset-form">
|
|
|
+ <view class="form-label">{{ t('newSignup.item7') }}</view>
|
|
|
+ <uni-easyinput
|
|
|
+ v-model="email"
|
|
|
+ :placeholder="t('forget.form')"
|
|
|
+ class="custom-input"
|
|
|
+ >
|
|
|
+ </uni-easyinput>
|
|
|
+
|
|
|
+ <view class="reset-button">
|
|
|
+ <u-button block :loading="loading" @click="handleReset">{{ t('forget.forget') }}</u-button>
|
|
|
+ </view>
|
|
|
+ <view class="login-link">
|
|
|
+ <text @click="handleLogin" class="link-text">{{ t('signin.login') }}</text>
|
|
|
</view>
|
|
|
- </view>
|
|
|
- </cwg-page-wrapper>
|
|
|
+ </view>
|
|
|
+ </uni-col>
|
|
|
+ </uni-row>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ </cwg-page-wrapper>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { ref } from 'vue'
|
|
|
-import { useI18n } from 'vue-i18n'
|
|
|
-import useRouter from '@/hooks/useRouter'
|
|
|
-import { userApi } from '@/api/user'
|
|
|
-import config from '@/config'
|
|
|
-
|
|
|
-const { t } = useI18n()
|
|
|
-const router = useRouter()
|
|
|
-const loading = ref(false)
|
|
|
-const email = ref('')
|
|
|
-
|
|
|
-async function handleReset() {
|
|
|
+ import { ref } from 'vue'
|
|
|
+ import { useI18n } from 'vue-i18n'
|
|
|
+ import useRouter from '@/hooks/useRouter'
|
|
|
+ import { userApi } from '@/api/user'
|
|
|
+ import config from '@/config'
|
|
|
+
|
|
|
+ const { t } = useI18n()
|
|
|
+ const router = useRouter()
|
|
|
+ const loading = ref(false)
|
|
|
+ const email = ref('')
|
|
|
+
|
|
|
+ async function handleReset() {
|
|
|
if (!email.value) {
|
|
|
- uni.showToast({ title: t('vaildate.email.empty'), icon: 'none' })
|
|
|
- return
|
|
|
+ uni.showToast({ title: t('vaildate.email.empty'), icon: 'none' })
|
|
|
+ return
|
|
|
}
|
|
|
if (!config.Pattern.Email.test(email.value)) {
|
|
|
- uni.showToast({ title: t('vaildate.email.format'), icon: 'none' })
|
|
|
- return
|
|
|
+ uni.showToast({ title: t('vaildate.email.format'), icon: 'none' })
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
loading.value = true
|
|
|
try {
|
|
|
- const res = await userApi.updatePassword({ email: email.value })
|
|
|
- uni.showToast({ title: res.msg || '成功', icon: 'none' })
|
|
|
- router.push('/pages/login/index')
|
|
|
- }
|
|
|
- catch (error: any) {
|
|
|
- uni.showToast({ title: error.message || '重置失败', icon: 'none' })
|
|
|
+ const res = await userApi.forgetPwd({ email: email.value })
|
|
|
+ uni.showToast({ title: res.msg , icon: 'success' })
|
|
|
+ setTimeout(() => { router.push('/pages/login/index') }, 1000)
|
|
|
+ } catch (error: any) {
|
|
|
+ uni.showToast({ title: error.message, icon: 'none' })
|
|
|
+ } finally {
|
|
|
+ loading.value = false
|
|
|
}
|
|
|
- finally {
|
|
|
- loading.value = false
|
|
|
- }
|
|
|
-}
|
|
|
+ }
|
|
|
|
|
|
-function handleChange(value: any) {
|
|
|
+ function handleChange(value: any) {
|
|
|
if (value.key == 'email') {
|
|
|
- email.value = value.value
|
|
|
+ email.value = value.value
|
|
|
}
|
|
|
-}
|
|
|
+ }
|
|
|
|
|
|
-function handleLogin() {
|
|
|
+ function handleLogin() {
|
|
|
router.push('/pages/login/index')
|
|
|
-}
|
|
|
+ }
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
-@import "@/uni.scss";
|
|
|
+ @import "@/uni.scss";
|
|
|
+
|
|
|
+ :deep(uni-content) {
|
|
|
+ padding-left: 0 !important;
|
|
|
+ }
|
|
|
+ .reset-container {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ }
|
|
|
|
|
|
-.reset-container {
|
|
|
- padding: px2rpx(40) 0;
|
|
|
-}
|
|
|
+ .content {
|
|
|
+ width: px2rpx(650);
|
|
|
+ margin: 0 auto;
|
|
|
+ }
|
|
|
|
|
|
-.reset-button {
|
|
|
+ .reset-title {
|
|
|
+ font-size: px2rpx(28);
|
|
|
+ font-weight: bold;
|
|
|
+ color: #141d22;
|
|
|
+ margin-bottom: px2rpx(40);
|
|
|
+ }
|
|
|
+
|
|
|
+ .reset-form {
|
|
|
+ width: 100%;
|
|
|
+ }
|
|
|
+
|
|
|
+ .form-label {
|
|
|
+ font-size: px2rpx(14);
|
|
|
+ color: #333;
|
|
|
+ margin-bottom: px2rpx(8);
|
|
|
+ }
|
|
|
+
|
|
|
+ .custom-input {
|
|
|
+ margin-bottom: px2rpx(40);
|
|
|
+
|
|
|
+ :deep(.uni-easyinput__content) {
|
|
|
+ height: px2rpx(40);
|
|
|
+ border: 1px solid #dcdfe6;
|
|
|
+ border-radius: px2rpx(4);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .reset-button {
|
|
|
margin-bottom: px2rpx(20);
|
|
|
|
|
|
- u-button {
|
|
|
- height: px2rpx(44);
|
|
|
- border-radius: px2rpx(12);
|
|
|
- background: var(--main-yellow);
|
|
|
+ :deep(button) {
|
|
|
+ width: 100%;
|
|
|
+ height: px2rpx(44);
|
|
|
+ line-height: px2rpx(44);
|
|
|
+ border-radius: px2rpx(4);
|
|
|
+ background-color: #fddb46; // 主题黄
|
|
|
+ border: none;
|
|
|
+ color: #333;
|
|
|
+ font-size: px2rpx(16);
|
|
|
+ font-weight: 500;
|
|
|
+ margin: 0;
|
|
|
+
|
|
|
+ &::after {
|
|
|
border: none;
|
|
|
- color: var(--black);
|
|
|
- font-size: var(--font-size-16);
|
|
|
- font-weight: bold;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
:deep(u-button--loading) {
|
|
|
- opacity: 0.8;
|
|
|
+ opacity: 0.8;
|
|
|
}
|
|
|
-}
|
|
|
+ }
|
|
|
|
|
|
-.login-link {
|
|
|
+ .login-link {
|
|
|
text-align: center;
|
|
|
- font-size: var(--font-size-14);
|
|
|
- color: var(--gray);
|
|
|
|
|
|
- text {
|
|
|
- color: var(--main-yellow);
|
|
|
- margin-left: px2rpx(4);
|
|
|
+ .link-text {
|
|
|
+ font-size: px2rpx(14);
|
|
|
+ color: #005bbb;
|
|
|
+ cursor: pointer;
|
|
|
+ text-decoration: none;
|
|
|
}
|
|
|
-}
|
|
|
+ }
|
|
|
</style>
|