Commit b41ec423 by 梁建民

格式化

parent c3026ab2
Showing with 8 additions and 5 deletions
...@@ -74,17 +74,20 @@ const getData = (url, type, param, callBack, loading, isheader) => { ...@@ -74,17 +74,20 @@ const getData = (url, type, param, callBack, loading, isheader) => {
}; };
//上传文件 //上传文件
const uploadFile = (url,paths,callBack) => { const uploadFile = (url, paths, callBack) => {
wx.showLoading({ wx.showLoading({
title: '上传中', title: '上传中',
mask:true mask: true
}) })
for (var i = 0; i < paths.length; i++) { for (var i = 0; i < paths.length; i++) {
wx.uploadFile({ wx.uploadFile({
url: url, url: url,
filePath: paths[i], filePath: paths[i],
name: 'upload', name: 'upload',
formData: { token: wx.getStorageSync('access_token'), source: 2}, formData: {
token: wx.getStorageSync('access_token'),
source: 2
},
header: { header: {
"Content-Type": "multipart/form-data" "Content-Type": "multipart/form-data"
}, },
...@@ -120,13 +123,13 @@ const uploadFile = (url,paths,callBack) => { ...@@ -120,13 +123,13 @@ const uploadFile = (url,paths,callBack) => {
} }
}; };
const chooseImg = (url,num, callback) => { const chooseImg = (url, num, callback) => {
wx.chooseImage({ wx.chooseImage({
count: num, count: num,
sizeType: ['original', 'compressed'], sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'], sourceType: ['album', 'camera'],
success: (res) => { success: (res) => {
uploadFile(url,res.tempFilePaths, (rtn) => { uploadFile(url, res.tempFilePaths, (rtn) => {
callback(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