|
@@ -57,7 +57,8 @@
|
|
|
<script>
|
|
|
import uniPopup from '@/components/uni-popup/uni-popup.vue'
|
|
|
import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog.vue'
|
|
|
- import service from '../../service.js';
|
|
|
+ import {saveEmployee } from '@/api/employee'
|
|
|
+ const baseUrl = getApp().globalData.baseUrl
|
|
|
import {
|
|
|
mapState,
|
|
|
mapMutations
|
|
@@ -87,8 +88,33 @@
|
|
|
},
|
|
|
methods: {
|
|
|
onChooseAvatar(e) {
|
|
|
+ const _this = this
|
|
|
const { avatarUrl } = e.detail
|
|
|
this.avatarUrl = avatarUrl
|
|
|
+ uni.uploadFile({
|
|
|
+ url: baseUrl + '/upload',
|
|
|
+ filePath: avatarUrl,
|
|
|
+ name: 'file',
|
|
|
+ success: (uploadFileRes) => {
|
|
|
+ const ret = JSON.parse(uploadFileRes.data)
|
|
|
+ console.log(ret,'uploadFileRes')
|
|
|
+ if(ret.status == 200){
|
|
|
+ saveEmployee({id:_this.userInfo.userid,photo: ret.data}).then(res => {
|
|
|
+ if(res.status == 200){
|
|
|
+ uni.showToast({
|
|
|
+ icon: "none",
|
|
|
+ title: "修改头像成功"
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ uni.showToast({
|
|
|
+ icon: "none",
|
|
|
+ title: "修改头像失败,请重试"
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
loginOut(){
|
|
|
this.$refs.openModal.open()
|