头像显示、上传功能

init
zhusiyu 3 years ago
parent cc3aade1fd
commit 39b1952f46

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

@ -8,46 +8,68 @@
* 头像组件 * 头像组件
* src * src
*/ */
import interConfig from '../api/commonInter'; import interConfig from '../api/commonInter.js';
import {Avatar} from 'ant-design-vue'; import {Avatar} from 'ant-design-vue';
import BaseConfig from '../../../global-llibs/base-config'
import StaticParams from '../../../global-llibs/staticParams'; import StaticParams from '../../../global-llibs/staticParams';
export default{
data(){ export default {
data() {
return { return {
imgUrl: this.$store.state.userStore.portraitUrl, imgUrl: this.$store.state.userStore.portraitUrl,
} }
}, },
props: ['personId'], props: ['personId'],
created() { created() {
if(!this.imgUrl || this.imgUrl === "") { if (!this.imgUrl || this.imgUrl === "") {
this.getImgSrc(this.$props.personId) this.getImgSrc(this.$props.personId)
} }
}, },
mounted() {
this.getImgSrc()
},
methods: { methods: {
showMessage(){ showMessage() {
//this.$emit('showMessage') this.$emit('showMessage')
}, },
getImgSrc: function (personId) { getImgSrc() {
if (personId && personId != '') { let param = {
this.InterfaceConfig.callInterface([{ person_id: BaseConfig.userInfo.person_id_cookie,
url: interConfig.getPersonTxByYw.url, identity_id: BaseConfig.userInfo.identity_id_cookie
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);
}
}
})
} }
} 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: { watch: {
personId: function (newVal) { personId: function (newVal) {

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

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

Loading…
Cancel
Save