Commit b41ec423 by 梁建民

格式化

parent c3026ab2
Showing with 43 additions and 40 deletions
......@@ -51,9 +51,9 @@ const getData = (url, type, param, callBack, loading, isheader) => {
wx.hideNavigationBarLoading();
if (loading) {
wx.hideLoading();
}
if (loading) {
wx.hideLoading();
}
},
fail: (err) => {
......@@ -65,53 +65,56 @@ const getData = (url, type, param, callBack, loading, isheader) => {
wx.hideNavigationBarLoading();
if (loading) {
wx.hideLoading();
}
if (loading) {
wx.hideLoading();
}
}
})
};
//上传文件
const uploadFile = (url,paths,callBack) => {
wx.showLoading({
title: '上传中',
mask:true
})
const uploadFile = (url, paths, callBack) => {
wx.showLoading({
title: '上传中',
mask: true
})
for (var i = 0; i < paths.length; i++) {
wx.uploadFile({
url: url,
url: url,
filePath: paths[i],
name: 'upload',
formData: { token: wx.getStorageSync('access_token'), source: 2},
header: {
"Content-Type": "multipart/form-data"
},
formData: {
token: wx.getStorageSync('access_token'),
source: 2
},
header: {
"Content-Type": "multipart/form-data"
},
success: (res) => {
var data = JSON.parse(res.data);
if (data.errcode == 103200) {
wx.showToast({
title: '上传成功',
icon: 'none',
duration: 2000
});
callBack(data.data[0])
var data = JSON.parse(res.data);
if (data.errcode == 103200) {
wx.showToast({
title: '上传成功',
icon: 'none',
duration: 2000
});
callBack(data.data[0])
} else {
wx.showToast({
title: '上传失败',
icon: 'none',
duration: 2000
});
wx.showToast({
title: '上传失败',
icon: 'none',
duration: 2000
});
}
},
fail: (e) => {
console.log(e)
wx.showToast({
title: '上传失败',
icon: 'none',
duration: 2000
});
console.log(e)
wx.showToast({
title: '上传失败',
icon: 'none',
duration: 2000
});
},
complete: () => {
wx.hideLoading();
......@@ -120,14 +123,14 @@ const uploadFile = (url,paths,callBack) => {
}
};
const chooseImg = (url,num, callback) => {
const chooseImg = (url, num, callback) => {
wx.chooseImage({
count: num,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: (res) => {
uploadFile(url,res.tempFilePaths, (rtn) => {
callback(rtn)
uploadFile(url, res.tempFilePaths, (rtn) => {
callback(rtn)
})
}
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment