tianyi 2 weeks ago
parent
commit
7fe32d7150
  1. 54
      package1/ieBrowser/profileSetup.vue

54
package1/ieBrowser/profileSetup.vue

@ -148,19 +148,55 @@
this.form.anonymousName = this.nameSeeds[Math.floor(Math.random() * this.nameSeeds.length)] this.form.anonymousName = this.nameSeeds[Math.floor(Math.random() * this.nameSeeds.length)]
}, },
chooseAvatar() { chooseAvatar() {
uni.chooseImage({ let that = this;
uni.chooseMedia({
count: 1, count: 1,
sizeType: ['compressed'], mediaType: ['image'],
sourceType: ['album', 'camera'], sourceType: ['camera', 'album'],
success: async (res) => { camera: 'back',
const filePath = res.tempFilePaths && res.tempFilePaths[0] success(res) {
if (!filePath) return that.upLoadFile(res.tempFiles[0].tempFilePath)
const result = await tui.uploadFile('/upload/file', filePath) },
const url = typeof result === 'string' ? result : (result.url || result.fileUrl || result.path || result.fullPath || result) fail() {
if (url && typeof url === 'string') this.form.avatarUrl = url 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() { validateStep() {
if (this.step === 2 && !this.form.anonymousName.trim()) { if (this.step === 2 && !this.form.anonymousName.trim()) {
uni.showToast({ title: '先起一个昵称吧', icon: 'none' }) uni.showToast({ title: '先起一个昵称吧', icon: 'none' })

Loading…
Cancel
Save