|
|
@@ -1,6 +1,7 @@
|
|
|
<script setup lang="ts">
|
|
|
-import {ref, computed} from 'vue';
|
|
|
+import {ref, computed} from 'vue'
|
|
|
import {userInfo, userInfoUpdate} from '../../api/user.ts'
|
|
|
+import {parseRole, parseTime} from "../../utils"
|
|
|
import {router} from '../../router'
|
|
|
import {UserFilled} from "@element-plus/icons-vue";
|
|
|
|
|
|
@@ -18,19 +19,21 @@ const displayInfoCard = ref(false)
|
|
|
const password = ref('')
|
|
|
const confirmPassword = ref('')
|
|
|
|
|
|
-const hasPasswordInput = computed(() => password.value != '');
|
|
|
-const hasConfirmPasswordInput = computed(() => confirmPassword.value != '');
|
|
|
-const isPasswordIdentical = computed(() => password.value == confirmPassword.value);
|
|
|
+const hasConfirmPasswordInput = computed(() => confirmPassword.value != '')
|
|
|
+const isPasswordIdentical = computed(() => password.value == confirmPassword.value)
|
|
|
+const changeDisabled = computed(() => {
|
|
|
+ return !(hasConfirmPasswordInput.value && isPasswordIdentical.value)
|
|
|
+})
|
|
|
|
|
|
getUserInfo()
|
|
|
|
|
|
function getUserInfo() {
|
|
|
userInfo().then(res => {
|
|
|
- name.value = res.result.name
|
|
|
- tel.value = res.result.phone
|
|
|
- storeName.value = res.result.storeName
|
|
|
- address.value = res.result.address
|
|
|
- regTime.value = parseTime(res.result.createTime)
|
|
|
+ name.value = res.data.result.name
|
|
|
+ tel.value = res.data.result.phone
|
|
|
+ storeName.value = res.data.result.storeName
|
|
|
+ address.value = res.data.result.address
|
|
|
+ regTime.value = parseTime(res.data.result.createTime)
|
|
|
|
|
|
newName.value = name.value
|
|
|
})
|
|
|
@@ -42,18 +45,18 @@ function updateInfo() {
|
|
|
password: null,
|
|
|
address: address.value,
|
|
|
}).then(res => {
|
|
|
- if (res.code === '000') {
|
|
|
+ if (res.data.code === '000') {
|
|
|
ElMessage({
|
|
|
customClass: 'customMessage',
|
|
|
type: 'success',
|
|
|
message: '更新成功!',
|
|
|
})
|
|
|
getUserInfo()
|
|
|
- } else if (res.code === '400') {
|
|
|
+ } else if (res.data.code === '400') {
|
|
|
ElMessage({
|
|
|
customClass: 'customMessage',
|
|
|
type: 'error',
|
|
|
- message: '更新失败!',
|
|
|
+ message: res.data.msg,
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
@@ -65,7 +68,7 @@ function updatePassword() {
|
|
|
password: password.value,
|
|
|
address: null
|
|
|
}).then(res => {
|
|
|
- if (res.code === '000') {
|
|
|
+ if (res.data.code === '000') {
|
|
|
password.value = ''
|
|
|
confirmPassword.value = ''
|
|
|
ElMessageBox.alert(
|
|
|
@@ -78,36 +81,18 @@ function updatePassword() {
|
|
|
showClose: false,
|
|
|
roundButton: true,
|
|
|
center: true
|
|
|
-
|
|
|
}).then(() => router.push({path: "/login"}))
|
|
|
- } else if (res.code === '400') {
|
|
|
+ } else if (res.data.code === '400') {
|
|
|
ElMessage({
|
|
|
customClass: 'customMessage',
|
|
|
type: 'error',
|
|
|
- message: '更新失败!',
|
|
|
+ message: res.data.msg,
|
|
|
})
|
|
|
password.value = ''
|
|
|
confirmPassword.value = ''
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
-function parseRole() {
|
|
|
- if (role === 'MANAGER') {
|
|
|
- return "管理员"
|
|
|
- } else if (role === 'CUSTOMER') {
|
|
|
- return "顾客"
|
|
|
- } else if (role === 'STAFF') {
|
|
|
- return "商家"
|
|
|
- } else if (role === 'CEO') {
|
|
|
- return "CEO"
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-function parseTime(time) {
|
|
|
- let times = time.split(/T|\./)
|
|
|
- return times[0] + " " + times[1]
|
|
|
-}
|
|
|
</script>
|
|
|
|
|
|
|
|
|
@@ -136,7 +121,7 @@ function parseTime(time) {
|
|
|
</template>
|
|
|
|
|
|
<el-descriptions-item label="身份">
|
|
|
- <el-tag>{{ parseRole() }}</el-tag>
|
|
|
+ <el-tag>{{ parseRole(role) }}</el-tag>
|
|
|
</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="所属商店" v-if="role === 'STAFF'">
|
|
|
@@ -189,7 +174,8 @@ function parseTime(time) {
|
|
|
<template #header>
|
|
|
<div class="card-header">
|
|
|
<span>修改密码</span>
|
|
|
- <el-button @click="updatePassword" :disabled="!hasConfirmPasswordInput || !isPasswordIdentical">修改
|
|
|
+ <el-button @click="updatePassword" :disabled="changeDisabled">
|
|
|
+ 修改
|
|
|
</el-button>
|
|
|
</div>
|
|
|
</template>
|