美文网首页
uniapp上传图片

uniapp上传图片

作者: jesse28 | 来源:发表于2024-01-15 10:45 被阅读0次
 //识别车辆号牌
    identifyImg() {
      this.carShow = false;
      //选取图片
      lj.chooseImage({
        count: 1,
        success: (res) => {
          console.log("res", res);
          lj.showLoading({
            mask: true,
            title: "识别中...",
          });
          uni.uploadFile({
            url: `${recognise}/baiduAPI/getLicense`,
            // file: res?.tempFiles[0],
            filePath:res?.tempFilePaths[0],//注意这里要用filePath,不然真机不行
            name: "file",
            // header:{
            //   'content-type':'multipart/form-data'
            // },
            fail:(err)=>{
              lj.hideLoading();
            },
            success: (res) => {
              console.log("上传1", res);
              console.log("上传2", JSON.parse(res.data));
              if (JSON.parse(res.data)?.resMap?.data?.number) {
                this.form.vehicleNumber = JSON.parse(
                  res.data
                )?.resMap?.data?.number;
                const maps = {
                  blue: "蓝",
                  green: "绿",
                  yellow: "黄",
                };
                this.form.vehicleNumberColor =
                  maps[JSON.parse(res.data)?.resMap?.data?.color];
                this.form.vehicleNumberColorShow =
                  this.vehicleNumberColorColumns.find(
                    (item) => item.value === this.form.vehicleNumberColor
                  )?.label;
                this.$forceUpdate();
                this.vehicleNumberChange();
                lj.hideLoading();
              } else {
                lj.hideLoading();
                lj.showToast({
                  title: "识别失败",
                  duration: 2000,
                  icon: "none",
                });
              }
            },
          });
        },
      });
    },

相关文章

网友评论

      本文标题:uniapp上传图片

      本文链接:https://www.haomeiwen.com/subject/bgqhodtx.html