对接后端个人信息部分接口

This commit is contained in:
龙运模 2024-07-03 20:05:29 +08:00
parent 43f9a8d49c
commit 0bb1d10f4b
26 changed files with 695 additions and 86 deletions

View File

@ -6,8 +6,8 @@ VUE_APP_TITLE = 德木测试
# 象纬云科
# 接口地址
VUE_APP_API_BASEURL = https://api.dev.dwoodauto.com/api/v1
VUE_APP_API_DEV = https://api.dev.dwoodauto.com
VUE_APP_API_BASEURL = https://xwapi.dev.dwoodauto.com/api/v1
VUE_APP_API_DEV = https://xwapi.dev.dwoodauto.com
# WS地址
VUE_APP_WS_URL = wss://api.dev.dwoodauto.com/wss

12
src/api/model/oss.js Normal file
View File

@ -0,0 +1,12 @@
import config from "@/config";
import http from "@/utils/request";
export default {
ossGet: {
url: `${config.API_URL}/oss.get.sign`,
name: "获取oss参数",
post: async function (params) {
return await http.oss(this.url, params);
},
}
};

View File

@ -44,9 +44,9 @@ export { default as Page } from './menu/Page.vue'
export { default as Loading } from './menu/Loading.vue'
export { default as Authentication } from './menu/Authenticat.vue'
export { default as Tags } from './menu/Tags.vue'
export { default as WorkOrder } from './menu/WorkOrder.vue'
export { default as Order } from './menu/WorkOrder.vue'
export { default as Finance } from './menu/Finance.vue'
export { default as ReportForms } from './menu/ReportForms.vue'
export { default as Reports } from './menu/ReportForms.vue'
export { default as Shipment } from './menu/Shipment.vue'
export { default as Stock } from './menu/Stock.vue'

View File

@ -0,0 +1,164 @@
<template>
<el-upload
:class="{'avatar-img avatar-uploader':imageUrl,'avatar-uploader':!imageUrl,'user-avatar-uploader':upload_type==2}"
:action="oss.host"
:data="upload_data"
:show-file-list="false"
:on-success="handleAvatarSuccess"
:on-error="handleAvatarError"
:before-upload="beforeAvatarUpload"
>
<div v-if="upload_type ==1">
<el-image v-if="imageUrl" :src="imageUrl" class="avatar" fit="cover" ></el-image>
<div v-else class="avatar-icon">
<div class="avatar-uploader-icon"><el-icon-Plus /></div>
</div>
</div>
<div class="userAvatar" v-else>
<el-image :src="this.$store.state.global.login_avatar" class="avatar" fit="cover" ></el-image>
</div>
</el-upload>
</template>
<script>
export default {
name: "uploadImg",
props:{
url:{
type:String,
default: ""
},
// type 1 2
type:{
type:[String,Number],
default: 1
}
},
data(){
return{
upload_type:1,
imageUrl:'',
oss:{
host:''
},
upload_data:{}
}
},
watch:{
url:{
handler(newVal){
this.imageUrl = newVal;
},
immediate:true,
deep:true
},
type:{
handler(newVal) {
this.upload_type = newVal;
},
immediate:true,
deep:true
}
},
mounted() {
},
methods:{
//
beforeAvatarUpload(file){
if(!['image/jpeg','image/png','image/gif'].includes(file.type)){
this.$message.warning(`选择的文件类型 ${file.type} 非图像类文件`);
return false;
}
return new Promise((resolve)=>{
setTimeout(async ()=>{
let params = {
dir:"user/images/"
}
const res = await this.$API.oss.ossGet.post(params);
this.oss = res.data;
this.upload_data = {
name: new Date().getTime() + file.name,
key: this.oss.dir +file.name,
policy: this.oss.policy,
OSSAccessKeyId: this.oss.accessid,
success_action_status: "200",
callback: this.oss.callback,
signature: this.oss.signature,
"Cache-Control": this.oss.cache_control,
};
resolve()
},100)
})
},
//
handleAvatarSuccess(file){
this.imageUrl = file.data.base_url+file.data.filename;
this.$emit('parentParams',this.imageUrl);
},
//
handleAvatarError(){
this.$message.warning('上传失败请重新上传');
}
}
}
</script>
<style lang="scss" scoped>
.avatar-uploader .avatar {
width: 80px;
height: 80px;
display: block;
}
.avatar-uploader{
border: 1px dashed var(--el-border-color);
border-radius: 6px;
cursor: pointer;
position: relative;
overflow: hidden;
transition: var(--el-transition-duration-fast);
height: 80px;
width: 80px;
}
.user-avatar-uploader{
width: 70px;
height: 70px;
}
.avatar-img{
border: none;
}
.avatar-uploader:hover {
border-color: var(--el-color-primary);
}
.avatar-icon{
width: 80px;
height: 80px;
display: flex;
align-items: center;
justify-content: center;
}
.avatar-icon .avatar-uploader-icon {
color: #8c939d;
text-align: center;
width: 28px;
height: 28px;
}
.userAvatar{
width: 70px;
height: 70px;
display: flex;
align-items: center;
justify-content: center;
.avatar{
width: 100%;
height: 100%;
border-radius: 50%;
}
}
</style>

View File

@ -0,0 +1,201 @@
<template>
<el-upload
:class="imageList.length>0?'avatar-img avatar-uploader':'avatar-uploader'"
:action="oss.host"
:data="upload_data"
:show-file-list="false"
:on-success="handleAvatarSuccess"
:on-error="handleAvatarError"
:before-upload="beforeAvatarUpload"
>
<div class="imgList">
<div class="imgBox" v-for="(item,index) in imageList" :key="index" @click.stop="imgOpen">
<el-image :src="item.url?item.url:item" :zoom-rate="1.2" :max-scale="7" :min-scale="0.2" :hide-on-click-modal="true" :preview-teleported="true" :initial-index="index" :preview-src-list="imageList" class="avatar" fit="cover" />
<div class="deleteIcon" @click.stop="imgDelete(index)">
<div class="iconBox">
<div class="iconBtn"><sc-icon-Delete /></div>
</div>
</div>
</div>
</div>
<div class="avatar-icon" v-if="imageList.length<=num">
<div class="avatar-uploader-icon"><el-icon-Plus /></div>
</div>
</el-upload>
</template>
<script>
export default {
name: "uploadListImg",
props:{
list:{
type:Array,
},
length:{
type:Number,
}
},
data(){
return{
imageList:[],
num:2,
oss:{
host:''
},
upload_data:{}
}
},
watch:{
'list':{
handler(val){
if(val){
this.imageList = val;
}
},
immediate:true,
deep:true
},
'length':{
handler(val){
if(val){
this.num = val;
}
},
deep:true
}
},
mounted() {
},
methods:{
//
beforeAvatarUpload(file){
if(!['image/jpeg','image/png','image/gif'].includes(file.type)){
this.$message.warning(`选择的文件类型 ${file.type} 非图像类文件`);
return false;
}
return new Promise((resolve)=>{
setTimeout(async ()=>{
let params = {
dir:"user/images/"
}
const res = await this.$API.oss.ossGet.post(params);
this.oss = res.data;
this.upload_data = {
name: new Date().getTime() + file.name,
key: this.oss.dir +file.name,
policy: this.oss.policy,
OSSAccessKeyId: this.oss.accessid,
success_action_status: "200",
callback: this.oss.callback,
signature: this.oss.signature,
"Cache-Control": this.oss.cache_control,
};
resolve()
},100)
})
},
//
handleAvatarSuccess(file){
let imageUrl = file.data.base_url+file.data.filename;
this.imageList.push(imageUrl)
this.$emit('parentParams',this.imageList);
},
//
handleAvatarError(){
this.$message.warning('上传失败请重新上传');
},
imgOpen(){
return
},
imgDelete(num){
this.imageList.forEach((item,index)=>{
if(index == num){
this.imageList.splice(index,1);
}
})
}
}
}
</script>
<style lang="scss" scoped>
.avatar-uploader .avatar {
width: 80px;
height: 80px;
display: block;
}
.avatar-uploader{
cursor: pointer;
position: relative;
overflow: hidden;
height: 80px;
transition: var(--el-transition-duration-fast);
}
.avatar-img{
border: none;
}
.avatar-uploader:hover {
border-color: var(--el-color-primary);
}
.imgList{
display: flex;
align-items: center;
.imgBox{
margin-right: 20px;
position: relative;
.avatar{
border-radius: 4px;
}
.deleteIcon{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.8);
align-items: center;
justify-content: center;
border-radius: 4px;
display: none;
.iconBox{
width: 32px;
padding: 9px 16px;
border-radius: 20px;
background: var(--el-color-primary);
display: flex;
align-items: center;
justify-content: center;
color: #fff;
.iconBtn{
width: 14px;
height: 14px;
display: flex;
align-items: center;
justify-content: center;
}
}
}
}
.imgBox:hover .deleteIcon{
display: flex;
}
}
.avatar-icon{
width: 80px;
height: 80px;
display: flex;
align-items: center;
justify-content: center;
border: 1px dashed var(--el-border-color);
border-radius: 6px;
}
.avatar-icon .avatar-uploader-icon {
color: #8c939d;
text-align: center;
width: 28px;
height: 28px;
}
</style>

View File

@ -11,6 +11,7 @@ const routes = [
meta: {
icon: "sc-icon-Home",
title: "首页",
hidden: true
},
children: [{
name: "dashboard",
@ -31,7 +32,7 @@ const routes = [
},{
name: "document",
path: "/document",
component: "document/list",
component: "docsManager/index",
meta: {
icon: "sc-icon-UserInfo",
title: "文档管理",
@ -39,7 +40,7 @@ const routes = [
},{
name: "earlyWarning",
path: "/early-warning",
component: "early/list",
component: "earlyManager/index",
meta: {
icon: "sc-icon-UserInfo",
title: "预警管理",
@ -58,8 +59,9 @@ const routes = [
name: "order",
path: "/order",
meta: {
icon: "sc-icon-WorkOrder",
icon: "sc-icon-order",
title: "维保工单",
hidden: true
},
children: [{
name: "order",
@ -93,6 +95,7 @@ const routes = [
meta: {
icon: "sc-icon-Stock",
title: "库存管理",
hidden:true
},
children: [{
name: "stock",
@ -126,6 +129,7 @@ const routes = [
meta: {
icon: "sc-icon-Shipment",
title: "出货管理",
hidden:true
},
children: [{
name: "shipment",
@ -159,6 +163,7 @@ const routes = [
meta: {
icon: "sc-icon-Finance",
title: "财务管理",
hidden:true
},
children: [{
name: "finance",
@ -184,6 +189,7 @@ const routes = [
meta: {
icon: "sc-icon-ReportForms",
title: "报表统计",
hidden:true
},
children: [{
name: "report",
@ -209,6 +215,7 @@ const routes = [
meta: {
icon: "sc-icon-Setup",
title: "系统设置",
hidden: true
},
children: [{
name: "system",

View File

@ -4,7 +4,7 @@ import tool from '@/utils/tool'
export default {
successCode: 200, //请求完成代码
pageSize: 20, //表格每一页条数
pageSize: 30, //表格每一页条数
pageSizes: [10, 20, 30, 40, 50], //表格可设置的一页条数
paginationLayout: "total, sizes, prev, pager, next, jumper", //表格分页布局,可设置"total, sizes, prev, pager, next, jumper"
parseData: function (res) { //数据分析

View File

@ -53,7 +53,7 @@
</div>
<el-dropdown class="user panel-item" trigger="click" @command="handleUser">
<div class="user-avatar">
<el-avatar :size="22">{{ userNameF }}</el-avatar>
<el-avatar :size="22" shape="circle" :src="this.$store.state.global.login_avatar"><span class="userName">{{ userNameF }}</span></el-avatar>
<label>{{ userName }}</label>
<el-icon class="el-icon--right"><el-icon-arrow-down /></el-icon>
</div>
@ -125,22 +125,33 @@
}
},
created() {
var userInfo = this.$TOOL.data.get("USER_INFO");
this.userName = userInfo.name;
this.userNameF = this.userName.substring(0, 1);
const userInfo = this.$TOOL.data.get("USER_INFO");
this.$store.commit("SET_LOGIN_AVATAR", userInfo.avatar);
this.$store.commit("SET_LOGIN_NAME", userInfo.name);
this.userName = this.$store.state.global.login_name;
if(userInfo.company_info){
this.companyName = userInfo.company_info.name;
}
if(this.userName!=''){
this.userNameF = this.userName.substring(0, 1);
}
this.avatar = this.$store.state.global.login_avatar;
this.userId = userInfo.id;
},
methods: {
//
handleUser(command) {
if (command == "uc") {
this.$router.push({ path: '/usercenter' });
this.$router.push({ path: '/user/center' });
}
if (command == "cmd") {
this.$router.push({ path: '/cmd' });
}
if (command == "clearCache") {
this.$confirm('清除缓存会将系统初始化,包括登录状态、主题、语言设置等,是否继续?', '提示', {
type: 'info',
this.$confirm('清除缓存会将系统初始化,包括登录状态、主题、语言设置等,是否继续?', '警告', {
type: 'warning',
}).then(() => {
const loading = this.$loading()
this.$TOOL.data.clear()
@ -154,7 +165,7 @@
})
}
if (command == "outLogin") {
this.$confirm('确认是否退出当前用户?', '提示', {
this.$confirm('确认是否退出当前用户?', '警告', {
type: 'warning',
confirmButtonText: '退出',
confirmButtonClass: 'el-button--danger'

View File

@ -55,8 +55,8 @@
<header class="adminui-header">
<div class="adminui-header-left">
<div class="logo-bar">
<!-- <img class="logo" src="https://dm-auto.oss-cn-shanghai.aliyuncs.com/xw_cloud/image/login_logo.png">-->
<span>{{ $CONFIG.APP_NAME }}</span>
<img class="logo" src="https://dm-auto.oss-cn-shanghai.aliyuncs.com/xw_cloud/image/login_logo.png">
<!-- <span>{{ $CONFIG.APP_NAME }}</span>-->
</div>
<Topbar v-if="!ismobile"></Topbar>
</div>

View File

@ -66,7 +66,7 @@ router.beforeEach(async (to, from, next) => {
}
//加载动态/静态路由
if(!isGetRouter){
let apiMenu = [] // tool.data.get("MENU") ||
let apiMenu = tool.data.get("MENU") || [] //
let userInfo = tool.data.get("USER_INFO")
let userMenu = treeFilter(userRoutes, node => {
return node.meta.role ? node.meta.role.filter(item=>userInfo.role.indexOf(item)>-1).length > 0 : true
@ -102,7 +102,7 @@ router.onError((error) => {
//入侵追加自定义方法、对象
router.sc_getMenu = () => {
var apiMenu = [] // tool.data.get("MENU") ||
var apiMenu = tool.data.get("MENU") || [] // tool.data.get("MENU")
let userInfo = tool.data.get("USER_INFO")
let userMenu = treeFilter(userRoutes, node => {
return node.meta.role ? node.meta.role.filter(item=>userInfo.role.indexOf(item)>-1).length > 0 : true

View File

@ -19,6 +19,8 @@ import scForm from './components/scForm'
import scTitle from './components/scTitle'
import scWaterMark from './components/scWaterMark'
import scQrCode from './components/scQrCode'
import ossImgUpload from "./components/scUpload/uploadImg";
import ossImgListUpload from "./components/scUpload/uploadListImg";
import scStatusIndicator from './components/scMini/scStatusIndicator'
import scTrend from './components/scMini/scTrend'
@ -62,6 +64,8 @@ export default {
app.component('scQrCode', scQrCode);
app.component('scStatusIndicator', scStatusIndicator);
app.component('scTrend', scTrend);
app.component('ossImgUpload', ossImgUpload);
app.component('ossImgListUpload', ossImgListUpload);
//注册全局指令
app.directive('auth', auth)

View File

@ -12,6 +12,14 @@ export default {
layoutTags: config.LAYOUT_TAGS,
//主题
theme: config.THEME,
// 获取聊天记录
msg: "",
// 用户消息总数
msgNum:0,
// 用户名
login_name:'管理员',
// 用户头像
login_avatar:'https://dm-auto.oss-cn-shanghai.aliyuncs.com/mes-login/logo.png',
},
mutations: {
SET_ismobile(state, key){
@ -28,6 +36,15 @@ export default {
},
TOGGLE_layoutTags(state){
state.layoutTags = !state.layoutTags
}
},
SET_LOGIN_NAME(state, key) {
state.login_name = key
},
SET_LOGIN_AVATAR(state, key) {
state.login_avatar = key
},
SET_WS_Msg_NUM(state, key) {
state.msgNum = key
},
}
}

View File

@ -122,6 +122,28 @@ var http = {
})
},
/** oss
* @param {string} url
* @param {{}} data
* @param {{}} config
*/
oss:function (url, data = {}, config = {}){
return new Promise((resolve, reject) => {
axios({
method: "post",
url: url,
data: data,
...config,
})
.then((response) => {
resolve(response.data);
})
.catch((error) => {
reject(error);
});
});
},
/** put
* @param {string} url 接口地址
* @param {object} data 请求参数

View File

@ -17,7 +17,7 @@ import document from './document'
import share from './share'
export default {
name: 'list',
name: 'index',
components: {
document,
share

View File

@ -35,7 +35,7 @@
<el-table-column label="创建时间" prop="date" width="180"></el-table-column>
<el-table-column label="状态" prop="status" width="80">
<template #default="scope">
<el-switch v-model="scope.row.status" @change="changeSwitch($event, scope.row)" :loading="scope.row.$switch_status" :active-value="true" :inactive-value="false"></el-switch>
<el-switch v-model="scope.row.status" :size="size" @change="changeSwitch($event, scope.row)" :loading="scope.row.$switch_status" :active-value="true" :inactive-value="false"></el-switch>
</template>
</el-table-column>
<el-table-column label="备注" prop="remark" min-width="150"></el-table-column>

View File

@ -114,8 +114,8 @@
},
computed: {
allCompsList(){
var allCompsList = []
for(var key in this.allComps){
const allCompsList = [];
for(let key in this.allComps){
allCompsList.push({
key: key,
title: allComps[key].title,
@ -123,7 +123,9 @@
description: allComps[key].description
})
}
var myCopmsList = this.grid.copmsList.reduce(function(a, b){return a.concat(b)})
const myCopmsList = this.grid.copmsList.reduce(function (a, b) {
return a.concat(b)
});
for(let comp of allCompsList){
const _item = myCopmsList.find((item)=>{return item === comp.key})
if(_item){
@ -133,7 +135,7 @@
return allCompsList
},
myCompsList(){
var myGrid = this.$TOOL.data.get("DASHBOARDGRID")
const myGrid = this.$TOOL.data.get("DASHBOARDGRID");
return this.allCompsList.filter(item => !item.disabled && myGrid.includes(item.key))
},
nowCompsList(){

View File

@ -27,9 +27,8 @@
export default {
data() {
return {
userType: 'admin',
form: {
user: "long",
user: "ykxiao",
password: "123456",
autologin: false
},
@ -45,53 +44,43 @@
}
},
watch: {
userType(val) {
if (val == 'admin') {
this.form.user = 'admin'
this.form.password = 'admin'
} else if (val == 'user') {
this.form.user = 'user'
this.form.password = 'user'
}
}
},
mounted() {
},
methods: {
async login() {
var validate = await this.$refs.loginForm.validate().catch(() => { })
const validate = await this.$refs.loginForm.validate().catch(() => {});
if (!validate) { return false }
this.islogin = true
var data = {
const data = {
login_name: this.form.user,
password: this.form.password //this.$TOOL.crypto.MD5(this.form.password)
}
password: this.form.password
};
//token
var user = await this.$API.auth.token.post(data)
const user = await this.$API.auth.token.post(data);
if (user.code == 200) {
this.$TOOL.cookie.set("TOKEN", user.data.token, {
expires: this.form.autologin ? 24 * 60 * 60 : 0
})
this.$TOOL.data.set("USER_INFO", user.data.user)
if(user.data.user.avatar!=''){
this.$store.commit("SET_LOGIN_AVATAR", user.data.user.avatar);
}
this.$store.commit("SET_LOGIN_NAME", user.data.user.name);
} else {
this.islogin = false
this.$message.warning(user.message)
return false
}
//
var menu = await this.$API.system.menu.myMenus.get();
// if (this.form.user == 'admin') {
// menu = await this.$API.system.menu.myMenus.get()
// } else {
// menu = await this.$API.demo.menu.get()
// }
const menu = await this.$API.system.menu.myMenus.get();
if (menu.code == 200) {
if (menu.data.menu.length == 0) {
this.islogin = false
this.$alert("当前用户无任何菜单权限,请联系系统管理员", "无权限访问", {
await this.$alert("当前用户无任何菜单权限,请联系系统管理员", "无权限访问", {
type: 'error',
center: true
})
@ -109,7 +98,6 @@
this.$router.replace({
path: '/'
})
this.$message.success("Login Success 登录成功")
this.islogin = false
},
}

View File

@ -0,0 +1,24 @@
<template>
<view>2112</view>
</template>
<script>
export default {
name: "index",
data(){
return{
}
},
mounted() {
},
methods:{
}
}
</script>
<style scoped lang="scss">
</style>

View File

@ -0,0 +1,26 @@
<template>
<view>
</view>
</template>
<script>
export default {
name: "index",
data(){
return{
}
},
mounted() {
},
methods:{
}
}
</script>
<style scoped lang="scss">
</style>

View File

@ -0,0 +1,26 @@
<template>
<view>
</view>
</template>
<script>
export default {
name: "index",
data(){
return{
}
},
mounted() {
},
methods:{
}
}
</script>
<style scoped lang="scss">
</style>

View File

@ -4,10 +4,10 @@
<el-container>
<el-header style="height: auto;display: block;">
<div class="user-info-top">
<el-avatar :size="70" src="img/avatar.jpg"></el-avatar>
<ossImgUpload @parentParams="parentParams" :url="this.$store.state.global.login_avatar" type="2" />
<div class="userView">
<h2 class="name">{{ user.userName }}</h2>
<p><el-tag round effect="plain" size="small" disable-transitions>{{ user.role }}</el-tag></p>
<h2 class="name">{{ this.$store.state.global.login_name }}</h2>
<p v-if="user.role!=''"><el-tag round effect="plain" size="small" disable-transitions>{{ user.role }}</el-tag></p>
</div>
</div>
</el-header>
@ -91,21 +91,13 @@
}
]
},
// {
// groupName: "",
// list: [
// {
// icon: "el-icon-office-building",
// title: "",
// component: "upToEnterprise"
// }
// ]
// }
],
user: {
userName: "龙隆",
role: "管理员",
avatar:this.$store.state.global.login_avatar,
name: this.$store.state.global.login_name,
role: "",
},
userNameF:'',
page: "account"
}
},
@ -123,9 +115,22 @@
}
})
},
created() {
const userInfo = this.$TOOL.data.get('USER_INFO');
this.user.role = userInfo.user_roles && userInfo.user_roles.role_names.length>0?userInfo.user_roles.role_names[0]:'';
},
methods: {
openPage(item){
this.page = item.index
},
async parentParams(files) {
let params = {
avatar: files
}
const res = await this.$API.user.uploadAvatar.post(params);
if (res.code == 200) {
this.$store.commit("SET_LOGIN_AVATAR", files);
}
}
}
}

View File

@ -1,20 +1,29 @@
<template>
<el-card shadow="never" header="账户信息">
<el-form ref="form" :model="form" label-width="90px" style="margin-top:10px;width: 518px;">
<el-form-item label="账号">
<el-form ref="form" :model="form" :rules="rules" label-width="90px" style="margin-top:10px;width: 480px;">
<el-form-item label="" prop="avatar">
<ossImgUpload @parentParams="parentParams" :url="this.$store.state.global.login_avatar" />
</el-form-item>
<el-form-item label="账号" prop="user">
<el-input v-model="form.user" disabled></el-input>
<div class="el-form-item-msg">账号信息用于登录系统不允许修改</div>
</el-form-item>
<el-form-item label="手机号码">
<el-input v-model="form.mobile"></el-input>
</el-form-item>
<el-form-item label="真实姓名">
<el-form-item label="姓名" prop="name">
<el-input v-model="form.name"></el-input>
</el-form-item>
<el-form-item label="邮箱地址">
<el-form-item label="手机号码" prop="mobile">
<el-input v-model="form.mobile"></el-input>
</el-form-item>
<el-form-item label="验证码" prop="verify_code">
<div class="login-msg-yzm">
<el-input v-model="form.verify_code" clearable placeholder="请输入验证码"></el-input>
<el-button style="margin-left:10px;" @click="getYzm" :disabled="disabled">获取验证码<span v-if="disabled"> ({{ time }})</span></el-button>
</div>
</el-form-item>
<el-form-item label="邮箱地址" prop="email">
<el-input v-model="form.email"></el-input>
</el-form-item>
<el-form-item label="个性签名">
<el-form-item label="个性签名" prop="about">
<el-input v-model="form.about" type="textarea"></el-input>
</el-form-item>
<el-form-item>
@ -25,20 +34,111 @@
</template>
<script>
export default {
data() {
return {
form: {
user: "administrator@scuiadmin.com",
name: "Sakuya",
mobile:'18828382888',
email:'',
about: "正所谓富贵险中求"
}
const {verifyPhone} = require("@/utils/verificate");
export default {
data() {
return {
disabled:false,
time:0,
userRole:[],
form: {
id: "",
avatar:this.$store.state.global.login_avatar,
name: this.$store.state.global.login_name,
login_name: '',
user: "",
mobile: "",
email: "",
about: "正所谓富贵险中求",
},
rules: {
name: [
{required: true, message: '请输入姓名'}
],
mobile: [
{required: true, message: '请输入手机号'},
{validator: verifyPhone, trigger: 'blur'}
],
verify_code:[
{required: true, message: '请输入验证码'}
]
}
}
},
mounted() {
this.getInfo();
},
methods:{
//
async parentParams(files) {
let params = {
avatar:files
}
const res = await this.$API.user.uploadAvatar.post(params);
if (res.code == 200) {
this.$store.commit("SET_LOGIN_AVATAR", files);
}
},
async getInfo() {
const res = await this.$API.user.getInformation.post();
if(res.code == 200){
const userInfo = JSON.parse(JSON.stringify(this.$TOOL.data.get('USER_INFO')));
this.form.user = userInfo.login_name;
this.userRole = userInfo.user_roles && userInfo.user_roles.role_names.length>0?userInfo.user_roles.role_names:[];
this.$store.commit("SET_LOGIN_AVATAR", res.data.avatar);
this.$store.commit("SET_LOGIN_NAME", res.data.name);
Object.assign(this.form,res.data);
Object.assign(userInfo,res.data);
this.$TOOL.data.set('USER_INFO',userInfo);
}
},
async getYzm() {
const validate = await this.$refs.form.validateField("mobile").catch(() => {});
if (!validate) {
return false
}
const res = await this.$API.system.user.verifyCode.post({mobile: this.form.mobile});
if (res.code === 200) {
this.$message.success('短信已发送至手机号码');
this.disabled = true
this.time = 60
const t = setInterval(() => {
this.time -= 1
if (this.time < 1) {
clearInterval(t)
this.disabled = false
this.time = 0
}
}, 1000);
}
},
save() {
this.$refs.form.validate(async (valid) => {
if (valid) {
const res = await this.$API.system.user.updateProfile.post(this.form)
if (res.code === 200) {
// this.$TOOL.data.set("USER_INFO", res.data)
this.$message.success("操作成功");
await this.getInfo();
}
} else {
return false
}
})
},
}
}
</script>
<style>
<style lang="scss" scoped>
.login-msg-yzm{
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
}
</style>