43 lines
856 B
JavaScript
43 lines
856 B
JavaScript
let uplodeImg = () => {
|
|
return new Promise((reslove, reject) => {
|
|
uni.chooseImage({
|
|
count: 1,
|
|
sizeType: ['compressed'],
|
|
sourceType: ['album'],
|
|
success: (res) => {
|
|
var imageSrc = res.tempFilePaths[0]
|
|
uni.showLoading({
|
|
title: '上传中',
|
|
duration: 1000
|
|
})
|
|
let that = this
|
|
uni.uploadFile({
|
|
url: 'http://ceshi-suyuan.lihaink.cn/api/user/imageUpload',
|
|
filePath: imageSrc,
|
|
name: 'file',
|
|
// formData: {
|
|
// 'user': 'test'
|
|
// },
|
|
success: (res) => {
|
|
uni.showToast({
|
|
title: '上传成功',
|
|
icon: 'success',
|
|
duration: 1000,
|
|
})
|
|
reslove(JSON.parse(res.data))
|
|
|
|
},
|
|
fail: (err) => {
|
|
reject(err)
|
|
uni.showToast({
|
|
title: '检查网络',
|
|
duration: 1000,
|
|
})
|
|
|
|
},
|
|
});
|
|
}
|
|
})
|
|
})
|
|
}
|
|
export default uplodeImg |