1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

后台管理修改密码

This commit is contained in:
程序员小墨 2023-04-24 22:45:57 +08:00
parent 9a8f3d050c
commit d3fb7827f1
3 changed files with 167 additions and 167 deletions

View File

@ -29,7 +29,6 @@ export function getOrderDetail(params) {
* @returns * @returns
*/ */
export function deliverOrder(params) { export function deliverOrder(params) {
console.log("params", params)
return send_request({ return send_request({
url: '/shop/order/manage/deliverOrder', url: '/shop/order/manage/deliverOrder',
method: 'POST', method: 'POST',

View File

@ -24,6 +24,24 @@ export function userLogout() {
return null; return null;
}; };
/**
* 修改密码
* @returns
*/
export function updatePwd({ oldpwd, newpwd }) {
let userId = localStorage.getItem("ms_user_id")
return send_request({
url: '/user/updatePwd',
method: 'POST',
useQS: true,
params: {
"userId": userId,
"oldpwd": oldpwd,
"newpwd": newpwd,
},
});
};
/** /**
* 获取用户列表 * 获取用户列表
* @returns * @returns

View File

@ -1,67 +1,63 @@
<template> <template>
<div> <div>
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="12"> <el-col :span="12">
<el-card shadow="hover"> <el-card shadow="hover">
<template #header> <template #header>
<div class="clearfix"> <div class="clearfix">
<span>基础信息</span> <span>基础信息</span>
</div> </div>
</template> </template>
<div class="info"> <div class="info">
<div class="info-image" @click="showDialog"> <div class="info-image" @click="showDialog">
<el-avatar :size="100" :src="avatarImg" /> <el-avatar :size="100" :src="avatarImg" />
<span class="info-edit"> <span class="info-edit">
<i class="el-icon-lx-camerafill"></i> <i class="el-icon-lx-camerafill"></i>
</span> </span>
</div> </div>
<div class="info-name">{{ name }}</div> <div class="info-name">{{ name }}</div>
<!-- <div class="info-desc">不可能我的代码怎么可能会有bug</div> --> </div>
</div> </el-card>
</el-card> </el-col>
</el-col> <el-col :span="12">
<el-col :span="12"> <el-card shadow="hover">
<el-card shadow="hover"> <template #header>
<template #header> <div class="clearfix">
<div class="clearfix"> <span>账户编辑</span>
<span>账户编辑</span> </div>
</div> </template>
</template> <el-form label-width="90px">
<el-form label-width="90px"> <el-form-item label="用户名:"> {{ name }} </el-form-item>
<el-form-item label="用户名:"> {{ name }} </el-form-item> <el-form-item label="旧密码:">
<el-form-item label="旧密码:"> <el-input type="password" v-model="form.old"></el-input>
<el-input type="password" v-model="form.old"></el-input> </el-form-item>
</el-form-item> <el-form-item label="新密码:">
<el-form-item label="新密码:"> <el-input type="password" v-model="form.new"></el-input>
<el-input type="password" v-model="form.new"></el-input> </el-form-item>
</el-form-item> <el-form-item label="确认密码:">
<el-form-item label="确认密码:"> <el-input type="password" v-model="form.new1"></el-input>
<el-input type="password" v-model="form.new1"></el-input> </el-form-item>
</el-form-item> <el-form-item>
<!-- <el-form-item label="个人简介:"> <el-button type="primary" @click="onSubmit">保存</el-button>
<el-input v-model="form.desc"></el-input> </el-form-item>
</el-form-item> --> </el-form>
<el-form-item> </el-card>
<el-button type="primary" @click="onSubmit">保存</el-button> </el-col>
</el-form-item> </el-row>
</el-form> <el-dialog title="裁剪图片" v-model="dialogVisible" width="600px">
</el-card> <vue-cropper ref="cropper" :src="imgSrc" :ready="cropImage" :zoom="cropImage" :cropmove="cropImage"
</el-col> style="width: 100%; height: 400px"></vue-cropper>
</el-row>
<el-dialog title="裁剪图片" v-model="dialogVisible" width="600px">
<vue-cropper ref="cropper" :src="imgSrc" :ready="cropImage" :zoom="cropImage" :cropmove="cropImage"
style="width: 100%; height: 400px"></vue-cropper>
<template #footer> <template #footer>
<span class="dialog-footer"> <span class="dialog-footer">
<el-button class="crop-demo-btn" type="primary">选择图片 <el-button class="crop-demo-btn" type="primary">选择图片
<input class="crop-input" type="file" name="image" accept="image/*" @change="setImage" /> <input class="crop-input" type="file" name="image" accept="image/*" @change="setImage" />
</el-button> </el-button>
<el-button type="primary" @click="saveAvatar">上传并保存</el-button> <el-button type="primary" @click="saveAvatar">上传并保存</el-button>
</span> </span>
</template> </template>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<script setup lang="ts" name="user"> <script setup lang="ts" name="user">
@ -70,65 +66,52 @@ import VueCropper from 'vue-cropperjs';
import 'cropperjs/dist/cropper.css'; import 'cropperjs/dist/cropper.css';
import avatar from '../assets/img/img.jpg'; import avatar from '../assets/img/img.jpg';
import { ElMessage, ElMessageBox, ElLoading } from 'element-plus'; import { ElMessage, ElMessageBox, ElLoading } from 'element-plus';
import send_request from '../utils/send_request'; import * as userApi from '../api/user';
const name = localStorage.getItem('ms_username'); const name = localStorage.getItem('ms_username');
const user_id = localStorage.getItem('ms_user_id'); const user_id = localStorage.getItem('ms_user_id');
const form = reactive({ const form = reactive({
user_id: user_id, user_id: user_id,
old: '', old: '',
new: '', new: '',
new1: '', new1: '',
desc: '' desc: ''
}); });
const onSubmit = async () => { const onSubmit = async () => {
if (form.old == '' || form.new == '' || form.new1 == '') { if (form.old == '' || form.new == '' || form.new1 == '') {
// //
ElMessageBox.confirm('输入为空,请检查', '提示', { ElMessageBox.confirm('输入为空,请检查', '提示', {
type: 'warning' type: 'warning'
}) })
return return
} else if (form.new != form.new1) { } else if (form.new != form.new1) {
// //
ElMessageBox.confirm('新密码2次输入的不相同', '提示', { ElMessageBox.confirm('新密码2次输入的不相同', '提示', {
type: 'warning' type: 'warning'
}) })
return return
} else if (form.new == form.old) { } else if (form.new == form.old) {
// //
ElMessageBox.confirm('新、旧密码相同', '提示', { ElMessageBox.confirm('新、旧密码相同', '提示', {
type: 'warning' type: 'warning'
}) })
return return
} }
ElMessageBox.confirm('确认要修改密码吗?', '提示', { ElMessageBox.confirm('确认要修改密码吗?', '提示', {
type: 'warning' type: 'warning'
}) }).then(async () => {
.then(async () => { userApi.updatePwd({
console.log("send_request v1/user/alterPSW") oldpwd: form.old,
newpwd: form.new,
const loading = ElLoading.service({ }).then((data) => {
lock: true, data && ElMessage.success(data);
text: '请稍候', })
background: 'rgba(0, 0, 0, 0.7)', }).catch((err) => {
}); ElMessage.success('删除失败');
// await send_request('v1/user/alterPSW', "POST", { console.log("err", err)
// "userId": form.user_id, });
// "oldPSW": form.old, return;
// "newPSW": form.new
// }, (data: any) => {
// console.log(data);
// ElMessage.success('');
// // tableData.value.splice(index, 1);
// })
loading.close();
})
.catch(() => {
ElMessage.success('删除失败');
});
return;
}; };
@ -139,92 +122,92 @@ const dialogVisible = ref(false);
const cropper: any = ref(); const cropper: any = ref();
const showDialog = () => { const showDialog = () => {
dialogVisible.value = true; dialogVisible.value = true;
imgSrc.value = avatarImg.value; imgSrc.value = avatarImg.value;
}; };
const setImage = (e: any) => { const setImage = (e: any) => {
const file = e.target.files[0]; const file = e.target.files[0];
if (!file.type.includes('image/')) { if (!file.type.includes('image/')) {
return; return;
} }
const reader = new FileReader(); const reader = new FileReader();
reader.onload = (event: any) => { reader.onload = (event: any) => {
dialogVisible.value = true; dialogVisible.value = true;
imgSrc.value = event.target.result; imgSrc.value = event.target.result;
cropper.value && cropper.value.replace(event.target.result); cropper.value && cropper.value.replace(event.target.result);
}; };
reader.readAsDataURL(file); reader.readAsDataURL(file);
}; };
const cropImage = () => { const cropImage = () => {
cropImg.value = cropper.value.getCroppedCanvas().toDataURL(); cropImg.value = cropper.value.getCroppedCanvas().toDataURL();
}; };
const saveAvatar = () => { const saveAvatar = () => {
avatarImg.value = cropImg.value; avatarImg.value = cropImg.value;
dialogVisible.value = false; dialogVisible.value = false;
}; };
</script> </script>
<style scoped> <style scoped>
.info { .info {
text-align: center; text-align: center;
padding: 35px 0; padding: 35px 0;
} }
.info-image { .info-image {
position: relative; position: relative;
margin: auto; margin: auto;
width: 100px; width: 100px;
height: 100px; height: 100px;
background: #f8f8f8; background: #f8f8f8;
border: 1px solid #eee; border: 1px solid #eee;
border-radius: 50px; border-radius: 50px;
overflow: hidden; overflow: hidden;
} }
.info-edit { .info-edit {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
position: absolute; position: absolute;
left: 0; left: 0;
top: 0; top: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
background: rgba(0, 0, 0, 0.5); background: rgba(0, 0, 0, 0.5);
opacity: 0; opacity: 0;
transition: opacity 0.3s ease; transition: opacity 0.3s ease;
} }
.info-edit i { .info-edit i {
color: #eee; color: #eee;
font-size: 25px; font-size: 25px;
} }
.info-image:hover .info-edit { .info-image:hover .info-edit {
opacity: 1; opacity: 1;
} }
.info-name { .info-name {
margin: 15px 0 10px; margin: 15px 0 10px;
font-size: 24px; font-size: 24px;
font-weight: 500; font-weight: 500;
color: #262626; color: #262626;
} }
.crop-demo-btn { .crop-demo-btn {
position: relative; position: relative;
} }
.crop-input { .crop-input {
position: absolute; position: absolute;
width: 100px; width: 100px;
height: 40px; height: 40px;
left: 0; left: 0;
top: 0; top: 0;
opacity: 0; opacity: 0;
cursor: pointer; cursor: pointer;
} }
</style> </style>