黎海 2 年之前
父节点
当前提交
6b84adc40f
共有 1 个文件被更改,包括 103 次插入35 次删除
  1. 103 35
      src/pages/confirmOrder/details/index.vue

+ 103 - 35
src/pages/confirmOrder/details/index.vue

@@ -82,9 +82,9 @@
82 82
       </div>
83 83
       <div class="project">
84 84
         <div class="project-title">
85
-          <div>共<span>{{order_data.project_num}}个</span>项目</div>
85
+          <div>共<span>{{order_data.project_list.length}}个</span>项目</div>
86 86
           <div class="add-project"
87
-               @click="isProject=true">添加</div>
87
+               @click="addProject">添加</div>
88 88
         </div>
89 89
         <div class="project-list">
90 90
           <div class="project-info"
@@ -101,7 +101,9 @@
101 101
                 <div> <span v-if="item.device_name">{{item.device_name}}({{item.room}}){{item.use_time}}分钟</span></div>
102 102
                 <div><img @click="eidt(item)"
103 103
                        src="https://we-spa.oss-cn-shenzhen.aliyuncs.com/pad_clerk/icon/coupon/eidt.png">
104
-                  <img class="delete"
104
+                  <img v-if="order_data.project_list.length>1"
105
+                       @click="deleteProject(item)"
106
+                       class="delete"
105 107
                        src="https://we-spa.oss-cn-shenzhen.aliyuncs.com/pad_clerk/icon/coupon/delete.png"
106 108
                        alt="">
107 109
                 </div>
@@ -110,7 +112,8 @@
110 112
           </div>
111 113
         </div>
112 114
       </div>
113
-      <div class="cost">
115
+      <div class="cost"
116
+           v-if="!isChange">
114 117
         <div class="cost-title">
115 118
           <div>预约费用</div>
116 119
           <div>¥399</div>
@@ -134,7 +137,8 @@
134 137
           合计: <span class="price-num"><span class="min-size">¥</span>399<span class="min-size">.00</span></span>
135 138
         </div>
136 139
       </div>
137
-      <div class="payment">{{order_data.status==0?'立即支付':'确定订单'}}</div>
140
+      <div class="payment"
141
+           @click="determine">{{isChange?'确定订单':'立即支付'}}</div>
138 142
     </div>
139 143
     <!-- 选择优惠券 -->
140 144
     <mine-pupop :show="isCoupun">
@@ -396,6 +400,8 @@ export default {
396 400
       isTs: false,//是否展示选择时间弹窗
397 401
       isPore: false,//皮肤状态弹窗
398 402
       id: 0,//订单id
403
+      isChange: false,//项目是否有改变
404
+      isEditProject: false,//是否编辑项目
399 405
     };
400 406
   },
401 407
   computed: {
@@ -424,43 +430,104 @@ export default {
424 430
         this.productsList = res.data.list
425 431
       })
426 432
     },
427
-    eidt () {
428
-
433
+    eidt (item) {
434
+      this.projectInfo = item.id
435
+      this.getProducts(item.id)
436
+      this.isEditProject = true
437
+      this.isProject = true
438
+    },
439
+    deleteProject (item) {
440
+      this.order_data.project_list.forEach((res, index) => {
441
+        if (item.id == res.id) {
442
+          this.order_data.project_list.splice(index, 1)
443
+          this.$message({
444
+            message: '删除成功',
445
+            type: 'success'
446
+          });
447
+        }
448
+      })
449
+    },
450
+    addProject () {
451
+      this.projectInfo = ''
452
+      this.isEditProject = false
453
+      this.isProject = true
429 454
     },
430 455
     //新增
431 456
     orderUpdate () {
432
-      if (this.projectInfo.length == 0) return
433
-      //项目包重组
434
-      let projectInfo = {}, nowProjectInfo = {}, productsInfo = {}
435
-      this.projectList.forEach(item => {
436
-        if (this.projectInfo == item.id) {
437
-          nowProjectInfo = item
457
+      // 编辑
458
+      if (this.isEditProject) {
459
+        if (this.productsInfo != '') {
460
+          this.order_data.project_list.forEach(e => {
461
+            if (this.projectInfo == e.id) {
462
+              this.productsList.forEach(item => {
463
+                if (e.product_ids != '') {
464
+                  e.price = Number(e.price) - Number(item.price)
465
+                }
466
+                e.product_ids = this.productsInfo
467
+                if (item.id == e.product_ids) {
468
+                  this.isChange = true
469
+                  e.product_names = item.name
470
+                  e.price = Number(e.price) + Number(item.price)
471
+                  this.isProject = false
472
+                  this.isEditProject = false
473
+                }
474
+              })
475
+            }
476
+          })
477
+        } else {
478
+          this.isProject = false
479
+          return
438 480
         }
439
-      })
440
-      if (this.productsInfo.length != 0) {
441
-        this.productsList.forEach(item => {
442
-          if (item.id == this.productsInfo) {
443
-            productsInfo = item
481
+      } else {
482
+        //新增
483
+        let isIndexOf = false
484
+        if (this.projectInfo.length == 0) return
485
+        this.order_data.project_list.forEach(res => {
486
+          if (this.projectInfo == res.id) {
487
+            isIndexOf = true
488
+            this.$message.error('该项目已存在');
444 489
           }
445 490
         })
446
-      }
447
-      console.log(nowProjectInfo, 'nowProjectInfo', productsInfo);
448
-      projectInfo['name'] = nowProjectInfo.name
449
-      projectInfo['cover_url'] = nowProjectInfo.cover_url
450
-      projectInfo['device_name'] = ''
451
-      projectInfo['room'] = ''
452
-      projectInfo['use_time'] = ''
453
-      projectInfo['price'] = nowProjectInfo.price
454
-      projectInfo['product_names'] = ''
491
+        if (isIndexOf) return
492
+        //项目包重组
493
+        let projectInfo = {}, nowProjectInfo = {}, productsInfo = {}
494
+        this.projectList.forEach(item => {
495
+          if (this.projectInfo == item.id) {
496
+            nowProjectInfo = item
497
+          }
498
+        })
499
+        if (this.productsInfo.length != 0) {
500
+          this.productsList.forEach(item => {
501
+            if (item.id == this.productsInfo) {
502
+              productsInfo = item
503
+            }
504
+          })
505
+        }
506
+        console.log(nowProjectInfo, 'nowProjectInfo', productsInfo);
507
+        projectInfo['name'] = nowProjectInfo.name
508
+        projectInfo['id'] = nowProjectInfo.id
509
+        projectInfo['cover_url'] = nowProjectInfo.cover_url
510
+        projectInfo['device_name'] = ''
511
+        projectInfo['room'] = ''
512
+        projectInfo['use_time'] = ''
513
+        projectInfo['price'] = nowProjectInfo.price
514
+        projectInfo['product_names'] = ''
455 515
 
456
-      if (Object.keys(productsInfo).length > 0) {
457
-        projectInfo['product_id'] = productsInfo.id
458
-        projectInfo.product_names = productsInfo.name
459
-        projectInfo.price += Number(productsInfo.price)
516
+        if (Object.keys(productsInfo).length > 0) {
517
+          projectInfo['product_ids'] = productsInfo.id
518
+          projectInfo.product_names = productsInfo.name
519
+          projectInfo.price += Number(productsInfo.price)
520
+        }
521
+        this.order_data.project_list.push(projectInfo)
522
+        this.isChange = true
523
+        this.isProject = false
524
+      }
525
+    },
526
+    //确定订单&支付
527
+    determine () { 
528
+      if (condition) {
529
+        
460 530
       }
461
-      this.order_data.project_list.push(projectInfo)
462
-      this.isProject = false
463
-
464 531
     },
465 532
     onOperation (index) {
466 533
       if (this.programmeList[index].onSelect) {
@@ -888,7 +955,8 @@ export default {
888 955
       }
889 956
     }
890 957
     .payment {
891
-      position: relative;
958
+      position: absolute;
959
+      bottom: 0;
892 960
       margin-top: 18px;
893 961
       left: 50%;
894 962
       transform: translateX(-50%);