当前位置: 首页 > article >正文

微信小程序上传pdf和显示

引用:https://blog.csdn.net/qq_54027065/article/details/129854339

     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)
              }
            })


          }
        })
      },

http://www.kler.cn/a/400503.html

相关文章:

  • 使用python编写工具:快速生成chrome插件相关文件结构
  • iOS逆向入门:使用theos注入第三方依赖库
  • KUKU FM 音频Linux平台免费下载工具
  • 防火墙----iptables
  • 鸿蒙next版开发:拍照实现方案(ArkTS)
  • llm 从0开始学习大语言模型, transformer架构学习
  • Rust “xxx“.to_string()和Rust String::from(“xxx“)区别(将字符串字面量(str类型)转换为String类型)
  • 数学建模——模型假设环节介绍
  • 基于单片机的手持金属探测仪设计
  • UE5入门教程:蓝图变量
  • 表格的选择弹窗,选中后返显到表格中
  • 在应用启动时,使用 UniApp 提供的 API 检查和请求权限。
  • 避免误差!Android 中正确计算时间差的方式
  • 网页web无插件播放器EasyPlayer.js H.265流媒体播放器的decoder.js报Unexpected token ‘<‘错误
  • 大麦抢票科技
  • [AI] 如何让计算机具备核心直觉知识:从常识推理到具身智能
  • 高并发的API请求有哪些注意事项?
  • 2024版本IDEA创建Sprintboot项目下载依赖缓慢
  • 正在执行例行维护 请一分钟后回来
  • ASP.NET Core Webapi 返回数据的三种方式