From 7fe32d715048beeb788886aca49132b0cea1e921 Mon Sep 17 00:00:00 2001 From: tianyi <13521030702@163.com> Date: Thu, 21 May 2026 12:14:29 +0800 Subject: [PATCH] 1 --- package1/ieBrowser/profileSetup.vue | 54 ++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 9 deletions(-) diff --git a/package1/ieBrowser/profileSetup.vue b/package1/ieBrowser/profileSetup.vue index a03500f..ce6c607 100644 --- a/package1/ieBrowser/profileSetup.vue +++ b/package1/ieBrowser/profileSetup.vue @@ -148,19 +148,55 @@ this.form.anonymousName = this.nameSeeds[Math.floor(Math.random() * this.nameSeeds.length)] }, chooseAvatar() { - uni.chooseImage({ + let that = this; + uni.chooseMedia({ count: 1, - sizeType: ['compressed'], - sourceType: ['album', 'camera'], - success: async (res) => { - const filePath = res.tempFilePaths && res.tempFilePaths[0] - if (!filePath) return - const result = await tui.uploadFile('/upload/file', filePath) - const url = typeof result === 'string' ? result : (result.url || result.fileUrl || result.path || result.fullPath || result) - if (url && typeof url === 'string') this.form.avatarUrl = url + mediaType: ['image'], + sourceType: ['camera', 'album'], + camera: 'back', + success(res) { + that.upLoadFile(res.tempFiles[0].tempFilePath) + }, + fail() { + uni.hideLoading(); } }) }, + async upLoadFile(path) { + let that = this; + uni.showLoading({ + title: '加载中...', + mask: true + }) + let hiver_token = uni.getStorageSync("hiver_token") + await uni.uploadFile({ + url: that.tui.interfaceUrl() + '/upload/file', + filePath: path, + name: 'file', + header: { + "content-type": "multipart/form-data", + 'accessToken': hiver_token + }, + formData: {}, + success: (uploadFileRes) => { + + let path = JSON.parse(uploadFileRes.data) + + this.form.avatarUrl = path.result + }, + fail: (err) => { + uni.hideLoading(); + uni.showToast({ + title: JSON.stringify(err), + icon: 'none' + }) + } + }); + await setTimeout(res => { + that.parentId = '' + // uni.hideLoading(); + }, 1000) + }, validateStep() { if (this.step === 2 && !this.form.anonymousName.trim()) { uni.showToast({ title: '先起一个昵称吧', icon: 'none' })