Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
ufo-app-web
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
TaoHuang
6 years ago
Commit
494d886d377585aff03ab572de45eedb9a3bc584
1 parent
0accaa94
fix upload
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
6 deletions
apps/pages/single/license/components/upload.vue
create-app.js
doraemon/middleware/qiniu.js
package.json
apps/pages/single/license/components/upload.vue
View file @
494d886
...
...
@@ -66,19 +66,31 @@ export default {
return {
multiple: false,
action: {
target: '/
/upload.qiniup.com/
',
target: '/
mapp/upload
',
data(file) {
return {
token: vm.token,
key: 'license/' + Date.now() + '/' + file.name
key: 'license/' + Date.now() + '/' + file.name,
bucket: 'goodsimg',
userId: vm.getUid(),
method: 'yoho.fileupload'
};
}
},
file: this.value,
initialIndex: 0
initialIndex: 0,
uid: ''
};
},
async mounted() {
const user = await this.$sdk.getUser();
this.uid = user.uid;
},
methods: {
getUid() {
return this.uid;
},
filesAdded(files) {
let hasIgnore = false;
const maxSize = 10 * 1024 * 1024; // 10M
...
...
@@ -121,10 +133,10 @@ export default {
this.initialIndex = this.file.findIndex(i => file.name === i.name);
const imgs = this.file.map(f => {
return
'//img01.yohoboys.com/' + f.response.key
+ '?imageView2/2/w/450/q/60';
return
this.getUploadImgAbsoluteUrl(f.response.data, 'goodsimg')
+ '?imageView2/2/w/450/q/60';
});
if (file && file.response && file.response.
key
) {
if (file && file.response && file.response.
data
) {
this.$createImagePreview({
$props: {
imgs,
...
...
@@ -145,6 +157,24 @@ export default {
},
fileRemove(file) {
this.$emit('file-change', file);
},
getUploadImgAbsoluteUrl(url, bucket) {
if (!url) {
return null;
}
let urlArr = url.split('/'),
stag = urlArr[urlArr.length - 1].substr(0, 2),
domain = `static.yhbimg.com/${bucket}`;
url = domain + url;
if (stag === '01') {
return `//img11.${url}`;
} else if (stag === '03') {
return `//flv01.${url}`;
} else {
return `//img12.${url}`;
}
}
},
computed: {
...
...
create-app.js
View file @
494d886
...
...
@@ -88,6 +88,7 @@ exports.createApp = async(app) => {
app
.
use
(
setYohoDataMiddleware
);
app
.
use
(
userMiddleware
);
app
.
get
(
'/mapp/getToken'
,
qiniuMiddleware
.
getToken
);
app
.
post
(
'/mapp/upload'
,
qiniuMiddleware
.
upload
);
app
.
use
(
'/mapp/alipay'
,
alipayRouter
);
app
.
use
(
'/mapp'
,
ssrApiMiddleware
);
...
...
doraemon/middleware/qiniu.js
View file @
494d886
...
...
@@ -6,6 +6,8 @@
const
qiniu
=
require
(
'qiniu'
);
const
qiniuConfig
=
global
.
yoho
.
config
.
qiniu
;
const
qiniuYohoCdnConfig
=
global
.
yoho
.
config
.
qiniuYohoCdn
;
const
request
=
require
(
'request'
);
const
{
config
}
=
global
.
yoho
;
function
getToken
(
req
,
res
)
{
let
conf
=
qiniuConfig
;
...
...
@@ -28,6 +30,17 @@ function getToken(req, res) {
});
}
function
upload
(
req
,
res
,
next
)
{
let
localReq
=
request
(
config
.
domains
.
api
);
req
.
pipe
(
localReq
).
pipe
(
res
);
localReq
.
on
(
'error'
,
function
(
err
)
{
next
(
err
);
});
}
module
.
exports
=
{
getToken
getToken
,
upload
};
...
...
package.json
View file @
494d886
...
...
@@ -49,6 +49,7 @@
"lottie-web"
:
"^5.4.2"
,
"mysql"
:
"^2.16.0"
,
"qiniu"
:
"^7.2.1"
,
"request"
:
"^2.88.0"
,
"request-promise"
:
"^4.2.2"
,
"serve-favicon"
:
"^2.5.0"
,
"source-map"
:
"^0.7.3"
,
...
...
Please
register
or
login
to post a comment