uploadimg(pic) {
var that = this;
uni.showLoading({
title: '上传中'
});
let token = uni.getStorageSync('token');
uni.uploadFile({
url: configs.upload,
filePath: pic,
name: 'formFiles',
header: {
Authorization: token
},
success(res) {
uni.hideLoading();
console.log(res);
let datas = JSON.parse(res.data);
if (datas.code == 1) {
uni.showToast({
title: '上传成功',
duration: 2000
});
that.$emit('upload', datas.data.fileUrl);
} else {
uni.showToast({
title: datas.msg,
icon: 'none',
duration: 2000
});
}
},
fail() {
uni.hideLoading();
}
});
}