Explorar el Código

feat:注册,忘记密码

ljc hace 2 meses
padre
commit
3773281551
Se han modificado 4 ficheros con 127 adiciones y 80 borrados
  1. 1 1
      api/user.ts
  2. 2 1
      locale/cn.json
  3. 4 5
      pages/login/regist.vue
  4. 120 73
      pages/login/reset.vue

+ 1 - 1
api/user.ts

@@ -40,7 +40,7 @@ export const userApi = {
         return post('/custom/logout', {})
         return post('/custom/logout', {})
     },
     },
     // 忘记密码
     // 忘记密码
-    updatePassword: (params: { email: string }) => {
+  forgetPwd: (params: { email: string }) => {
         return post('/custom/update/password/send/email', params)
         return post('/custom/update/password/send/email', params)
     },
     },
     // 账户
     // 账户

+ 2 - 1
locale/cn.json

@@ -37,7 +37,8 @@
       "index": "登录",
       "index": "登录",
       "forget": "forget",
       "forget": "forget",
       "regist": "regist",
       "regist": "regist",
-      "reset": "忘记密码"
+      "reset": "忘记密码",
+      "resetTitle": "重制密码"
     },
     },
     "apply-record": {
     "apply-record": {
       "index": "开卡记录",
       "index": "开卡记录",

+ 4 - 5
pages/login/regist.vue

@@ -1,5 +1,5 @@
 <template>
 <template>
-  <view class="regist-page" :isHeaderFixed="true" :isLoginPage="true">
+  <cwg-page-wrapper isLoginPage>
     <view class="regist-content">
     <view class="regist-content">
       <uni-row class="content">
       <uni-row class="content">
         <uni-col :span="20" :offset="2" :sm="{ span: 14, offset: 5 }">
         <uni-col :span="20" :offset="2" :sm="{ span: 14, offset: 5 }">
@@ -41,7 +41,7 @@
               <uni-col :xs="24" :md="24">
               <uni-col :xs="24" :md="24">
                 <uni-forms-item name="emailCode" :label="t('newSignup.item9')">
                 <uni-forms-item name="emailCode" :label="t('newSignup.item9')">
                   <uni-easyinput :disabled="!isAgeValid || !formData.birthDate"
                   <uni-easyinput :disabled="!isAgeValid || !formData.birthDate"
-                                 v-model="formData.emailCode" :placeholder="t('newSignup.item8')">
+                                 v-model="formData.emailCode" :placeholder="t('newSignup.item10')">
                     <template #right>
                     <template #right>
                       <view class="btn-code" @click="(!isAgeValid || !formData.birthDate) ? '' : handleGetCode()">
                       <view class="btn-code" @click="(!isAgeValid || !formData.birthDate) ? '' : handleGetCode()">
                         {{ getCodeString }}
                         {{ getCodeString }}
@@ -138,8 +138,8 @@
       </uni-row>
       </uni-row>
     </view>
     </view>
 
 
-    <cwg-custom-footer />
-  </view>
+<!--    <cwg-custom-footer />-->
+  </cwg-page-wrapper>
 </template>
 </template>
 <script setup>
 <script setup>
   import { ref, watch, onMounted, computed } from 'vue'
   import { ref, watch, onMounted, computed } from 'vue'
@@ -546,7 +546,6 @@
   }
   }
 
 
   .regist-content {
   .regist-content {
-    width: 100vw;
     display: flex;
     display: flex;
     align-items: center;
     align-items: center;
     justify-content: center;
     justify-content: center;

+ 120 - 73
pages/login/reset.vue

@@ -1,108 +1,155 @@
 <template>
 <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>
-        </view>
-    </cwg-page-wrapper>
+          </view>
+        </uni-col>
+      </uni-row>
+    </view>
+
+  </cwg-page-wrapper>
 </template>
 </template>
 
 
 <script setup lang="ts">
 <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) {
     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)) {
     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
     loading.value = true
     try {
     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') {
     if (value.key == 'email') {
-        email.value = value.value
+      email.value = value.value
     }
     }
-}
+  }
 
 
-function handleLogin() {
+  function handleLogin() {
     router.push('/pages/login/index')
     router.push('/pages/login/index')
-}
+  }
 </script>
 </script>
 
 
 <style scoped lang="scss">
 <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);
     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;
         border: none;
-        color: var(--black);
-        font-size: var(--font-size-16);
-        font-weight: bold;
+      }
     }
     }
 
 
     :deep(u-button--loading) {
     :deep(u-button--loading) {
-        opacity: 0.8;
+      opacity: 0.8;
     }
     }
-}
+  }
 
 
-.login-link {
+  .login-link {
     text-align: center;
     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>
 </style>