uni.uploadFile() 成功后返回数据为JSON.stringify()

      uni.chooseVideo({
        sourceType: ['camera'],
        success: (file) => {
          uni.showLoading({
            title: '正在上传认证视频'
          })
          uni.uploadFile({
            url: `${baseUrl}/authenticate/certbyfacevideo.json`,
            name: 'file',
            filePath: file.tempFilePath,
            formData: {
              name: this.$store.state?.certification?.userIdCardInfo?.name,
              idCardNo: this.$store.state?.certification?.userIdCardInfo?.idCardNo,
            },
            header: {
              'X-Requested-With': 'XMLHttpRequest'
            },
            fail: () => {
              uni.hideLoading()
              uni.showToast({
                title: '上传视频失败',
                icon: 'none',
                duration: 2500
              })
            },
            success: ({ data }) => {
              // =======这里返回的 data 是JSON字符串啊========
              const resData = JSON.parse(data)
              JSON.stringify()
              uni.hideLoading()
              if (Number(resData.flag) === 1) {
                uni.showToast({
                  title: '认证成功',
                  icon: 'none',
                  duration: 2500
                })
                uni.navigateTo({
                  url: '/pages/verificationCodeSMS/index'
                })
              } else {
                uni.showToast({
                  title: resData.msg || '认证失败',
                  icon: 'none',
                  duration: 2500
                })
              }
            }
          });
        },
        fail: (error) => {
          uni.showToast({
            title: error.errMsg || 'Error',
            icon: 'none',
            duration: 2500
          })
        }
      })

 

上一篇:vue上传文件前台及后台接收【我】


下一篇:字符串Hash