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


          }
        })
      },
相关推荐
2501_9209555737 分钟前
PDF文件损坏打不开怎么修复?2025年最新修复工具测评与对比
pdf
季春二九39 分钟前
PDF-XChange Editor丨加拿大PDF编辑转换工具
pdf
亮子AI6 小时前
【小程序】详细比较微信小程序的 onLoad 和 onShow
微信小程序·小程序
开开心心就好6 小时前
微软官方出品:免费数据恢复工具推荐
网络·笔记·microsoft·pdf·word·音视频·symfony
Dontla6 小时前
如何在PDF文档中打钩?(福昕阅读器)打√
pdf·福昕阅读器
拓端研究室6 小时前
2025全球生成式人工智能AIGC产业全景与行业应用研究报告|附900+份报告PDF、数据、可视化模板汇总下载
pdf·aigc
拓端研究室6 小时前
专题:2025中国制造业出海与出海品牌社媒影响力洞察报告|附300+份报告PDF、数据、绘图模板汇总下载
pdf
烽火连城诀6 小时前
PDF 全文翻译开发实现思路:挑战、细节与工程化解决方案
pdf·pdf全文翻译·pdf保持格式翻译·全文翻译·pdf版式保持
袁煦丞 cpolar内网穿透实验室6 小时前
Stirling-PDF合并拆分加密样样行:cpolar内网穿透实验室第563个成功挑战
pdf·远程工作·内网穿透·cpolar·pdf工具
小嘟嚷ovo6 小时前
h5单页预览PDF文件模糊问题解决
pdf