|
- var UIPhotoViewer = api.require("UIPhotoViewer");
- UIPhotoViewer.clearCache();
- $api.fnRequestPermission(["storage"]).then(() => {
- UIPhotoViewer.open(
- {
- images: urls,
- activeIndex,
- bgColor: "#000",
- gestureClose: true,
- atime: 0,
- },
- (ret) => {
- var currentIndex = ret.index;
- if (ret.eventType === "show") {
- api.setScreenOrientation({ orientation: "auto" });
- }
- if (ret.eventType === "change" && callback) {
- callback(ret.index);
- }
- if (ret.eventType === "click") {
- api.setScreenOrientation({ orientation: "portrait_up" });
- UIPhotoViewer.close();
- } else if (ret.eventType === "gestureColse") {
- api.setScreenOrientation({ orientation: "portrait_up" });
- } else if (ret.eventType === "longPress") {
- if (!openDownload) return;
- api.actionSheet({ buttons: ["保存图片"] }, (ret) => {
- if (ret.buttonIndex === 1) {
- // 保存图片
- $api.saveImageToAlbum(urls[currentIndex]);
- }
- });
- }
- }
- );
- });
复制代码 |
|