头像显示、上传功能

init
zhusiyu 3 years ago
parent cc3aade1fd
commit 39b1952f46

@ -52,4 +52,9 @@ export default {
method:"get",
isTestLogin:true
},
"getPersonTxBy": {
url: "person/getPersonTxByYw",
method: "get",
isTestLogin: false
},
}

@ -8,46 +8,68 @@
* 头像组件
* src
*/
import interConfig from '../api/commonInter';
import interConfig from '../api/commonInter.js';
import {Avatar} from 'ant-design-vue';
import BaseConfig from '../../../global-llibs/base-config'
import StaticParams from '../../../global-llibs/staticParams';
export default{
data(){
export default {
data() {
return {
imgUrl: this.$store.state.userStore.portraitUrl,
}
},
props: ['personId'],
created() {
if(!this.imgUrl || this.imgUrl === "") {
if (!this.imgUrl || this.imgUrl === "") {
this.getImgSrc(this.$props.personId)
}
},
mounted() {
this.getImgSrc()
},
methods: {
showMessage(){
//this.$emit('showMessage')
showMessage() {
this.$emit('showMessage')
},
getImgSrc: function (personId) {
if (personId && personId != '') {
this.InterfaceConfig.callInterface([{
url: interConfig.getPersonTxByYw.url,
params: {
person_id: personId,
identity_id: 5,
},
method: interConfig.getPersonTxByYw.method,
isTestLogin: interConfig.getPersonTxByYw.isTestLogin,
}], (result) => {
let resData = result[0].data;
if (result[0].status === 200) {
if (resData.success === true) {
this.imgUrl = StaticParams.getThumbUrl(resData.file_id + "." + resData.extension, 100, 100, 100);
this.$store.commit('userStore/setPortraitUrl', this.imgUrl);
}
}
})
getImgSrc() {
let param = {
person_id: BaseConfig.userInfo.person_id_cookie,
identity_id: BaseConfig.userInfo.identity_id_cookie
}
}
this.InterfaceConfig.callInterface([{
url: interConfig.getPersonTxBy.url,
params: param,
method: interConfig.getPersonTxBy.method,
isTestLogin: interConfig.getPersonTxBy.isTestLogin,
}], (result) => {
// console.log('------', result)
if (result[0].data.file_id !== "") {
this.imgUrl = result[0].data.file_id + ',' + result[0].data.extension
}
})
},
// getImgSrc: function (personId) {
// if (personId && personId != '') {
// this.InterfaceConfig.callInterface([{
// url: interConfig.getPersonTxByYw.url,
// params: {
// person_id: personId,
// identity_id: 5,
// },
// method: interConfig.getPersonTxByYw.method,
// isTestLogin: interConfig.getPersonTxByYw.isTestLogin,
// }], (result) => {
// let resData = result[0].data;
// if (result[0].status === 200) {
// if (resData.success === true) {
// this.imgUrl = StaticParams.getThumbUrl(resData.file_id + "." + resData.extension, 100, 100, 100);
// this.$store.commit('userStore/setPortraitUrl', this.imgUrl);
// }
// }
// })
// }
// }
},
watch: {
personId: function (newVal) {

@ -9,9 +9,20 @@ export default {
method: "post",
isTestLogin: true
},
"personTx": {
url: "intellioa/sys/cloudPlatform/getPersonTxByYw",
//获取头像
// "personTx": {
// url: "intellioa/sys/cloudPlatform/getPersonTxByYw",
// method: "get",
// isTestLogin: true
// },
"getPersonTxByYw": {
url: "person/getPersonTxByYw",
method: "get",
isTestLogin: true
isTestLogin: false
},
"setPersonTxByYw": {
url: "person/setPersonTxByYw",
method: "post",
isTestLogin: false
},
}

@ -28,7 +28,7 @@
<div class="colRightTbox">
<div class="titleLogo">头像信息</div>
<div class="mypicture">
<img v-if="txfull" src="" alt=""
<img v-if="txfull" :src="imgSrc" alt=""
style="display:inline-block;width: 100%;height: 100%;"
ref="imgChange">
<img v-if="!txfull" src="./images/emptyPic.png"
@ -44,7 +44,7 @@
v-model:file-list="fileListPic" :before-upload="beforeUpload"
class="fixBtnChange" @change="picFileChange">更换图片
</a-upload>
<a-button class="fixBtnSave" type="primary">保存头像</a-button>
<a-button class="fixBtnSave" type="primary" @click="saveTx"></a-button>
<span>仅支持.jpg.jpeg.png.bmp图片格式</span>
</div>
<div class="colRightBbox">
@ -67,11 +67,12 @@
</template>
<script>
import {Modal, Row, Col, Button, Icon, Upload} from 'ant-design-vue';
import {Modal, Row, Col, Button, Icon, Upload, message} from 'ant-design-vue';
import InterConfig from './interConfig'
import GUID_UUID from '../../../../../global-llibs/guid-uuid'
import BaseConfig from '../../../../../global-llibs/base-config'
import Uploader from '../../../../../components/common/uploader/Upload.vue'
import StaticParams from '../../../../../global-llibs/staticParams';
export default {
name: "PersonMsgModal",
@ -90,6 +91,7 @@
fileListPic: [],
personIdPic: '',
txfull: true,
imgSrc: '',
}
},
components: {
@ -99,6 +101,7 @@
AButton: Button,
AIcon: Icon,
AUpload: Upload,
// AMessage: message,
Uploader,
},
created() {
@ -144,7 +147,7 @@
},
uploadComplete: function (file) {
this.fileList = file
console.log('uploadComplete参数', file)
//console.log('uploadComplete', file)
},
//
changeModifyPhoto() {
@ -171,14 +174,15 @@
identity_id: BaseConfig.userInfo.identity_id_cookie
}
this.InterfaceConfig.callInterface([{
url: InterConfig.personTx.url,
url: InterConfig.getPersonTxByYw.url,
params: param,
method: InterConfig.personTx.method,
isTestLogin: InterConfig.personTx.isTestLogin,
method: InterConfig.getPersonTxByYw.method,
isTestLogin: InterConfig.getPersonTxByYw.isTestLogin,
}], (result) => {
//console.log('', result)
console.log('获取头像', result)
if (result[0].data.file_id !== "") {
this.$refs.imgChange.src = result[0].data.file_id
this.imgSrc = result[0].data.file_id + ',' + result[0].data.extension
// console.log('fileId', this.$refs.imgChange.src)
} else {
this.txfull = false
}
@ -190,6 +194,27 @@
let targetUrl = val.fileList[val.fileList.length - 1]
this.$refs.imgChange.src = targetUrl.thumbUrl
},
//
saveTx() {
let param = {
person_id: BaseConfig.userInfo.person_id_cookie,
identity_id: BaseConfig.userInfo.identity_id_cookie,
file_id: this.$refs.imgChange.src,
extension: 'png',
}
this.InterfaceConfig.callInterface([{
url: InterConfig.setPersonTxByYw.url,
params: param,
method: InterConfig.setPersonTxByYw.method,
isTestLogin: InterConfig.setPersonTxByYw.isTestLogin,
}], (result) => {
if (!result[0].data.success) {
message.error('保存失败')
} else {
message.success('保存成功')
}
})
}
}
}
</script>

Loading…
Cancel
Save