Explorar o código

防抖、提示显示不全

baijunde hai 9 meses
pai
achega
bb74187610
Modificáronse 3 ficheiros con 93 adicións e 42 borrados
  1. 82 36
      pages/order/index.vue
  2. 5 1
      pages/store/editStore.vue
  3. 6 5
      pages/store/tdtuMap.vue

+ 82 - 36
pages/order/index.vue

@@ -779,42 +779,88 @@
 			},
 			//商户去取车
 			goGetCar(item) {
-				console.log(item)
-				let data = {
-					taskId: item.taskId,
-					checkType: item.checkType,
-					paramState: '05', //商户接单成功
-					serveType: '01'
-				}
-				let that = this
-				// uni.navigateTo({
-				// 		url: (window.location.href = `https://uri.amap.com/navigation?to=${item.userLongitude},${item.userLatitude},${item.carAddress}&mode=car&policy=1&src=https://gawl.gazhcs.com/wap/index.html&callnative=0`)
-				// })
-				this.serviceList = []
-				let page = {
-					num: 1,
-					size: 10
-				}
-				this.getserviceList(page)
-				uni.openLocation({
-					longitude: Number(item.userLongitude),
-					latitude: Number(item.userLatitude),
-					name: item.carAddres, // 位置名称
-					// address: e.F_Address, // 位置地点
-					success: function(res) {
-						console.log('打开系统位置地图成功')
-						that.$http.post("/ts/merchant/update/Serve", data).then(res => {
-							if (res.data.code == 200) {
-								// this.isReceive = true
-
-							}
-						})
-					},
-					fail: function(error) {
-						console.log(error)
-					},
-				})
-			},
+			    // 清除之前的定时器,实现防抖
+			    if (this.getCarDebounceTimer) {
+			      clearTimeout(this.getCarDebounceTimer);
+			    }
+			
+			    // 2000ms后执行真正的逻辑
+			    this.getCarDebounceTimer = setTimeout(() => {
+			      console.log(item);
+			      let data = {
+			        taskId: item.taskId,
+			        checkType: item.checkType,
+			        paramState: '05', //商户接单成功
+			        serveType: '01'
+			      };
+			      let that = this;
+			      
+			      this.serviceList = [];
+			      let page = {
+			        num: 1,
+			        size: 10
+			      };
+			      this.getserviceList(page);
+			      
+			      uni.openLocation({
+			        longitude: Number(item.userLongitude),
+			        latitude: Number(item.userLatitude),
+			        name: item.carAddres, // 位置名称(注意:原代码可能笔误,应该是carAddress?)
+			        // address: e.F_Address, // 位置地点
+			        success: function(res) {
+			          console.log('打开系统位置地图成功');
+			          that.$http.post("/ts/merchant/update/Serve", data).then(res => {
+			            if (res.data.code == 200) {
+			              // this.isReceive = true
+			            }
+			          });
+			        },
+			        fail: function(error) {
+			          console.log(error);
+			        },
+			      });
+			
+			      // 执行完成后清空定时器(可选,防止内存泄漏)
+			      this.getCarDebounceTimer = null;
+			    }, 2000); // 防抖间隔2000ms
+			  },
+			// goGetCar(item) {
+			// 	console.log(item)
+			// 	let data = {
+			// 		taskId: item.taskId,
+			// 		checkType: item.checkType,
+			// 		paramState: '05', //商户接单成功
+			// 		serveType: '01'
+			// 	}
+			// 	let that = this
+			// 	// uni.navigateTo({
+			// 	// 		url: (window.location.href = `https://uri.amap.com/navigation?to=${item.userLongitude},${item.userLatitude},${item.carAddress}&mode=car&policy=1&src=https://gawl.gazhcs.com/wap/index.html&callnative=0`)
+			// 	// })
+			// 	this.serviceList = []
+			// 	let page = {
+			// 		num: 1,
+			// 		size: 10
+			// 	}
+			// 	this.getserviceList(page)
+			// 	uni.openLocation({
+			// 		longitude: Number(item.userLongitude),
+			// 		latitude: Number(item.userLatitude),
+			// 		name: item.carAddres, // 位置名称
+			// 		// address: e.F_Address, // 位置地点
+			// 		success: function(res) {
+			// 			console.log('打开系统位置地图成功')
+			// 			that.$http.post("/ts/merchant/update/Serve", data).then(res => {
+			// 				if (res.data.code == 200) {
+			// 					// this.isReceive = true
+
+			// 				}
+			// 			})
+			// 		},
+			// 		fail: function(error) {
+			// 			console.log(error)
+			// 		},
+			// 	})
+			// },
 			//救援出发
 			depart(item) {
 				console.log(item)

+ 5 - 1
pages/store/editStore.vue

@@ -239,7 +239,11 @@
 					headPhoto: this.form.headPhoto.join(',')
 				}).then(res => {
 					if (res.data.success) {
-						this.$tip.success(res.data.result || '成功')
+						// this.$tip.success(res.data.result || '成功')
+						uni.showToast({
+							title: '提交成功',
+							icon: 'none'
+						});
 						uni.navigateTo({
 							url: '/pages/index/shop'
 						})

+ 6 - 5
pages/store/tdtuMap.vue

@@ -73,13 +73,14 @@ export default {
     }
   },
   mounted() {
+		this.$nextTick(() => {
+		  setTimeout(() => {
+		    this.initMap();
+		  }, 500);
+		});
     // 确保在H5环境下运行
     // #ifdef H5
-    this.$nextTick(() => {
-      setTimeout(() => {
-        this.initMap();
-      }, 500);
-    });
+   
     // #endif
 
     // 非H5环境提示