|
@@ -55,22 +55,24 @@ const uploadImg = (req, res, next) => { |
|
@@ -55,22 +55,24 @@ const uploadImg = (req, res, next) => { |
55
|
file: f,
|
55
|
file: f,
|
56
|
uid: req.user.uid.toString(),
|
56
|
uid: req.user.uid.toString(),
|
57
|
method: 'yoho.fileupload'
|
57
|
method: 'yoho.fileupload'
|
|
|
58
|
+ }).then(result => {
|
|
|
59
|
+ if (result.code !== 200) {
|
|
|
60
|
+ return Promise.reject(Error('上传出错'));
|
|
|
61
|
+ }
|
|
|
62
|
+
|
|
|
63
|
+ return result;
|
58
|
});
|
64
|
});
|
59
|
})
|
65
|
})
|
60
|
).then(result => {
|
66
|
).then(result => {
|
61
|
- const images = result.reduce((t, r) => {
|
|
|
62
|
- if (r && r.data && r.code === 200) {
|
|
|
63
|
- t.push(utils.getUploadImgAbsoluteUrl(_.get(r, 'data'), req.body.bucket));
|
|
|
64
|
- }
|
67
|
+ const data = result.reduce((t, r) => {
|
|
|
68
|
+ t.images.push(utils.getUploadImgAbsoluteUrl(_.get(r, 'data'), req.body.bucket));
|
|
|
69
|
+ t.imageList.push(_.get(r, 'data'));
|
65
|
return t;
|
70
|
return t;
|
66
|
- }, []);
|
71
|
+ }, { images: [], imageList: [] });
|
67
|
|
72
|
|
68
|
res.json({
|
73
|
res.json({
|
69
|
code: 200,
|
74
|
code: 200,
|
70
|
- data: {
|
|
|
71
|
- images,
|
|
|
72
|
- imageList: images
|
|
|
73
|
- },
|
75
|
+ data,
|
74
|
message: '上传成功'
|
76
|
message: '上传成功'
|
75
|
});
|
77
|
});
|
76
|
}).catch(next);
|
78
|
}).catch(next);
|