Преглед изворни кода

refactor(orderDetail): 优化组件结构和代码格式

简化了多个组件的模板结构,减少了冗余代码,提升了可读性。同时,更新了收单项点击处理逻辑,增加了异步请求以获取详细信息。
Yannay пре 1 месец
родитељ
комит
e521d4f583
2 измењених фајлова са 36 додато и 68 уклоњено
  1. 7 2
      pages/orderDetailRefactored/components/PageThree.vue
  2. 29 66
      pages/orderDetailRefactored/index.vue

+ 7 - 2
pages/orderDetailRefactored/components/PageThree.vue

@@ -539,7 +539,7 @@ export default {
539
         bankName: this.paymentInfo.bankName || '',
539
         bankName: this.paymentInfo.bankName || '',
540
         bankCardNumber: this.paymentInfo.bankAccount || '',
540
         bankCardNumber: this.paymentInfo.bankAccount || '',
541
         idCard: this.paymentInfo.idNumber || '',
541
         idCard: this.paymentInfo.idNumber || '',
542
-        paymentMethod: this.paymentMethod || ''
542
+        // paymentMethod: this.paymentMethod || ''
543
       })
543
       })
544
 
544
 
545
       if (!this.paymentInfo.customName || !this.paymentInfo.bankName ||
545
       if (!this.paymentInfo.customName || !this.paymentInfo.bankName ||
@@ -572,8 +572,13 @@ export default {
572
     /**
572
     /**
573
      * 确认转账
573
      * 确认转账
574
      */
574
      */
575
-    confirmTransfer() {
575
+    async confirmTransfer() {
576
       this.payNowModalVisible = false
576
       this.payNowModalVisible = false
577
+
578
+      await uni.$u.api.updateClueOrderForm({
579
+        id: this.orderDetail.id,
580
+        paymentMethod: this.paymentMethod || ''
581
+      })
577
       //如果是小葫芦线上刚支付就调用接口,如果不是小葫芦线上支付就不要调用接口,直接点击下一步
582
       //如果是小葫芦线上刚支付就调用接口,如果不是小葫芦线上支付就不要调用接口,直接点击下一步
578
       if (this.paymentMethod === '小葫芦线上支付') {
583
       if (this.paymentMethod === '小葫芦线上支付') {
579
         this.$emit('confirm-pay')
584
         this.$emit('confirm-pay')

+ 29 - 66
pages/orderDetailRefactored/index.vue

@@ -20,88 +20,44 @@
20
     </u-navbar>
20
     </u-navbar>
21
 
21
 
22
     <!-- 收单列表切换 -->
22
     <!-- 收单列表切换 -->
23
-    <u-tabs 
24
-      keyName="brand" 
25
-      :list="receiptList" 
26
-      @click="handleReceiptClick"
27
-      class="receipt-tabs"
28
-    />
23
+    <u-tabs keyName="brand" :list="receiptList" @click="handleReceiptClick" class="receipt-tabs" />
29
 
24
 
30
     <!-- 订单详情视图 -->
25
     <!-- 订单详情视图 -->
31
-    <OrderDetailView 
32
-      :order-detail="orderDetail" 
33
-      :top-info="topInfo" 
34
-      :order-id="orderId"
35
-      :current-receipt="currentReceipt" 
36
-    />
26
+    <OrderDetailView :order-detail="orderDetail" :top-info="topInfo" :order-id="orderId"
27
+      :current-receipt="currentReceipt" />
37
 
28
 
38
     <!-- 加一单模态窗 -->
29
     <!-- 加一单模态窗 -->
39
-    <u-modal 
40
-      :show="addOneModalVisible" 
41
-      title="加一单" 
42
-      showCancelButton 
43
-      @cancel="handleAddOneCancel"
44
-      @confirm="handleAddOneConfirm"
45
-    >
30
+    <u-modal :show="addOneModalVisible" title="加一单" showCancelButton @cancel="handleAddOneCancel"
31
+      @confirm="handleAddOneConfirm">
46
       <view class="add-one-modal-content">
32
       <view class="add-one-modal-content">
47
         <view class="add-one-form-item">
33
         <view class="add-one-form-item">
48
           <text class="form-label">品牌<text class="required">*</text></text>
34
           <text class="form-label">品牌<text class="required">*</text></text>
49
-          <u-button 
50
-            type="primary" 
51
-            plain 
52
-            @click="showBrandSelector = true"
53
-            class="brand-select-btn"
54
-          >
35
+          <u-button type="primary" plain @click="showBrandSelector = true" class="brand-select-btn">
55
             {{ currentAddBrand.dictLabel || '点击请选择品牌' }}
36
             {{ currentAddBrand.dictLabel || '点击请选择品牌' }}
56
           </u-button>
37
           </u-button>
57
         </view>
38
         </view>
58
         <view class="add-one-form-item">
39
         <view class="add-one-form-item">
59
           <text class="form-label">型号</text>
40
           <text class="form-label">型号</text>
60
-          <u-input 
61
-            v-model="currentAddModel" 
62
-            placeholder="请输入型号" 
63
-            class="form-input"
64
-          />
41
+          <u-input v-model="currentAddModel" placeholder="请输入型号" class="form-input" />
65
         </view>
42
         </view>
66
         <view class="add-one-form-item">
43
         <view class="add-one-form-item">
67
           <text class="form-label">价格</text>
44
           <text class="form-label">价格</text>
68
-          <u-input 
69
-            v-model="currentAddPrice" 
70
-            placeholder="请输入价格" 
71
-            type="number"
72
-            class="form-input"
73
-          />
45
+          <u-input v-model="currentAddPrice" placeholder="请输入价格" type="number" class="form-input" />
74
         </view>
46
         </view>
75
       </view>
47
       </view>
76
     </u-modal>
48
     </u-modal>
77
 
49
 
78
     <!-- 品牌选择器 -->
50
     <!-- 品牌选择器 -->
79
-    <u-picker 
80
-      :show="showBrandSelector" 
81
-      :columns="brandColumns" 
82
-      keyName="dictLabel"
83
-      @confirm="handleBrandConfirm" 
84
-      @cancel="showBrandSelector = false" 
85
-    />
51
+    <u-picker :show="showBrandSelector" :columns="brandColumns" keyName="dictLabel" @confirm="handleBrandConfirm"
52
+      @cancel="showBrandSelector = false" />
86
 
53
 
87
     <!-- 编辑品牌选择器 -->
54
     <!-- 编辑品牌选择器 -->
88
-    <u-picker 
89
-      :show="editBrandSelectorVisible" 
90
-      :columns="brandColumns" 
91
-      keyName="dictLabel"
92
-      @confirm="handleEditBrandConfirm" 
93
-      @cancel="editBrandSelectorVisible = false" 
94
-    />
55
+    <u-picker :show="editBrandSelectorVisible" :columns="brandColumns" keyName="dictLabel"
56
+      @confirm="handleEditBrandConfirm" @cancel="editBrandSelectorVisible = false" />
95
 
57
 
96
     <!-- 修改型号/价格弹窗 -->
58
     <!-- 修改型号/价格弹窗 -->
97
-    <CustomModal 
98
-      :visible="modalVisible" 
99
-      :title="modalConfig.title" 
100
-      :value="modalConfig.value"
101
-      :placeholder="modalConfig.placeholder" 
102
-      @cancel="handleModalCancel" 
103
-      @confirm="handleModalConfirm" 
104
-    />
59
+    <CustomModal :visible="modalVisible" :title="modalConfig.title" :value="modalConfig.value"
60
+      :placeholder="modalConfig.placeholder" @cancel="handleModalCancel" @confirm="handleModalConfirm" />
105
   </view>
61
   </view>
106
 </template>
62
 </template>
107
 
63
 
@@ -219,11 +175,18 @@ export default {
219
     /**
175
     /**
220
      * 点击收单项
176
      * 点击收单项
221
      */
177
      */
222
-    handleReceiptClick(item) {
223
-      this.currentReceipt = item
224
-      this.topInfo.brand = item.brand || '暂无'
225
-      this.topInfo.model = item.model || '暂无'
226
-      this.topInfo.price = item.sellingPrice || '暂无'
178
+    async handleReceiptClick(item) {
179
+      console.log('点击了收单', item)
180
+      //获取当前的收单form详情
181
+      const res = await uni.$u.api.getReceiptForm(item.id)
182
+      console.log('收单详情', res)
183
+
184
+      if (res.code === 200) {
185
+        this.currentReceipt = res.data || {}
186
+        this.topInfo.brand = res.data.brand || '暂无'
187
+        this.topInfo.model = res.data.model || '暂无'
188
+        this.topInfo.price = res.data.sellingPrice || '暂无'
189
+      }
227
     },
190
     },
228
 
191
 
229
     /**
192
     /**
@@ -349,7 +312,7 @@ export default {
349
         uni.$u.toast('请选择品牌')
312
         uni.$u.toast('请选择品牌')
350
         return
313
         return
351
       }
314
       }
352
-      
315
+
353
       try {
316
       try {
354
         await uni.$u.api.addReceiptForm({
317
         await uni.$u.api.addReceiptForm({
355
           brand: this.currentAddBrand.dictValue,
318
           brand: this.currentAddBrand.dictValue,
@@ -403,7 +366,7 @@ export default {
403
   font-weight: bold;
366
   font-weight: bold;
404
   color: #333;
367
   color: #333;
405
   font-size: 28rpx;
368
   font-size: 28rpx;
406
-  
369
+
407
   &.price {
370
   &.price {
408
     color: blueviolet;
371
     color: blueviolet;
409
   }
372
   }
@@ -443,7 +406,7 @@ export default {
443
 
406
 
444
 .add-one-form-item {
407
 .add-one-form-item {
445
   margin-bottom: 30rpx;
408
   margin-bottom: 30rpx;
446
-  
409
+
447
   &:last-child {
410
   &:last-child {
448
     margin-bottom: 0;
411
     margin-bottom: 0;
449
   }
412
   }