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


          }
        })
      },
相关推荐
weixin_584121433 小时前
vue3+ts导出PDF
javascript·vue.js·pdf
Access开发易登软件5 小时前
Access开发导出PDF的N种姿势,你get了吗?
后端·低代码·pdf·excel·vba·access·access开发
SY_FC11 小时前
uniapp阿里云验证码使用
阿里云·uni-app·notepad++
沐雪架构师11 小时前
Docling将pdf转markdown以及与AI生态集成
人工智能·pdf
kevin 111 小时前
扫描件、PDF、图片都能比对!让文档差异无所遁形
大数据·人工智能·pdf
algonaut11 小时前
adobe acrobat 安装到使用再到PDF编辑【适合小白,只看一篇就够!!!】
java·开发语言·其他·pdf
拓端研究室16 小时前
专题:2025电力行业5G工厂及绿色转型、市场机制研究报告|附100+份报告PDF、数据仪表盘汇总下载
5g·pdf
zlpzlpzyd18 小时前
jodconverter将word转pdf底层libreoffice的问题
pdf·word
weixin_4721835419 小时前
微信小程序预览和分享文件
微信小程序·小程序