Blame view

src/views/mySelf/myCars/rzCarNumber.vue 4.68 KB
5e52ed7c   刘淇   个人中心
1
2
3
4
  <template>
    <div style="background: #fff;width: 100%;height: 100%">
      <h3 style="padding: 10px 10px;border-bottom: 5px solid #f5f5f5">
        车牌号码:
176eff96   刘淇   添加车牌
5
        <b style="color:#2282C5">{{$route.query.carNumber}}</b>
5e52ed7c   刘淇   个人中心
6
7
8
9
      </h3>
  
      <div style="padding: 10px 10px">
  
bbbb9624   刘淇   车牌认证
10
        <van-uploader style="width: 100%" :after-read="afterRead" v-model="fileList" :max-count="1" preview-size="350">
5e52ed7c   刘淇   个人中心
11
  
bbbb9624   刘淇   车牌认证
12
          <div class="uploadBg"></div>
5e52ed7c   刘淇   个人中心
13
          <!--<van-image  style="width: 100%;height: 200px;"-->
176eff96   刘淇   添加车牌
14
          <!--:src="require('../../../assets/images/myCars/fornt.png')" />-->
5e52ed7c   刘淇   个人中心
15
16
17
        </van-uploader>
  
        <!--<div class="uploadBg">-->
176eff96   刘淇   添加车牌
18
        <!---->
5e52ed7c   刘淇   个人中心
19
20
21
        <!--</div>-->
  
  
acba8420   刘淇   车牌认证 上传图片
22
        <h4 style="padding-top: 30px;">
5e52ed7c   刘淇   个人中心
23
24
25
26
27
28
29
30
31
32
          照片须符合如下条件:
        </h4>
        <h6>
          1、行驶证正面
        </h6>
        <h6>
          2、信息清晰显示真实有效
        </h6>
  
        <van-button type="info" round block style="margin-top: 40px;" @click="toMyCarsPage">立即验证</van-button>
5e52ed7c   刘淇   个人中心
33
34
      </div>
  
5e52ed7c   刘淇   个人中心
35
36
37
38
39
    </div>
  
  </template>
  
  <script>
bbbb9624   刘淇   车牌认证
40
41
  import axios from 'axios'
  import { uploadPic, userCarsInfoEdit } from "@/api/myCars/myCars";
5e52ed7c   刘淇   个人中心
42
43
44
45
46
  export default {
    name: "rzCarNumber",
    data() {
      return {
        fileList: [],
bbbb9624   刘淇   车牌认证
47
48
        path:'',
        picSrc:'',
5e52ed7c   刘淇   个人中心
49
50
      };
    },
176eff96   刘淇   添加车牌
51
52
53
54
    created() {
      console.log(this.$route.query);
    },
    methods: {
5e52ed7c   刘淇   个人中心
55
56
      afterRead(file) {
        // 此时可以自行将文件上传至服务器
bbbb9624   刘淇   车牌认证
57
58
59
        // console.log(file);
        // console.log(file.content)
        // this.picSrc = file.content
d3808923   刘淇   停车记录
60
61
        // this.path = file.content
        this.uploadPic(file)
5e52ed7c   刘淇   个人中心
62
63
      },
      toMyCarsPage() {
176eff96   刘淇   添加车牌
64
65
66
67
68
69
70
71
72
73
        console.log(this.fileList);
        console.log(this.fileList.length);
        // this.$router.push({
        //     name: "myCars"
        //   }
        // );
  
        if(this.fileList.length==0){
          this.$toast('请先上传图片')
        }else{
bbbb9624   刘淇   车牌认证
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
          let jsondata = {}
          let arr = [];
          let carlist = {
            carNumber: this.$route.query.carNumber,
            cerPicturePath: this.path,
            carNumberColor: this.$route.query.carNumberColor,
            id: this.$route.query.id
          };
          arr.push(carlist);
          // 状态;1-已使用,0-未使用, 2-已使用+未使用
          jsondata.optType = "02";
          jsondata.carNumbers = JSON.stringify(arr);
          jsondata.sign = this.$utils.signObject(jsondata);
          userCarsInfoEdit(jsondata).then(response => {
            console.log(response);
            if(response.code==0){
              this.$router.push({
                  name: "myCars"
                }
              );
            }
          });
176eff96   刘淇   添加车牌
96
97
        }
      },
d3808923   刘淇   停车记录
98
99
      uploadPic(file) {
  
bbbb9624   刘淇   车牌认证
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
        let data = new FormData();
        data.append('picFile', file.file);
        data.append('fileType', '11');
        data.append('token', this.$utils.userToken);
        let config = {
          headers: { //添加请求头
            "Content-Type": "multipart/form-data"
          }
        };
        // jsondata.sign = this.$utils.signObject(jsondata)
        //上传图片
        axios.post("https://pay.ccccitd.cc/pic/uploadPic",data, config).then(res => {
          console.log(res.data);
          console.log(res.data.data);
          this.path = res.data.data
          // console.log(this.path);
        })
  
d3808923   刘淇   停车记录
118
119
120
  
  
  
bbbb9624   刘淇   车牌认证
121
        // params.sign = this.$utils.signObject(params);
d3808923   刘淇   停车记录
122
        //uploafile为自定义上传路径,记得引入
bbbb9624   刘淇   车牌认证
123
124
125
126
127
        // var jsondata = {
        //   fileType: '11',
        //   picFile: file.content
        // }
        // jsondata.sign = this.$utils.signObject(jsondata);
d3808923   刘淇   停车记录
128
  
bbbb9624   刘淇   车牌认证
129
130
131
132
133
        // let formData=new FormData();
        // formData.append('picFile',file);
        // formData.append('fileType','11');
        // formData.append("token", this.$utils.userToken)
        // console.log(this.$utils.userToken)
d3808923   刘淇   停车记录
134
  
bbbb9624   刘淇   车牌认证
135
136
137
138
139
140
141
142
143
144
145
146
147
148
        // var jsondata = {
        //   fileType: '11',
        //   picFile: file[0]
        // }
        // uploadPic({
        //   filePath: file[0],
        //   name: "picFile",
        //
        //   formData: this.$utils.signObject(jsondata)
        // }).then((res) => {
        //
        //   //上传成功返回结果
        //   console.log(res);
        // });
d3808923   刘淇   停车记录
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
  
  
  
  
        // let jsondata = {
        //   fileType: '11',
        //   picFile:file.file
        // };
        // // jsondata.sign = this.$utils.signObject(jsondata);
        // //通过formData上传文件
        // let formData = new FormData();
        // formData.append("file", file)
        // formData.append("fileType", '11')
        // uploadPic(jsondata).then(response => {
        //   console.log(jsondata)
        //   if(response.code=='0'){
        //
        //   }
        // });
5e52ed7c   刘淇   个人中心
168
169
170
171
172
173
      }
    }
  };
  </script>
  
  <style scoped>
176eff96   刘淇   添加车牌
174
175
176
177
178
    .uploadBg {
      width: 100%;
      height: 200px;
      background: #eee url("../../../assets/images/myCars/fornt.png") no-repeat;
      background-size: 100% 100%;
5e52ed7c   刘淇   个人中心
179
  
176eff96   刘淇   添加车牌
180
    }
bbbb9624   刘淇   车牌认证
181
182
183
184
  
    >>> .van-uploader__input-wrapper{
      width: 100%;
    }
5e52ed7c   刘淇   个人中心
185
  </style>