Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuy-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
1
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
htoo
5 years ago
Commit
5af8170ead3a0b93cbd05adf7cd7632283240db6
2 parents
968cc865
9cb17aa7
Merge branch 'hotfix/upload' into develop
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
56 additions
and
35 deletions
.npmrc
apps/common/controllers/upload.js
apps/common/router.js
config/common.js
package.json
public/scss/activity/_index.css
public/scss/base.css
public/scss/brands/_index.css
public/scss/cart/_index.css
public/scss/channel/_index.css
public/scss/home/_index.css
public/scss/passport/_index.css
public/scss/product/_index.css
yarn.lock
.npmrc
View file @
5af8170
phantomjs_cdnurl=http://npm.taobao.org/mirrors/phantomjs
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
registry=http://npm.yohops.com
package-lock=false
...
...
apps/common/controllers/upload.js
View file @
5af8170
'use strict'
;
const
request
=
require
(
'request-promise'
);
const
fs
=
require
(
'fs'
);
const
_
=
require
(
'lodash'
);
const
utils
=
require
(
'../models/utils'
);
const
yohoApi
=
global
.
yoho
.
API
;
const
AllowedBucket
=
{
sns
:
'sns'
,
evidenceImages
:
'evidenceImages'
};
const
uploadImg
=
(
req
,
res
,
next
)
=>
{
let
files
=
req
.
files
&&
req
.
files
.
file
||
[];
...
...
@@ -16,7 +21,6 @@ const uploadImg = (req, res, next) => {
req
.
body
.
files
=
[];
files
.
forEach
(
file
=>
{
let
types
=
file
.
type
.
split
(
'/'
);
if
(
!
types
||
types
[
0
]
!==
'image'
)
{
...
...
@@ -27,7 +31,6 @@ const uploadImg = (req, res, next) => {
errTip
=
'上传文件尺寸太大!'
;
}
req
.
body
.
files
.
push
(
fs
.
createReadStream
(
file
.
path
));
req
.
body
.
files
.
push
(
file
.
name
);
});
if
(
errTip
)
{
...
...
@@ -36,24 +39,40 @@ const uploadImg = (req, res, next) => {
});
}
request
({
method
:
'post'
,
url
:
'http://upload.static.yohobuy.com'
,
formData
:
{
fileData
:
req
.
body
.
files
,
project
:
req
.
body
.
bucket
},
json
:
true
}).
then
(
function
(
result
)
{
if
(
result
&&
result
.
code
===
200
)
{
result
.
data
=
result
.
data
||
{};
result
.
data
.
images
=
_
.
map
(
_
.
get
(
result
,
'data.imagesList'
),
(
it
)
=>
{
return
utils
.
getUploadImgAbsoluteUrl
(
it
,
req
.
body
.
bucket
);
const
bucket
=
AllowedBucket
[
req
.
body
.
bucket
];
if
(
!
bucket
)
{
return
res
.
json
({
code
:
400
,
message
:
'参数错误'
});
}
Promise
.
all
(
req
.
body
.
files
.
map
(
f
=>
{
return
yohoApi
.
postFile
(
''
,
{
bucket
:
req
.
body
.
bucket
,
file
:
f
,
uid
:
req
.
user
.
uid
.
toString
(),
method
:
'yoho.fileupload'
});
}
})
).
then
(
result
=>
{
const
images
=
result
.
reduce
((
t
,
r
)
=>
{
if
(
r
&&
r
.
data
&&
r
.
code
===
200
)
{
t
.
push
(
utils
.
getUploadImgAbsoluteUrl
(
_
.
get
(
r
,
'data'
),
req
.
body
.
bucket
));
}
return
t
;
},
[]);
res
.
json
(
result
);
res
.
json
({
code
:
200
,
data
:
{
images
,
imageList
:
images
},
message
:
'上传成功'
});
}).
catch
(
next
);
};
...
...
apps/common/router.js
View file @
5af8170
...
...
@@ -18,11 +18,12 @@ const erp2goods = require(`${cRoot}/erp2goods`);
const
getBanner
=
require
(
`
$
{
cRoot
}
/getBanner`
)
;
const
passport
=
require
(
`
$
{
cRoot
}
/passport`
)
;
const
suggestFeedBack
=
require
(
`
$
{
cRoot
}
/suggestFeedBack`
)
;
const
auth
=
require
(
`
$
{
global
.
middleware
}
/auth`
)
;
router
.
get
(
'/recentReview'
,
rvCtrl
.
index
);
// 最近浏览
router
.
post
(
'/getRecommend'
,
rvCtrl
.
getRecommend
);
// 为你优选
router
.
post
(
'/upload/image'
,
multipartMiddleware
,
uploadCtrl
.
uploadImg
);
router
.
post
(
'/upload/image'
,
auth
,
multipartMiddleware
,
uploadCtrl
.
uploadImg
);
router
.
get
(
'/erp2goods'
,
erp2goods
.
find
);
...
...
config/common.js
View file @
5af8170
...
...
@@ -88,7 +88,7 @@ module.exports = {
infoFile
:
{
name
:
'info'
,
level
:
'info'
,
filename
:
'/Data/logs/yohobuy-node/info/info.log'
,
filename
:
'
.
/Data/logs/yohobuy-node/info/info.log'
,
maxFiles
:
1
,
tailable
:
true
,
maxsize
:
Math
.
pow
(
1024
,
3
),
...
...
@@ -100,7 +100,7 @@ module.exports = {
errorFile
:
{
name
:
'error'
,
level
:
'error'
,
filename
:
'/Data/logs/yohobuy-node/error/error.log'
,
filename
:
'
.
/Data/logs/yohobuy-node/error/error.log'
,
maxFiles
:
1
,
tailable
:
true
,
maxsize
:
Math
.
pow
(
1024
,
3
),
...
...
package.json
View file @
5af8170
...
...
@@ -57,10 +57,10 @@
"sitemap"
:
"^1.12.1"
,
"urlencode"
:
"^1.1.0"
,
"uuid"
:
"^2.0.2"
,
"yo-cli"
:
"=2.1.13"
,
"yoho-express-session"
:
"^2.0.0"
,
"yoho-node-lib"
:
"=0.6.40"
,
"yoho-zookeeper"
:
"^1.0.10"
,
"yo-cli"
:
"=1.0.7"
"yoho-node-lib"
:
"^0.6.46"
,
"yoho-zookeeper"
:
"^1.0.10"
},
"devDependencies"
:
{
"autoprefixer"
:
"^8.3.0"
,
...
...
@@ -103,8 +103,6 @@
"stylelint"
:
"^9.2.0"
,
"stylelint-config-yoho"
:
"1.3.0"
,
"stylelint-formatter-table"
:
"^1.0.3"
,
"webpack"
:
"^4.6.0"
,
"webpack-cli"
:
"^2.0.15"
,
"webpack-dev-server"
:
"^3.1.4"
,
"yoho-eventproxy"
:
"^0.3.6"
,
"yoho-handlebars"
:
"^4.0.6"
,
...
...
public/scss/activity/_index.css
View file @
5af8170
@import
"../variables"
;
@import
"../channel/index"
;
@import
"activity"
;
...
...
public/scss/base.css
View file @
5af8170
@charset
"utf-8"
;
/* 公共 */
@import
"variables"
;
@import
"common/index"
;
@import
"plugin/index"
;
@import
"common/dialog"
;
@import
"pager"
;
@import
"path-nav"
;
@import
"share"
;
@import
"variables"
;
...
...
public/scss/brands/_index.css
View file @
5af8170
@import
"../channel/index"
@import
"../variables"
;
@import
"../channel/index"
;
...
...
public/scss/cart/_index.css
View file @
5af8170
@import
"../variables"
;
@import
"order-ensure"
;
@import
"easypay"
;
@import
"cart"
;
@import
"goods-detail"
;
@import
"cart-togetherGoods"
;
@import
"../variables"
;
...
...
public/scss/channel/_index.css
View file @
5af8170
@import
"../variables"
;
@import
"base"
;
@import
"index-pliffy"
;
@import
"min-index"
;
@import
"brand"
;
@import
"coupon"
;
@import
"../variables"
;
...
...
public/scss/home/_index.css
View file @
5af8170
@import
"../variables"
;
@import
"base"
;
@import
"default"
;
@import
"order-block"
;
...
...
@@ -19,7 +20,6 @@
@import
"coupons"
;
@import
"favorite"
;
@import
"user-info"
;
@import
"../variables"
;
@import
"returns-detail"
;
@import
"returns-save"
;
@import
"me-gift"
;
...
...
public/scss/passport/_index.css
View file @
5af8170
@import
"../variables"
;
@import
"base"
;
@import
"login"
;
@import
"register"
;
...
...
@@ -6,4 +7,3 @@
@import
"relate"
;
@import
"third"
;
@import
"_bind-tip.css"
;
@import
"../variables"
;
...
...
public/scss/product/_index.css
View file @
5af8170
@import
"../variables"
;
@import
"search"
;
@import
"filter-box"
;
@import
"sort-pager"
;
...
...
@@ -15,7 +16,6 @@
@import
"top-coupon"
;
@import
"new-arrive"
;
@import
"good-slide"
;
@import
"../variables"
;
@import
"seo/index"
;
.product-page
{
...
...
yarn.lock
View file @
5af8170
This diff could not be displayed because it is too large.
Please
register
or
login
to post a comment