-
zhangwei
2025-01-23 e5a77d6a551d13e4cf74624b31b0fa3e328b304d
src/common/utils/util.js
@@ -838,5 +838,33 @@
         }
      }
   },
   checkFileExtensions(str) {
      const extensions = ['pdf', 'doc', 'docx', 'xls', 'xlsx'];
      return extensions.some(extension => str.includes(extension));
   },
   previewWechat(urlPdf) {
      uni.showLoading({
         title: '正在加载中..'
      })
      uni.downloadFile({
         url: urlPdf,
         success: function(res) {
            var filePath = res.tempFilePath;
            const index = urlPdf.lastIndexOf(".");
            const suffix = urlPdf.substring(index + 1);
            uni.openDocument({
               fileType: suffix,
               filePath: filePath,
               showMenu: true,
               success: function(res) {
                  console.log('打开文档成功');
                  uni.hideLoading()
               },
            });
         },
         complete: function(r) {
            uni.hideLoading()
         }
      });
   },
}