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


          }
        })
      },
相关推荐
reasonsummer10 小时前
【办公类-53-09】20260131Python模仿制作2025学年第二学期校历(excel+pdf)
python·pdf
咖啡の猫10 小时前
微信小程序案例 - 自定义 tabBar
微信小程序·小程序·notepad++
心语星光11 小时前
用python语言的pyautogui库实现伪批量将xdf文件打印为pdf文件
开发语言·python·pdf·自动化
iReachers11 小时前
PDF一机一码加密大师1.1.0更新至2026最新版, 强力加密PDF, 无需额外安装阅读器, 附CSDN下载地址
pdf
咖啡の猫11 小时前
微信小程序全局数据共享
微信小程序·小程序
桐溪漂流11 小时前
微信小程序cli脚本预览上传
微信小程序·小程序
咖啡の猫11 小时前
微信小程序使用 npm 包
微信小程序·小程序·npm
web打印社区1 天前
前端开发实现PDF打印需求:从基础方案到专业解决方案
前端·vue.js·react.js·electron·pdf
东东5161 天前
xxx食堂移动预约点餐系统 (springboot+微信小程序)
spring boot·微信小程序·小程序·毕业设计·个人开发·毕设
Kratzdisteln1 天前
【MCM】(x= (N_A),y=(N_G),z=(p))RGB=T*
pdf