Commit 249594b5efb9e8a402bceccdcc667a257aec3bea
1 parent
ea291b39
提交登陆
Showing
4 changed files
with
76 additions
and
9 deletions
src/api/mycar.js
... | ... | @@ -9,3 +9,29 @@ export function getPersonCarNumPC() { |
9 | 9 | method: 'post' |
10 | 10 | }) |
11 | 11 | } |
12 | + | |
13 | +/** | |
14 | + * 绑定车牌 | |
15 | + * @param params | |
16 | + */ | |
17 | +export function boundCarNum(params) { | |
18 | + return request({ | |
19 | + url: '/personCarNumPc/boundCarNum', | |
20 | + method: 'post', | |
21 | + params | |
22 | + }) | |
23 | +} | |
24 | + | |
25 | +/** | |
26 | + * 解绑车牌 | |
27 | + * @param params | |
28 | + */ | |
29 | +export function unboundCarNum(params) { | |
30 | + return request({ | |
31 | + url: '/personCarNumPc/unboundCarNum', | |
32 | + method: 'post', | |
33 | + params | |
34 | + }) | |
35 | +} | |
36 | + | |
37 | + | ... | ... |
src/store/modules/user.js
... | ... | @@ -32,7 +32,6 @@ const actions = { |
32 | 32 | return new Promise((resolve, reject) => { |
33 | 33 | login({ userPhone: phone.trim(), validatorCode: password }).then(response => { |
34 | 34 | const { data } = response |
35 | - debugger; | |
36 | 35 | commit('SET_TOKEN', data.token) |
37 | 36 | setToken(data.token) |
38 | 37 | resolve() |
... | ... | @@ -47,11 +46,9 @@ const actions = { |
47 | 46 | return new Promise((resolve, reject) => { |
48 | 47 | getInfo(state.token).then(response => { |
49 | 48 | const { data } = response |
50 | - | |
51 | 49 | if (!data) { |
52 | 50 | reject('Verification failed, please Login again.') |
53 | 51 | } |
54 | - | |
55 | 52 | const { custName, headPicUrl } = data |
56 | 53 | |
57 | 54 | commit('SET_NAME', custName) | ... | ... |
src/views/login/index.vue
src/views/mycar/index.vue
... | ... | @@ -67,7 +67,7 @@ |
67 | 67 | </template> |
68 | 68 | |
69 | 69 | <script> |
70 | - import {getPersonCarNumPC} from '@/api/mycar.js'; | |
70 | + import {getPersonCarNumPC,boundCarNum,unboundCarNum} from '@/api/mycar.js'; | |
71 | 71 | export default { |
72 | 72 | data() { |
73 | 73 | var carNumValidator = (rule, value, callback) => { |
... | ... | @@ -75,7 +75,7 @@ |
75 | 75 | callback(new Error('请输入车牌号')); |
76 | 76 | } |
77 | 77 | |
78 | - if ( !/^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$/.test(this.bondform.carNum)||this.bondform.carNum.length<8) { | |
78 | + if (!/^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$/.test(this.bondform.carNum)||this.bondform.carNum.length<7) { | |
79 | 79 | callback(new Error('请输入正确的车牌号')); |
80 | 80 | } |
81 | 81 | callback(); |
... | ... | @@ -84,7 +84,7 @@ |
84 | 84 | return { |
85 | 85 | form: { |
86 | 86 | custId: '', |
87 | - phone: '' | |
87 | + phone: '', | |
88 | 88 | }, |
89 | 89 | /**绑定车牌.*/ |
90 | 90 | bondform: { |
... | ... | @@ -108,9 +108,27 @@ |
108 | 108 | methods: { |
109 | 109 | /**绑定车牌*/ |
110 | 110 | bondCarNum:function(formName){ |
111 | + let that = this; | |
112 | + let custId = this.form.custId; | |
113 | + let carNum = this.bondform.carNum; | |
111 | 114 | this.$refs[formName].validate((valid) => { |
112 | 115 | if (valid) { |
113 | - alert('submit!'); | |
116 | + let req ={ | |
117 | + custId:custId, | |
118 | + carNumber:carNum, | |
119 | + sysCode:'1001', | |
120 | + carBindingStatus:1, //绑定 | |
121 | + }; | |
122 | + boundCarNum(req).then(response =>{ | |
123 | + if(response.code='8888'){ | |
124 | + that.bondform.carNum=''; | |
125 | + this.$message({ | |
126 | + type: 'success', | |
127 | + message: '车牌绑定成功!' | |
128 | + }); | |
129 | + | |
130 | + } | |
131 | + }); | |
114 | 132 | } else { |
115 | 133 | console.log('error submit!!'); |
116 | 134 | return false; |
... | ... | @@ -129,7 +147,34 @@ |
129 | 147 | }, |
130 | 148 | /**解绑车牌.*/ |
131 | 149 | alredyBoundCarBtn:function (carNum) { |
132 | - debugger | |
150 | + if("" == carNum || null ==carNum || undefined == carNum){ | |
151 | + this.$message({ | |
152 | + type: 'error', | |
153 | + message: '解绑的车牌不能为空' | |
154 | + }); | |
155 | + } | |
156 | + let that =this; | |
157 | + let custId = this.form.custId; | |
158 | + let req ={ | |
159 | + custId:custId, | |
160 | + carNumber:carNum, | |
161 | + sysCode:'1001', | |
162 | + carBindingStatus:2, //解绑 | |
163 | + }; | |
164 | + unboundCarNum(req).then(response =>{ | |
165 | + if(response.code ='8888'){ | |
166 | + this.$message({ | |
167 | + type: 'success', | |
168 | + message: '车牌解绑成功!' | |
169 | + }); | |
170 | + this.getPersonCarNumPC(); | |
171 | + }else{ | |
172 | + this.$message({ | |
173 | + type: 'error', | |
174 | + message: '车牌解绑失败!' | |
175 | + }); | |
176 | + } | |
177 | + }); | |
133 | 178 | } |
134 | 179 | }, |
135 | 180 | mounted:function(){ | ... | ... |