Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wisdom-ces
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
wangqinghua
wisdom-ces
Commits
65d5e096
Commit
65d5e096
authored
Apr 09, 2019
by
wangqinghua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
4.0.1
parent
7f9f12b4
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
71 deletions
+54
-71
activityDetail.html
src/pages/home/activity/activityDetail/activityDetail.html
+5
-5
activityDetail.ts
src/pages/home/activity/activityDetail/activityDetail.ts
+3
-35
learning-explain.html
...ages/home/learning/learning-explain/learning-explain.html
+0
-1
appUpdateService.ts
src/service/appUpdateService.ts
+0
-20
common.service.ts
src/service/common.service.ts
+46
-10
No files found.
src/pages/home/activity/activityDetail/activityDetail.html
View file @
65d5e096
...
...
@@ -18,11 +18,11 @@
<div
class=
"item1-introduction"
>
{{introduce}}
</div>
<
!--<div class="item1-introduction">--
>
<
!--<ng-container *ngFor="let file of activity?.fileUploadEntities">--
>
<
!--<p (click)="downLoad(file)" class="margin-bottom-15" >附件:{{file.showName}}</p>--
>
<
!--</ng-container>--
>
<
!--</div>--
>
<
div
class=
"item1-introduction"
>
<
ng-container
*
ngFor=
"let file of activity?.fileUploadEntities"
>
<
p
(
click
)="
downLoad
(
file
)"
class=
"margin-bottom-15"
>
附件:{{file.showName}}
</p
>
<
/ng-container
>
<
/div
>
</div>
</div>
...
...
src/pages/home/activity/activityDetail/activityDetail.ts
View file @
65d5e096
...
...
@@ -174,41 +174,9 @@ export class ActivityDetailPage {
confirm
.
present
();
}
// //下载附件
// downLoad(file){
// this.tabSer.downFile(file).subscribe(
// (res)=>{
// this.commonSer.downloadFile("附件.xlsx",res);
// }
// )
// }
downLoad
(
file
)
{
const
fileTransfer
:
FileTransferObject
=
this
.
fileTransfer
.
create
();
const
url
=
encodeURI
(
AppGlobal
.
domain
+
'/wisdomgroup/modules/common/file/download/'
+
file
.
id
);
alert
(
url
);
const
folder
=
this
.
file
.
externalRootDirectory
+
file
.
showName
;
//apk保存的目录
alert
(
folder
)
this
.
diagnostic
.
requestExternalStorageAuthorization
().
then
((
status
)
=>
{
alert
(
"Authorization request for external storage use was "
+
(
status
==
this
.
diagnostic
.
permissionStatus
.
GRANTED
?
"授予"
:
"拒绝"
));
fileTransfer
.
download
(
url
,
folder
).
then
((
entry
)
=>
{
const
alertSuccess
=
this
.
alertCtrl
.
create
({
title
:
`Download Succeeded!`
,
subTitle
:
`
${
url
}
was successfully downloaded to:
${
entry
.
toURL
()}
`
,
buttons
:
[
'Ok'
]
});
alertSuccess
.
present
();
},
(
error
)
=>
{
const
alertFailure
=
this
.
alertCtrl
.
create
({
title
:
`Download Failed!`
,
subTitle
:
`
${
url
}
was not successfully downloaded. Error code:
${
error
.
exception
}
`
,
buttons
:
[
'Ok'
]
});
alertFailure
.
present
();
});
}).
catch
(
error
=>
{
//Handle error
});
//下载附件
downLoad
(
file
){
this
.
commonSer
.
downloadFile
(
file
.
id
,
file
.
showName
)
}
}
src/pages/home/learning/learning-explain/learning-explain.html
View file @
65d5e096
...
...
@@ -10,6 +10,5 @@
<ion-content>
<p
class=
"explain margin-top-100"
>
本次答题共计{{item?.questionCount}}题,满分{{item?.fullMarks}}分
</p>
<p
class=
"explain margin-top-20"
>
时间:{{item?.timeLimit | formatTime}}
</p>
<p
class=
"explain margin-top-20"
>
分数超过{{item?.score}}分通过
</p>
<button
class=
"submit-btn submit"
(
click
)="
goToDO
()"
>
开始答题
</button>
</ion-content>
src/service/appUpdateService.ts
View file @
65d5e096
...
...
@@ -51,26 +51,6 @@ export class AppUpdateService {
enableBackdropDismiss
:
false
,
buttons
:
[
'后台下载'
]
});
// const fileTransfer: FileTransferObject = this.fileTransfer.create();
// const apk = this.file.externalRootDirectory + 'app.apk'; //apk保存的目录
// fileTransfer.download(AppGlobal.domain+apkUrl, apk).then(() => {
// this.fileOpener.open(apk, 'application/vnd.android.package-archive').then(() => {
// console.log('File is opened')
// }).catch(e => {
// console.log('Error openening file', e)
// });
// });
// fileTransfer.onProgress((event: ProgressEvent) => {
// let num = Math.floor(event.loaded / event.total * 100);
// if (num === 100) {
// alert.dismiss();
// } else {
// let title = document.getElementsByClassName('alert-title')[0];
// title && (title.innerHTML = '下载进度:' + num + '%');
// }
// });
// console.log("this apkUrl is" + apkUrl);
const
xhr
=
new
XMLHttpRequest
();
const
url
=
AppGlobal
.
domain
+
apkUrl
;
xhr
.
open
(
"GET"
,
url
);
...
...
src/service/common.service.ts
View file @
65d5e096
import
{
Injectable
}
from
"@angular/core"
;
import
{
AlertController
,
ToastController
}
from
"ionic-angular"
;
import
{
AppGlobal
}
from
"./appHttpService"
;
import
{
File
}
from
"@ionic-native/file"
;
@
Injectable
()
export
class
CommonService
{
constructor
(
public
toastCtrl
:
ToastController
,
public
alertCtrl
:
AlertController
){}
constructor
(
public
toastCtrl
:
ToastController
,
public
alertCtrl
:
AlertController
,
private
file
:
File
,
){}
/**
* JSON格式数据转化为字符串 接口调用
...
...
@@ -87,14 +89,47 @@ export class CommonService{
* 下载文件
* @param url 文件URL
*/
downloadFile
(
title
,
data
:
Response
)
{
const
blob
=
new
Blob
([
data
]);
const
url
=
window
.
URL
.
createObjectURL
(
blob
);
let
link
=
document
.
createElement
(
"a"
);
link
.
setAttribute
(
"href"
,
url
);
link
.
setAttribute
(
"download"
,
title
);
document
.
body
.
appendChild
(
link
);
link
.
click
();
document
.
body
.
removeChild
(
link
);
downloadFile
(
fileID
,
fileName
)
{
const
xhr
=
new
XMLHttpRequest
();
const
url
=
encodeURI
(
AppGlobal
.
domain
+
'/wisdomgroup/modules/common/file/download/'
+
fileID
);
xhr
.
open
(
'GET'
,
url
);
xhr
.
setRequestHeader
(
"Content-Type"
,
"application/x-www-form-urlencoded"
);
xhr
.
responseType
=
"blob"
;
xhr
.
addEventListener
(
"loadstart"
,(
ev
)
=>
{
})
xhr
.
addEventListener
(
"progress"
,(
ev
)
=>
{
let
progress
=
Math
.
round
(
100.0
*
ev
.
loaded
/
ev
.
total
);
// alert(progress);
})
xhr
.
addEventListener
(
"load"
,(
ev
)
=>
{
const
blob
=
xhr
.
response
;
if
(
blob
){
let
path
=
this
.
file
.
externalDataDirectory
;
this
.
file
.
writeFile
(
path
,
fileName
,
blob
,{
//写入文件
replace
:
true
}).
then
(
()
=>
{
let
toast
=
this
.
toastCtrl
.
create
({
message
:
"下载完成!保存路径:"
+
this
.
file
.
externalDataDirectory
,
duration
:
2000
,
position
:
'bottom'
,
dismissOnPageChange
:
true
,
});
toast
.
present
();
}).
catch
((
err
)
=>
{
this
.
toast
(
"下载文件失败!"
)
})
}
});
xhr
.
addEventListener
(
"loadend"
,
(
ev
)
=>
{
// 结束下载事件
});
xhr
.
addEventListener
(
"error"
,
(
ev
)
=>
{
this
.
alert
(
'下载附件失败!'
);
});
xhr
.
addEventListener
(
"abort"
,
(
ev
)
=>
{
});
xhr
.
send
();
}
}
\ No newline at end of file
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