zoukankan      html  css  js  c++  java
  • pc端微信上传BUG

    PC 端微信打开小程序 上传 临时路径返回wxfile://tmp 
    本地测试无法打开 后端无法接收
    修改代码

     // /线下支付==》上传
      upHeaderPhoto() {
        const that = this;
        wx.chooseImage({
          count: 1,
          sizeType: ['original', 'compressed'],
          sourceType: ['album', 'camera'],
          success(res) {
            // tempFilePath可以作为img标签的src属性显示图片
            const tempFilePaths = res.tempFilePaths
            let imgPathArr = []
            tempFilePaths.forEach((item, index) => {
              console.log(tempFilePaths[index], '虚拟路径图片')
              wx.uploadFile({
                url: api.get_UpdataWxCode,
                filePath: tempFilePaths[index],
                name: 'file',
                formData: {
                  'paytype': 1,
                  "type": 'paycertificate'
                },
                header: {
                  // 'Content-Type': 'multipart/form-data',(这个地方注释掉就可以了 解决PC打开微信小程序上传路径的问题)
                  'X-Requested-With': 'XMLHttpRequest',
                  'user-token': wx.getStorageSync('user_token'),
                },
                responseType: 'text',
                success: (res) => {
                  console.log(JSON.parse(res.data), '服务器返回的微信图片')
                  imgPathArr.push(JSON.parse(res.data).data.src)
                  that.setData({
                    imgPathArr: that.data.imgPathArr.concat(imgPathArr)
                  })
                }
              })
            })
            // }
          }
        })
      },
    

      

     

  • 相关阅读:
    C语言32个关键字详解
    C语言格式控制符
    c++关键字详解
    多码流简介
    Jtag管脚定义
    关于RGB信号的电平
    缩略语MSPS
    【转】松下18650的容量判别方法
    电信号在FR4材料中的传播速度
    dropout voltage
  • 原文地址:https://www.cnblogs.com/xiaoxiaoxun/p/13521813.html
Copyright © 2011-2022 走看看