Explorar o código

部分字段绑定接口

Yannay hai 2 meses
pai
achega
c594d66603

+ 65 - 5
pages/acceptOrderOrder/compounts/orderCard.vue

@@ -2,13 +2,16 @@
2 2
     <view class="order-card" :class="{ 'order-card-overTime': order.isDelay }" @click.stop="handleClick(order)">
3 3
         <view class="order-card-header">
4 4
             <view class="order-card-header-left">
5
+                <view class="order-card-header-left-band" style="backgroundColor: #007AFF;" v-show="order.itemBrand">
6
+                    {{ order.itemBrand }}
7
+                </view>
5 8
                 <view class="order-card-header-left-band" v-for="value in order.tags" :key="value.id"
6 9
                     :style="{ backgroundColor: value.color }">
7 10
                     {{ value.name }}
8 11
                 </view>
9
-                <view class="order-card-header-left-band" v-if="order.tags.length == 0" style="backgroundColor: #999;">
12
+                <!-- <view class="order-card-header-left-band" v-if="order.tags.length == 0" style="backgroundColor: #999;">
10 13
                     暂无标签
11
-                </view>
14
+                </view> -->
12 15
             </view>
13 16
             <view class="order-card-header-right">
14 17
                 <view class="order-card-header-right-price">
@@ -36,7 +39,7 @@
36 39
                 </u-col>
37 40
                 <u-col span="5.5">
38 41
                     <view @click.stop="handleBusy(order)">
39
-                        <u-button type="primary" size="medium">在忙</u-button>
42
+                        <u-button type="primary" size="medium">在忙({{ buzyTime / 1000 }}s)</u-button>
40 43
 
41 44
                     </view>
42 45
                 </u-col>
@@ -62,11 +65,19 @@
62 65
                     </view>
63 66
                 </u-col>
64 67
             </u-row>
68
+            <u-row justify="between" v-if="order.status == '4'">
69
+                <u-col span="12">
70
+                    <view @click.stop="handleShare(order)">
71
+                        <u-button type="primary" size="medium">待跟进</u-button>
72
+                    </view>
73
+                </u-col>
74
+            </u-row>
65 75
         </view>
66 76
     </view>
67 77
 </template>
68 78
 
69 79
 <script>
80
+// order.status 1未接,2已接单,3完成一键分享,4未接待跟进
70 81
 export default {
71 82
     props: {
72 83
         order: {
@@ -74,6 +85,14 @@ export default {
74 85
             default: () => ({})
75 86
         }
76 87
     },
88
+    data() {
89
+        return {
90
+            buzyTime: 300000,
91
+            // buzyTime: 5000,
92
+            busyTimer: null,
93
+
94
+        }
95
+    },
77 96
     computed: {
78 97
         statue() {
79 98
             switch (this.order.status) {
@@ -86,16 +105,42 @@ export default {
86 105
             }
87 106
         }
88 107
     },
108
+    watch: {
109
+        buzyTime: {
110
+            handler(newVal) {
111
+                // console.log('newVal', newVal);
112
+                if (newVal == 0) {
113
+
114
+                    // 移动到最后
115
+                    this.handleBusy(this.order)
116
+                }
117
+            },
118
+            deep: true
119
+        }
120
+    },
121
+
122
+    mounted() {
123
+        this.openTimer()
124
+        console.log('order', this.order);
125
+
126
+    },
127
+    beforeDestroy() {
128
+        this.closeTimer()
129
+    },
89 130
     methods: {
90 131
         handleAcceptOrder(order) {
91
-            console.log('立即接单',order);
92
-             this.$emit('handleCardClick', order);
132
+            console.log('立即接单', order);
133
+            this.$emit('handleCardClick', order);
93 134
         },
94 135
         handleWillFollow(order) {
95 136
             console.log('待跟进', order);
96 137
         },
97 138
         handleBusy(order) {
139
+            this.closeTimer()
98 140
             console.log('在忙', order);
141
+            this.$emit('handleBuzyBtnClick', {
142
+                ...order,
143
+            });
99 144
         },
100 145
         handleTag(order) {
101 146
             console.log('打标签', order);
@@ -106,7 +151,22 @@ export default {
106 151
         handleClick(order) {
107 152
             console.log('点击了订单', order);
108 153
             this.$emit('handleCardClick', order);
154
+        },
155
+        openTimer() {
156
+            // 组件挂载时启动定时器
157
+            console.log('组件挂载时启动定时器');
158
+            this.busyTimer = setInterval(() => {
159
+                this.buzyTime -= 1000;
160
+            }, 1000);
161
+        },
162
+        closeTimer() {
163
+            // 组件卸载时清理定时器,防止内存泄漏
164
+            if (this.busyTimer) {
165
+                clearInterval(this.busyTimer);
166
+                this.busyTimer = null;
167
+            }
109 168
         }
169
+
110 170
     }
111 171
 }
112 172
 </script>

+ 49 - 13
pages/acceptOrderOrder/index.vue

@@ -3,11 +3,16 @@
3 3
 		<u-navbar title="接单中心" :autoBack="true" :placeholder="true" v-hideNav></u-navbar>
4 4
 
5 5
 		<scroll-view class="scroll_wrap" scroll-y @scrolltolower="scrolltolower">
6
-			<order-card v-for="order in ordersList" :key="order.id" :order="order" @handleCardClick="handleCardClick"></order-card>
6
+			<order-card v-for="order, index in ordersList" :key="order.receiptId" :order="order"
7
+				@handleCardClick="handleCardClick" @handleBuzyBtnClick="handleBuzyBtnClick"></order-card>
7 8
 			<view class="hasMore">
8 9
 				{{ ordersList.length >= page.total ? '没有更多了~' : '向下滑动加载更多~' }}
9 10
 			</view>
10 11
 		</scroll-view>
12
+
13
+		<view class="createOrder" @click="handleAddClick">
14
+			<u-icon name="plus" size="30" color="#ffffff"></u-icon>
15
+		</view>
11 16
 	</view>
12 17
 </template>
13 18
 <script>
@@ -32,17 +37,17 @@ export default {
32 37
 	methods: {
33 38
 		async getOrderList() {
34 39
 
35
-			const { rows,total } = await uni.$u.api.selectClueOrderFormList({
40
+			const { rows, total } = await uni.$u.api.selectClueOrderFormList({
36 41
 				pageSize: this.page.pageSize,
37 42
 				pageNum: this.page.pageNum,
38 43
 			}
39 44
 			);
40 45
 			console.log('接单列表', rows);
41 46
 			this.ordersList.push(...rows);
42
-			this.page.total=total;
47
+			this.page.total = total;
43 48
 		},
44 49
 		scrolltolower() {
45
-			if(this.ordersList.length>=this.page.total){
50
+			if (this.ordersList.length >= this.page.total) {
46 51
 				return uni.$u.toast('没有更多了');
47 52
 			}
48 53
 			this.page.pageNum++;
@@ -52,6 +57,7 @@ export default {
52 57
 			this.ordersList = [];
53 58
 			this.page.pageNum = 1;
54 59
 		},
60
+		// 跳转按钮接单
55 61
 		handleCardClick(order) {
56 62
 			console.log('点击了订单', order);
57 63
 			//跳转
@@ -64,6 +70,19 @@ export default {
64 70
 				url: `/pages/orderDetailNew/index?orderId=${order.id}&item=${order.item}&type=${this.type}&clueId=${order.clueId}`,
65 71
 			})
66 72
 		},
73
+		// 在忙按钮先延迟把当前项目移动到队列末尾
74
+		// 点击或者在忙的时候倒计时300s结束之后触发
75
+		// 目前的问题是移动到当前10个item
76
+		// 队列的最后,而不是全部队列的最后
77
+		handleBuzyBtnClick(order) {
78
+			console.log('在忙', order);
79
+			// 先把当前项目移动到队列末尾
80
+			const index = this.ordersList.findIndex(item => item.id == order.id);
81
+			if (index != -1) {
82
+				const item = this.ordersList.splice(index, 1)[0];
83
+				this.ordersList.push(item);
84
+			}
85
+		},
67 86
 
68 87
 	},
69 88
 	onLoad() {
@@ -76,13 +95,30 @@ export default {
76 95
 </script>
77 96
 
78 97
 <style scoped>
79
-	.scroll_wrap {
80
-		height: calc( 100vh - 44px );
81
-	}
82
-	.hasMore {
83
-		text-align: center;
84
-		padding: 20rpx 0;
85
-		font-size: 24rpx;
86
-		color: #999;
87
-	}
98
+.scroll_wrap {
99
+	height: calc(100vh - 44px);
100
+}
101
+
102
+.hasMore {
103
+	text-align: center;
104
+	padding: 20rpx 0;
105
+	font-size: 24rpx;
106
+	color: #999;
107
+}
108
+
109
+.createOrder {
110
+	position: fixed;
111
+	bottom: 20rpx;
112
+	right: 20rpx;
113
+	z-index: 999;
114
+	background-color: #007AFF;
115
+	border-radius: 50%;
116
+	padding: 10rpx;
117
+	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
118
+	width: 80rpx;
119
+	height: 80rpx;
120
+	display: flex;
121
+	justify-content: center;
122
+	align-items: center;
123
+}
88 124
 </style>

+ 11 - 4
pages/orderDetailNew/components/orderDetailNewView.vue

@@ -2,16 +2,17 @@
2 2
     <view class="orderDetailNewView">
3 3
 
4 4
         <view class="page-item" v-show="activeIndex === 0">
5
-            <pageOne @handleNextClick="handleNextClick" />
5
+            <pageOne @handleNextClick="handleNextClick" :orderDetail="detail" />
6 6
         </view>
7 7
         <view class="page-item" v-show="activeIndex === 1">
8
-            <pageTwo @handleNextClick="handleNextClick" />
8
+            <pageTwo @handleNextClick="handleNextClick" :orderDetail="detail" />
9 9
         </view>
10 10
         <view class="page-item" v-show="activeIndex === 2">
11
-            <pageThree @handleNextClick="handleNextClick" :detailImages="allFroms.formTwo.detailImages || []" />
11
+            <pageThree @handleNextClick="handleNextClick" :detailImages="allFroms.formTwo.detailImages || []"
12
+                :orderDetail="detail" />
12 13
         </view>
13 14
         <view class="page-item" v-show="activeIndex === 3">
14
-            <pageFour @handleNextClick="handleNextClick" />
15
+            <pageFour @handleNextClick="handleNextClick" :orderDetail="detail" />
15 16
         </view>
16 17
 
17 18
         <ul class="page">
@@ -27,6 +28,12 @@ import pageTwo from './pageTwo.vue'
27 28
 import pageThree from './pageThree.vue'
28 29
 import pageFour from './pageFour.vue'
29 30
 export default {
31
+    props: {
32
+        detail: {
33
+            type: Object,
34
+            default: () => { },
35
+        }
36
+    },
30 37
     components: {
31 38
         pageOne,
32 39
         pageTwo,

+ 48 - 16
pages/orderDetailNew/components/pageFour.vue

@@ -189,6 +189,12 @@
189 189
 
190 190
 <script>
191 191
 export default {
192
+    props: {
193
+        orderDetail: {
194
+            type: Object,
195
+            default: () => { },
196
+        }
197
+    },
192 198
     data() {
193 199
         return {
194 200
             // 入库信息相关的数据
@@ -288,19 +294,31 @@ export default {
288 294
         },
289 295
         // 重新计算分成比例
290 296
         recalculatePercentage() {
291
-            const totalRows = this.profitSharingList.length;
292
-            if (totalRows > 0) {
293
-                // 计算平均比例(向下取整)
294
-                const avgPercentage = Math.floor(100 / totalRows);
295
-                // 设置所有行的比例
296
-                this.profitSharingList.forEach(item => {
297
-                    item.percentage = avgPercentage;
297
+            // 分别计算前端和后端的行数
298
+            const frontendRows = this.profitSharingList.filter(item => item.accountType === 'frontend');
299
+            const backendRows = this.profitSharingList.filter(item => item.accountType === 'backend');
300
+
301
+            // 计算前端平均比例
302
+            if (frontendRows.length > 0) {
303
+                const frontendAvg = Math.floor(100 / frontendRows.length);
304
+                frontendRows.forEach(item => {
305
+                    item.percentage = frontendAvg;
306
+                });
307
+            }
308
+
309
+            // 计算后端平均比例
310
+            if (backendRows.length > 0) {
311
+                const backendAvg = Math.floor(100 / backendRows.length);
312
+                backendRows.forEach(item => {
313
+                    item.percentage = backendAvg;
298 314
                 });
299 315
             }
300 316
         },
301 317
         // 切换账户类型
302 318
         toggleAccountType(item) {
303 319
             item.accountType = item.accountType === 'frontend' ? 'backend' : 'frontend';
320
+            // 重新计算分成比例
321
+            this.recalculatePercentage();
304 322
         },
305 323
         // 处理百分比输入
306 324
         handlePercentageInput(item) {
@@ -357,15 +375,29 @@ export default {
357 375
                 }
358 376
             }
359 377
 
360
-            // 校验分成比例总和,总和必须是100%
361
-            // const totalPercentage = this.profitSharingList.reduce((sum, item) => sum + Number(item.percentage), 0);
362
-            // if (totalPercentage !== 100) {
363
-            //     uni.showToast({
364
-            //         title: '分成比例总和必须为100%',
365
-            //         icon: 'none'
366
-            //     });
367
-            //     return false;
368
-            // }
378
+            // 校验前端分成比例总和必须是100%
379
+            const frontendTotal = this.profitSharingList
380
+                .filter(item => item.accountType === 'frontend')
381
+                .reduce((sum, item) => sum + Number(item.percentage), 0);
382
+            if (frontendTotal !== 100) {
383
+                uni.showToast({
384
+                    title: '前端分成比例总和必须为100%',
385
+                    icon: 'none'
386
+                });
387
+                return false;
388
+            }
389
+
390
+            // 校验后端分成比例总和必须是100%
391
+            const backendTotal = this.profitSharingList
392
+                .filter(item => item.accountType === 'backend')
393
+                .reduce((sum, item) => sum + Number(item.percentage), 0);
394
+            if (backendTotal !== 100) {
395
+                uni.showToast({
396
+                    title: '后端分成比例总和必须为100%',
397
+                    icon: 'none'
398
+                });
399
+                return false;
400
+            }
369 401
 
370 402
             return true;
371 403
         }

+ 37 - 15
pages/orderDetailNew/components/pageOne.vue

@@ -48,21 +48,21 @@
48 48
             <u-row class="info-row">
49 49
                 <u-col span="6">
50 50
                     <view class="info-label">发单人</view>
51
-                    <view class="info-value">张三</view>
51
+                    <view class="info-value">{{ orderDetail.createNickName || '未填写' }}</view>
52 52
                 </u-col>
53 53
                 <u-col span="6">
54 54
                     <view class="info-label">型号</view>
55
-                    <view class="info-value">iPhone 15 Pro</view>
55
+                    <view class="info-value">{{ orderDetail.model || '未填写' }}</view>
56 56
                 </u-col>
57 57
             </u-row>
58 58
             <u-row class="info-row">
59 59
                 <u-col span="6">
60 60
                     <view class="info-label">上门时间</view>
61
-                    <view class="info-value">2025-12-20 14:30</view>
61
+                    <view class="info-value">{{ orderDetail.visitTime || '未填写' }}</view>
62 62
                 </u-col>
63 63
                 <u-col span="6">
64 64
                     <view class="info-label">地址</view>
65
-                    <view class="info-value">北京市朝阳区建国路88号</view>
65
+                    <view class="info-value">{{ orderDetail.address || '未填写' }}</view>
66 66
                 </u-col>
67 67
             </u-row>
68 68
         </view>
@@ -73,13 +73,13 @@
73 73
                 <u-icon name="phone" size="40" color="#07C160" style="margin-bottom: 10rpx;"></u-icon>
74 74
                 <view class="connect-title">电话</view>
75 75
                 <!-- 小红点 -->
76
-                <view v-if="phone" class="red-dot"></view>
76
+                <view v-if="orderDetail.phone" class="red-dot"></view>
77 77
             </view>
78 78
             <view class="connect-card wechat-card" @click="handleWechatClick">
79 79
                 <u-icon name="chat" size="40" color="#07C160" style="margin-bottom: 10rpx;"></u-icon>
80 80
                 <view class="connect-title">微信</view>
81 81
                 <!-- 小红点 -->
82
-                <view v-if="wechat" class="red-dot"></view>
82
+                <view v-if="orderDetail.wechat" class="red-dot"></view>
83 83
             </view>
84 84
         </view>
85 85
 
@@ -91,6 +91,12 @@
91 91
 import picComp from './picComp.vue'
92 92
 
93 93
 export default {
94
+    props: {
95
+        orderDetail: {
96
+            type: Object,
97
+            default: () => { },
98
+        }
99
+    },
94 100
     components: {
95 101
         picComp
96 102
     },
@@ -100,11 +106,13 @@ export default {
100 106
                 truePic: [],
101 107
                 chatRecords: [],
102 108
             },
103
-            phone: '13800138000',
104
-            wechat: 'wechat123456',
105
-            // 控制小红点显示的变量
106 109
         }
107 110
     },
111
+    beforeMount() {
112
+        setTimeout(() => {
113
+            console.log('orderDetail', this.orderDetail);
114
+        }, 5000)
115
+    },
108 116
     methods: {
109 117
         // 上传图片
110 118
         uploadImage(type) {
@@ -162,13 +170,27 @@ export default {
162 170
         },
163 171
         // 电话卡片点击事件
164 172
         handlePhoneClick() {
165
-            console.log('电话卡片被点击', '电话号码:', this.phone)
166
-            // 这里可以添加拨打电话的逻辑,例如调用uni.makePhoneCall
173
+            console.log('电话卡片被点击', '电话号码:', this.orderDetail.phone)
174
+            if (this.orderDetail.phone) {
175
+                //    稍后调用整个拨打电话的逻辑
176
+            } else {
177
+                uni.showToast({
178
+                    title: '该订单暂时没有电话号码',
179
+                    icon: 'none'
180
+                })
181
+            }
167 182
         },
168 183
         // 微信卡片点击事件
169 184
         handleWechatClick() {
170
-            console.log('微信卡片被点击', '微信号:', this.wechat)
171
-            // 这里可以添加打开微信的逻辑
185
+            console.log('微信卡片被点击', '微信号:', this.orderDetail.wechat)
186
+            if (this.orderDetail.wechat) {
187
+                //    稍后调用打开微信的逻辑
188
+            } else {
189
+                uni.showToast({
190
+                    title: '该订单暂时没有微信号',
191
+                    icon: 'none'
192
+                })
193
+            }
172 194
         },
173 195
         // 下一步
174 196
         handleNextClick() {
@@ -328,8 +350,8 @@ export default {
328 350
     position: absolute;
329 351
     top: 15rpx;
330 352
     right: 15rpx;
331
-    width: 16rpx;
332
-    height: 16rpx;
353
+    width: 25rpx;
354
+    height: 25rpx;
333 355
     background-color: #ff4d4f;
334 356
     border-radius: 50%;
335 357
     box-shadow: 0 0 4rpx rgba(255, 77, 79, 0.3);

+ 27 - 11
pages/orderDetailNew/components/pageThree.vue

@@ -128,15 +128,38 @@
128 128
 import picComp from './picComp.vue'
129 129
 
130 130
 export default {
131
-    components: {
132
-        picComp
133
-    },
134 131
     props: {
132
+        orderDetail: {
133
+            type: Object,
134
+            default: () => { },
135
+        },
135 136
         detailImages: {
136 137
             type: Array,
137 138
             default: () => []
138 139
         }
139 140
     },
141
+    watch: {
142
+        orderDetail: {
143
+            handler(newVal) {
144
+                if (newVal) {
145
+                    this.paymentInfo.accountHolder = newVal.accountHolder || ''
146
+                    this.paymentInfo.bankName = newVal.bankName || ''
147
+                    this.paymentInfo.bankAccount = newVal.bankCardNumber || ''
148
+                    this.paymentInfo.idNumber = newVal.idCard || ''
149
+                }
150
+            },
151
+            deep: true,
152
+        },
153
+        detailImages: {
154
+            handler(newVal) {
155
+                this.localDetailImages = [...newVal];
156
+            },
157
+            deep: true
158
+        }
159
+    },
160
+    components: {
161
+        picComp
162
+    },
140 163
     data() {
141 164
         return {
142 165
             unpaidModelShow: false,
@@ -160,14 +183,7 @@ export default {
160 183
             startY: 0 // 触摸起始Y坐标
161 184
         };
162 185
     },
163
-    watch: {
164
-        detailImages: {
165
-            handler(newVal) {
166
-                this.localDetailImages = [...newVal];
167
-            },
168
-            deep: true
169
-        }
170
-    },
186
+
171 187
     methods: {
172 188
         // 上传高清细节图
173 189
         uploadDetailImage() {

+ 17 - 0
pages/orderDetailNew/components/pageTwo.vue

@@ -132,6 +132,23 @@
132 132
 import picComp from './picComp.vue'
133 133
 
134 134
 export default {
135
+    props: {
136
+        orderDetail: {
137
+            type: Object,
138
+            default: () => { },
139
+        }
140
+    },
141
+    watch: {
142
+        orderDetail: {
143
+            handler(newVal, oldVal) {
144
+                if (newVal) {
145
+                    this.approvedPrice = newVal.itemPrice || 0;
146
+                }
147
+            },
148
+            deep: true,
149
+        }
150
+    },
151
+
135 152
     components: {
136 153
         picComp
137 154
     },

+ 36 - 3
pages/orderDetailNew/index.vue

@@ -12,14 +12,14 @@
12 12
                 </view>
13 13
             </template>
14 14
             <template v-slot:right>
15
-                <view class="slot-right">
15
+                <view class="slot-right" @click="handleAddClick">
16 16
                     <image src="/static/icons/plus.png" mode="scaleToFill" />
17 17
                     <text>加一单</text>
18 18
                 </view>
19 19
             </template>
20 20
         </u-navbar>
21 21
 
22
-        <orderDetailNewView />
22
+        <orderDetailNewView :detail="receiptDetail" />
23 23
 
24 24
         <!-- 通用模态窗 -->
25 25
         <custom-modal :visible="modalVisible" :title="modalConfig.title" :value="modalConfig.value"
@@ -49,9 +49,27 @@ export default {
49 49
                 title: '',
50 50
                 value: '',
51 51
                 placeholder: ''
52
-            }
52
+            },
53
+            item: '',
54
+            orderId: '',
55
+            type: '',
56
+            clueId: '',
57
+            // 订单详情
58
+            receiptDetail: {},
53 59
         }
54 60
     },
61
+    onLoad(option) {
62
+        // 接收参数
63
+        const { item, orderId, type, clueId } = option;
64
+        console.log('接收的参数:', option);
65
+        this.item = item;
66
+        this.orderId = orderId;
67
+        this.type = type;
68
+        this.clueId = clueId;
69
+
70
+        //查询订单详情
71
+        this.getOrderDetail();
72
+    },
55 73
     methods: {
56 74
         handleBrandClick() {
57 75
             this.openModal('brand', '请输入品牌', this.topInfo.brand, '请输入品牌')
@@ -85,6 +103,21 @@ export default {
85 103
 
86 104
             this.modalVisible = false
87 105
             this.currentEditField = ''
106
+        },
107
+        handleAddClick() {
108
+            console.log('加一单')
109
+        },
110
+
111
+        //查询订单详情
112
+        async getOrderDetail() {
113
+            const res = await uni.$u.api
114
+                .getClueSendFormVoByOrderId({
115
+                    id: this.orderId,
116
+                })
117
+            console.log('订单详情', res);
118
+            if (res.code === 200) {
119
+                this.receiptDetail = res.data;
120
+            }
88 121
         }
89 122
     }
90 123
 }