2021/04/26 16:12
6551
公司继续在插件开发方面发力。近日,公司开发出安卓app 附件预览插件,还能够支付动态添加水印。
本插件适用安卓版本区间:5.0 - 11.0。能够覆盖目前绝大多数安卓手机。
在App.vue配置初始化
复制代码onLaunch: function() { console.log('App Launch') console.log("初始化插件。") const yszyunOpenModule = uni.requireNativePlugin('yszyun-OpenModule');
yszyunOpenModule.init()
},openDocFile(path, title)
plus.io.convertLocalFileSystemURL("tempFilePath")
str1: '水印测试', str2: '测试人员2',
const openModule = uni.requireNativePlugin('yszyun-OpenModule');
{ var _this = this;
uni.showLoading({ title: "文件下载中"
}) const downloadTask = uni.downloadFile({ url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-81f1d72a-96c3-47b4-ab95-0a2aaf322724/' + url, success: (res) => { if (res.statusCode === 200) { console.log("下载成功 res res.tempFilePath:" + JSON.stringify(res));
_this.filePaths = plus.io.convertLocalFileSystemURL(res.tempFilePath); console.log("下载成功 res res.filePaths:" + _this.filePaths);
uni.hideLoading()
uni.showModal({ title: '提示', content: "下载完成,打开" + title, success: function(res) { if (res.confirm) { console.log('用户点击确定');
_this.openDocFile(_this.filePaths, title)
} else if (res.cancel) { console.log('用户点击取消');
}
}
});
}
}
});
downloadTask.onProgressUpdate((res) => { console.log('下载进度' + res.progress); console.log('已经下载的数据长度' + res.totalBytesWritten); console.log('预期需要下载的数据总长度' + res.totalBytesExpectedToWrite);
});
},
openDocFile(path, title) {
yszyunOpenModule.openFile({ docPath: path, docName: title
}, { angle: 20, isShow: true, str1: '水印测试', str2: '测试人员2', txtColor: '#44000000', txtSize: 12, verSpacing: 300, horSpacing: 150, strSpacing: 15, verPadding: 40, horPadding: 20
});
}



