Kaynağa Gözat

购物车弹窗 数量加减按钮 添加节流功能

xiaoxin 2 ay önce
ebeveyn
işleme
c59eb6d44a

+ 1 - 1
my/recruit/index.vue

@@ -1,7 +1,7 @@
 <template>
 	<view>
 		<view class="hehuo_view" v-if="XCXIsSelect == '是'">
-			<image src="../../static/images/my/hezuobg.png"></image>
+			<image src="https://mxys.chuanghai-tech.com/wmfile/20260413/82f8fa0d183f4bd3bfdab908ae8247d2.png"></image>
 			<view class="text_view">
 				<view class="item_view">
 					<view class="item_title">意向代理城市</view>

+ 1 - 1
pages/index/index.vue

@@ -2004,7 +2004,7 @@
 		height: 120rpx;
 		color: #fff;
 		font-size: 20rpx;
-		background-image: url(@/static/images/my/kefu.png);
+		background-image: url(https://mxys.chuanghai-tech.com/wmfile/20260413/b645b4f41ba34128ae6b88d2fe30c813.png);
 		background-repeat: no-repeat;
 		background-size: contain;
 	}

+ 22 - 5
pages/index/shop/goodsDet.vue

@@ -193,7 +193,7 @@
 				<text>¥</text>
 				{{ totalPrice }}
 			</view>
-			<view class="settlement_ri" @click.stop="goConfirm()">去结算</view>
+			<view class="settlement_ri" @click.stop="goConfirm_throttle()">去结算</view>
 		</view>
 		<!-- 购物车弹窗 -->
 		<u-popup v-model="popupShow" mode="bottom" border-radius="20">
@@ -220,11 +220,11 @@
 
 							<view class="flex justify-between align-center" style="margin-left: auto">
 								<view class="flex align-center justify-between">
-									<view @click.stop="noAdd(item, ind)">
+									<view @click.stop="noAdd_throttle(item, ind)">
 										<image src="../../../static/images/index/jian.png" style="width: 54rpx; height: 54rpx"></image>
 									</view>
 									<view class="text-center margin-lr-xs">{{ item.goodsNum }}</view>
-									<view @click.stop="add(item, ind)">
+									<view @click.stop="add_throttle(item, ind)">
 										<image src="../../../static/images/index/add.png" style="width: 50rpx; height: 50rpx"></image>
 									</view>
 								</view>
@@ -242,7 +242,7 @@
 					<text>¥</text>
 					{{ totalPrice }}
 				</view>
-				<view class="settlement_ri" @click.stop="goConfirm()">去结算</view>
+				<view class="settlement_ri" @click.stop="goConfirm_throttle()">去结算</view>
 			</view>
 		</u-popup>
 
@@ -294,6 +294,7 @@
 </template>
 
 <script>
+import { throttle } from '@/utils/throttle.js'
 import empty from '@/components/empty.vue'
 export default {
 	components: {
@@ -383,7 +384,8 @@ export default {
 			count: 0,
 			EvaluateList: [],
 			dataList: [], //店铺商品
-			backType: ''
+			backType: '',
+			isClick: true
 		}
 	},
 	onLoad(option) {
@@ -425,8 +427,14 @@ export default {
 				uni.hideLoading()
 			})
 		},
+		goConfirm_throttle: throttle(function () {
+			this.goConfirm()
+		}, 1000),
 		// 去结算
 		goConfirm() {
+			if (!this.isClick) {
+				return
+			}
 			if (!this.userId) {
 				uni.navigateTo({
 					url: '/pages/public/login'
@@ -664,6 +672,9 @@ export default {
 			// 	}
 			// })
 		},
+		add_throttle: throttle(function (item, index) {
+			this.add(item, index)
+		}, 180),
 		// 添加数量
 		add(item, index) {
 			// this.count++;
@@ -678,6 +689,7 @@ export default {
 			}
 			this.$Request.get('/app/order/updateGoodsNum', data).then((res) => {
 				if (res.code == 0) {
+					this.isClick = false
 					this.getOrderList()
 				} else {
 					this.$queue.showToast(res.msg)
@@ -685,6 +697,9 @@ export default {
 				}
 			})
 		},
+		noAdd_throttle: throttle(function (item, index) {
+			this.noAdd(item, index)
+		}, 180),
 		// 减少数量
 		noAdd(item, index) {
 			console.log(item, index)
@@ -698,6 +713,7 @@ export default {
 			}
 			this.$Request.get('/app/order/updateGoodsNum', data).then((res) => {
 				if (res.code == 0) {
+					this.isClick = false
 					this.getOrderList()
 				}
 			})
@@ -754,6 +770,7 @@ export default {
 						}
 					}
 				}
+				this.isClick = true
 				uni.hideLoading()
 			})
 		},

+ 25 - 12
pages/index/shop/index.vue

@@ -453,11 +453,11 @@
 
 									<view class="flex justify-between align-center" style="margin-left: auto">
 										<view class="flex align-center justify-between">
-											<view @click.stop="noAdd(item, ind)">
+											<view @click.stop="noAdd_throttle(item, ind)">
 												<image src="../../../static/images/index/jian.png" style="width: 54rpx; height: 54rpx"></image>
 											</view>
 											<view class="text-center margin-lr-xs">{{ item.goodsNum }}</view>
-											<view @click.stop="add(item, ind)">
+											<view @click.stop="add_throttle(item, ind)">
 												<image src="../../../static/images/index/add.png" style="width: 50rpx; height: 50rpx"></image>
 											</view>
 										</view>
@@ -731,28 +731,29 @@ export default {
 			shop_zhizhao: [],
 			shopTypeId: '',
 			showShopTypeId: false,
-			supermarketGoodsList: []
+			supermarketGoodsList: [],
+			isClick: true
 		}
 	},
 	onLoad(option) {
-		console.log(option, 'option',option.shopId)
+		console.log(option, 'option', option.shopId)
 		this.shopId = option.shopId
-		if(option.lat==''||option.lat==undefined){
+		if (option.lat == '' || option.lat == undefined) {
 			uni.getLocation({
 				type: 'gcj02', //返回可以用于uni.openLocation的经纬度
-				success: (res) => { 
+				success: (res) => {
 					console.log(res, '经纬度')
 					this.lat = res.latitude
 					this.lng = res.longitude
 					this.getData()
 				}
 			})
-		}else{
+		} else {
 			this.lat = option.lat
 			this.lng = option.lng
 			this.getData()
 		}
-		
+
 		this.shopTypeId = option.shopTypeId.split(',')
 		this.showShopTypeId = this.shopTypeId.includes('10')
 
@@ -770,7 +771,7 @@ export default {
 				title: '店铺详情'
 			})
 		}
-		
+
 		uni.showLoading({
 			title: '加载中',
 			mask: true // 是否显示透明蒙层,防止触摸穿透
@@ -968,7 +969,7 @@ export default {
 			}
 
 			this.$Request.get(urlreq, data).then((res) => {
-				console.log(res, '999',data)
+				console.log(res, '999', data)
 				if (res.code == 0 && res.data) {
 					this.dataList = res.data.list
 					this.shopDet = res.data.goodsShop
@@ -1002,7 +1003,7 @@ export default {
 
 					if (urlreq == '/app/goods/selectGoodsClassifyList') {
 						this.getSupermarketGoodsList(this.dataList[0].classifyId)
-					}else{
+					} else {
 						this.getSupermarketGoodsList(this.dataList[0].classifyId)
 					}
 				}
@@ -1015,7 +1016,7 @@ export default {
 				page: this.page,
 				limit: this.limit
 			}
-			console.log(dataRight,'ll')
+			console.log(dataRight, 'll')
 
 			this.$Request.get('/app/goods/selectSupermarketGoodsList', dataRight).then((res) => {
 				// console.log(res, '9996329')
@@ -1288,6 +1289,9 @@ export default {
 				})
 			}
 		},
+		add_throttle: throttle(function (item, index) {
+			this.add(item, index)
+		}, 180),
 		// 添加数量
 		add(item, index) {
 			// this.count++;
@@ -1301,6 +1305,7 @@ export default {
 			}
 			this.$Request.get('/app/order/updateGoodsNum', data).then((res) => {
 				if (res.code == 0) {
+					this.isClick = false
 					this.getOrderList()
 				} else {
 					this.$queue.showToast(res.msg)
@@ -1308,6 +1313,9 @@ export default {
 				}
 			})
 		},
+		noAdd_throttle: throttle(function (item, index) {
+			this.noAdd(item, index)
+		}, 180),
 		// 减少数量
 		noAdd(item, index) {
 			this.goodsList.orderGoodsList[0][index].goodsNum--
@@ -1320,6 +1328,7 @@ export default {
 			}
 			this.$Request.get('/app/order/updateGoodsNum', data).then((res) => {
 				if (res.code == 0) {
+					this.isClick = false
 					this.getOrderList()
 				}
 			})
@@ -1381,6 +1390,7 @@ export default {
 						}
 					}
 				}
+				this.isClick = true
 				// 加载提示关闭
 				uni.hideLoading()
 			})
@@ -1397,6 +1407,9 @@ export default {
 		}, 1000),
 		// 去结算
 		goConfirm() {
+			if (!this.isClick) {
+				return
+			}
 			if (!this.userId) {
 				uni.navigateTo({
 					url: '/pages/public/login'

+ 11 - 11
pages/my/index.vue

@@ -563,22 +563,22 @@ export default {
 					this.$queue.setData('userName', res.data.userName ? res.data.userName : res.data.nickName)
 					this.avatar = res.data.avatar ? res.data.avatar : 'https://mxys.chuanghai-tech.com/wmfile/20250814/fff4dc5d02ea4af881db9685f2e1e61d.png'
 					this.userName = res.data.userName ? res.data.userName : res.data.nickName
-					
-					const vip=res.data.isVip==1?true:false
-					
+
+					const vip = res.data.isVip == 1 ? true : false
+
 					// 2. 解析为时间戳(毫秒)
-					const expireTimestamp = new Date(res.data.vipExpirationTime).getTime();
+					const expireTimestamp = new Date(res.data.vipExpirationTime).getTime()
 					// 获取当前时间的时间戳
-					const currentTimestamp = new Date().getTime();
-					if(vip==true){
+					const currentTimestamp = new Date().getTime()
+					if (vip == true) {
 						// 3. 比较:当前时间 > 有效期 → 已过期
 						if (currentTimestamp > expireTimestamp) {
-						  this.isVip = false
-						  // 这里写过期后的逻辑(比如提示用户、跳转页面等)
+							this.isVip = false
+							// 这里写过期后的逻辑(比如提示用户、跳转页面等)
 						} else {
-						  this.isVip = true
+							this.isVip = true
 						}
-					}else{
+					} else {
 						this.isVip = false
 					}
 				}
@@ -845,7 +845,7 @@ page {
 	height: 120rpx;
 	color: #fff;
 	font-size: 20rpx;
-	background-image: url(@/static/images/my/kefu.png);
+	background-image: url(https://mxys.chuanghai-tech.com/wmfile/20260413/b645b4f41ba34128ae6b88d2fe30c813.png);
 	background-repeat: no-repeat;
 	background-size: contain;
 }

+ 24 - 5
pages/order/index.vue

@@ -49,7 +49,17 @@
 						</view>
 					</view>
 					<view style="padding: 0 30rpx; font-size: 20px">
-						{{ item.orderTypeExtra == 0 ? '上门堂食' :item.orderTypeExtra == 1 ? '上门取餐' : item.orderTypeExtra == 2 ? '骑手配送' : item.orderTypeExtra == 3 ? '商家配送' : '' }} 
+						{{
+							item.orderTypeExtra == 0
+								? '上门堂食'
+								: item.orderTypeExtra == 1
+								? '上门取餐'
+								: item.orderTypeExtra == 2
+								? '骑手配送'
+								: item.orderTypeExtra == 3
+								? '商家配送'
+								: ''
+						}}
 						<view v-if="item.orderSequence">#{{ item.orderSequence }}</view>
 					</view>
 					<view style="padding: 0 30rpx; font-size: 16px" v-if="item.idCard">身份证号:{{ item.idCard }}</view>
@@ -187,9 +197,18 @@
 
 							<view v-if="item.riderPhone" @click.stop="bindphone(item.riderPhone)">骑手电话:{{ item.riderPhone }}</view>
 							<view>
-								{{ item.orderTypeExtra == 0 ? '上门堂食' :item.orderTypeExtra == 1 ? '上门取餐' : item.orderTypeExtra == 2 ? '骑手配送' : item.orderTypeExtra == 3 ? '商家配送' : '' }} #{{
-									item.orderSequence
+								{{
+									item.orderTypeExtra == 0
+										? '上门堂食'
+										: item.orderTypeExtra == 1
+										? '上门取餐'
+										: item.orderTypeExtra == 2
+										? '骑手配送'
+										: item.orderTypeExtra == 3
+										? '商家配送'
+										: ''
 								}}
+								#{{ item.orderSequence }}
 							</view>
 						</view>
 						<view style="margin-left: auto; height: 100%; margin-top: auto">
@@ -699,7 +718,7 @@ export default {
 			}
 			// #endif
 			uni.navigateTo({
-				url: '/pages/index/shop/index?shopId=' + e + '&shopTypeId=' + item.shopTypeId+'&lat='+uni.getStorageSync('lat')+'&lng='+uni.getStorageSync('lng')
+				url: '/pages/index/shop/index?shopId=' + e + '&shopTypeId=' + item.shopTypeId + '&lat=' + uni.getStorageSync('lat') + '&lng=' + uni.getStorageSync('lng')
 			})
 		},
 		// 完成订单
@@ -1791,7 +1810,7 @@ export default {
 	height: 120rpx;
 	color: #fff;
 	font-size: 20rpx;
-	background-image: url(@/static/images/my/kefu.png);
+	background-image: url(https://mxys.chuanghai-tech.com/wmfile/20260413/b645b4f41ba34128ae6b88d2fe30c813.png);
 	background-repeat: no-repeat;
 	background-size: contain;
 }