mkm
/
yanzhiAPP
Template
2
0
Fork 0
yanzhiAPP/utils/uplodeImg.js

43 lines
856 B
JavaScript
Raw Permalink Normal View History

2023-10-25 19:55:18 +08:00
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