Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yoho-blk
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
1
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
yyq
9 years ago
Commit
199f20525cd535e85ce9fe4e4df9d4fe5d095295
1 parent
0d9af92f
上传图片路径不一致问题解决
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
40 deletions
apps/me/models/returns.js
apps/me/views/partial/refund-detail.hbs
doraemon/controllers/upload.js
public/js/plugins/upload.js
public/scss/me/return/_refund-detail.css
apps/me/models/returns.js
View file @
199f205
...
...
@@ -25,6 +25,24 @@ const returnAddress = {
phone
:
'17714194699'
};
/**
* 获取原图片路径
* @function _getForceSourceUrl
* @param { String } url 图片路径
* @return { String } 原图片路径
*/
const
_getForceSourceUrl
=
(
url
)
=>
{
const
str
=
[
'?imageView'
,
'?imageMogr2'
];
_
.
forEach
(
str
,
value
=>
{
url
=
_
.
split
(
url
,
value
,
1
)[
0
];
});
url
.
replace
(
'http:'
,
''
);
return
url
;
};
/**
* 获取用户退换货列表
* @function getUserReturn
...
...
@@ -356,6 +374,14 @@ const _setRefundDetailData = (data) => {
let
goods
=
[];
_
.
forEach
(
data
.
goods_list
,
value
=>
{
let
evidence
;
if
(
!
_
.
isEmpty
(
value
.
evidence_images
))
{
evidence
=
[];
_
.
forEach
(
value
.
evidence_images
,
img
=>
{
evidence
.
push
(
_getForceSourceUrl
(
img
));
});
}
goods
.
push
({
img
:
value
.
goods_image
,
name
:
value
.
product_name
,
...
...
@@ -365,7 +391,7 @@ const _setRefundDetailData = (data) => {
reason
:
value
.
reason_name
||
'--'
,
price
:
value
.
sales_price
,
remark
:
value
.
remark
,
evidence
:
value
.
evidence_images
evidence
:
evidence
});
});
...
...
apps/me/views/partial/refund-detail.hbs
View file @
199f205
...
...
@@ -140,9 +140,9 @@
<dd>
<label>
照片凭证:
</label>
{{#
evidence
}}
<div
class=
"evidence-img"
>
<img
class=
"lazy"
data-original=
"
{{
image
.
70
90
}}
"
>
</div>
<a
href=
"
{{
this
}}
"
class=
"evidence-img"
target=
"_blank"
>
<img
class=
"lazy"
data-original=
"
{{
this
}}
"
>
</a>
{{/
evidence
}}
</dd>
{{/if}}
...
...
doraemon/controllers/upload.js
View file @
199f205
...
...
@@ -10,16 +10,16 @@ const request = require('request');
const
fs
=
require
(
'fs'
);
// 获取图片绝对地址
const
getImgHost
=
(
url
)
=>
{
let
domain
=
'static.yhbimg.com/goodsimg'
,
const
getImgHost
=
(
url
,
bucket
)
=>
{
let
domain
=
`
static
.
yhbimg
.
com
/
$
{
bucket
}
`
,
urlArr
=
url
.
split
(
'/'
),
num
=
urlArr
[
urlArr
.
length
-
1
].
substr
(
1
,
1
),
url1
=
domain
+
url
;
if
(
num
===
'1'
)
{
return
'http://img11.'
+
url1
;
return
`
http
:
//img11.${url1}`
;
}
else
{
return
'http://img12.'
+
url1
;
return
`
http
:
//img12.${url1}`
;
}
};
...
...
@@ -45,41 +45,35 @@ const uploadImg = (req, res) => {
req
.
body
.
fileNames
[
fileIndex
]
=
files
[
fileIndex
].
name
;
}
if
(
req
.
body
.
bucket
===
'goodsimg'
)
{
request
.
post
({
url
:
'http://upload.static.yohobuy.com'
,
formData
:
{
fileData
:
req
.
body
.
files
,
project
:
req
.
body
.
bucket
},
json
:
true
},
(
error
,
httpResponse
,
rebody
)
=>
{
if
(
!
error
&&
httpResponse
.
statusCode
===
200
)
{
imgs
=
rebody
.
data
.
imagesList
||
[];
datas
=
[];
request
.
post
({
url
:
'http://upload.static.yohobuy.com'
,
formData
:
{
fileData
:
req
.
body
.
files
,
project
:
req
.
body
.
bucket
},
json
:
true
},
(
error
,
httpResponse
,
rebody
)
=>
{
console
.
log
(
httpResponse
);
if
(
!
error
&&
httpResponse
.
statusCode
===
200
)
{
imgs
=
rebody
.
data
.
imagesList
||
[];
datas
=
[];
// 生成图片绝对地址
for
(
i
=
0
;
i
<
imgs
.
length
;
i
++
)
{
datas
.
push
(
getImgHost
(
imgs
[
i
]));
}
// 生成图片绝对地址
for
(
i
=
0
;
i
<
imgs
.
length
;
i
++
)
{
datas
.
push
(
getImgHost
(
imgs
[
i
],
req
.
body
.
bucket
));
}
}
res
.
json
({
code
:
200
,
data
:
datas
[
0
],
datas
:
datas
,
imgs
:
imgs
,
names
:
req
.
body
.
fileNames
,
message
:
'上传成功'
,
status
:
true
});
});
}
else
{
res
.
json
({
code
:
500
,
message
:
'上传图片失败, 请稍后重试!'
code
:
200
,
data
:
datas
[
0
],
datas
:
datas
,
imgs
:
imgs
,
names
:
req
.
body
.
fileNames
,
message
:
'上传成功'
,
status
:
true
});
}
}
);
}
else
{
res
.
json
({
code
:
401
,
...
...
public/js/plugins/upload.js
View file @
199f205
...
...
@@ -6,7 +6,7 @@ var tpl = '<div style="width: 0px; height: 0px; overflow: hidden;">' +
'<form id="yoho-upload" method="post" enctype="multipart/form-data" '
+
'action="/common/uploadImg" target="ajaxUpload">'
+
'<input type="file" name="filename" class="file-name" />'
+
'<input type="hidden" name="bucket" value="
goodsimg
" />'
+
'<input type="hidden" name="bucket" value="
evidenceImages
" />'
+
'</form>'
+
'</div>'
;
...
...
public/scss/me/return/_refund-detail.css
View file @
199f205
...
...
@@ -197,10 +197,15 @@
.evidence-img
{
width
:
70px
;
height
:
9
0px
;
height
:
7
0px
;
display
:
inline-block
;
vertical-align
:
top
;
}
.evidence-img
>
img
{
width
:
100%
;
height
:
100%
;
}
}
}
}
...
...
Please
register
or
login
to post a comment