微信小程序上传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)
              }
            })


          }
        })
      },
相关推荐
qq_422152579 小时前
PDF 加水印工具怎么选?2026 年文档版权保护方案对比
前端·pdf·github
杨浦老苏18 小时前
PDF文档管理平台PDFManager
docker·pdf·工具·群晖
rickys208018 小时前
腾讯会议截图自动去除黑边转PDF
pdf·腾讯会议
2601_9618752419 小时前
法考资料电子版|pdf|资料已整理
elasticsearch·搜索引擎·pdf·全文检索·solr·lucene·sphinx
kidding72319 小时前
高效备忘清单工具类小程序
前端·计算机网络·微信小程序·小程序
前端 贾公子1 天前
小程序蓝牙打印探索与实践 (最终章)
前端·微信小程序·小程序
matlab_xiaowang1 天前
WeasyPrint:把 HTML 变成 PDF 的文档工厂
前端·其他·pdf·html
子非衣1 天前
Java使用Aspose进行Word转PDF时异常卡主问题
java·pdf·word
俊哥工具1 天前
027免费开源硬盘检测工具,一键查看健康度,杜绝数据丢失
pdf·电脑·word·excel·音视频
小羊Yveesss1 天前
2026年个人能做微信小程序吗?
微信小程序·小程序