Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
ET04
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
ET04
Commits
870b1602
Commit
870b1602
authored
Feb 25, 2021
by
wangxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
加载上传资源
parent
7756cba8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
111 additions
and
31 deletions
+111
-31
form.component.html
form/src/app/form/form.component.html
+53
-16
form.component.ts
form/src/app/form/form.component.ts
+51
-3
Scene.js
play/assets/tmpGame/script/Scene.js
+7
-12
No files found.
form/src/app/form/form.component.html
View file @
870b1602
...
...
@@ -13,25 +13,62 @@
></app-audio-recorder>
</div>
<div
style=
"width: 300px; margin-top: 100px"
>
<button
nz-button
nzType=
"primary"
>
添加选项
</button>
<div
*
ngFor=
"let it of picArr; let i = index"
style=
"padding: 0.5vw"
>
<div
class=
"border"
style=
"display: flex; align-items: center"
>
<div
class=
"item-box"
style=
"width: 30%"
>
<h5
style=
"padding-bottom: 1vw"
>
选项-{{ i + 1 }}
</h5>
<div
style=
"display: flex; align-items: center"
>
<span
style=
"padding-right: 10px"
>
图片:
</span>
</div>
<div
style=
"width: 300px; margin-top: 50px"
>
<span>
图1:
</span>
<app-upload-image-with-preview
[
picUrl
]="
item
.
pic_url
"
(
imageUploaded
)="
onImageUploadSuccess
($
event
,
'
pic_url
')"
style=
"width: 100%"
[
picUrl
]="
it
.
pic_url
"
(
imageUploaded
)="
onImageUploadSuccessByItem
($
event
,
it
)"
></app-upload-image-with-preview>
<div
style=
"display: flex; justify-items: center; padding-top: 10px"
>
<button
style=
"margin-left: 10px"
nz-button
nzType=
"danger"
(
click
)="
deleteItem
(
it
)"
>
</app-upload-image-with-preview>
<span>
删除
</span>
</button>
</div>
</div>
<div
style=
"margin-top: 5px"
>
<span>
音频:
</span>
<!--中间部分-->
<div
style=
"width: 30%; margin-left: 5%; padding: 1vw"
>
<div
style=
"display: flex; align-items: center; margin-bottom: 0.5vw"
>
<span
style=
"width: 50px"
>
音频:
</span>
</div>
<app-audio-recorder
[
audioUrl
]="
item
.
audio_url
"
(
audioUploaded
)="
onAudioUploadSuccess
($
event
,
'
audio_url
')"
></app-audio-recorder>
[
audioUrl
]="
it
.
audio_url
"
(
audioUploaded
)="
onAudioUploadSuccessByItem
($
event
,
it
)"
>
</app-audio-recorder>
<div
style=
"display: flex; align-items: center; margin-bottom: 0.5vw"
></div>
</div>
</div>
</div>
<div
nz-col
nzSpan=
"8"
class=
"add-btn-box"
style=
"margin-top: 100px"
>
<button
style=
"margin: auto; width: 60%; height: 60%"
nz-button
nzType=
"dashed"
class=
"add-btn"
(
click
)="
addPic
()"
>
<em
nz-icon
nzType=
"plus-circle"
nzTheme=
"outline"
></em>
添加选项
</button>
</div>
</div>
</div>
form/src/app/form/form.component.ts
View file @
870b1602
...
...
@@ -18,9 +18,10 @@ import { JsonPipe } from "@angular/common";
})
export
class
FormComponent
implements
OnInit
,
OnChanges
,
OnDestroy
{
// 储存数据用
saveKey
=
"
test
_001
"
;
saveKey
=
"
andy
_001
"
;
// 储存对象
item
;
picArr
=
[];
constructor
(
private
appRef
:
ApplicationRef
,
...
...
@@ -44,7 +45,6 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
ngOnInit
()
{
this
.
item
=
{};
this
.
item
[
"
total
"
]
=
0
;
// 获取存储的数据
(
<
any
>
window
).
courseware
.
getData
((
data
)
=>
{
...
...
@@ -80,7 +80,28 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
*/
onAudioUploadSuccess
(
e
,
key
)
{
this
.
item
[
key
]
=
e
.
url
;
this
.
item
[
"
total
"
]
=
this
.
item
[
"
total
"
]
+
1
;
this
.
save
();
}
onImageUploadSuccessByItem
(
e
,
item
,
id
=
null
)
{
if
(
id
!=
null
)
{
item
[
"
pic_url_
"
+
id
]
=
e
.
url
;
console
.
log
(
"
upload pic 1
"
+
e
.
url
);
}
else
{
item
.
pic_url
=
e
.
url
;
console
.
log
(
"
upload pic 2
"
+
e
.
url
);
}
this
.
save
();
console
.
log
(
"
this.item:
"
,
this
.
picArr
);
}
onAudioUploadSuccessByItem
(
e
,
item
,
id
=
null
)
{
if
(
id
!=
null
)
{
item
[
"
audio_url_
"
+
id
]
=
e
.
url
;
}
else
{
item
.
audio_url
=
e
.
url
;
}
this
.
save
();
}
...
...
@@ -94,10 +115,37 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this
.
save
();
}
saveItem
()
{
console
.
log
(
"
in saveItem
"
);
console
.
log
(
"
this.item
"
+
JSON
.
stringify
(
this
.
item
));
this
.
save
();
}
deleteItem
(
data
)
{
const
index
=
this
.
picArr
.
indexOf
(
data
);
if
(
index
!==
-
1
)
{
this
.
picArr
.
splice
(
index
,
1
);
}
this
.
save
();
}
addPic
()
{
const
data
=
{
pic_url
:
""
,
audio_url
:
""
,
};
this
.
picArr
.
push
(
data
);
this
.
saveItem
();
}
/**
* 储存数据
*/
save
()
{
this
.
item
[
"
options
"
]
=
this
.
picArr
;
(
<
any
>
window
).
courseware
.
setData
(
this
.
item
,
null
,
this
.
saveKey
);
this
.
refresh
();
...
...
play/assets/tmpGame/script/Scene.js
View file @
870b1602
...
...
@@ -96,22 +96,21 @@ cc.Class({
},
preloadItem
()
{
// this.addPreloadImage();
// this.addPreloadAudio();
// this.addPreloadAnima();
// this.preload();
this
.
initView
();
this
.
addPreloadImage
();
this
.
addPreloadAudio
();
this
.
addPreloadAnima
();
this
.
preload
();
},
addPreloadImage
()
{
for
(
var
i
=
0
;
i
<
this
.
data
.
total
;
i
++
)
{
this
.
_imageResList
.
push
({
url
:
this
.
data
[
"
pic_url_
"
+
i
]
});
for
(
var
i
=
0
;
i
<
this
.
data
.
options
;
i
++
)
{
this
.
_imageResList
.
push
({
url
:
this
.
data
.
options
[
i
]
[
"
pic_url_
"
+
i
]
});
}
},
addPreloadAudio
()
{
for
(
var
i
=
0
;
i
<
this
.
data
.
total
;
i
++
)
{
this
.
_audioResList
.
push
({
url
:
this
.
data
[
"
audio_url_
"
+
i
]
});
this
.
_audioResList
.
push
({
url
:
this
.
data
.
options
[
i
]
[
"
audio_url_
"
+
i
]
});
}
},
...
...
@@ -162,10 +161,6 @@ cc.Class({
this
.
playAudioByUrl
(
this
.
data
.
audio_title
);
});
if
(
window
&&
window
[
"
air
"
])
{
window
[
"
air
"
].
hideAirClassLoading
();
}
// for (var i = 0; i < this.data.total; i++) {
// const op_s = cc.instantiate(this.op_sound);
// op_s.getComponent("op_sound")._opId = i;
...
...
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