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

 

已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 技术黑板 设计师:CSDN官方博客 返回首页