/**
 *上传图片
 */
import requestUrl from './ajax.env.js'

export function uploadFileImage(url) {
	return new Promise(function(resolve,reject) {
		uni.chooseImage({
			count: 1, //默认1
			sizeType: ['original','compressed'], //可以指定是原图还是压缩图，默认二者都有
			sourceType: ['album'], //从相册选择
			success: (res) => {
				const tempFilePaths = res.tempFilePaths;
				console.log(tempFilePaths)
				const uploadTask = uni.uploadFile({
					url : requestUrl+url,
					filePath: tempFilePaths[0],
					name: 'file',
					header: {
					    "Content-Type": "multipart/form-data",
					},
					formData: {
						'user': 'test'
					},
					success: function (res) {
						console.log(res)
						resolve(res);
					},
					error : function(e){
						reject(res)
					}
				})
			}
		});
	});
}
