From c3daaa877d6f877fb9dde83d78e15b720ed530c4 Mon Sep 17 00:00:00 2001 From: whyneedname <542399163@qq.com> Date: Sat, 29 Oct 2022 18:15:04 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=A4=B4=E5=83=8F=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/user/PersonalData/index.vue | 42 +++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/pages/user/PersonalData/index.vue b/pages/user/PersonalData/index.vue index cab9879..6d9890f 100644 --- a/pages/user/PersonalData/index.vue +++ b/pages/user/PersonalData/index.vue @@ -83,7 +83,8 @@ chooseImage } from "@/utils"; import { - VUE_APP_API_URL + VUE_APP_API_URL, + BXG_TENANT_ID } from "@/config"; import { postUserEdit, @@ -192,7 +193,44 @@ }); }, onChooseAvatar(e) { - this.avatar = e.detail.avatarUrl; + uni.getImageInfo({ + src: e.detail.avatarUrl, + success: image => { + // console.log(image) + uni.showLoading({ title: '图片上传中', mask: true }) + uni.uploadFile({ + url: `${VUE_APP_API_URL}/api/upload`, + file: image, + filePath: image.path, + header: { + Authorization: 'Bearer ' + store.getters.token, + 'tenant-id': BXG_TENANT_ID + }, + name: 'file', + success: res => { + this.avatar = JSON.parse(res.data).data; + console.log('this.avatar', this.avatar) + }, + fail: err => { + uni.showToast({ + title: '上传图片失败', + icon: 'none', + duration: 2000, + }) + }, + complete: res => { + uni.hideLoading() + }, + }) + }, + fail: err => { + uni.showToast({ + title: '获取图片信息失败', + icon: 'none', + duration: 2000, + }) + }, + }) }, chooseImage() { chooseImage((img) => {