From 1201bf91b3dcac3f5b69c755ff2e54c362956467 Mon Sep 17 00:00:00 2001
From: admin <344137771@qq.com>
Date: Mon, 09 Mar 2026 16:41:01 +0800
Subject: [PATCH] 1
---
src/views/changePassword/index.vue | 151 +++++++++++++++++++++++++++++++++++---------------
1 files changed, 105 insertions(+), 46 deletions(-)
diff --git a/src/views/changePassword/index.vue b/src/views/changePassword/index.vue
index c5a2c79..8b29dee 100644
--- a/src/views/changePassword/index.vue
+++ b/src/views/changePassword/index.vue
@@ -1,70 +1,129 @@
<template>
- <div class="changePassword">
- <fx-header>
- <template #title>
- {{ $t('changeLoginPassword') }}
- </template>
- </fx-header>
- <div class="content">
- <ExInput :label="$t('oldPassword')" :placeholderText="$t('entryPassword')" v-model="oldPassword"
- typeText="password" />
- <ExInput :label="$t('newPassword')" :placeholderText="$t('entryPassword')" :tips="$t('setPasswordTips')"
- v-model="newPassword" typeText="password" />
- <ExInput :label="$t('sureNewPassword')" :placeholderText="$t('entryPassword')" :tips="$t('setPasswordTips')"
- v-model="rePassword" typeText="password" />
- <van-button class="w-full" style="margin-top:10px;" type="primary" @click="submit">{{ $t('sure') }}
- </van-button>
- </div>
+ <div class="change-password">
+ <assets-head :title="''" :show-left="true" />
+ <div class="edit-content">
+ <div class="edit-input-wrap">
+ <input
+ v-model="oldPassword"
+ type="password"
+ class="edit-input"
+ :placeholder="$t('oldPassword')"
+ />
+ </div>
+ <div class="edit-input-wrap">
+ <input
+ v-model="newPassword"
+ type="password"
+ class="edit-input"
+ :placeholder="$t('newPassword')"
+ />
+ </div>
+ <div class="edit-input-wrap">
+ <input
+ v-model="rePassword"
+ type="password"
+ class="edit-input"
+ :placeholder="$t('sureNewPassword')"
+ />
+ </div>
+ <button class="edit-submit" @click="submit">{{ $t('sure') }}</button>
</div>
+ </div>
</template>
<script setup>
-import ExInput from "@/components/ex-input/index.vue";
-import { _changePassword } from '@/service/user.api.js'
import { ref } from "vue";
import { showToast } from "vant";
import { useRouter } from "vue-router";
import { useI18n } from "vue-i18n";
-const { t } = useI18n()
-const router = useRouter()
+import { _changePassword } from "@/service/user.api.js";
+import AssetsHead from "@/components/Transform/assets-head/index.vue";
-const oldPassword = ref('')
-const newPassword = ref('')
-const rePassword = ref('')
+const { t } = useI18n();
+const router = useRouter();
+
+const oldPassword = ref("");
+const newPassword = ref("");
+const rePassword = ref("");
const submit = () => {
- _changePassword({
- old_password: oldPassword.value,
- password: newPassword.value,
- re_password: rePassword.value,
- }).then((res) => {
- showToast(t('changeSuccess'))
- setTimeout(() => {
- router.push('/my/index')
- }, 1000);
+ if (!oldPassword.value) {
+ showToast(t("旧密码不能为空"));
+ return;
+ }
+ if (!newPassword.value || newPassword.value.length < 6) {
+ showToast(t("setPasswordTips"));
+ return;
+ }
+ if (newPassword.value !== rePassword.value) {
+ showToast(t("noSamePassword"));
+ return;
+ }
+ _changePassword({
+ old_password: oldPassword.value,
+ password: newPassword.value,
+ re_password: rePassword.value,
+ })
+ .then(() => {
+ showToast(t("changeSuccess"));
+ setTimeout(() => router.push("/my/index"), 1000);
})
-}
+ .catch((err) => {
+ const msg = err?.message || err?.msg;
+ if (msg && (msg.includes("旧密码") || msg.includes("incorrect") || msg.includes("wrong"))) {
+ showToast(t("旧密码不正确"));
+ } else {
+ showToast(msg || t("fail"));
+ }
+ });
+};
</script>
<style lang="scss" scoped>
-.changePassword {
- width: 100%;
- box-sizing: border-box;
+.change-password {
+ min-height: 100vh;
+ background: #fff;
+ box-sizing: border-box;
}
-.line {
- width: 100%;
- height: 2px;
- background: $light-grey;
+.edit-content {
+ padding: 24px 16px;
}
-.content {
- padding: 16px;
- font-size: 13px;
+.edit-input-wrap {
+ height: 48px;
+ margin-bottom: 20px;
+ padding: 0 16px;
+ background: #f5f5f5;
+ border-radius: 10px;
+ display: flex;
+ align-items: center;
}
-.hightLight {
- background: $btn_main;
- color: $text_color;
+.edit-input {
+ flex: 1;
+ height: 100%;
+ border: none;
+ background: transparent;
+ font-size: 16px;
+ color: #333;
+ outline: none;
+}
+
+.edit-input::placeholder {
+ color: #999;
+}
+
+.edit-submit {
+ width: 100%;
+ margin-top: 40px;
+ padding: 16px 0;
+ border: none;
+ border-radius: 12px;
+ background: linear-gradient(90deg, #5e2bc8, #a443cf);
+ color: #fff;
+ font-size: 16px;
+ font-weight: 600;
+ cursor: pointer;
}
</style>
--
Gitblit v1.9.3