Commit acc7ee230ce5fe24f0e2b4283cf92032aac82fda
1 parent
7a7226feae
Exists in
master
购物车,用户推荐,新增验光逻辑修改
Showing
4 changed files
with
191 additions
and
183 deletions
Show diff stats
src/pages/cart/cart.vue
... | ... | @@ -93,8 +93,8 @@ export default { |
93 | 93 | computed: { |
94 | 94 | |
95 | 95 | cartList() { |
96 | - // console.log('cart-list', this.$store.state.cart.cartList); | |
97 | - return this.$store.state.cart.cartList | |
96 | + // console.log('cart-list', this.$store.state.cart.cartList); | |
97 | + return this.$store.state.cart.cartList | |
98 | 98 | }, |
99 | 99 | childIsOpen() { |
100 | 100 | const temp = [] |
... | ... | @@ -107,97 +107,24 @@ export default { |
107 | 107 | } |
108 | 108 | }, |
109 | 109 | onLoad: function() { |
110 | - // 判断是否授权 | |
111 | - // uni.getSetting({ | |
112 | - // success(res) { | |
113 | - // console.log('authSetting',res.authSetting) | |
114 | - // if(res.authSetting['scope.userInfo'] !== true) { | |
115 | - | |
116 | - // uni.switchTab({ | |
117 | - // url:'/pages/user/user' | |
118 | - // }) | |
119 | - // }else { | |
120 | - // } | |
121 | - // } | |
122 | - // }) | |
123 | - | |
124 | - // console.log('usr-my',this.$store.state.user.userInfo) | |
125 | - // store.dispatch('cart/addCart',{ | |
126 | - // "num":1, | |
127 | - // "pid": 7,//产品id | |
128 | - // "uid":1, | |
129 | - // "sk_id": 72, | |
130 | - // "price": 120, | |
131 | - // "mp_id":1, | |
132 | - // "checkedSKU":{ | |
133 | - // "discount": "45", | |
134 | - // "in_price": "6000", | |
135 | - // "kc": "0", | |
136 | - // "model_pic": null, | |
137 | - // "out_price": 191.8, | |
138 | - // "pic": "https://glass.xiuyetang.com//upload_jk/7/7_22AE0C.jpg", | |
139 | - // "pid": "7", | |
140 | - // "real_price": 99, | |
141 | - // "sk_id": "89", | |
142 | - // "sku_name": "1.56非球面防蓝光_黑", | |
143 | - // "sku_shop_value": "", | |
144 | - // "sku_value": "58_61", | |
145 | - // "status": "1", | |
146 | - // }, | |
147 | - // }); | |
110 | + // store.dispatch('cart/addCart', { | |
111 | + // uid: this.$store.state.user.userInfo.uid, | |
112 | + // openid: this.$store.state.user.userInfo.openid, | |
113 | + // mp_id: 7, | |
114 | + // sk_id: 7, | |
115 | + // num: 1, | |
116 | + // pid: 8, | |
117 | + // price: 128, | |
118 | + // checkedSKU:{}, | |
119 | + // }) | |
148 | 120 | store.dispatch('cart/getCartList', { |
149 | - uid: 1 // 用户id | |
121 | + uid: this.$store.state.user.userInfo.uid // 用户id | |
150 | 122 | }) |
123 | + | |
151 | 124 | }, |
152 | 125 | |
153 | 126 | methods: { |
154 | - // 跳转到对应的选购页面 | |
155 | - // toshop(id,type){ | |
156 | - // console.log('===',id,type) | |
157 | - // switch(type){ | |
158 | - // case 1: | |
159 | - // uni.navigateTo({ | |
160 | - // url: `../detailsChoiceArgs/detailsChoiceArgs?oderId=`+id+`&goodType=`+type, | |
161 | - // success: res => {}, | |
162 | - // fail: () => {}, | |
163 | - // complete: () => {} | |
164 | - // }); | |
165 | - // break; | |
166 | - // case 2: | |
167 | - // uni.navigateTo({ | |
168 | - // url: `../detailStandard/detailStandard_k?oderId=`+id+`&goodType=`+type, | |
169 | - // success: res => {}, | |
170 | - // fail: () => {}, | |
171 | - // complete: () => {} | |
172 | - // }); | |
173 | - // break; | |
174 | - // case 3||4: | |
175 | - // uni.navigateTo({ | |
176 | - // url: `../detailStandard/detailStandard_sun?oderId=`+id+`&goodType=`+type, | |
177 | - // success: res => {}, | |
178 | - // fail: () => {}, | |
179 | - // complete: () => {} | |
180 | - // }); | |
181 | - // break; | |
182 | - // // case 4: | |
183 | - // // uni.navigateTo({ | |
184 | - // // url: `../detailStandard/detailStandard_sun?oderId=`+id+`&goodType=`+type, | |
185 | - // // success: res => {}, | |
186 | - // // fail: () => {}, | |
187 | - // // complete: () => {} | |
188 | - // // }); | |
189 | - // case 5: | |
190 | - // uni.navigateTo({ | |
191 | - // url: `../purchaseLenses/purchaseLenses?oderId=`+id+`&goodType=`+type, | |
192 | - // success: res => {}, | |
193 | - // fail: () => {}, | |
194 | - // complete: () => {} | |
195 | - // }); | |
196 | - // break; | |
197 | - // default : | |
198 | - // break | |
199 | - // } | |
200 | - // }, | |
127 | + | |
201 | 128 | toGoods(id, type) { |
202 | 129 | uni.navigateTo({ |
203 | 130 | url: '../frameDetail/frameDetail?oderId=' + id, |
... | ... | @@ -254,9 +181,12 @@ export default { |
254 | 181 | } else { |
255 | 182 | this.addDisabled = true |
256 | 183 | // 修改num |
184 | + if(this.childIsOpen[index]){ | |
185 | + this.totalPrice = this.totalPrice + this.$store.state.cart.cartList[index].nowPrice | |
186 | + } | |
257 | 187 | store.dispatch('cart/modiCart', { |
258 | - uid: 1, | |
259 | - // openid: '', | |
188 | + uid: this.$store.state.user.userInfo.uid, | |
189 | + openid: this.$store.state.user.userInfo.openid, | |
260 | 190 | mp_id: mp_id, |
261 | 191 | sk_id: sk_id, |
262 | 192 | cart_id: cart_id, |
... | ... | @@ -274,9 +204,12 @@ export default { |
274 | 204 | } else { |
275 | 205 | this.desDisabled = false |
276 | 206 | // post 请求修改相关参数 |
207 | + if(this.childIsOpen[index]){ | |
208 | + this.totalPrice = this.totalPrice - this.$store.state.cart.cartList[index].nowPrice | |
209 | + } | |
277 | 210 | store.dispatch('cart/modiCart', { |
278 | - uid: 1, | |
279 | - // openid: '', | |
211 | + uid: this.$store.state.user.userInfo.uid, | |
212 | + openid: this.$store.state.user.userInfo.openid, | |
280 | 213 | mp_id: mp_id, |
281 | 214 | sk_id: sk_id, |
282 | 215 | cart_id: cart_id, |
... | ... | @@ -289,6 +222,9 @@ export default { |
289 | 222 | this.desDisabled = true |
290 | 223 | } |
291 | 224 | } |
225 | + // store.dispatch('cart/getCartList', { | |
226 | + // uid: this.$store.state.user.userInfo.uid // 用户id | |
227 | + // }) | |
292 | 228 | }, |
293 | 229 | |
294 | 230 | Change(isopen, indexC) { |
... | ... | @@ -340,8 +276,8 @@ export default { |
340 | 276 | if (res.confirm) { |
341 | 277 | // this.$store.state.cart.cartList.splice(index,1) |
342 | 278 | store.dispatch('cart/delCart', { |
343 | - uid: 1, // 用户id | |
344 | - openid: '', | |
279 | + uid: this.$store.state.user.userInfo.uid, | |
280 | + openid: this.$store.state.user.userInfo.openid, | |
345 | 281 | cart_id: cart_id, // 要修改的购物车id |
346 | 282 | arg: index // 由于action 传参是能接收两参数,因此将index放入对象 |
347 | 283 | }) | ... | ... |
src/pages/newOpticsData/newOpticsData.vue
... | ... | @@ -161,13 +161,14 @@ |
161 | 161 | confirm: false, // 用户是否确认 |
162 | 162 | tabicon:['/static/detail-button.png','/static/detail-button-unselected.png'], |
163 | 163 | name: '夏小花', |
164 | + oldname:'',// 用于判读用户是否改变名字 | |
164 | 165 | pickerInfoChioce:{ |
165 | - "leftSph": 0, | |
166 | - "rightSph": 0, | |
167 | - "leftCyl": 0, | |
168 | - "rightCyl": 0, | |
169 | - "leftAxi": 0, | |
170 | - "rightAxi": 0, | |
166 | + "leftSph": '', | |
167 | + "rightSph": '', | |
168 | + "leftCyl": '', | |
169 | + "rightCyl": '', | |
170 | + "leftAxi": '', | |
171 | + "rightAxi": '', | |
171 | 172 | "time":{ |
172 | 173 | "year":0, |
173 | 174 | "month": 0, |
... | ... | @@ -175,6 +176,7 @@ |
175 | 176 | } |
176 | 177 | }, |
177 | 178 | pd: '',// 瞳距 |
179 | + oldpd: '',// 用于判断用户是否改变瞳距 | |
178 | 180 | kinds:Number, // kinds=1,提交为新增验光,2为修改 |
179 | 181 | mp_id: Number |
180 | 182 | }; |
... | ... | @@ -225,6 +227,8 @@ |
225 | 227 | this.name=loveList[option.index].name |
226 | 228 | this.pd=loveList[option.index].pd |
227 | 229 | this.mp_id=loveList[option.index].mp_id |
230 | + this.oldname=loveList[option.index].name | |
231 | + this.oldpd=loveList[option.index].pd | |
228 | 232 | // 将kinds =2时的值传到该页面 |
229 | 233 | this.pickerInfoList[0].nameArray1.unshift(loveList[option.index].leftSph) |
230 | 234 | this.pickerInfoList[0].nameArray2.unshift(loveList[option.index].rightSph) |
... | ... | @@ -258,7 +262,7 @@ |
258 | 262 | uni.showToast({ |
259 | 263 | title:"请输入有效数据;示例:89", |
260 | 264 | icon: "none", |
261 | - duration: 3000, | |
265 | + duration: 2000, | |
262 | 266 | }) |
263 | 267 | this.pd = '' |
264 | 268 | } |
... | ... | @@ -270,88 +274,158 @@ |
270 | 274 | uni.showToast({ |
271 | 275 | title:"请输入验光单取名", |
272 | 276 | icon: "none", |
273 | - duration: 3000, | |
277 | + duration: 2000, | |
274 | 278 | }) |
275 | - } | |
276 | - if(this.pd==''){ | |
277 | - uni.showToast({ | |
278 | - title:"请输入瞳距", | |
279 | - icon: "none", | |
280 | - duration: 3000, | |
281 | - }) | |
282 | - } | |
283 | - if(this.confirm){ | |
284 | - if(this.kinds==1){ | |
285 | - // 添加用户验光单 | |
286 | - console.log('kinds====>',this.kinds) | |
287 | - store.dispatch('myLoveList/addMylove', { | |
288 | - | |
289 | - uid: this.$store.state.user.userInfo.uid, | |
290 | - openid: this.$store.state.user.userInfo.openid, | |
291 | - // mp_name: this.$store.state.user.userInfo.mp_name, | |
292 | - leftSph: this.pickerInfoChioce.leftSph, | |
293 | - rightSph: this.pickerInfoChioce.rightSph, | |
294 | - leftCyl: this.pickerInfoChioce.leftCyl, | |
295 | - rightCyl: this.pickerInfoChioce.rightCyl, | |
296 | - leftAxi: this.pickerInfoChioce.leftAxi, | |
297 | - rightAxi: this.pickerInfoChioce.rightAxi, | |
298 | - pd: this.pd,// 瞳距 | |
299 | - mp_name:this.name, | |
300 | - // time: this.pickerInfoChioce.time, | |
301 | - // img_url2: "http://localhost:8087/images/shop_1/1/", | |
302 | - }); | |
303 | - store.dispatch('myLoveList/getLoveList', { | |
304 | - uid: this.$store.state.user.userInfo.uid, | |
305 | - }); | |
306 | - uni.navigateBack({ | |
307 | - delta:1, | |
308 | - animationDuration:2000 | |
309 | - }) | |
310 | - } | |
311 | - if(this.kinds==2){ | |
312 | - // console.log('kinds====>',this.kinds) | |
313 | - // console.log('pickerindex=====>',this.pickerInfoList[0].nameIndex1) | |
314 | - // console.log('this.pickerInfoChioce====>',type(this.pickerInfoChioce)) | |
315 | - const leftList = ["leftSph","leftCyl","leftAxi"]; | |
316 | - const rightList = ["rightSph", "rightCyl", "rigthAxi"]; | |
317 | - for (let j=0; j<3; j++) { | |
318 | - if(this.pickerInfoList[j].nameIndex1!=0){ | |
279 | + }else{ | |
280 | + | |
281 | + if(this.pd==''){ | |
282 | + uni.showToast({ | |
283 | + title:"请输入瞳距", | |
284 | + icon: "none", | |
285 | + duration: 2000, | |
286 | + }) | |
287 | + }else{ | |
288 | + | |
289 | + if(this.kinds==1){ | |
290 | + // 添加用户验光单 | |
291 | + console.log('kinds====>',this.pickerInfoChioce.leftSph) | |
292 | + console.log('kinds====>',this.pickerInfoChioce.leftSph==Number) | |
293 | + console.log('kinds====>',this.pickerInfoChioce.rightSph==Number) | |
294 | + if(this.pickerInfoChioce.rightSph==''||this.pickerInfoChioce.leftSph==''|| | |
295 | + this.pickerInfoChioce.leftCyl==''||this.pickerInfoChioce.rightCyl==''|| | |
296 | + this.pickerInfoChioce.leftAxi==''||this.pickerInfoChioce.rightAxi=='' | |
297 | + ){ | |
298 | + uni.showToast({ | |
299 | + title:"请输入您的验光数据", | |
300 | + icon: "none", | |
301 | + duration: 2000, | |
302 | + }) | |
303 | + }else{ | |
304 | + if(this.confirm){ | |
305 | + store.dispatch('myLoveList/addMylove', { | |
306 | + | |
307 | + uid: this.$store.state.user.userInfo.uid, | |
308 | + openid: this.$store.state.user.userInfo.openid, | |
309 | + // mp_name: this.$store.state.user.userInfo.mp_name, | |
310 | + leftSph: this.pickerInfoChioce.leftSph, | |
311 | + rightSph: this.pickerInfoChioce.rightSph, | |
312 | + leftCyl: this.pickerInfoChioce.leftCyl, | |
313 | + rightCyl: this.pickerInfoChioce.rightCyl, | |
314 | + leftAxi: this.pickerInfoChioce.leftAxi, | |
315 | + rightAxi: this.pickerInfoChioce.rightAxi, | |
316 | + pd: this.pd,// 瞳距 | |
317 | + mp_name:this.name, | |
318 | + // time: this.pickerInfoChioce.time, | |
319 | + // img_url2: "http://localhost:8087/images/shop_1/1/", | |
320 | + }); | |
321 | + store.dispatch('myLoveList/getLoveList', { | |
322 | + uid: this.$store.state.user.userInfo.uid, | |
323 | + }); | |
324 | + uni.navigateBack({ | |
325 | + delta:1, | |
326 | + animationDuration:2000 | |
327 | + }) | |
328 | + | |
329 | + } else{ | |
330 | + uni.showToast({ | |
331 | + title:"请确认您的验光数据", | |
332 | + icon: "none", | |
333 | + duration: 3000, | |
334 | + }) | |
335 | + } | |
319 | 336 | |
320 | - store.dispatch('myLoveList/updateMylove', { | |
321 | - uid: this.$store.state.user.userInfo.uid, | |
322 | - openid: this.$store.state.user.userInfo.openid, | |
323 | - mp_id: this.mp_id, | |
324 | - keyname: leftList[j], | |
325 | - keyvalue: this.pickerInfoList[j].nameArray1[this.pickerInfoList[j].nameIndex1], | |
326 | - }); | |
327 | - } | |
328 | - if(this.pickerInfoList[j].nameIndex2 !=0) { | |
329 | - store.dispatch('myLoveList/updateMylove', { | |
330 | - uid: this.$store.state.user.userInfo.uid, | |
331 | - openid: this.$store.state.user.userInfo.openid, | |
332 | - mp_id: this.mp_id, | |
333 | - keyname: rightList[j], | |
334 | - keyvalue: this.pickerInfoList[j].nameArray2[this.pickerInfoList[j].nameIndex2] | |
335 | - }); | |
336 | 337 | } |
338 | + | |
337 | 339 | } |
338 | - store.dispatch('myLoveList/getLoveList', { | |
339 | - uid: this.$store.state.user.userInfo.uid, | |
340 | - }); | |
341 | - uni.navigateBack({ | |
342 | - delta:1, | |
343 | - animationDuration:2000 | |
344 | - }) | |
340 | + if(this.kinds==2){ | |
341 | + // console.log('kinds====>',this.kinds) | |
342 | + // console.log('pickerindex=====>',this.pickerInfoList[0].nameIndex1) | |
343 | + // console.log('this.pickerInfoChioce====>',type(this.pickerInfoChioce)) | |
344 | + if(this.confirm){ | |
345 | + const leftList = ["leftSph","leftCyl","leftAxi"]; | |
346 | + const rightList = ["rightSph", "rightCyl", "rightAxi"]; | |
347 | + let flag=0; | |
348 | + if(this.name!=this.oldname){ | |
349 | + store.dispatch('myLoveList/updateMylove', { | |
350 | + uid: this.$store.state.user.userInfo.uid, | |
351 | + openid: this.$store.state.user.userInfo.openid, | |
352 | + mp_id: this.mp_id, | |
353 | + keyname: 'name', | |
354 | + keyvalue: this.name, | |
355 | + }); | |
356 | + flag=1 | |
357 | + } | |
358 | + if(this.pd!=this.oldpd){ | |
359 | + store.dispatch('myLoveList/updateMylove', { | |
360 | + uid: this.$store.state.user.userInfo.uid, | |
361 | + openid: this.$store.state.user.userInfo.openid, | |
362 | + mp_id: this.mp_id, | |
363 | + keyname: 'pd', | |
364 | + keyvalue: this.pd, | |
365 | + }); | |
366 | + flag=1 | |
367 | + } | |
368 | + // 先验证是否有改动项, | |
369 | + for (let j=0; j<3; j++) { | |
370 | + if(this.pickerInfoList[j].nameIndex1!=0||this.pickerInfoList[j].nameIndex2!=0){ | |
371 | + if(this.pickerInfoList[j].nameArray1[this.pickerInfoList[j].nameIndex1]!=''&& | |
372 | + this.pickerInfoList[j].nameArray2[this.pickerInfoList[j].nameIndex2]!=''){ | |
373 | + if(this.pickerInfoList[j].nameIndex1!=0){ | |
374 | + store.dispatch('myLoveList/updateMylove', { | |
375 | + uid: this.$store.state.user.userInfo.uid, | |
376 | + openid: this.$store.state.user.userInfo.openid, | |
377 | + mp_id: this.mp_id, | |
378 | + keyname: leftList[j], | |
379 | + keyvalue: this.pickerInfoList[j].nameArray1[this.pickerInfoList[j].nameIndex1], | |
380 | + }); | |
381 | + } | |
382 | + if(this.pickerInfoList[j].nameIndex2!=0){ | |
383 | + store.dispatch('myLoveList/updateMylove', { | |
384 | + uid: this.$store.state.user.userInfo.uid, | |
385 | + openid: this.$store.state.user.userInfo.openid, | |
386 | + mp_id: this.mp_id, | |
387 | + keyname: rightList[j], | |
388 | + keyvalue: this.pickerInfoList[j].nameArray2[this.pickerInfoList[j].nameIndex2] | |
389 | + }); | |
390 | + } | |
391 | + flag=1; | |
392 | + } else{ | |
393 | + flag=0; | |
394 | + uni.showToast({ | |
395 | + title:"请输入您的验光数据", | |
396 | + icon: "none", | |
397 | + duration: 2000, | |
398 | + }) | |
399 | + | |
400 | + } | |
401 | + } | |
402 | + | |
403 | + } | |
404 | + if(flag!=0){ | |
405 | + store.dispatch('myLoveList/getLoveList', { | |
406 | + uid: this.$store.state.user.userInfo.uid, | |
407 | + }); | |
408 | + uni.navigateBack({ | |
409 | + delta:1, | |
410 | + animationDuration:2000 | |
411 | + }) | |
412 | + } | |
345 | 413 | |
414 | + } else{ | |
415 | + uni.showToast({ | |
416 | + title:"请确认您的验光数据", | |
417 | + icon: "none", | |
418 | + duration: 3000, | |
419 | + }) | |
420 | + } | |
421 | + | |
422 | + } | |
423 | + | |
424 | + | |
346 | 425 | } |
347 | - | |
348 | - } else{ | |
349 | - uni.showToast({ | |
350 | - title:"请确认你的验光数据", | |
351 | - icon: "none", | |
352 | - duration: 3000, | |
353 | - }) | |
426 | + | |
354 | 427 | } |
428 | + | |
355 | 429 | }, |
356 | 430 | changeConfirm() { |
357 | 431 | this.confirm = !this.confirm | ... | ... |
src/pages/user/user.vue
src/store/modules/cart.js
... | ... | @@ -20,11 +20,7 @@ const mutations = { |
20 | 20 | MODI: (state, args) => { |
21 | 21 | console.log('the num', state.cartList[args.index].num) |
22 | 22 | console.log('mutations====>isadd', args) |
23 | - if (args.isadd) { | |
24 | - state.cartList[args.index].num = args.num | |
25 | - } else { | |
26 | - state.cartList[args.index].num = args.num | |
27 | - } | |
23 | + state.cartList[args.index].num = args.num | |
28 | 24 | console.log('the num', state.cartList[args.index].num) |
29 | 25 | } |
30 | 26 | |
... | ... | @@ -53,14 +49,15 @@ const actions = { |
53 | 49 | }, |
54 | 50 | |
55 | 51 | modiCart({ commit }, param) { |
56 | - const args = Object.assign({ num: param.num }, param.args) | |
52 | + const arg = Object.assign({ num: param.num }, param.args) | |
57 | 53 | delete param.args |
58 | 54 | request({ |
59 | 55 | url: cartModi, |
60 | 56 | data: param, |
61 | 57 | success: (res) => { |
58 | + console.log('modiCart-res=====>',res.data) | |
62 | 59 | console.log('modi-parm', param) |
63 | - commit('MODI', args) | |
60 | + commit('MODI', arg) | |
64 | 61 | }, |
65 | 62 | fail: (res) => { |
66 | 63 | console.log('fail status === > ', res) | ... | ... |