|
@@ -1,5 +1,6 @@
|
|
|
import methods from "@/common/methodTool";
|
|
|
export function download(url) {
|
|
|
+ url = methods.splitImgHost(url);
|
|
|
// #ifdef H5
|
|
|
window.location.href = url;
|
|
|
// #endif
|
|
@@ -34,7 +35,10 @@ function saveImgToLoca(url) {
|
|
|
uni.getFileSystemManager().saveFile({
|
|
|
tempFilePath,
|
|
|
success: function (res) {
|
|
|
- console.log("🚀 ~ file: util.js:37 ~ uni.getFileSystemManager ~ res:", res)
|
|
|
+ console.log(
|
|
|
+ "🚀 ~ file: util.js:37 ~ uni.getFileSystemManager ~ res:",
|
|
|
+ res
|
|
|
+ );
|
|
|
uni.showToast({
|
|
|
title: "保存成功",
|
|
|
icon: "none",
|
|
@@ -76,3 +80,37 @@ function saveImgToLoca(url) {
|
|
|
},
|
|
|
});
|
|
|
}
|
|
|
+export function preview(url) {
|
|
|
+ url = methods.splitImgHost(url);
|
|
|
+ // #ifdef H5
|
|
|
+ uni.navigateTo({
|
|
|
+ url: `/pages/webview/sdlink?url=https://preview.xyyxt.net?src=${url}`,
|
|
|
+ });
|
|
|
+ // #endif
|
|
|
+ // #ifdef MP-WEIXIN
|
|
|
+ uni.downloadFile({
|
|
|
+ url: url,
|
|
|
+ success: ({ tempFilePath }) => {
|
|
|
+ uni.openDocument({
|
|
|
+ filePath: tempFilePath,
|
|
|
+ showMenu: true,
|
|
|
+ success: (res) => {},
|
|
|
+ fail: (err) => {
|
|
|
+ uni.showToast({
|
|
|
+ icon: "none",
|
|
|
+ title: "文档地址错误",
|
|
|
+ });
|
|
|
+ },
|
|
|
+ });
|
|
|
+ },
|
|
|
+ fail: (err) => {
|
|
|
+ this.downLoading = false;
|
|
|
+ uni.showModal({
|
|
|
+ title: "提示",
|
|
|
+ content: "文档错误," + err.errMsg,
|
|
|
+ showCancel: false,
|
|
|
+ });
|
|
|
+ },
|
|
|
+ });
|
|
|
+ // #endif
|
|
|
+}
|