Fly пре 5 месеци
родитељ
комит
9e6749993e

+ 19 - 0
App.vue

@@ -26,4 +26,23 @@
 		overflow: hidden;
 		text-overflow: ellipsis; 
 	}
+	.tdt-label{
+		// display: block;
+		// min-width: 100rpx;
+		// width: 1;
+		min-width: 300rpx;
+		max-width: 500rpx;
+		border-radius: 14rpx;
+		padding: 15rpx !important;
+		line-height: 1.3 !important; 
+		white-space: pre-wrap !important;  
+		text-align: center;
+		// transform: translateX(-50%) !important;
+	}
+	.map-label{
+		// white-space: pre-wrap; 
+		display: block;
+		
+	}
+	
 </style>

+ 205 - 0
components/Touchbox/Touchbox.vue

@@ -0,0 +1,205 @@
+<template>
+	<view class="site-box" ref="fixbox" :style="{ 'z-index':zIndex , 'height':popupHeight + 'px'}">
+		<view class="tap-touch-line" @touchmove="getstart" @touchend="getend" />
+		<slot />
+		<!-- 		<scroll-view :style="{'height':scrollHeight - 20 + 'px' }" scroll-y="true" :show-scrollbar="false">
+			<template v-for="item in siteListArr">
+				<siteListModel :info="item" @checkSiteDetails="checkSiteDetails" />
+			</template>
+		</scroll-view> -->
+		<!-- @touchmove="getstart" @tap="tap" @touchend="getend" -->
+		<!-- :style="{'height':windowHeight + 'px','width':windowWidth + 'px','top':fixboxtop +'px','border-top-left-radius':radius,'border-top-right-radius':radius,'z-index':zIndex}" -->
+		<!-- <view class="content" :style="{'height':windowHeight + 'px'}">
+			<view class="tapBoxTouchLine" v-if="showLine">
+				<view class="line" :style="{'transform': `scaleY(${lineScale})`,'width':`${lineWidth}rpx`}"></view>
+			</view>
+			<slot />
+		</view> -->
+	</view>
+</template>
+
+<script>
+	export default {
+		name: 'Touchbox',
+		data() {
+			return {
+				windowHeight: 0,
+				touchHeight: uni.upx2px(80),
+				popupHeight: 0,
+				oldHeight: 0,
+				scrollHeight: 0,
+				minTop: 0,
+				maxTop: 0,
+			};
+		},
+
+		props: {
+			zIndex: {
+				type: Number,
+				default: 99,
+			},
+			smallHeight: {
+				type: Number,
+				default: 0.35,
+			},
+			maxHeight: {
+				type: Number,
+				default: 0.65,
+			},
+			// minHeight: {
+			// 	type: Number,
+			// 	default: 0.2,
+			// },
+		},
+		created() {
+			const { windowHeight } = uni.getSystemInfoSync();
+			this.windowHeight = windowHeight;
+			// this.windowWidth = uni.getSystemInfoSync().windowWidth;
+			this.popupHeight = this.oldHeight = windowHeight * this.smallHeight;
+
+			this.maxTop = windowHeight * (1 - this.smallHeight);
+			this.minTop = windowHeight * (1 - this.maxHeight);
+
+			// minTop:0,
+			// maxTop:0,
+		},
+		mounted() {
+			this.$nextTick(function() {
+				// this.windowWidth = uni.getSystemInfoSync().windowWidth;
+				// this.windowHeight = uni.getSystemInfoSync().windowHeight;
+				// var defaultHeight = this.windowHeight * (1 - this.minHeight);
+				// this.firsttop = defaultHeight;
+				// this.phonetop =
+				// 	(this.windowHeight * this.maxHeight - this.windowHeight * this.minHeight) / 2;
+				// this.phoneMinTop =
+				// 	(this.windowHeight * this.minHeight - this.windowHeight * this.smallHeight) / 2;
+				// this.fixboxtop = defaultHeight;
+				// this.$emit('currentHeight', this.windowHeight - this.fixboxtop);
+				// this.$emit('maxtHeight', this.windowHeight * this.maxHeight);
+			});
+		},
+		onReady() {},
+		computed: {},
+		watch: {
+			popupHeight(newH, oldH) {
+				this.scrollHeight = newH - this.touchHeight; 
+			},
+			scrollHeight: {
+				handler(newH) {
+					this.$emit('currentHeight', newH);
+				},
+				immediate: true
+			}
+		},
+		methods: {
+			// 隐藏
+			concealList() {
+				this.popupHeight = this.touchHeight
+			},
+			getstart(e) {
+				e.preventDefault();
+				const { clientY, screenY } = e.touches[0];
+				const Y = clientY || screenY;
+				console.log(Y, this.maxTop)
+				// // 这里特殊处理 解决:在滑动框内如果存在滚动元素,则会出现滑动时滑动框和内部滚动同时滑的问题
+				if (Y < this.minTop || Y > (this.windowHeight - this.touchHeight)) {
+					return
+				}
+				this.popupHeight = this.windowHeight - Y;
+			},
+			getend() {
+				if (this.popupHeight >= this.oldHeight && (this.popupHeight - this.oldHeight) > 50) {
+					// 上拉
+					this.popupHeight = this.windowHeight * this.maxHeight
+				} else if ((this.oldHeight - this.popupHeight) > 50) {
+					console.log("this.oldHeight = ", this.oldHeight, "this.popupHeight = ", this.popupHeight)
+					const s_h = this.windowHeight * this.smallHeight;
+					// 下拉
+					if (this.popupHeight >= s_h) {
+						// 在中等偏上区域,还原成中等高度
+						this.popupHeight = s_h
+					} else {
+						// 在中等偏下区域,还原成最小高度
+						this.popupHeight = this.touchHeight
+					}
+
+				} else {
+					// 拉取幅度不够,还原,防止误触发
+					this.popupHeight = this.oldHeight
+				};
+				
+				// 记录当前高度
+				this.oldHeight = this.popupHeight;
+			},
+		},
+	};
+</script>
+
+<style lang="scss" scoped>
+	.site-box {
+		position: fixed;
+		left: 0;
+		right: 0;
+		bottom: 0;
+		background-color: #ffffff;
+		// padding: 0 12px;
+		transition-property: top;
+		transition-duration: 0.7s;
+		border-radius: 40rpx 40rpx 0 0;
+
+		.tap-touch-line {
+			width: 100%;
+			height: 80rpx;
+			position: relative;
+
+			&:before {
+				content: '';
+				position: absolute;
+				left: 50%;
+				top: 50%;
+				transform: translate(-50%, -50%);
+				width: 30%;
+				height: 8rpx;
+				border-radius: 4rpx;
+				background-color: rgb(214, 215, 217);
+			}
+		}
+	}
+
+	// .tapBoxTouchLine {
+	// 	display: flex;
+	// 	align-items: center;
+	// 	justify-content: center;
+	// 	padding: 20rpx 0 30rpx;
+	// }
+
+	// .line {
+	// 	margin: 0px;
+	// 	vertical-align: middle;
+	// 	// border-bottom: 8rpx solid rgb(214, 215, 217);
+	// 	height: 8rpx;
+	// 	background-color: rgb(214, 215, 217);
+	// 	border-radius: 4rpx;
+
+	// 	// border: 4rpx;
+	// 	// border-top-color: rgb(214, 215, 217);
+	// 	// border-right-color: rgb(214, 215, 217);
+	// 	// border-left-color: rgb(214, 215, 217);
+	// }
+
+	// .fixedbox {
+	// 	position: fixed;
+	// 	left: 0;
+	// 	background-color: #ffffff;
+	// 	padding: 0 12px;
+	// }
+
+	// .fixedbox2 {
+	// 	position: fixed;
+	// 	left: 0;
+	// 	background-color: #ffffff;
+	// 	padding: 0 12px;
+	// 	transition-property: top;
+	// 	transition-duration: 0.4s;
+	// }
+</style>

+ 3 - 0
components/city/json.js

@@ -1,4 +1,7 @@
 export const cityJson = [{
+		value: undefined,
+		label: '全市'
+	},{
 		value: '420102',
 		label: '江岸区'
 	},

Разлика између датотеке није приказан због своје велике величине
+ 92 - 38
components/tiandituMap/tiandituMap.vue


+ 49 - 31
pages/map/index.vue

@@ -1,21 +1,24 @@
 <template>
 	<view class="map-box">
 		<search ref="searchRef" @handleSearch="handleSearch" v-if="showMap" />
-		
+
 		<tiandituMap ref="tiandituMapRefs" @handleSearch="$refs.searchRef.handleSearch()" @clickMap="handleClickMap"
 			@moveMap="moveMapSearch" @onLoadTianDiTu="initMaps" @onSelect="selectPoint" :apiKey="apiKey"
 			@handleMapSite="handleMapSite">
 		</tiandituMap>
-		
-		<bab-Touchbox ref="TouchboxRef" v-if="showMap && siteListArr && siteListArr.length > 0" :zIndex="1001"
+
+		<!-- 		<Touchbox ref="TouchboxRef"  :zIndex="1001"
 			:minHeight="0.35" :maxHeight="0.8" :touchHeight="64" @currentHeight="setTouchHeight"
 			@maxtHeight="setScrollMaxHeight">
-			<scroll-view :style="{'height':TouchHeight - 40  +'px' }" scroll-y="true" :show-scrollbar="false">
+			
+		</Touchbox> -->
+		<Touchbox ref="TouchboxRef" :maxHeight="0.8" v-if="showMap && siteListArr && siteListArr.length > 0" :zIndex="1001" @currentHeight="e => TouchHeight = e">
+			<scroll-view :style="{'height':TouchHeight - 15  +'px' }" scroll-y="true" :show-scrollbar="false">
 				<template v-for="item in siteListArr">
 					<siteListModel :info="item" @checkSiteDetails="checkSiteDetails" />
 				</template>
 			</scroll-view>
-		</bab-Touchbox>
+		</Touchbox>
 
 		<siteDetails ref="siteDetailsRef" />
 	</view>
@@ -28,7 +31,8 @@
 	import siteDetails from "./model/siteDetails.vue"
 	import $config from "@/config/index.js"
 	import { EventBus } from "@/utils/vueBus.js"
-	import { getLocation } from "@/utils/tool.js"
+	import { getLocation, throttle } from "@/utils/tool.js"
+	let mapThat = this;
 	export default {
 		name: 'tdtmap',
 		components: {
@@ -38,6 +42,7 @@
 		},
 		data() {
 			return {
+				mapThat: this,
 				showMap: false,
 				longitude: undefined,
 				latitude: undefined,
@@ -47,19 +52,18 @@
 				winTop: 0,
 				datalist: [],
 				startY: 0,
-				// domMaxHeight: '50vh',
-				// domMinHeight: '0vh',
 				selectItem: {},
 				iStatusBarHeight: 0,
-				 
+
 
 				siteListArr: [],
 				TouchHeight: 0,
 			}
 		},
 		created() {
+			mapThat = this;
 			getLocation();
-	 
+
 			this.getMapCenterPoint()
 		},
 		mounted() {
@@ -81,15 +85,18 @@
 			siteListArr: {
 				handler(newArr) {
 					try {
-						this.$refs.tiandituMapRefs.clearIcon();
+						this.$refs.tiandituMapRefs.clearIcon().then(res => {
+							this.$nextTick(() => {
+								(newArr || []).forEach((el, index) => {
+									const { longitude, latitude, mapTypeIcon } = el
+									this.$refs.tiandituMapRefs.setIcon(longitude, latitude, false,
+										mapTypeIcon,
+										el);
+								})
+							})
+						});
 					} catch (error) {}
-					this.$nextTick(() => {
-						(newArr || []).forEach((el, index) => {
-							const { longitude, latitude, mapTypeIcon } = el
-							this.$refs.tiandituMapRefs.setIcon(longitude, latitude, false, mapTypeIcon,
-								el);
-						})
-					})
+
 				},
 				deep: true
 			}
@@ -170,20 +177,31 @@
 					this.siteListArr = res || [];
 				}).catch(err => {
 					this.siteListArr = [];
+				}).finally(() => {
+					clearTimeout(this.SearchTimeout)
+					this.SearchTimeout = null;
 				})
-				// if (!this.selfLatitude || !this.selfLongitude) {
-				// 	getLocation().then(res => {
-				// 		this.selfLatitude = res.longitude;
-				// 		this.selfLongitude = res.latitude;
-				// 		this.onSearch(val)
-				// 	}).catch(err => {
-				// 		this.onSearch(val)
-				// 	})
-				// } else {
-				// 	this.onSearch(val)
-				// };
-			}, 
-
+			},
+			// //普通搜索
+			// handleSearch(val = {}) {
+			// 	const parms = {
+			// 		...val,
+			// 		longitude: this.longitude,
+			// 		latitude: this.latitude,
+			// 		radius: 5000
+			// 	};
+			// 	getMapList_Api(parms).then(res => {
+			// 		if (!res || res.length === 0) {
+			// 			uni.showToast({
+			// 				title: "当前区域无办理点位",
+			// 				icon: 'none'
+			// 			})
+			// 		}
+			// 		this.siteListArr = res || [];
+			// 	}).catch(err => {
+			// 		this.siteListArr = [];
+			// 	})
+			// },
 			open(lon, lat, mapTypeIcon) {
 				if (lon && lat) {
 					this.$nextTick(() => {

+ 34 - 27
pages/map/model/search.vue

@@ -42,16 +42,18 @@
 				locationName: undefined,
 				selfLatitude: undefined,
 				selfLongitude: undefined,
-
+				// selfLatitude: 30.482926,
+				// selfLongitude: 114.414431,
 				params: {
-					// selfLatitude: 30.482926,
-					// selfLongitude: 114.414431,
 					code: undefined,
 					codeLabel: undefined,
 
 					mapTypeId: undefined,
 					typeName: undefined,
-				}
+				},
+				
+				
+				SearchTimeout: null, 
 			}
 		},
 		mounted() {
@@ -74,31 +76,36 @@
 			 */
 			handleSearch(callBack) {
 				try {
-					if (!callBack && !this.locationPower) {
-						this.onSearchFocus()
-						return
-					}
-					uni.showLoading({
-						mask: true
-					})
-					this.locationPower = true;
-					getLocation().then(res => {
-						const { longitude, latitude } = res || {}
-						if (longitude && latitude) {
-							this.selfLatitude = longitude;
-							this.selfLongitude = latitude;
+					clearTimeout(this.SearchTimeout)
+					this.SearchTimeout = null;
+					this.SearchTimeout = setTimeout(() => {
+						if (!callBack && !this.locationPower) {
+							this.onSearchFocus()
+							return
 						}
-						callBack && callBack({ longitude: res.longitude, latitude: res.latitude })
-					}).catch(err => {
-						this.locationPower = false
-						uni.showToast({
-							title: '获取定位失败',
-							icon: 'none'
+						uni.showLoading({
+							mask: true
+						})
+						this.locationPower = true;
+						getLocation().then(res => {
+							const { longitude, latitude } = res || {}
+							if (longitude && latitude) {
+								this.selfLatitude = latitude;
+								this.selfLongitude = longitude;
+							}
+							callBack && callBack({ longitude: res.longitude, latitude: res.latitude })
+						}).catch(err => {
+							this.locationPower = false
+							uni.showToast({
+								title: '获取定位失败',
+								icon: 'none'
+							})
+						}).finally(() => {
+							if (!callBack) this.onSearchFocus()
+							uni.hideLoading()
 						})
-					}).finally(() => {
-						if (!callBack) this.onSearchFocus()
-						uni.hideLoading()
-					})
+					}, 150)
+
 				} catch (error) {
 					console.log(999977999, error)
 					//TODO handle the exception

Разлика између датотеке није приказан због своје велике величине
+ 54 - 42
pages/map/model/siteDetails.vue


+ 25 - 13
pages/map/model/siteList.vue

@@ -5,10 +5,10 @@
 			<view class="site-left">
 				<!-- class="one-row" -->
 				<text class="">{{`${info.provinceName}${info.cityName}${info.areaName}${info.address}`}}</text>
-				<text class="">距离{{getDistance(info.distance)}}</text>
+				<text class="site-distance">距离{{getDistance(info.distance)}}</text>
 			</view>
 			<view class="site-right">
-				<view class="site-btn" @click.stop="getPhoneCall(info.outerPhone)">
+				<view class="site-btn" @click.stop="getPhoneCall(info.mapContactList)">
 					<view class="site-icon">
 						<svg t="1733972888261" class="icon" viewBox="0 0 1024 1024" version="1.1"
 							xmlns="http://www.w3.org/2000/svg" p-id="4331" xmlns:xlink="http://www.w3.org/1999/xlink">
@@ -37,13 +37,15 @@
 			<text class="time-lable">办公时间</text>
 			<text class="site-time-val">{{info.workTimeRemark}}</text>
 		</view>
+		<telList ref="telListRef" />
 	</view>
 </template>
-<!-- <script type="text/javascript" src="https://webapi.amap.com/maps?v=2.0&key=427c1b3b7b0aaa258221992c860859f7"></script> -->
+
 <script>
-	import { distanceCalculate, PhoneCall, getMapLocation } from "@/utils/tool.js";
+	import { distanceCalculate, getMapLocation } from "@/utils/tool.js";
 	import { openMap } from "@/utils/openApp.js"
 	import { EventBus } from "@/utils/vueBus.js"
+	import telList from "./telList.vue"
 	export default {
 		props: {
 			info: {
@@ -52,6 +54,7 @@
 				default: () => {}
 			}
 		},
+		components: { telList },
 		data() {
 			return {
 				// outerPhone
@@ -65,7 +68,7 @@
 				return distanceCalculate(num)
 			},
 			getPhoneCall(tel) {
-				PhoneCall(tel)
+				this.$refs.telListRef.open({tel})
 			},
 			openLocation(info) {
 				const { areaCode, cityCode, provinceCode, provinceName, cityName, areaName, address } = info
@@ -75,7 +78,7 @@
 				openMap({ name, code: code, type: "baidu" })
 			},
 			openSite(info) {
-				this.$emit('checkSiteDetails',info)
+				this.$emit('checkSiteDetails', info)
 				// EventBus.$emit('TianDiTuSite', info)
 			}
 		}
@@ -85,8 +88,10 @@
 <style lang="scss" scoped>
 	.site-item {
 		width: 100%;
-		padding-bottom: 20rpx;
-		background-color: #f7f7f7;
+		padding: 20rpx;
+		// background-color: #f7f7f7;
+		border-bottom: 10rpx solid #f7f7f7;
+
 		// box-shadow: 1px 1px 1px 1px #ccc;
 		// background-color: #ccc;
 		.site-name {
@@ -101,7 +106,7 @@
 			display: flex;
 			justify-content: space-between;
 			align-items: center;
-		
+
 
 			.site-left {
 				width: 1px;
@@ -110,6 +115,10 @@
 				flex-direction: column;
 				font-size: 28rpx;
 				padding-bottom: 15rpx;
+
+				.site-distance {
+					color: #7D7D7D;
+				}
 			}
 
 			.site-right {
@@ -161,9 +170,11 @@
 			text {
 				flex-shrink: 0;
 			}
-			.time-lable{
+
+			.time-lable {
 				color: #7D7D7D;
 			}
+
 			.site-time-val {
 				width: 1rpx;
 				flex: 1;
@@ -171,11 +182,12 @@
 				// text-align: right;
 			}
 		}
-		&:first-child{
+
+		&:first-child {
 			.site-name {
-				padding-top: 0; 
+				padding-top: 0;
 			}
-			
+
 		}
 	}
 </style>

+ 105 - 0
pages/map/model/telList.vue

@@ -0,0 +1,105 @@
+<template>
+	<uni-popup ref="telRef" type="center" border-radius="10px 10px 0 0" maskBackgroundColor='rgba(0, 0, 0, 0.1)'>
+		<view class="tel-box">
+			<view class="tel-title">请选择电话拨打</view>
+			<view class="tel-number">
+				<view class="tel-number-item" v-for="item in telList" @click.stop="onPhoneCall(item.phone)">
+					<text>{{item.phone}}</text>
+					<text style="margin-left: 15rpx;" v-if="item.remark">({{item.remark}})</text>
+				</view>
+			</view>
+			<view class="tel-btns" @click.stop="onClose()">
+				<view class="tel-btn">关闭</view>
+			</view>
+		</view>
+	</uni-popup>
+</template>
+
+<script>
+	import { PhoneCall } from "@/utils/tool.js";
+	export default {
+		data() {
+			return {
+				telList: []
+			}
+		},
+		mounted() {
+			// this.$refs.telRef.open()
+		},
+		methods: {
+			open(parmas = {}) {
+				const { tel } = parmas;
+				if (tel) {
+					if (tel.length === 1) {
+						this.onPhoneCall(tel[0].phone)
+					} else {
+						this.telList = tel;
+						this.$refs.telRef.open()
+					}
+				}
+			},
+			onPhoneCall(phone) {
+				PhoneCall(phone).then(res => {
+					this.onClose()
+				})
+			},
+			onClose() {
+				this.$refs.telRef.close()
+				this.telList = [];
+			}
+		}
+	}
+</script>
+
+<style lang="scss" scoped>
+	.uni-popup {
+		z-index: 1002;
+
+		.tel-box {
+			width: 80vw;
+			min-height: 30vh;
+			height: auto;
+			max-height: 70vh;
+			background-color: #fff;
+			border-radius: 40rpx;
+			display: flex;
+			flex-direction: column;
+			// justify-content: center;
+			align-items: center;
+			justify-content: space-between;
+
+			.tel-title {
+				font-size: 36rpx;
+				padding: 20rpx 0;
+			}
+
+			.tel-number {
+				height: 1px;
+				flex: 1;
+				overflow: hidden;
+				overflow-y: auto;
+
+				.tel-number-item {
+					padding: 20rpx;
+					color: #3291F8;
+				}
+			}
+
+			.tel-btns {
+				padding: 20rpx 0;
+
+				.tel-btn {
+					width: 260rpx;
+					height: 80rpx;
+					display: flex;
+					justify-content: center;
+					align-items: center;
+					color: #fff;
+					border-radius: 10rpx;
+					background-color: #3291F8;
+				}
+
+			}
+		}
+	}
+</style>

+ 1 - 1
uni_modules/uni-popup/components/uni-popup/uni-popup.vue

@@ -4,7 +4,7 @@
 			<uni-transition key="1" v-if="maskShow" name="mask" mode-class="fade" :styles="maskClass"
 				:duration="duration" :show="showTrans" @click="onTap" />
 			<uni-transition key="2" :mode-class="ani" name="content" :styles="transClass" :duration="duration"
-				:show="showTrans" @click="onTap">
+				:show="showTrans" @click.stop="onTap">
 				<view class="uni-popup__wrapper" :style="getStyles" :class="[popupstyle]" @click="clear">
 					<slot />
 				</view>

+ 2 - 2
uni_modules/uni-transition/components/uni-transition/uni-transition.vue

@@ -1,9 +1,9 @@
 <template>
   <!-- #ifndef APP-NVUE -->
-  <view v-show="isShow" ref="ani" :animation="animationData" :class="customClass" :style="transformStyles" @click="onClick"><slot></slot></view>
+  <view v-show="isShow" ref="ani" :animation="animationData" :class="customClass" :style="transformStyles" @click.stop="onClick"><slot></slot></view>
   <!-- #endif -->
   <!-- #ifdef APP-NVUE -->
-  <view v-if="isShow" ref="ani" :animation="animationData" :class="customClass" :style="transformStyles" @click="onClick"><slot></slot></view>
+  <view v-if="isShow" ref="ani" :animation="animationData" :class="customClass" :style="transformStyles" @click.stop="onClick"><slot></slot></view>
   <!-- #endif -->
 </template>
 

+ 54 - 14
utils/tool.js

@@ -15,15 +15,23 @@ export const distanceCalculate = (num) => {
 // 拨打电话
 
 export const PhoneCall = (tel) => {
-	if (tel) {
-		uni.makePhoneCall({
-			phoneNumber: tel + ''
-		});
-	} else {
-		uni.showToast({
-			title: '暂未设置电话'
-		});
-	}
+	return new Promise((resolve, reject) => {
+		if (tel) {
+			uni.makePhoneCall({
+				phoneNumber: tel + '',
+				success: res => {
+					resolve()
+				},
+				fail: () => {
+					reject()
+				}
+			});
+		} else {
+			uni.showToast({
+				title: '暂未设置电话'
+			});
+		}
+	})
 }
 
 // 导航
@@ -44,16 +52,14 @@ export const getLocation = () => {
 			uni.getLocation({
 				type: 'wgs84', // 返回可以用于uni.openLocation的经纬度
 				success: (res) => {
-					console.log("getLocation 1111111111111111111= " , res)
+					console.log("getLocation 1111111111111111111= ", res)
 					// this.selfLatitude = res.longitude;
 					// this.selfLongitude = res.latitude;
 					resolve(res)
 				},
 				fail: (err) => {
 					console.log('获取位置失败2 :', err);
-				},
-				fail: () => {
-					console.log('获取位置失败3 :');
+					reject()
 				}
 			});
 		} catch (error) {
@@ -61,4 +67,38 @@ export const getLocation = () => {
 			//TODO handle the exception
 		}
 	})
-}
+}
+
+// 防抖:
+export const debounce = (func, delay) => {
+	console.log("防抖防抖防抖")
+	let timer;
+	return function() {
+		if (timer) {
+			clearTimeout(timer);
+		}
+		timer = setTimeout(() => {
+			func.apply(this, arguments);
+		}, delay);
+	};
+}
+
+
+// 节流:
+export const throttle = (func, delay) => {
+	let timer = null;
+	return () => {
+		if (!timer) {
+			func.apply(this, arguments);
+			timer = setTimeout(() => {
+				timer = null;
+			}, delay);
+		}
+	};
+}
+
+// // 使用
+// let myFunc = throttle(function() {
+//     console.log('节流函数被触发');
+// }, 1000);
+// window.addEventListener('scroll', myFunc);