Commit bbbb96245d25362500acdc6d31c6ec243ddb06a7
1 parent
5d00ef92
车牌认证
Showing
3 changed files
with
83 additions
and
22 deletions
src/api/myCars/myCars.js
src/router/index.js
... | ... | @@ -98,8 +98,8 @@ export default new Router({ |
98 | 98 | { |
99 | 99 | path: "/rzCarNumber", |
100 | 100 | name: "rzCarNumber", |
101 | - component: () => import("@/views//mySelf/myCars/rzCarNumber.vue") | |
102 | - // meta: {title: "认证车牌"} | |
101 | + component: () => import("@/views//mySelf/myCars/rzCarNumber.vue"), | |
102 | + meta: {title: "认证车牌"} | |
103 | 103 | }, |
104 | 104 | { |
105 | 105 | path: "/cardList", | ... | ... |
src/views/mySelf/myCars/rzCarNumber.vue
... | ... | @@ -7,9 +7,9 @@ |
7 | 7 | |
8 | 8 | <div style="padding: 10px 10px"> |
9 | 9 | |
10 | - <van-uploader style="width: 100%" :after-read="afterRead" v-model="fileList" :max-count="1" preview-size="200"> | |
10 | + <van-uploader style="width: 100%" :after-read="afterRead" v-model="fileList" :max-count="1" preview-size="350"> | |
11 | 11 | |
12 | - <!--<!–<div class="uploadBg"></div>–>--> | |
12 | + <div class="uploadBg"></div> | |
13 | 13 | <!--<van-image style="width: 100%;height: 200px;"--> |
14 | 14 | <!--:src="require('../../../assets/images/myCars/fornt.png')" />--> |
15 | 15 | </van-uploader> |
... | ... | @@ -30,7 +30,6 @@ |
30 | 30 | </h6> |
31 | 31 | |
32 | 32 | <van-button type="info" round block style="margin-top: 40px;" @click="toMyCarsPage">立即验证</van-button> |
33 | - | |
34 | 33 | </div> |
35 | 34 | |
36 | 35 | </div> |
... | ... | @@ -38,13 +37,15 @@ |
38 | 37 | </template> |
39 | 38 | |
40 | 39 | <script> |
41 | -import { uploadPic } from "@/api/myCars/myCars"; | |
40 | +import axios from 'axios' | |
41 | +import { uploadPic, userCarsInfoEdit } from "@/api/myCars/myCars"; | |
42 | 42 | export default { |
43 | 43 | name: "rzCarNumber", |
44 | 44 | data() { |
45 | 45 | return { |
46 | 46 | fileList: [], |
47 | - path:'' | |
47 | + path:'', | |
48 | + picSrc:'', | |
48 | 49 | }; |
49 | 50 | }, |
50 | 51 | created() { |
... | ... | @@ -53,7 +54,9 @@ export default { |
53 | 54 | methods: { |
54 | 55 | afterRead(file) { |
55 | 56 | // 此时可以自行将文件上传至服务器 |
56 | - console.log(file); | |
57 | + // console.log(file); | |
58 | + // console.log(file.content) | |
59 | + // this.picSrc = file.content | |
57 | 60 | // this.path = file.content |
58 | 61 | this.uploadPic(file) |
59 | 62 | }, |
... | ... | @@ -68,29 +71,81 @@ export default { |
68 | 71 | if(this.fileList.length==0){ |
69 | 72 | this.$toast('请先上传图片') |
70 | 73 | }else{ |
71 | - | |
74 | + let jsondata = {} | |
75 | + let arr = []; | |
76 | + let carlist = { | |
77 | + carNumber: this.$route.query.carNumber, | |
78 | + cerPicturePath: this.path, | |
79 | + carNumberColor: this.$route.query.carNumberColor, | |
80 | + id: this.$route.query.id | |
81 | + }; | |
82 | + arr.push(carlist); | |
83 | + // 状态;1-已使用,0-未使用, 2-已使用+未使用 | |
84 | + jsondata.optType = "02"; | |
85 | + jsondata.carNumbers = JSON.stringify(arr); | |
86 | + jsondata.sign = this.$utils.signObject(jsondata); | |
87 | + userCarsInfoEdit(jsondata).then(response => { | |
88 | + console.log(response); | |
89 | + if(response.code==0){ | |
90 | + this.$router.push({ | |
91 | + name: "myCars" | |
92 | + } | |
93 | + ); | |
94 | + } | |
95 | + }); | |
72 | 96 | } |
73 | 97 | }, |
74 | 98 | uploadPic(file) { |
75 | 99 | |
100 | + let data = new FormData(); | |
101 | + data.append('picFile', file.file); | |
102 | + data.append('fileType', '11'); | |
103 | + data.append('token', this.$utils.userToken); | |
104 | + let config = { | |
105 | + headers: { //添加请求头 | |
106 | + "Content-Type": "multipart/form-data" | |
107 | + } | |
108 | + }; | |
109 | + // jsondata.sign = this.$utils.signObject(jsondata) | |
110 | + //上传图片 | |
111 | + axios.post("https://pay.ccccitd.cc/pic/uploadPic",data, config).then(res => { | |
112 | + console.log(res.data); | |
113 | + console.log(res.data.data); | |
114 | + this.path = res.data.data | |
115 | + // console.log(this.path); | |
116 | + }) | |
117 | + | |
76 | 118 | |
77 | 119 | |
78 | 120 | |
79 | - let params=new FormData(); | |
80 | - params.append('file',file.file); | |
81 | - params.append('fileType','11'); | |
82 | - params.sign = this.$utils.signObject(params); | |
121 | + // params.sign = this.$utils.signObject(params); | |
83 | 122 | //uploafile为自定义上传路径,记得引入 |
123 | + // var jsondata = { | |
124 | + // fileType: '11', | |
125 | + // picFile: file.content | |
126 | + // } | |
127 | + // jsondata.sign = this.$utils.signObject(jsondata); | |
84 | 128 | |
85 | - uploadPic({ | |
86 | - filePath: file.content, | |
87 | - name: "picFile", | |
88 | - formData: params, | |
89 | - }).then((res) => { | |
129 | + // let formData=new FormData(); | |
130 | + // formData.append('picFile',file); | |
131 | + // formData.append('fileType','11'); | |
132 | + // formData.append("token", this.$utils.userToken) | |
133 | + // console.log(this.$utils.userToken) | |
90 | 134 | |
91 | - //上传成功返回结果 | |
92 | - console.log(res); | |
93 | - }); | |
135 | + // var jsondata = { | |
136 | + // fileType: '11', | |
137 | + // picFile: file[0] | |
138 | + // } | |
139 | + // uploadPic({ | |
140 | + // filePath: file[0], | |
141 | + // name: "picFile", | |
142 | + // | |
143 | + // formData: this.$utils.signObject(jsondata) | |
144 | + // }).then((res) => { | |
145 | + // | |
146 | + // //上传成功返回结果 | |
147 | + // console.log(res); | |
148 | + // }); | |
94 | 149 | |
95 | 150 | |
96 | 151 | |
... | ... | @@ -123,4 +178,8 @@ export default { |
123 | 178 | background-size: 100% 100%; |
124 | 179 | |
125 | 180 | } |
181 | + | |
182 | + >>> .van-uploader__input-wrapper{ | |
183 | + width: 100%; | |
184 | + } | |
126 | 185 | </style> | ... | ... |