其他分享
首页 > 其他分享> > uni.uploadFile() 成功后返回数据为JSON.stringify()

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

 

标签:stringify,showToast,title,uploadFile,JSON,duration,uni,2500
来源: https://blog.csdn.net/qq_41887214/article/details/114103638