Blame view

src/views/carManage/certification.vue 4.1 KB
002e5c7b   刘淇   添加车牌
1
2
3
4
  <template>
    <div>
      <group>
        <cell>
76b0bb3d   刘淇   车辆认证
5
6
          <p slot="title">车牌号码:{{ $route.query.carNum }}</p>
          <p slot class="carColor" :class="carBgFilter($route.query.carNumberColor)"></p>
002e5c7b   刘淇   添加车牌
7
8
9
10
        </cell>
      </group>
  
      <div style="padding: 15px;position: relative">
76b0bb3d   刘淇   车辆认证
11
        <img :src="carPic" width="100%" height="180px">
002e5c7b   刘淇   添加车牌
12
13
14
15
16
        <div class="camera"></div>
        <input type="file" class="upload" @change="addImg" ref="inputer"
               accept="image/png,image/jpeg,image/gif,image/jpg"/>
  
      </div>
002e5c7b   刘淇   添加车牌
17
18
19
20
21
22
23
24
25
26
27
      <div class="tipWrap">
        <span>照片须符合如下条件:</span>
        <p>
          1、行驶证正面。
        </p>
        <p>
          2、信息清晰显示真实有效。
        </p>
      </div>
  
      <div style="padding: 20px 15px">
76b0bb3d   刘淇   车辆认证
28
        <x-button type="primary" @click.native="cerHandle">提交认证</x-button>
002e5c7b   刘淇   添加车牌
29
30
31
32
33
34
      </div>
  
    </div>
  </template>
  
  <script>
76b0bb3d   刘淇   车辆认证
35
36
  
  import { userCarsInfoEdit, uploadPic } from "@/api/myCars/myCars";
002e5c7b   刘淇   添加车牌
37
38
39
40
  export default {
    name: "certification",
    data() {
      return {
76b0bb3d   刘淇   车辆认证
41
        carPic: require("../../assets/images/myCars/carPic.png"),
002e5c7b   刘淇   添加车牌
42
        formData: new FormData(),
76b0bb3d   刘淇   车辆认证
43
        fil: ""
002e5c7b   刘淇   添加车牌
44
45
46
      };
    },
    methods: {
76b0bb3d   刘淇   车辆认证
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
      addImg(e) {
        // this.formData = new window.FormData();
        // 获取待上传的文件对象
        this.fil = e.target.files[0];
        console.log(this.fil);
        let file = e.target.files[0];
        // 声明一个读取文件对象
        let reader = new FileReader();
        // 开始读取文件内容
        reader.readAsDataURL(file);
        // 读取操作结束时触发
        reader.onloadend = (ev) => {
          // 赋值给vue对象属性
          this.carPic = ev.target.result;
        };
002e5c7b   刘淇   添加车牌
62
      },
76b0bb3d   刘淇   车辆认证
63
64
65
66
67
68
      cerHandle() {
        if (this.fil) {
          console.log(this.fil);
          let params = new FormData();
          params.append("picFile", this.fil);
          params.append("fileType", 7);
aabd3df4   刘淇   购买会员卡
69
          params.append("token", sessionStorage.getItem("wx_Token")); // sessionStorage.getItem("wx_Token")
76b0bb3d   刘淇   车辆认证
70
71
72
73
74
75
          uploadPic(params).then(data => {
            console.log(data);
            if (data.code == 0) {
              let res = data.data;
              this.rez(res);
            } else {
2690b31c   刘淇   车辆认证
76
              this.$vux.toast.text(data.message, "top");
76b0bb3d   刘淇   车辆认证
77
78
79
            }
          });
        } else {
2690b31c   刘淇   车辆认证
80
          this.$vux.toast.text("请先上传图片再认证", "top");
002e5c7b   刘淇   添加车牌
81
        }
002e5c7b   刘淇   添加车牌
82
      },
76b0bb3d   刘淇   车辆认证
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
      rez(res) {
        let arr = [];
        let carlist = {
          carNumber: this.$route.query.carNum,
          cerPicturePath: res,
          carNumberColor: this.$route.query.carNumberColor,
          id: this.$route.query.id
        };
        let jsondata = this.$utils.commonParams();
        arr.push(carlist);
        // 状态;1-已使用,0-未使用, 2-已使用+未使用
        jsondata.optType = "02";
        jsondata.carNumbers = JSON.stringify(arr);
        jsondata.sign = this.$utils.signObject(jsondata);
        userCarsInfoEdit(jsondata).then(data => {
          console.log(data);
          if (data.code == 0) {
            this.$router.push({
              path: "myCars"
            });
          } else {
            this.$vux.toast.text(data.message, "top");
          }
        });
      },
      carBgFilter: function(val) {
        console.log(val);
        // 车牌颜色:0:蓝牌;1:黄牌;2:白牌;3:黑牌;4:绿色
        if (val == 0) {
          return "blueBg";
        }
        if (val == 1) {
          return "yellowBg";
        }
        if (val == 2) {
          return "whiteBg";
        }
        if (val == 3) {
          return "blackBg";
        }
        if (val == 4) {
          return "greenBg";
        }
      }
    }
002e5c7b   刘淇   添加车牌
128
129
130
131
132
133
134
135
  };
  </script>
  
  <style scoped lang="scss">
    > > > .weui-cells {
      margin-top: 0;
    }
  
002e5c7b   刘淇   添加车牌
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
    .carPic {
      width: 100%;
      height: 160px;
      background: url("../../assets/images/myCars/carPic.png");
      background-size: 100% 100%;
    }
  
    .camera {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      width: 70px;
      height: 70px;
      background: url("../../assets/images/myCars/camera.png");
      background-size: 100% 100%;
    }
  
    .upload {
      width: 100%;
      height: 100%;
      opacity: 0;
      position: absolute;
      top: 0;
      left: 0;
      z-index: 100;
    }
  
    .tipWrap {
      padding: 15px;
      p {
        text-indent: 15px;
      }
    }
  </style>