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


          }
        })
      },
相关推荐
窝窝和牛牛42 分钟前
记录小白使用 Cursor 开发第一个微信小程序(二):创建项目、编译、预览、发布(250308)
微信小程序·小程序
JobsandCzj8 小时前
PDF 分割工具
javascript·小程序·pdf
沈健_算法小生8 小时前
基于DeepSeek实现PDF嵌入SVG图片无损放大
pdf
人民广场吃泡面8 小时前
UniApp 运行的微信小程序如何进行深度优化
微信小程序·小程序·uni-app
编程毕设9 小时前
【含文档+PPT+源码】基于微信小程序的在线考试与选课教学辅助系统
java·微信小程序·小程序
d3soft11 小时前
【清华大学】实用DeepSeek赋能家庭教育 56页PDF文档完整版
ai·pdf·deepseek
开开心心就好12 小时前
电脑睡眠智能管控:定时、依状态灵活调整,多模式随心选
javascript·windows·python·安全·django·pdf·电脑
T-shmily13 小时前
Hbuilder X开发微信小程序:利用uni-app和uview UI框架创建项目详细步骤
微信小程序·uni-app
3D小将14 小时前
SolidWorks 转 PDF3D 技术详解
3d·pdf·3d格式转换·模型格式转换
伟贤AI之路16 小时前
夏门大学DeepSeek 手册:从社会大众到高校及企业的全面应用实践研究(附 PDF 下载)
pdf