|
楼主 |
发表于 2017-6-14 09:52:36
|
显示全部楼层
browse=function(url,fileName, option)
这个里面的url、filename 这两个参数在点击onBrowse 里面如何获取?
另外,我写固定了一个url和filename,使用上边打开的效果,手机上看只有返回按钮,并没有展示图片效果如下:
代码如下:
Model.prototype.attachmentBrowse = function(event){
debugger;
event[0].cancel=true;
var url='http://127.0.0.1:8080/x5/$vdd901c498e1545adb6759ce8e71257ce$lzh_CN$s$dm/UI2/system/service/doc/common/uploadDoc.j?dochost=http://192.168.1.115:8080/DocServer/repository/file/view/563-DOC/last/content?key=63c386a3db4f2e240d7ab67834d4c294724f737027e52c59cb09ca378a0a8294f354cb841844dc7f16fc336669bb60036eaaae7560bd45348cc4146ec660e493d398dc6b66dcb02a3125663ab31c783a257ac78505cbbf5af32b001f3bb97fd5&docname=122255182618252095.jpg';
var fileName='122255182618252095.jpg';
this.browse(url, fileName, null);
};
/**
* fileEntry
* fullPath: "/test"
* name: "test"
* toURL():"filesystem:http://192.168.1.49:8080/temporary/test"
*
* 浏览本地文件需要传url为 toURL之后的
*/
Model.prototype.browse=function(url,fileName, option){
debugger;
alert('1browse');
var dtd = $.Deferred();
var self = this;
alert('2browse');
if(Browser.isX5App){
alert('Browser.isX5App');
if(this._isLocalFile(url)){
if(Browser.isAndroid){
window.open(url,"_system");
dtd.resolve(url);
}else if(Browser.isIOS){
window.open(url, '_blank', 'toolbarposition=top,location=no,enableViewportScale=yes');
dtd.resolve(url);
}
}else{
url = this._toFullUrl(url);
/*this.download(url, fileName,option).done(function(nativeUrl){
self.browse(nativeUrl).done(function(url){
dtd.resolve(url);
}).fail(function(err){
dtd.reject(err);
});
}).fail(function(err){
dtd.reject(err);
});*/
plugins.toast.showShortBottom("正在载入文件,请稍候。。。。");
handleDocumentWithURL(function(){
dtd.resolve(url);
},function(err){
dtd.reject(err);
},url);
}
}else{
alert('not Browser.isX5App');
//TODO:支持浏览器中filesystem的文件浏览
if(justep.Browser.isWeChat){
alert('justep.Browser.isWeChat 手机:');
var fileBrowseNode = $('<div style="z-index:9999;position:absolute;top:0;bottom:0;left:0;right:0;background-color:white;"></div>');
var closeBtn = $('<i class="icon-chevron-left" style="position:absolute;z-index:3;left:25px;width:50px;top:10px;height:36px;"/>').on('click',function(){
fileBrowseNode.remove();
}).appendTo(fileBrowseNode);
var fileFrame = $('<iframe src="'+url+'" style="width:100%;height:100%;padding-top:46px;position:absolute;background-color:white;border:none;"></iframe>').appendTo(fileBrowseNode);
fileBrowseNode.appendTo('body');
dtd.resolve(url);
}else{
alert('not justep.Browser.isWeChat');
window.open(url, '_blank');
dtd.resolve(url);
}
}
return dtd.promise();
};
|
|