微信小程序上传pdf和显示

引用:https://blog.csdn.net/qq_54027065/article/details/129854339

js 复制代码
     loadResume(){
        let that = this
        uni.showLoading({
          title:"下载中"
        })
        wx.downloadFile({
          url:url,
          success:(res)=>{
            console.log(res,"res11111")
            if (res.statusCode === 200){
              setTimeout(()=>{
                wx.openDocument({
                  filePath: res.tempFilePath,
                  fileType:"pdf"
                })

                // toast("加载成功")
                uni.hideLoading()
              },1000)
            }else{
              toast("文件不存在或者服务器报错")
              setTimeout(()=>{
                uni.hideLoading()
              },1000)
            }
          },
          error:()=>{
            uni.hideLoading()
          },
          finally:()=>{
            // uni.hideLoading()
          }
        })
      },
      uploadResume(){
        console.log("upload resume")
        wx.chooseMessageFile({
          count:1,
          type:"file",
          success:(res)=>{
            console.log(res,"res11")
            let path = res.tempFiles[0].path
            console.log(path,"path")

            var suffix = path.split(".")[1];
            if (suffix !== "pdf"){
              toast("只能上传pdf的文件")
              return
            }


            uni.showLoading({
              title:"上传中",
              mask:true
            })

            wx.uploadFile({
                url:url,
                header:{
                  "Authorization":getToken()
                },
                name:"file",
                filePath:path,
              success:(res)=>{
                  console.log(res,"hehe123")
                  if (res.statusCode === 200){

                    this.form.reviewInfo.resumeUrl = res.data
                    toast("上传成功")

                  }else{
                    toast("上传失败")
                  }

                  setTimeout(()=>{
                    uni.hideLoading()

                  },2000)
              },
              fail:(res)=>{
                toast("上传失败")
                setTimeout(()=>{
                  uni.hideLoading()

                },2000)
              }
            })


          }
        })
      },
相关推荐
忧郁的Mr.Li1 小时前
JAVA工具类---PDF电子签章工具类
java·pdf
AscendKing2 小时前
免费、易用、覆盖全平台的网页转 PDF 工具
pdf·html·网页保存·网页保存为pdf·保存网页位pdf
优化控制仿真模型3 小时前
【26年6月四级】英语四级高频核心词汇1500个pdf电子版+真题
经验分享·pdf
优化控制仿真模型3 小时前
【26大英赛】2012-2026年全国大学生英语竞赛ABCD类历年真题、样题及答案电子版PDF
经验分享·pdf
开开心心_Every4 小时前
内存清理软件灵活设置,自动阈值快捷键清
运维·服务器·pdf·web3·电脑·excel·共识算法
IT大师兄吖4 小时前
PaddleOCR-VL-1.5 PDF转MD 懒人整合包 界面微调
pdf
Miss 古月先生7 小时前
thinkphp6.0 html生成pdf
后端·pdf·php
胡单纯7 小时前
AI 直接解析 PDF 文档!OpenClaw 2026.3.3 新功能实测太强了
数据库·人工智能·pdf
开开心心就好7 小时前
操作简单的ISO文件编辑转换工具
java·前端·科技·edge·pdf·安全威胁分析·ddos
私人珍藏库18 小时前
【Windows】PDF超能助手(1.0.13)
windows·pdf·工具·软件·多功能