Commit 0df2ead740c2c5c18dd1fe9405e3f3241100278f

Authored by BigBoss
1 parent a658edc461
Exists in master

确认订单传参修改&新增眼镜数据的录入功能

src/components/BottomSheet/BottomSheet.vue
... ... @@ -181,22 +181,22 @@
181 181 <view class="ipts">
182 182 <view class="inputItem">
183 183 <text class="text">镜片宽度</text>
184   - <input class="input" @input="glassInfoInput($event,0)" type="text" :value="glassInfo.glassWidth" placeholder="请输入镜片宽度"/>
  184 + <input class="input" @input="glassInfoInput($event,0)" type="text" :value="glassInfo.glassWidth!=='0'?glassInfo.glassWidth:''" placeholder="请输入镜片宽度"/>
185 185 </view>
186 186 <view class="inputItem">
187 187 <text class="text">鼻梁宽度</text>
188   - <input class="input" @input="glassInfoInput($event,1)" type="text" :value="glassInfo.norseWidth" placeholder="请输入鼻梁宽度"/>
  188 + <input class="input" @input="glassInfoInput($event,1)" type="text" :value="glassInfo.norseWidth!=='0'?glassInfo.norseWidth:''" placeholder="请输入鼻梁宽度"/>
189 189 </view>
190 190 <view class="inputItem">
191 191 <text class="text">镜腿长度</text>
192   - <input class="input" @input="glassInfoInput($event,2)" type="text" :value="glassInfo.legWidth" placeholder="请输入镜腿长度"/>
  192 + <input class="input" @input="glassInfoInput($event,2)" type="text" :value="glassInfo.legWidth!=='0'?glassInfo.legWidth:''" placeholder="请输入镜腿长度"/>
193 193 </view>
194 194  
195 195 </view>
196   - <view class="confirm">
  196 + <!-- <view class="confirm">
197 197 <image class="image1" :src="confirm ? tabicon[0] : tabicon[1]" @tap="changeConfirm"></image>
198 198 <text>确认以上输入信息来源于我的验光数据!</text>
199   - </view>
  199 + </view> -->
200 200 </view>
201 201 </template>
202 202 <template v-else>
... ... @@ -332,8 +332,8 @@ import store from &#39;@/store&#39;
332 332 { nameC: '散光轴位', nameE: '(AXI)', nameArray1: [''], nameIndex1: 0, nameArray2: [''], nameIndex2: 0, key: 2 },
333 333 { nameC: '验光日期', nameE: '', nameArray1: [''], nameIndex1: 0, nameArray2: ['', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], nameIndex2: 0, nameArray3: [''], nameIndex3: 0 },
334 334 ],
335   - confirm: false, // 用户是否确认
336   - tabicon: ['/static/detail-button.png', '/static/detail-button-unselected.png'],
  335 + // confirm: false, // 用户是否确认
  336 + // tabicon: ['/static/detail-button.png', '/static/detail-button-unselected.png'],
337 337 name: '',
338 338 oldname: '', // 用于判读用户是否改变名字
339 339 pickerInfoChioce: {
... ... @@ -350,8 +350,8 @@ import store from &#39;@/store&#39;
350 350 },
351 351 },
352 352 glassInfo:{
353   - norseWidth:Number,//鼻宽
354 353 glassWidth:Number,//镜片宽度
  354 + norseWidth:Number,//鼻宽
355 355 legWidth:Number//镜腿长度
356 356 },
357 357 pd: '', // 瞳距
... ... @@ -420,7 +420,18 @@ import store from &#39;@/store&#39;
420 420  
421 421 return this.$store.state.myLoveList.loveList
422 422 },
  423 + glassInfoRight(){
  424 + const glassInfoArr = Object.values(this.glassInfo)
  425 + // console.log('glassInfoArr',glassInfoArr.find(item => item == '0'))
  426 + return glassInfoArr.find(item => item == '0') ==undefined
  427 + }
423 428 },
  429 + // beforeDestroy() {
  430 + // //获取关心的人列表
  431 + // store.dispatch('myLoveList/getLoveList', {
  432 + // uid: this.$store.state.user.userInfo.uid,
  433 + // });
  434 + // },
424 435 created() {
425 436 this.skuValueArray = this.skuList[0].sku_value.split("_")
426 437 // console.log(this.sk_id)
... ... @@ -439,13 +450,10 @@ import store from &#39;@/store&#39;
439 450 }else{
440 451 this.skId = this.sk_id
441 452 }
442   -
443 453 //获取关心的人列表
444 454 store.dispatch('myLoveList/getLoveList', {
445 455 uid: this.$store.state.user.userInfo.uid,
446 456 });
447   -
448   -
449 457 // 初始化SPL、CYL、AXI的值
450 458 for (let j = 0; j < 3; j++) {
451 459 for (let i = -12; i < 6; i++) {
... ... @@ -478,11 +486,14 @@ import store from &#39;@/store&#39;
478 486 },
479 487 name : "bottomSheet",
480 488 methods: {
  489 + //判断眼镜数据是否为0
481 490 checkGlassInfo(){
482   - const glassInfoArr = Object.values(this.glassInfo)
483   - if(glassInfoArr.find(item => item == '0') !=='undefind'){
484   - uni.showModal({
485   - title:'请完善镜框数据~'
  491 + // const glassInfoArr = Object.values(this.glassInfo)
  492 + // console.log(this.glassInfoRight)
  493 + if(!this.glassInfoRight){
  494 + uni.showToast({
  495 + title:'请完善镜框数据~',
  496 + icon:'none'
486 497 })
487 498 }
488 499 },
... ... @@ -491,8 +502,6 @@ import store from &#39;@/store&#39;
491 502 const glassWidth = this.glassInfo.glassWidth
492 503 const norseWidth = this.glassInfo.norseWidth
493 504 const legWidth = this.glassInfo.legWidth
494   - console.log(loveItem.glassWidth)
495   - console.log(glassWidth)
496 505 if(loveItem.glassWidth !== glassWidth){
497 506 store.dispatch('myLoveList/updateMylove', {
498 507 uid: this.$store.state.user.userInfo.uid,
... ... @@ -552,34 +561,38 @@ import store from &#39;@/store&#39;
552 561 },
553 562 comfirmChoose(){
554 563 this.checkGlassInfo()
555   - this.updateMylove()
556   - const price = this.skuList.filter(item=>item.sk_id == this.skId)[0].real_price
557   - this.$emit("chooseCartModi",this.mp_id,this.skId,price,this.pid,this.count,this.cart_id,this.index)//添加购物车
558   - this.$emit("closeBottom")
  564 + if(this.glassInfoRight){
  565 + this.updateMylove()
  566 + const price = this.skuList.filter(item=>item.sk_id == this.skId)[0].real_price
  567 + this.$emit("chooseCartModi",this.mp_id,this.skId,price,this.pid,this.count,this.cart_id,this.index)//添加购物车
  568 + this.$emit("closeBottom")
  569 + }
559 570 },
560 571 addCart(){
561 572 this.checkGlassInfo()
562   - this.updateMylove()
563   - const that = this
564   - const checkedSKUName = [that.goodInfo.attrList[0].meta_name,that.goodInfo.attrList[1].meta_name]
565   - const checkedSKU = []
566   - let j;
567   - for (let i = 0;i<that.current.length;i++) {
568   - checkedSKU.push(that.goodInfo.attrList[i].attr[that.current[i]])
569   - // console.log('i', i, j, i !== this.current.length - 1)
570   - if (i !== this.current.length - 1) {
571   - // 后续需修改算法:目前暂定只有两个参数选择,后续若有多个参数需要修改实现自适应
572   - j = this.current[i] * this.attrList[1].attr.length
573   - } else {
574   - j += this.current[i]
575   - }
  573 + if(this.glassInfoRight){
  574 + this.updateMylove()
  575 + const that = this
  576 + const checkedSKUName = [that.goodInfo.attrList[0].meta_name,that.goodInfo.attrList[1].meta_name]
  577 + const checkedSKU = []
  578 + let j;
  579 + for (let i = 0;i<that.current.length;i++) {
  580 + checkedSKU.push(that.goodInfo.attrList[i].attr[that.current[i]])
  581 + // console.log('i', i, j, i !== this.current.length - 1)
  582 + if (i !== this.current.length - 1) {
  583 + // 后续需修改算法:目前暂定只有两个参数选择,后续若有多个参数需要修改实现自适应
  584 + j = this.current[i] * this.attrList[1].attr.length
  585 + } else {
  586 + j += this.current[i]
  587 + }
  588 + }
  589 + const price = this.skuList.filter(item=>item.sk_id == this.skuList[j].sk_id)[0].real_price
  590 + let sk_id = this.skuList[j].sk_id
  591 + // console.log('选择的商品sk_id',sk_id,'选择的商品参数',checkedSKU)
  592 + // console.log('mp_id',this.mp_id,'数量',this.count)
  593 + this.$emit("addCart",this.mp_id,this.count,checkedSKU,sk_id,price)//添加购物车
  594 + this.$emit("closeBottom")//关闭弹窗
576 595 }
577   - const price = this.skuList.filter(item=>item.sk_id == this.skuList[j].sk_id)[0].real_price
578   - let sk_id = this.skuList[j].sk_id
579   - // console.log('选择的商品sk_id',sk_id,'选择的商品参数',checkedSKU)
580   - // console.log('mp_id',this.mp_id,'数量',this.count)
581   - this.$emit("addCart",this.mp_id,this.count,checkedSKU,sk_id,price)//添加购物车
582   - this.$emit("closeBottom")//关闭弹窗
583 596 },
584 597 onClickLoveItem(index,name){
585 598 const loveList = this.loveList
... ... @@ -689,9 +702,9 @@ import store from &#39;@/store&#39;
689 702 this.pd = ''
690 703 }
691 704 },
692   - changeConfirm() {
693   - this.confirm = !this.confirm
694   - },
  705 + // changeConfirm() {
  706 + // this.confirm = !this.confirm
  707 + // },
695 708 bindPickerChange01: function(e) {
696 709 this.pickerInfoList[0].nameIndex1 = e.target.value
697 710 this.pickerInfoChioce.leftSph = this.pickerInfoList[0].nameArray1[e.target.value]
... ... @@ -763,9 +776,6 @@ import store from &#39;@/store&#39;
763 776 } else {
764 777 if (this.kinds === 1) {
765 778 // 添加用户验光单
766   - console.log('kinds====>', this.pickerInfoChioce.leftSph)
767   - console.log('kinds====>', this.pickerInfoChioce.leftSph === Number)
768   - console.log('kinds====>', this.pickerInfoChioce.rightSph === Number)
769 779 if (this.pickerInfoChioce.rightSph === '' || this.pickerInfoChioce.leftSph === '' ||
770 780 this.pickerInfoChioce.leftCyl === '' || this.pickerInfoChioce.rightCyl === '' ||
771 781 this.pickerInfoChioce.leftAxi === '' || this.pickerInfoChioce.rightAxi === ''
... ... @@ -776,7 +786,7 @@ import store from &#39;@/store&#39;
776 786 duration: 2000,
777 787 })
778 788 } else {
779   - if (this.confirm) {
  789 + // if (this.confirm) {
780 790 store.dispatch('myLoveList/addMylove', {
781 791 uid: this.$store.state.user.userInfo.uid,
782 792 openid: this.$store.state.user.userInfo.openid,
... ... @@ -795,17 +805,10 @@ import store from &#39;@/store&#39;
795 805 this.mp_id = mpId
796 806 })
797 807 flag = 1
798   - } else {
799   - uni.showToast({
800   - title: '请确认您的验光数据',
801   - icon: 'none',
802   - duration: 3000,
803   - })
804   - }
805 808 }
806 809 }
807 810 if (this.kinds === 2) {
808   - if (this.confirm) {
  811 + // if (this.confirm) {
809 812 const leftList = ['leftSph', 'leftCyl', 'leftAxi']
810 813 const rightList = ['rightSph', 'rightCyl', 'rightAxi']
811 814 // let flag=0;
... ... @@ -865,18 +868,14 @@ import store from &#39;@/store&#39;
865 868 duration: 2000,
866 869 })
867 870 }
868   - if (flag !== 0) {
869   - store.dispatch('myLoveList/getLoveList', {
870   - uid: this.$store.state.user.userInfo.uid,
871   - })
872   - }
873   - } else {
874   - uni.showToast({
875   - title: '请确认您的验光数据',
876   - icon: 'none',
877   - duration: 3000,
878   - })
879   - }
  871 +
  872 + // } else {
  873 + // uni.showToast({
  874 + // title: '请确认您的验光数据',
  875 + // icon: 'none',
  876 + // duration: 3000,
  877 + // })
  878 + // }
880 879 }
881 880 }
882 881 }
... ...
src/pages/addOpticsData/addOpticsData.vue
... ... @@ -42,13 +42,13 @@
42 42 <text>瞳距(PD):</text><text>{{loveItem.pd}}</text>
43 43 </view>
44 44 <view class="dataInfoItem">
45   - <text>镜片宽度:</text><text>{{loveItem.glassWidth!=='0'?loveItem.glassWidth:'暂无数据'}}</text>
  45 + <text>镜片宽度:</text><text>{{loveItem.glassWidth!=''?loveItem.glassWidth:'暂无数据'}}</text>
46 46 </view>
47 47 <view class="dataInfoItem">
48   - <text>鼻梁宽度:</text><text>{{loveItem.norseWidth!=='0'?loveItem.norseWidth:'暂无数据'}}</text>
  48 + <text>鼻梁宽度:</text><text>{{loveItem.norseWidth!=''?loveItem.norseWidth:'暂无数据'}}</text>
49 49 </view>
50 50 <view class="dataInfoItem">
51   - <text>镜腿长度:</text><text>{{loveItem.legWidth!=='0'?loveItem.legWidth:'暂无数据'}}</text>
  51 + <text>镜腿长度:</text><text>{{loveItem.legWidth!=''?loveItem.legWidth:'暂无数据'}}</text>
52 52 </view>
53 53 </view>
54 54 </uni-collapse-item>
... ... @@ -87,7 +87,7 @@
87 87 },
88 88 computed:{
89 89 loveList() {
90   - console.log(this.$store.state.myLoveList.loveList)
  90 + // console.log(this.$store.state.myLoveList.loveList)
91 91 return this.$store.state.myLoveList.loveList || []
92 92 },
93 93 },
... ... @@ -96,7 +96,7 @@
96 96 this.whichTap = item
97 97 this.$refs.popup.open()
98 98 },
99   - //给时间搞一个nice的格式
  99 + //给时间搞一个的格式
100 100 getRightTime(time){
101 101 //如果小于10 则返回'0'+m
102 102 // function add(m){return m<10?'0'+m:m}
... ...
src/pages/confirmOrder/confirmOrder.vue
... ... @@ -280,9 +280,9 @@ export default {
280 280 onLoad({ pid, addressId, isCart, count, name }) {
281 281 if (isCart == 'false') {
282 282 this.pid = pid
283   - store.dispatch('read/fetch', {
284   - pid,
285   - })
  283 + // store.dispatch('read/fetch', {
  284 + // pid,
  285 + // })
286 286 }
287 287 this.count = count
288 288 this.name = name
... ... @@ -586,6 +586,9 @@ export default {
586 586 .price {
587 587 color: #ff6b4a;
588 588 font-size: 28rpx;
  589 + text{
  590 + margin-left: 10rpx;
  591 + }
589 592 }
590 593 .originCost {
591 594 text-decoration: line-through;
... ...
src/pages/newOpticsData/newOpticsData.vue
... ... @@ -133,15 +133,15 @@
133 133 <view class="ipts">
134 134 <view class="inputItem">
135 135 <text class="text">镜片宽度</text>
136   - <input class="input" @input="glassInfoInput($event,0)" type="text" :value="glassInfo.glassWidth" placeholder="请输入镜片宽度"/>
  136 + <input class="input" @input="glassInfoInput($event,0)" type="text" :value="glassInfo.glassWidth!='0'?glassInfo.glassWidth:''" placeholder="请输入镜片宽度"/>
137 137 </view>
138 138 <view class="inputItem">
139 139 <text class="text">鼻梁宽度</text>
140   - <input class="input" @input="glassInfoInput($event,1)" type="text" :value="glassInfo.norseWidth" placeholder="请输入鼻梁宽度"/>
  140 + <input class="input" @input="glassInfoInput($event,1)" type="text" :value="glassInfo.norseWidth!='0'?glassInfo.norseWidth:''" placeholder="请输入鼻梁宽度"/>
141 141 </view>
142 142 <view class="inputItem">
143 143 <text class="text">镜腿长度</text>
144   - <input class="input" @input="glassInfoInput($event,2)" type="text" :value="glassInfo.legWidth" placeholder="请输入镜腿长度"/>
  144 + <input class="input" @input="glassInfoInput($event,2)" type="text" :value="glassInfo.legWidth!='0'?glassInfo.legWidth:''" placeholder="请输入镜腿长度"/>
145 145 </view>
146 146  
147 147 </view>
... ... @@ -198,7 +198,8 @@
198 198 pd: '',// 瞳距
199 199 oldpd: '',// 用于判断用户是否改变瞳距
200 200 kinds:Number, // kinds=1,提交为新增验光,2为修改
201   - mp_id: Number
  201 + mp_id: Number,
  202 + loveItem:Object
202 203 };
203 204 },
204 205 onLoad: function (option) {
... ... @@ -240,10 +241,10 @@
240 241 } else{
241 242 console.log('args===>',option.index)
242 243 const loveList=Object.assign({},this.$store.state.myLoveList.loveList)
243   - console.log('args===>',loveList[option.index].in_time)
244   - console.log('args===>',loveList[option.index].in_time.toString().slice(0,4))
245   - console.log('args===>',loveList[option.index].in_time.toString().slice(5,6)==0)
246   - console.log('args===>',loveList[option.index].in_time.toString().slice(8,10))
  244 + // console.log('args===>',loveList[option.index].in_time)
  245 + // console.log('args===>',loveList[option.index].in_time.toString().slice(0,4))
  246 + // console.log('args===>',loveList[option.index].in_time.toString().slice(5,6)==0)
  247 + // console.log('args===>',loveList[option.index].in_time.toString().slice(8,10))
247 248 this.name=loveList[option.index].name
248 249 this.pd=loveList[option.index].pd
249 250 this.mp_id=loveList[option.index].mp_id
... ... @@ -268,6 +269,17 @@
268 269 } else{
269 270 this.pickerInfoList[3].nameArray3.unshift(loveList[option.index].in_time.toString().slice(8,10))
270 271 }
  272 + this.glassInfo.glassWidth = loveList[option.index].glassWidth
  273 + this.glassInfo.norseWidth = loveList[option.index].norseWidth
  274 + this.glassInfo.legWidth = loveList[option.index].legWidth
  275 + this.loveItem = loveList[option.index]
  276 + }
  277 + },
  278 + computed:{
  279 + //判断当前眼镜信息是否有0
  280 + glassInfoRight(){
  281 + const glassInfoArr = Object.values(this.glassInfo)
  282 + return glassInfoArr.find(item => item == '0') ==undefined
271 283 }
272 284 },
273 285 methods:{
... ... @@ -303,6 +315,41 @@
303 315 }
304 316  
305 317 },
  318 + updateMylove(){
  319 + const loveItem = this.loveItem
  320 + const glassWidth = this.glassInfo.glassWidth
  321 + const norseWidth = this.glassInfo.norseWidth
  322 + const legWidth = this.glassInfo.legWidth
  323 + // console.log(loveItem.glassWidth)
  324 + // console.log(glassWidth)
  325 + if(loveItem.glassWidth !== glassWidth){
  326 + store.dispatch('myLoveList/updateMylove', {
  327 + uid: this.$store.state.user.userInfo.uid,
  328 + openid: this.$store.state.user.userInfo.openid,
  329 + mp_id: this.mp_id,
  330 + keyname: 'glassWidth',
  331 + keyvalue: glassWidth
  332 + });
  333 + }
  334 + if(loveItem.norseWidth !== norseWidth){
  335 + store.dispatch('myLoveList/updateMylove', {
  336 + uid: this.$store.state.user.userInfo.uid,
  337 + openid: this.$store.state.user.userInfo.openid,
  338 + mp_id: this.mp_id,
  339 + keyname: 'norseWidth',
  340 + keyvalue: norseWidth
  341 + });
  342 + }
  343 + if(loveItem.legWidth !== legWidth){
  344 + store.dispatch('myLoveList/updateMylove', {
  345 + uid: this.$store.state.user.userInfo.uid,
  346 + openid: this.$store.state.user.userInfo.openid,
  347 + mp_id: this.mp_id,
  348 + keyname: 'legWidth',
  349 + keyvalue: legWidth
  350 + });
  351 + }
  352 + },
306 353 // 用户提交
307 354 handleSubmit(){
308 355 if(this.name==''){
... ... @@ -323,15 +370,12 @@
323 370  
324 371 if(this.kinds==1){
325 372 // 添加用户验光单
326   - console.log('kinds====>',this.pickerInfoChioce.leftSph)
327   - console.log('kinds====>',this.pickerInfoChioce.leftSph==Number)
328   - console.log('kinds====>',this.pickerInfoChioce.rightSph==Number)
329 373 if(this.pickerInfoChioce.rightSph==''||this.pickerInfoChioce.leftSph==''||
330 374 this.pickerInfoChioce.leftCyl==''||this.pickerInfoChioce.rightCyl==''||
331   - this.pickerInfoChioce.leftAxi==''||this.pickerInfoChioce.rightAxi==''
  375 + this.pickerInfoChioce.leftAxi==''||this.pickerInfoChioce.rightAxi=='' ||!this.glassInfoRight
332 376 ){
333 377 uni.showToast({
334   - title:"请输入您的验光数据",
  378 + title:"请完善您的数据~",
335 379 icon: "none",
336 380 duration: 2000,
337 381 })
... ... @@ -355,14 +399,10 @@
355 399 // time: this.pickerInfoChioce.time,
356 400 // img_url2: "http://localhost:8087/images/shop_1/1/",
357 401 });
358   - // store.dispatch('myLoveList/getLoveList', {
359   - // uid: this.$store.state.user.userInfo.uid,
360   - // });
361 402 uni.navigateBack({
362 403 delta:1,
363 404 animationDuration:2000
364 405 })
365   -
366 406 } else{
367 407 uni.showToast({
368 408 title:"请确认您的验光数据",
... ... @@ -370,20 +410,13 @@
370 410 duration: 3000,
371 411 })
372 412 }
373   -
374 413 }
375   -
376 414 }
377 415 if(this.kinds==2){
378   - // console.log('kinds====>',this.kinds)
379   - // console.log('pickerindex=====>',this.pickerInfoList[0].nameIndex1)
380   - // console.log('this.pickerInfoChioce====>',type(this.pickerInfoChioce))
381 416 if(this.confirm){
382 417 const leftList = ["leftSph","leftCyl","leftAxi"];
383 418 const rightList = ["rightSph", "rightCyl", "rightAxi"];
384 419 let flag=0;
385   -
386   -
387 420 if(this.name!=this.oldname){
388 421 store.dispatch('myLoveList/updateMylove', {
389 422 uid: this.$store.state.user.userInfo.uid,
... ... @@ -440,16 +473,14 @@
440 473 }
441 474  
442 475 }
  476 + this.updateMylove()
  477 + flag=1
443 478 if(flag!=0){
444   - store.dispatch('myLoveList/getLoveList', {
445   - uid: this.$store.state.user.userInfo.uid,
446   - });
447 479 uni.navigateBack({
448 480 delta:1,
449 481 animationDuration:2000
450 482 })
451 483 }
452   -
453 484 } else{
454 485 uni.showToast({
455 486 title:"请确认您的验光数据",
... ... @@ -457,14 +488,9 @@
457 488 duration: 3000,
458 489 })
459 490 }
460   -
461 491 }
462   -
463   -
464 492 }
465   -
466 493 }
467   -
468 494 },
469 495 changeConfirm() {
470 496 this.confirm = !this.confirm
... ...