<apex:page standardController="FileAddress__c" extensions="ImgPreviewVFController" showHeader="false">
|
<head>
|
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
|
<!-- <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" /> -->
|
<style type="text/css">
|
img{
|
max-width: 800px;
|
max-height: 800px;
|
height:auto;
|
zoom:expression( function(e) {
|
if(e.width>e.height) {if (e.width>128) { e.height = e.height*(128 /e.width); e.width=128; }}
|
else {if (e.height>128) { e.width = e.width*(128 /e.height); e.height=128; }}
|
e.style.zoom = '1'; }(this));
|
overflow:hidden;
|
}
|
</style>
|
<script>
|
window.onload = function(){
|
var current = 0;
|
document.getElementById('rotate').onclick = function(){
|
current = (current+90)%360;
|
this.style.transform = 'rotate('+current+'deg)';
|
}
|
};
|
/* var staticResources = JSON.parse('{!staticResource}'); */
|
/* var fileKey = '{!fileKey}'; */
|
/* var fileName = '{!fileName}'; */
|
var type = '{!type}';
|
var hostUrl = '{!hostUrl}';
|
|
/* var PARAMS = {};
|
PARAMS.fileKey = fileKey;
|
PARAMS.fileName = fileName;
|
PARAMS.token = staticResources.token;
|
console.log('PARAMS = ' + JSON.stringify(PARAMS)); */
|
setTimeout(function() {
|
console.log('This is an anonymous function called after a delay.');
|
if(type == 'preview'){
|
/* postAWS(hostUrl + '/api/file/cacheFileKey',PARAMS,'preview'); */
|
postAWS(hostUrl);
|
}
|
}, 3000);
|
//调用AWS进行预览或下载
|
/* function postAWS(url,PARAMS,preDown){ */
|
function postAWS(url){
|
debugger
|
/* console.log('filekey = ' + PARAMS.fileKey);
|
console.log('url = ' + url);
|
var cacheType = 0;
|
if(preDown == 'preview'){
|
cacheType = 1;
|
}
|
fetch(url, {
|
method: 'POST',
|
body: JSON.stringify({ 'fileKey': PARAMS.fileKey, "fileName": PARAMS.fileName, 'token': PARAMS.token,'cacheType':cacheType }),
|
headers: {
|
'Content-Type': 'application/json',
|
'pi-token': PARAMS.token
|
}
|
}).then((data) => {
|
return data.json();
|
}).then(result => {
|
console.log(result);
|
if(preDown == 'preview'){ */
|
/* //window.location.href = hostUrl + '/api/file/previewV3?key=' + result.object; */
|
var img = document.getElementsByTagName("img")[0];
|
/* var src = hostUrl + '/api/file/previewV3?key=' + result.object; */
|
var src = hostUrl;
|
/* console.log('src = ' + hostUrl + '/api/file/previewV3?key=' + result.object); */
|
console.log('src = ' + src);
|
img.src = src;
|
console.log('width = ' + img.style.width);
|
console.log('height = ' + img.style.height);
|
/* }
|
}) */
|
}
|
|
</script>
|
</head>
|
|
<body id='body' style="text-align: center">
|
<p style="font-size:20px">点击图片进行旋转</p>
|
<img id ="rotate" src=""/>
|
</body>
|
</apex:page>
|