Merge pull request 'fix: 修改头像预览,头像上传bug,以及黄色报错问题;' (#36) from yangws into main
Reviewed-on: #36
This commit is contained in:
commit
c6ace535e8
|
@ -34,6 +34,9 @@ export function getUserProfile() {
|
|||
export function uploadAvatar(data) {
|
||||
return request({
|
||||
url: '/system/user/profile/avatar',
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
},
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
</el-col>
|
||||
<el-col :xs="24" :md="12" :style="{ height: '350px' }">
|
||||
<div class="avatar-upload-preview">
|
||||
<img :src="options.previews.url" :style="options.previews.img" />
|
||||
<el-image style="width: 100px; height: 100px" :src="options.previews.url" :style="options.previews.img"/>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
@ -72,6 +72,7 @@ import 'vue-cropper/dist/index.css'
|
|||
import { VueCropper } from 'vue-cropper'
|
||||
import { uploadAvatar } from '@/api/system/user'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
const userStore = useUserStore()
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
@ -117,7 +118,10 @@ function changeScale(num) {
|
|||
/** 上传预处理 */
|
||||
function beforeUpload(file) {
|
||||
if (file.type.indexOf('image/') == -1) {
|
||||
proxy.$modal.msgError('文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件。')
|
||||
ElMessage({
|
||||
message: '文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件。',
|
||||
type: 'error',
|
||||
})
|
||||
} else {
|
||||
const reader = new FileReader()
|
||||
reader.readAsDataURL(file)
|
||||
|
@ -135,7 +139,10 @@ function uploadImg() {
|
|||
open.value = false
|
||||
options.img = import.meta.env.VITE_APP_BASE_API + response.imgUrl
|
||||
userStore.avatar = options.img
|
||||
proxy.$modal.msgSuccess('修改成功')
|
||||
ElMessage({
|
||||
message: '上传成功',
|
||||
type: 'success',
|
||||
})
|
||||
visible.value = false
|
||||
})
|
||||
})
|
||||
|
|
|
@ -11,16 +11,16 @@
|
|||
</el-form-item>
|
||||
<el-form-item label="性别">
|
||||
<el-radio-group v-model="user.sex">
|
||||
<el-radio label="0">男</el-radio>
|
||||
<el-radio label="1">女</el-radio>
|
||||
<el-radio value="0">男</el-radio>
|
||||
<el-radio value="1">女</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="任教学科">
|
||||
<el-radio-group v-model="user.edusubject">
|
||||
<template v-for="item in subjectList">
|
||||
<el-radio v-if="item.edustage == user.edustage" :label="item.itemtitle">{{
|
||||
item.itemtitle
|
||||
}}</el-radio>
|
||||
<template v-for="(item,index) in subjectList" :key="index">
|
||||
<el-radio v-if="item.edustage == user.edustage" :value="item.itemtitle">
|
||||
{{item.itemtitle }}
|
||||
</el-radio>
|
||||
</template>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
|
|
Loading…
Reference in New Issue