|
@@ -1,5 +1,5 @@
|
|
<template>
|
|
<template>
|
|
- <div>
|
|
|
|
|
|
+ <div style="position: relative; width: 100%; height: 100%;">
|
|
<h3>{{ $t('setting.editPassword') }}</h3>
|
|
<h3>{{ $t('setting.editPassword') }}</h3>
|
|
<v-divider class="mb-4"></v-divider>
|
|
<v-divider class="mb-4"></v-divider>
|
|
<div v-if="!showEdit" class="login-user mb-4">
|
|
<div v-if="!showEdit" class="login-user mb-4">
|
|
@@ -7,124 +7,18 @@
|
|
<span>{{ userInfo.phone }}</span>
|
|
<span>{{ userInfo.phone }}</span>
|
|
<span class="color-primary ml-5 text-decoration-underline cursor-pointer" @click="showEdit = true">修改密码</span>
|
|
<span class="color-primary ml-5 text-decoration-underline cursor-pointer" @click="showEdit = true">修改密码</span>
|
|
</div>
|
|
</div>
|
|
- <v-stepper v-if="showEdit" v-model="stepper" color="primary">
|
|
|
|
- <v-stepper-header>
|
|
|
|
- <v-stepper-item title="手机验证" value="1"></v-stepper-item>
|
|
|
|
- <v-divider></v-divider>
|
|
|
|
- <v-stepper-item title="修改密码" value="2"></v-stepper-item>
|
|
|
|
- </v-stepper-header>
|
|
|
|
- <v-stepper-window>
|
|
|
|
- <v-stepper-window-item value="1">
|
|
|
|
- <div class="d-flex justify-center">
|
|
|
|
- <PhonePage ref="phoneRef" style="width: 300px;" :phone="userInfo.phone" :phoneDisabled="true"></PhonePage>
|
|
|
|
- </div>
|
|
|
|
- <div class="text-center mt-5">
|
|
|
|
- <v-btn class="buttons" color="primary" @click="handleValidate">立即验证</v-btn>
|
|
|
|
- </div>
|
|
|
|
- <div class="text-end">
|
|
|
|
- <v-btn color="primary" variant="outlined" @click="handleClose">取 消</v-btn>
|
|
|
|
- </div>
|
|
|
|
- </v-stepper-window-item>
|
|
|
|
- <v-stepper-window-item value="2">
|
|
|
|
- <div class="d-flex justify-center">
|
|
|
|
- <v-form ref="passwordRef" style="width: 300px;">
|
|
|
|
- <v-text-field
|
|
|
|
- v-model="query.password"
|
|
|
|
- placeholder="请输入新密码"
|
|
|
|
- variant="outlined"
|
|
|
|
- density="compact"
|
|
|
|
- color="primary"
|
|
|
|
- prepend-inner-icon="mdi-lock-outline"
|
|
|
|
- :append-inner-icon="passwordType ? 'mdi-eye-outline' : 'mdi-eye-off-outline'"
|
|
|
|
- :type="passwordType ? 'text' : 'password'"
|
|
|
|
- :rules="[v=> !!v || '请填写新密码', validPassword]"
|
|
|
|
- @click:append-inner="passwordType = !passwordType"
|
|
|
|
- ></v-text-field>
|
|
|
|
- <v-text-field
|
|
|
|
- v-model="query.checkPassword"
|
|
|
|
- placeholder="请再次输入新密码"
|
|
|
|
- variant="outlined"
|
|
|
|
- density="compact"
|
|
|
|
- color="primary"
|
|
|
|
- prepend-inner-icon="mdi-lock-outline"
|
|
|
|
- :append-inner-icon="show ? 'mdi-eye-outline' : 'mdi-eye-off-outline'"
|
|
|
|
- :type="show ? 'text' : 'password'"
|
|
|
|
- :rules="[v=> !!v || '请再次输入新密码', passwordCheck]"
|
|
|
|
- @click:append-inner="show = !show"
|
|
|
|
- ></v-text-field>
|
|
|
|
- </v-form>
|
|
|
|
- </div>
|
|
|
|
- <div class="text-center mt-5">
|
|
|
|
- <v-btn class="buttons" color="primary" @click="handleSubmit" :loading="loading">确认修改</v-btn>
|
|
|
|
- </div>
|
|
|
|
- <div class="text-end">
|
|
|
|
- <v-btn color="primary" variant="outlined" @click="handleClose">取 消</v-btn>
|
|
|
|
- </div>
|
|
|
|
- </v-stepper-window-item>
|
|
|
|
- </v-stepper-window>
|
|
|
|
- </v-stepper>
|
|
|
|
|
|
+ <editPasswordPage v-if="showEdit" :phone="userInfo.phone" @cancel="showEdit = false" class="editPage"></editPasswordPage>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup name="editPassword">
|
|
<script setup name="editPassword">
|
|
-import PhonePage from '@/components/VerificationCode'
|
|
|
|
-import { updatePassword } from '@/api/common/index'
|
|
|
|
-import { ref, reactive, computed } from 'vue'
|
|
|
|
-import Snackbar from '@/plugins/snackbar'
|
|
|
|
|
|
+import { ref } from 'vue'
|
|
|
|
+import editPasswordPage from '@/views/login/components/editPassword.vue'
|
|
|
|
|
|
-const phoneRef = ref()
|
|
|
|
-const passwordRef = ref()
|
|
|
|
-const passwordType = ref(false)
|
|
|
|
-const show = ref(false)
|
|
|
|
-const loading = ref(false)
|
|
|
|
-const stepper = ref('1')
|
|
|
|
const showEdit = ref(false)
|
|
const showEdit = ref(false)
|
|
-let query = reactive({
|
|
|
|
- password: '',
|
|
|
|
- checkPassword: ''
|
|
|
|
-})
|
|
|
|
-
|
|
|
|
-const handleClose = () => {
|
|
|
|
- showEdit.value = false
|
|
|
|
- query = {
|
|
|
|
- password: '',
|
|
|
|
- checkPassword: ''
|
|
|
|
- }
|
|
|
|
- stepper.value = '1'
|
|
|
|
- passwordType.value = false
|
|
|
|
- loading.value = false
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// 密码效验
|
|
|
|
-const regex = /^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).{4,10}$/
|
|
|
|
-const validPassword = computed(() => {
|
|
|
|
- return regex.test(query.password) || '请输入4-10位数由数字、大小写字母组成的密码'
|
|
|
|
-})
|
|
|
|
-const passwordCheck = computed(() => {
|
|
|
|
- return (query.checkPassword === query.password && regex.test(query.checkPassword)) || '两次密码输入不一致'
|
|
|
|
-})
|
|
|
|
|
|
|
|
// 当前登录的用户信息
|
|
// 当前登录的用户信息
|
|
const userInfo = JSON.parse(localStorage.getItem('userInfo'))
|
|
const userInfo = JSON.parse(localStorage.getItem('userInfo'))
|
|
-
|
|
|
|
-const handleSubmit = async () => {
|
|
|
|
- const { valid} = await passwordRef.value.validate()
|
|
|
|
- if (!valid) return
|
|
|
|
- loading.value = true
|
|
|
|
- try {
|
|
|
|
- await updatePassword({ password: query.password, code: phoneRef.value.loginData.code })
|
|
|
|
- Snackbar.success('修改成功')
|
|
|
|
- } finally {
|
|
|
|
- loading.value = false
|
|
|
|
- showEdit.value = false
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-const handleValidate = async () => {
|
|
|
|
- const { valid } = await phoneRef.value.phoneForm.validate()
|
|
|
|
- if (!valid) return
|
|
|
|
- stepper.value = '2'
|
|
|
|
-}
|
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
@@ -138,4 +32,10 @@ h3 {
|
|
color: var(--color-666);
|
|
color: var(--color-666);
|
|
font-weight: 600;
|
|
font-weight: 600;
|
|
}
|
|
}
|
|
|
|
+.editPage {
|
|
|
|
+ position: absolute;
|
|
|
|
+ top: 50%;
|
|
|
|
+ left: 50%;
|
|
|
|
+ transform: translate(-50%, -50%);
|
|
|
|
+}
|
|
</style>
|
|
</style>
|