<template>
|
<div class="change-funds-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="confirmPassword"
|
type="password"
|
class="edit-input"
|
:placeholder="$t('sureNewPassword')"
|
/>
|
</div>
|
<button class="edit-submit" @click="submit">{{ $t('sure') }}</button>
|
</div>
|
</div>
|
</template>
|
|
<script setup>
|
import { ref } from "vue";
|
import { showToast } from "vant";
|
import { useRouter } from "vue-router";
|
import { useI18n } from "vue-i18n";
|
import { _changeFundsPassword } from "@/service/user.api.js";
|
import AssetsHead from "@/components/Transform/assets-head/index.vue";
|
|
const { t } = useI18n();
|
const router = useRouter();
|
|
const oldPassword = ref("");
|
const newPassword = ref("");
|
const confirmPassword = ref("");
|
|
const submit = () => {
|
if (!oldPassword.value) {
|
showToast(t("旧密码不能为空"));
|
return;
|
}
|
if (newPassword.value.length < 6) {
|
showToast(t("funpasswordTips"));
|
return;
|
}
|
if (newPassword.value !== confirmPassword.value) {
|
showToast(t("两次输入的资金密码不相同"));
|
return;
|
}
|
_changeFundsPassword({
|
old_safeword: oldPassword.value,
|
safeword: newPassword.value,
|
safeword_confirm: confirmPassword.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>
|
.change-funds-password {
|
min-height: 100vh;
|
background: #fff;
|
box-sizing: border-box;
|
}
|
|
.edit-content {
|
padding: 24px 16px;
|
}
|
|
.edit-input-wrap {
|
height: 48px;
|
margin-bottom: 20px;
|
padding: 0 16px;
|
background: #f5f5f5;
|
border-radius: 10px;
|
display: flex;
|
align-items: center;
|
}
|
|
.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>
|