-
+
+
+
+
+
+
+
+
+
+ 普通上传
+ 拍照上传
+
+
+
@@ -47,7 +77,7 @@
import { update_password, getinfo } from '@/api/common'
import stringify from '@/utils/stringify'
import UserForm from '@/components/UserForm'
-import { get_role_name_list, update } from '@/api/user/user'
+import { get_role_name_list, update, paizhao_upload_header_img } from '@/api/user/user'
export default {
name: 'User',
components: { UserForm },
@@ -72,8 +102,11 @@ export default {
}
}
return {
+ ImgVisible:false,
pdata: {},
- circleUrl: 'https://t7.baidu.com/it/u=2006997523,200382512&fm=193&f=GIF',
+ circleUrl: '',
+ UPLOAD_URL: process.env.VUE_APP_FACE_API + '/user/upload',
+ fileList:[],
activeName: 'first',
roledata: [],
loading: false,
@@ -104,10 +137,53 @@ export default {
this.getUserInfo()
},
methods: {
+ ptUpload() {
+ this.$refs['upload'].$children[0].$refs.input.click();
+ },
+ paiZhaoupload() {
+ const loading = this.$loading({
+ lock: true,
+ text: 'Loading',
+ spinner: 'el-icon-loading',
+ background: 'rgba(0, 0, 0, 0.7)'
+ });
+ paizhao_upload_header_img().then(rsp => {
+ this.circleUrl = process.env.VUE_APP_FACE_API + `/${rsp.data}`
+ this.pdata.avatar_url = rsp.data
+ loading.close()
+ this.ImgVisible = false
+ })
+
+ },
+ clickUpload () {
+ this.ImgVisible=true
+ },
+ handleImageClose() {
+ this.ImgVisible = false
+ },
+ handleAvatarSuccess(res, file) {
+ // this.$store.commit('user/SET_AVATAR', process.env.VUE_APP_BASE_API + `/${res.data}`)
+ this.pdata.avatar_url = res.data
+ this.circleUrl = process.env.VUE_APP_FACE_API + `/${res.data}`
+ this.ImgVisible = false
+ },
+ beforeAvatarUpload(file) {
+ const isJPG = file.type === 'image/jpeg';
+ const isLt2M = file.size / 1024 / 1024 < 2;
+
+ if (!isJPG) {
+ this.$message.error('上传头像图片只能是 JPG 格式!');
+ }
+ if (!isLt2M) {
+ this.$message.error('上传头像图片大小不能超过 2MB!');
+ }
+ return isJPG && isLt2M;
+ },
getUserInfo() {
this.loading = true
getinfo().then(res => {
this.pdata = res.data
+ this.circleUrl = process.env.VUE_APP_FACE_API +'/' +res.data.avatar_url
}).finally(() => { this.loading = false })
},
submitForm(formName) {
@@ -129,7 +205,10 @@ export default {
this.dialogVisible = false
this.getUserInfo()
this.$store.commit('user/SET_ROLE_NAME', this.pdata.role_name)
- this.$store.commit('user/SET_AVATAR', this.pdata.avatar_url || this.pdata.avatar_base64)
+ // this.$store.commit('user/SET_AVATAR', this.pdata.avatar_url)
+ if (this.pdata.avatar_url){
+ this.$store.commit('user/SET_AVATAR', process.env.VUE_APP_FACE_API + '/' +this.pdata.avatar_url)
+ }
this.$store.commit('user/SET_NAME', this.pdata.real_name)
})
},