Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
NFT
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hanfeng zhang
NFT
Commits
1a2f5989
Commit
1a2f5989
authored
Jul 21, 2021
by
salitedfish
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
阶段性提交
parent
55ac50fa
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
135 additions
and
41 deletions
+135
-41
Cell.vue
src/components/common/Cell.vue
+2
-2
create.ts
src/store/create.ts
+1
-1
index.vue
src/view/NFT/Create/components/certificate/index.vue
+20
-1
form.vue
src/view/NFT/Create/form.vue
+3
-2
upload.vue
src/view/NFT/Create/upload.vue
+109
-35
No files found.
src/components/common/Cell.vue
View file @
1a2f5989
...
@@ -53,7 +53,7 @@
...
@@ -53,7 +53,7 @@
<input
<input
@
click=
"eventEmit(type)"
@
click=
"eventEmit(type)"
:disabled=
"true"
:disabled=
"true"
v-if=
"$store.state.create.pickedList.length === 0"
v-if=
"
!$store.state.create.pickedList ||
$store.state.create.pickedList.length === 0"
type=
"text"
type=
"text"
class=
"bg-transparent"
class=
"bg-transparent"
:placeholder=
"placeholder"
:placeholder=
"placeholder"
...
@@ -214,7 +214,7 @@ export default Vue.extend({
...
@@ -214,7 +214,7 @@ export default Vue.extend({
}
}
},
},
cellOnChange
(
e
:
any
)
{
cellOnChange
(
e
:
any
)
{
if
(
e
.
target
.
value
.
length
>=
15
)
{
if
(
e
.
target
.
value
&&
e
.
target
.
value
.
length
>=
15
)
{
this
.
inputValue
=
(
this
.
inputValue
as
string
).
slice
(
0
,
15
)
this
.
inputValue
=
(
this
.
inputValue
as
string
).
slice
(
0
,
15
)
}
}
this
.
$emit
(
"cellOnChange"
,
this
.
inputValue
);
this
.
$emit
(
"cellOnChange"
,
this
.
inputValue
);
...
...
src/store/create.ts
View file @
1a2f5989
...
@@ -4,7 +4,7 @@ const stateData = {
...
@@ -4,7 +4,7 @@ const stateData = {
fileName
:
''
,
fileName
:
''
,
file
:
undefined
as
undefined
|
File
,
file
:
undefined
as
undefined
|
File
,
coverName
:
''
,
coverName
:
''
,
coverFile
:
undefined
as
undefined
|
File
coverFile
:
undefined
as
undefined
|
File
,
}
}
export
type
AppType
=
typeof
stateData
export
type
AppType
=
typeof
stateData
...
...
src/view/NFT/Create/components/certificate/index.vue
View file @
1a2f5989
...
@@ -11,7 +11,8 @@
...
@@ -11,7 +11,8 @@
<div>
影视区块链版权电子数据确权书
</div>
<div>
影视区块链版权电子数据确权书
</div>
</div>
</div>
<div>
<div>
<img
src=
"/img/cover.png"
class=
" w-20 xs:w-24 mx-auto mt-4"
/>
<img
v-if=
"!coverName"
src=
"/img/cover.png"
class=
" w-20 xs:w-24 mx-auto mt-4"
/>
<img
id=
"coverImg"
:src=
"showUploadFile"
v-else
class=
" w-20 xs:w-24 mx-auto mt-4"
/>
</div>
</div>
<div
class=
"float-box w-full absolute -bottom-10 text-3xs xs:text-2xs"
>
<div
class=
"float-box w-full absolute -bottom-10 text-3xs xs:text-2xs"
>
<div
class=
"w-11/12 p-2 flex-wrap mx-auto flex break-all bg-font-white shadow-md rounded text-font-black"
>
<div
class=
"w-11/12 p-2 flex-wrap mx-auto flex break-all bg-font-white shadow-md rounded text-font-black"
>
...
@@ -61,12 +62,30 @@ import Vue from "vue";
...
@@ -61,12 +62,30 @@ import Vue from "vue";
import
download
from
'downloadjs'
import
download
from
'downloadjs'
import
moment
from
'moment'
import
moment
from
'moment'
import
{
toPng
}
from
'html-to-image'
;
import
{
toPng
}
from
'html-to-image'
;
import
{
mapState
}
from
"vuex"
;
export
default
Vue
.
extend
({
export
default
Vue
.
extend
({
data
(){
data
(){
return
{
return
{
createTime
:
moment
(
new
Date
()).
format
(
'YYYY-MM-DD hh:mm:ss'
)
createTime
:
moment
(
new
Date
()).
format
(
'YYYY-MM-DD hh:mm:ss'
)
}
}
},
},
computed
:{
...
mapState
(
"create"
,
[
"coverFile"
,
"coverName"
]),
showUploadFile
(){
if
(
this
.
coverFile
)
{
return
window
.
URL
.
createObjectURL
(
this
.
coverFile
)
}
else
{
return
''
}
}
},
mounted
(){
const
fileReader
=
new
FileReader
();
fileReader
.
readAsDataURL
(
this
.
coverFile
);
fileReader
.
onload
=
function
(){
(
document
.
getElementById
(
"coverImg"
)
as
any
).
src
=
fileReader
.
result
;
}
},
props
:
{
props
:
{
name
:
{
name
:
{
type
:
String
,
type
:
String
,
...
...
src/view/NFT/Create/form.vue
View file @
1a2f5989
...
@@ -81,10 +81,10 @@
...
@@ -81,10 +81,10 @@
>
</app-cell>
>
</app-cell>
<app-cell
<app-cell
text=
"封面上传(非必填)"
text=
"封面上传(非必填)"
class=
"text-font-white my-3"
class=
"text-font-white my-3
"
type=
"upload"
type=
"upload"
placeholder=
"请上传相关封面"
placeholder=
"请上传相关封面"
:name=
"
file
Name"
:name=
"
cover
Name"
@
cellOnChange=
"$router.push(
{ name: 'NftUpload',params:{type:'封面图片'}})"
@
cellOnChange=
"$router.push(
{ name: 'NftUpload',params:{type:'封面图片'}})"
>
</app-cell>
>
</app-cell>
<app-cell
<app-cell
...
@@ -342,6 +342,7 @@ export default Vue.extend({
...
@@ -342,6 +342,7 @@ export default Vue.extend({
fileName
:
"fileName"
,
fileName
:
"fileName"
,
file
:
"file"
,
file
:
"file"
,
pickedList
:
"pickedList"
,
pickedList
:
"pickedList"
,
coverName
:
'coverName'
}),
}),
validation
():
boolean
{
validation
():
boolean
{
let
disabled
=
true
;
let
disabled
=
true
;
...
...
src/view/NFT/Create/upload.vue
View file @
1a2f5989
...
@@ -2,16 +2,12 @@
...
@@ -2,16 +2,12 @@
<
template
>
<
template
>
<Layout-Child
class=
"page-scroll text-center"
>
<Layout-Child
class=
"page-scroll text-center"
>
<div
class=
"text-font-white mt-20 text-center mb-20"
>
{{
uploadAccept
.
acceptTitle
}}
</div>
<div
class=
"text-font-white mt-20 text-center mb-20"
>
{{
uploadAccept
.
acceptTitle
}}
</div>
<input
<input
type=
"file"
id=
"upload"
class=
"hidden"
@
change=
"handleFileChange('inputFile')"
ref=
"inputFile"
:accept=
"uploadAccept.acceptType"
/>
type=
"file"
<input
type=
"file"
id=
"upload"
accept=
"image/*"
class=
" hidden"
ref=
'localImgElem'
@
change=
"handleFileChange('localImgElem')"
/>
id=
"upload"
<input
type=
"file"
id=
"upload"
accept=
"image/*"
capture=
"camera"
class=
" hidden"
ref=
'cameraElem'
@
change=
"handleFileChange('cameraElem')"
/>
class=
"hidden"
<van-action-sheet
v-model=
"show"
:actions=
"actions"
@
select=
"onSelect"
/>
@
change=
"handleFileChange"
ref=
"inputFile"
:accept=
"uploadAccept.acceptType"
/>
<label
for=
"u
pload"
class=
"inline-block"
>
<label
@
click=
"initU
pload"
class=
"inline-block"
>
<div
<div
ref=
"uploadBox"
ref=
"uploadBox"
class=
"
class=
"
...
@@ -24,33 +20,43 @@
...
@@ -24,33 +20,43 @@
"
"
>
>
<img
<img
v-if=
"s
tatus === uploadStatus.NULL
"
v-if=
"s
howNotUploadImg
"
src=
"@/assets/icons/upload.png"
src=
"@/assets/icons/upload.png"
alt=
""
alt=
""
class=
"mx-auto"
class=
"mx-auto"
/>
/>
<img
<img
v-else-if=
"s
tatus === uploadStatus.success
"
v-else-if=
"s
howImgUploadImg
"
src=
"@/assets/icons/file.png
"
:src=
"showUploadFile
"
alt=
""
alt=
""
class=
"mx-auto"
class=
"mx-auto"
/>
/>
<Loading
type=
"spiner"
v-else-if=
"status === uploadStatus.uploading"
/>
<img
<div
v-else-if=
"status === uploadStatus.failed"
>
上传失败
</div>
v-else-if=
"status === uploadStatus.success && uploadType !== '图片' && uploadType !== '封面图片'"
src=
"@/assets/icons/upload.png"
alt=
""
class=
"mx-auto"
/>
<Loading
type=
"spiner"
v-else-if=
"status === uploadStatus.uploading || coverstatus === uploadStatus.uploading"
/>
<div
v-else-if=
"status === uploadStatus.failed || coverstatus === uploadStatus.uploading"
>
上传失败
</div>
</div>
</div>
</label>
</label>
<div
class=
"text-center text-font-white"
>
<div
class=
"text-center text-font-white"
>
<div
v-if=
"
!fileName
"
class=
"mt-2"
>
{{
uploadAccept
.
acceptText
}}
</div>
<div
v-if=
"
(uploadType == '封面图片' && !coverName) || (uploadType !== '封面图片' && !fileName)
"
class=
"mt-2"
>
{{
uploadAccept
.
acceptText
}}
</div>
<div
v-
if=
"fileName"
class=
"mt-2"
>
<div
v-
else
class=
"mt-2"
>
{{
fileName
}}
{{
(
uploadType
==
'封面图片'
&&
coverName
)?
coverName
:
fileName
}}
</div>
</div>
<!--
<div
v-if=
"uploadType == '封面图片' && coverName"
class=
"mt-2"
>
{{
coverName
}}
</div>
<div
v-else-if=
"uploadType !== '封面图片' && fileName"
class=
"mt-2"
>
{{
fileName
}}
</div>
-->
<label
for=
"upload"
class=
"mt-2"
>
<label
for=
"upload"
class=
"mt-2"
>
<div
<div
v-if=
"
v-if=
"showReUpload"
status === uploadStatus.failed || status === uploadStatus.success
"
style=
"color: #0076ff"
style=
"color: #0076ff"
class=
"inline-block"
class=
"inline-block"
>
>
...
@@ -85,6 +91,9 @@ import Vue from "vue";
...
@@ -85,6 +91,9 @@ import Vue from "vue";
import
{
Uploader
,
Loading
}
from
"vant"
;
import
{
Uploader
,
Loading
}
from
"vant"
;
import
{
mapMutations
,
mapState
}
from
"vuex"
;
import
{
mapMutations
,
mapState
}
from
"vuex"
;
import
md5
from
"md5"
;
import
md5
from
"md5"
;
import
{
ActionSheet
}
from
'vant'
;
Vue
.
use
(
ActionSheet
);
enum
uploadStatus
{
enum
uploadStatus
{
NULL
,
NULL
,
...
@@ -100,7 +109,13 @@ export default Vue.extend({
...
@@ -100,7 +109,13 @@ export default Vue.extend({
uploading
:
false
,
uploading
:
false
,
uploadStatus
,
uploadStatus
,
status
:
uploadStatus
.
NULL
,
status
:
uploadStatus
.
NULL
,
coverstatus
:
uploadStatus
.
NULL
,
// accept:
// accept:
show
:
false
,
actions
:
[
{
name
:
'本地相册'
},
{
name
:
'拍照'
},
],
};
};
},
},
components
:
{
components
:
{
...
@@ -110,14 +125,18 @@ export default Vue.extend({
...
@@ -110,14 +125,18 @@ export default Vue.extend({
Loading
,
Loading
,
},
},
computed
:
{
computed
:
{
...
mapState
(
"create"
,
[
"fileName"
]),
...
mapState
(
"create"
,
[
"fileName"
,
"coverName"
,
'coverFile'
,
'file'
]),
nextBtnDisabled
():
boolean
{
nextBtnDisabled
():
boolean
{
return
!
this
.
fileName
;
if
(
this
.
uploadType
==
'封面图片'
)
{
return
!
this
.
coverName
}
else
{
return
!
this
.
fileName
;
}
},
},
uploadType
(){
uploadType
()
:
any
{
return
this
.
$route
.
params
.
type
return
this
.
$route
.
params
.
type
},
},
uploadAccept
(){
uploadAccept
()
:
object
{
switch
(
this
.
uploadType
){
switch
(
this
.
uploadType
){
case
'剧本'
:
case
'剧本'
:
return
{
acceptTitle
:
'请上传剧本附件'
,
acceptType
:
'application/pdf,application/msword,text/plain'
,
acceptText
:
'支持扩展名格式PDF'
}
return
{
acceptTitle
:
'请上传剧本附件'
,
acceptType
:
'application/pdf,application/msword,text/plain'
,
acceptText
:
'支持扩展名格式PDF'
}
...
@@ -134,12 +153,50 @@ export default Vue.extend({
...
@@ -134,12 +153,50 @@ export default Vue.extend({
default
:
default
:
return
{
acceptTitle
:
''
,
acceptType
:
''
,
acceptText
:
''
}
return
{
acceptTitle
:
''
,
acceptType
:
''
,
acceptText
:
''
}
}
}
},
showUploadFile
():
string
{
if
(
this
.
uploadType
==
'封面图片'
&&
this
.
coverFile
)
{
return
window
.
URL
.
createObjectURL
(
this
.
coverFile
)
}
else
if
(
this
.
uploadType
!==
'图片'
&&
this
.
file
)
{
return
window
.
URL
.
createObjectURL
(
this
.
file
)
}
else
{
return
''
}
},
showNotUploadImg
():
boolean
{
return
(
this
.
uploadType
!==
'封面图片'
&&
this
.
status
===
uploadStatus
.
NULL
)
||
(
this
.
uploadType
==
'封面图片'
&&
this
.
coverstatus
===
uploadStatus
.
NULL
)
},
showImgUploadImg
():
boolean
{
return
(
this
.
status
===
uploadStatus
.
success
&&
this
.
uploadType
==
'图片'
)
||
(
this
.
coverstatus
===
uploadStatus
.
success
&&
this
.
uploadType
==
'封面图片'
)
},
showReUpload
():
boolean
{
return
((
this
.
uploadType
!==
'封面图片'
)
&&
(
this
.
status
===
uploadStatus
.
failed
||
this
.
status
===
uploadStatus
.
success
))
||
((
this
.
uploadType
==
'封面图片'
)
&&
(
this
.
coverstatus
===
uploadStatus
.
failed
||
this
.
coverstatus
===
uploadStatus
.
success
))
}
}
},
},
methods
:
{
methods
:
{
handleFileChange
()
{
initUpload
(){
const
ele
=
this
.
$refs
.
inputFile
as
HTMLInputElement
;
if
(
this
.
uploadType
==
'图片'
||
this
.
uploadType
==
'封面图片'
)
{
this
.
show
=
true
}
else
{
(
this
.
$refs
.
inputFile
as
HTMLInputElement
).
click
()
}
},
onSelect
(
item
:
any
){
this
.
show
=
false
;
let
cEl
=
this
.
$refs
.
cameraElem
as
HTMLInputElement
let
fEl
=
this
.
$refs
.
localImgElem
as
HTMLInputElement
switch
(
item
.
name
){
case
'拍照'
:
cEl
.
click
();
break
;
case
'本地相册'
:
fEl
.
click
();
break
;
}
this
.
$toast
(
item
.
name
);
},
handleFileChange
(
ref
:
any
)
{
const
ele
=
this
.
$refs
[
ref
]
as
HTMLInputElement
;
const
files
=
ele
.
files
;
const
files
=
ele
.
files
;
if
(
files
&&
files
.
length
>=
1
)
{
if
(
files
&&
files
.
length
>=
1
)
{
this
.
afterRead
(
files
[
0
]);
this
.
afterRead
(
files
[
0
]);
...
@@ -152,21 +209,37 @@ export default Vue.extend({
...
@@ -152,21 +209,37 @@ export default Vue.extend({
try
{
try
{
const
ab
=
await
file
.
arrayBuffer
();
const
ab
=
await
file
.
arrayBuffer
();
const
fileMd5
=
md5
(
Buffer
.
from
(
ab
));
const
fileMd5
=
md5
(
Buffer
.
from
(
ab
));
this
.
status
=
uploadStatus
.
uploading
;
// const ossRet = await this.$service.nftService.ossPolicy();
// const ossRet = await this.$service.nftService.ossPolicy();
// const uploadRet = await this.$service.nftService.uploadFileToOss(
// const uploadRet = await this.$service.nftService.uploadFileToOss(
// file,
// file,
// ossRet
// ossRet
// );
// );
this
.
setState
({
if
(
this
.
uploadType
==
'封面图片'
)
{
fileName
:
file
.
name
,
this
.
coverstatus
=
uploadStatus
.
uploading
;
fileHash
:
fileMd5
,
this
.
setState
({
file
:
file
,
coverName
:
file
.
name
,
});
coverFile
:
file
,
this
.
status
=
uploadStatus
.
success
;
});
this
.
coverstatus
=
uploadStatus
.
success
;
}
else
{
this
.
status
=
uploadStatus
.
uploading
;
this
.
setState
({
fileName
:
file
.
name
,
fileHash
:
fileMd5
,
file
:
file
,
});
this
.
status
=
uploadStatus
.
success
;
}
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
err
,
"show err"
);
console
.
log
(
err
,
"show err"
);
this
.
status
=
uploadStatus
.
failed
;
if
(
this
.
uploadType
==
'封面图片'
)
{
this
.
coverstatus
=
uploadStatus
.
failed
;
}
else
{
this
.
status
=
uploadStatus
.
failed
;
}
}
}
},
},
afterRead2
(
file
:
any
)
{
afterRead2
(
file
:
any
)
{
...
@@ -181,6 +254,7 @@ export default Vue.extend({
...
@@ -181,6 +254,7 @@ export default Vue.extend({
},
},
});
});
</
script
>
</
script
>
<
style
scoped
>
<
style
scoped
>
.upload-box
{
.upload-box
{
width
:
140px
;
width
:
140px
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment