|
楼主 |
发表于 2016-11-4 14:58:59
|
显示全部楼层
本帖最后由 wex81997167 于 2016-11-4 15:01 编辑
能解决可以单独付费,这个是我整个段保存代码。现在是保存在内存中的淘木图片目录。我希望像QQ、微信那样存相册一保存就能够在相册看到。 试过直接存Camare,不会马上显示的,你可以多测试几款机型
Model.prototype.button4Click = function(event){
if(!justep.Browser.isX5App){
justep.Util.hint("请在App应用中使用该功能",{
"type":"danger",
});
return;
}
var row = this.comp("supplierGoodData");
var self = this;
this.comp("savePicPopOver").show();
function successCallback(fileDownloadResult) {
self.comp("savePicPopOver").hide();
if(justep.Browser.isIOS){
justep.Util.hint("'" + row.val("GoodName") + "'图片已保存到相册",{
type:"success"
});
} else if(justep.Browser.isAndroid){
justep.Util.hint("'" + row.val("GoodName") + "''图片已保存到手机内存中'淘木图片',建议通过'文件管理'工具查看",{
type:"success"
});
}
}
function errorCallback(FileTransferError) {
self.comp("savePicPopOver").hide();
justep.Util.hint("图片保存失败",{
"type":"warning",
});
}
var supplierGoodData = this.comp("supplierGoodData");
var fImages = supplierGoodData.val("PictureUrl");
var operateType = "download";
var src = null,json={},arr=[];
if (fImages !== null && fImages !== "" && fImages !== "[]") {
this.actionUrl = "/baas/taomuBaas/taomu/upGoodImg";
var imageList = eval("("+fImages+")");
var html = "";
if(justep.Browser.isIOS){
for(var n=0;n<imageList.length;n++){
var storeFileName = imageList[n].storeFileName;
var realFileName = imageList[n].realFileName ;
var ownerID = imageList[n].ownerID;
var url = this.actionUrl + '?realFileName=' + realFileName + '&storeFileName=' + storeFileName + '&ownerID=' + ownerID + '&operateType=' + operateType;
src = require.toUrl(url);
var host = window.location.host;
var eu = encodeURI("http://"+host+src);
var aDown = new FileTransfer();
aDown.saveToAlbum(eu, successCallback, errorCallback);
}
} else if(justep.Browser.isAndroid){
for(var n=0;n<imageList.length;n++){
var storeFileName = imageList[n].storeFileName;
var realFileName = imageList[n].realFileName ;
var ownerID = imageList[n].ownerID;
var url = this.actionUrl + '?realFileName=' + realFileName + '&storeFileName=' + storeFileName + '&ownerID=' + ownerID + '&operateType=' + operateType;
src = require.toUrl(url);
var host = window.location.host;
var eu = encodeURI("http://"+host+src);
// var filePath = cordova.file.externalRootDirectory+"/DCIM/Camera/"+realFileName;//"/"+src.replace(reg, '');
var filePath = cordova.file.externalRootDirectory+"/淘木图片/"+realFileName;
var aDown = new FileTransfer();
// 1下载文件的服务器地址,2保存设备上的URL,3下载成功回调,4下载失败回调,5可选参数 , 是否接收安全证书缺省为false。6可选参数 当前请求消息头
aDown.download(eu, filePath, successCallback, errorCallback, false, null);
}
}
}
}; |
|