export class 文件 {
	static 保存(路径, 调用成功, 调用失败, 调用结束) {
		var bianliang = {
			tempFilePath: 路径
		}
		if (调用成功 !== undefined) {
			bianliang.success = function (e) {
				var b = {
					存储文件路径: e.savedFilePath
				}
				调用成功(b)
			}
		}
		if (调用失败 !== undefined) {
			bianliang.fail = 调用失败
		}
		if (调用结束 !== undefined) {
			bianliang.complete = 调用结束
		}
		wx.saveFile(bianliang)
	}

	static 删除(路径, 调用成功, 调用失败, 调用结束) {
		var bianliang = {
			filePath: 路径
		}
		if (调用成功 !== undefined) {
			bianliang.success = 调用成功
		}
		if (调用失败 !== undefined) {
			bianliang.fail = 调用失败
		}
		if (调用结束 !== undefined) {
			bianliang.complete = 调用结束
		}
		wx.removeSavedFile(bianliang)
	}

	static 打开(路径, 类型, 调用成功, 调用失败, 调用结束) {
		var bianliang = {
			filePath: 路径
		}
		if (类型 !== undefined) {
			bianliang.fileType = 类型
		}
		if (调用成功 !== undefined) {
			bianliang.success = 调用成功
		}
		if (调用失败 !== undefined) {
			bianliang.fail = 调用失败
		}
		if (调用结束 !== undefined) {
			bianliang.complete = 调用结束
		}
		wx.openDocument(bianliang)
	}

	static 获取缓存文件列表(调用成功, 调用失败, 调用结束) {
		var bianliang = {}
		if (调用成功 !== undefined) {
			bianliang.success = function (e) {
				var 缓存文件项目数组 = e.fileList;
				e.fileList.forEach(function (item, index) {
					缓存文件项目数组[index].文件路径 = e.fileList[index].filePath,
					缓存文件项目数组[index].文件大小 = e.fileList[index].size,
					缓存文件项目数组[index].保存时间戳 = e.fileList[index].createTime
				})
				调用成功(缓存文件项目数组)
			}
		}
		if (调用失败 !== undefined) {
			bianliang.fail = 调用失败
		}
		if (调用结束 !== undefined) {
			bianliang.complete = 调用结束
		}
		wx.getSavedFileList(bianliang)
	}

	static 取本地文件信息(路径, 调用成功, 调用失败, 调用结束) {
		wx.getSavedFileInfo({
			filePath: 路径,
			success: 调用成功,
			fail: 调用失败,
			complete: 调用结束
		})
	}

	static 取文件信息(路径, 摘要算法, 调用成功, 调用失败, 调用结束) {
		wx.getFileInfo({
			filePath: 路径,
			digestAlgorithm: 摘要算法,
			success: 调用成功,
			fail: 调用失败,
			complete: 调用结束
		})
	}

}