完善
This commit is contained in:
		
							parent
							
								
									2ada89629c
								
							
						
					
					
						commit
						e4e988e169
					
				| 
						 | 
				
			
			@ -27,10 +27,8 @@ const install = (Vue, vm) => {
 | 
			
		|||
			// 设置自定义头部content-type
 | 
			
		||||
			header: {
 | 
			
		||||
				'content-type': 'application/json;charset=UTF-8',
 | 
			
		||||
				
 | 
			
		||||
			},
 | 
			
		||||
			// ......
 | 
			
		||||
		});
 | 
			
		||||
		})
 | 
			
		||||
 | 
			
		||||
// 请求拦截部分,如配置,每次请求前都会执行
 | 
			
		||||
	Vue.prototype.$u.http.interceptor.request = (config) => {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -107,6 +107,9 @@
 | 
			
		|||
							width: 25,
 | 
			
		||||
							height: 30,
 | 
			
		||||
							iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uZXgsJE6hXbRSwbKILB4',
 | 
			
		||||
							borderColor:'#fff',
 | 
			
		||||
							borderRadius:5,
 | 
			
		||||
							bgColor: 'rgba(255, 255, 255, 0.7)'
 | 
			
		||||
						}
 | 
			
		||||
						this.covers.push(shopCover);
 | 
			
		||||
					}
 | 
			
		||||
| 
						 | 
				
			
			@ -129,6 +132,9 @@
 | 
			
		|||
								fontWeight: 700,
 | 
			
		||||
								color: '#8883F0',
 | 
			
		||||
								textShadow: '2px 2px 0px white, -2px -2px 0px white, 2px -2px 0px white, -2px 2px 0px white',
 | 
			
		||||
								borderColor:'#fff',
 | 
			
		||||
								borderRadius:5,
 | 
			
		||||
								bgColor: 'rgba(255, 255, 255, 0.7)'
 | 
			
		||||
							}
 | 
			
		||||
						}
 | 
			
		||||
						this.covers.push(shopCover);
 | 
			
		||||
| 
						 | 
				
			
			@ -257,6 +263,9 @@
 | 
			
		|||
													fontWeight: 700,
 | 
			
		||||
													color: '#8883F0',
 | 
			
		||||
													textShadow: '2px 2px 0px white, -2px -2px 0px white, 2px -2px 0px white, -2px 2px 0px white',
 | 
			
		||||
													borderColor:'#fff',
 | 
			
		||||
													borderRadius:5,
 | 
			
		||||
													bgColor: 'rgba(255, 255, 255, 0.7)'
 | 
			
		||||
												}
 | 
			
		||||
											}
 | 
			
		||||
											this.covers.push(shopCover)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -132,6 +132,9 @@
 | 
			
		|||
						width: 25,
 | 
			
		||||
						height: 30,
 | 
			
		||||
						iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uZXgsJE6hXbRSwbKILB4',
 | 
			
		||||
						borderColor:'#fff',
 | 
			
		||||
						borderRadius:5,
 | 
			
		||||
						bgColor: 'rgba(255, 255, 255, 0.7)'
 | 
			
		||||
					};
 | 
			
		||||
					this.covers.push(shopCover);
 | 
			
		||||
					}
 | 
			
		||||
| 
						 | 
				
			
			@ -153,6 +156,9 @@
 | 
			
		|||
							fontWeight: 700,
 | 
			
		||||
							color: '#8883F0',
 | 
			
		||||
							textShadow: '2px 2px 0px white, -2px -2px 0px white, 2px -2px 0px white, -2px 2px 0px white',
 | 
			
		||||
							borderColor:'#fff',
 | 
			
		||||
							borderRadius:5,
 | 
			
		||||
							bgColor: 'rgba(255, 255, 255, 0.7)'
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
					this.covers.push(shopCover);
 | 
			
		||||
| 
						 | 
				
			
			@ -181,8 +187,6 @@
 | 
			
		|||
					onlyFromCamera: true,
 | 
			
		||||
					scanType: ['qrCode'],
 | 
			
		||||
					success: res => {
 | 
			
		||||
						// console.log('扫描结果:', res);
 | 
			
		||||
						// let id = res.result
 | 
			
		||||
						function getQueryParam(url, paramName) {
 | 
			
		||||
							let regex = new RegExp(`[?&]${paramName}=([^&]*)`);
 | 
			
		||||
							let results = regex.exec(url);
 | 
			
		||||
| 
						 | 
				
			
			@ -291,32 +295,28 @@
 | 
			
		|||
													anchorX: (() => {
 | 
			
		||||
														if (item.name.length <= 2) {
 | 
			
		||||
															return -12
 | 
			
		||||
														} else if (item.name.length <=
 | 
			
		||||
															3) {
 | 
			
		||||
														} else if (item.name.length <= 3) {
 | 
			
		||||
															return -20
 | 
			
		||||
														} else if (item.name.length <=
 | 
			
		||||
															4) {
 | 
			
		||||
														} else if (item.name.length <= 4) {
 | 
			
		||||
															return -25
 | 
			
		||||
														} else if (item.name.length <=
 | 
			
		||||
															5) {
 | 
			
		||||
														} else if (item.name.length <= 5) {
 | 
			
		||||
															return -30
 | 
			
		||||
														} else if (item.name.length <=
 | 
			
		||||
															6) {
 | 
			
		||||
														} else if (item.name.length <= 6) {
 | 
			
		||||
															return -35
 | 
			
		||||
														} else if (item.name.length <=
 | 
			
		||||
															8) {
 | 
			
		||||
														} else if (item.name.length <= 8) {
 | 
			
		||||
															return -40
 | 
			
		||||
														} else if (item.name.length <=
 | 
			
		||||
															10) {
 | 
			
		||||
														} else if (item.name.length <= 10) {
 | 
			
		||||
															return -45
 | 
			
		||||
														} else {
 | 
			
		||||
															return -item.name.length *
 | 
			
		||||
																5
 | 
			
		||||
															return -item.name.length * 5
 | 
			
		||||
														}
 | 
			
		||||
													})(),
 | 
			
		||||
													fontWeight: 700,
 | 
			
		||||
													color: '#8883F0',
 | 
			
		||||
													textShadow: '2px 2px 0px white, -2px -2px 0px white, 2px -2px 0px white, -2px 2px 0px white',
 | 
			
		||||
													borderColor:'#fff',
 | 
			
		||||
													borderRadius:5,
 | 
			
		||||
													bgColor: 'rgba(255, 255, 255, 0.7)'
 | 
			
		||||
												}
 | 
			
		||||
											};
 | 
			
		||||
											this.covers.push(shopCover);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -186,61 +186,7 @@
 | 
			
		|||
				})
 | 
			
		||||
			},
 | 
			
		||||
 | 
			
		||||
			updateMarkers() {
 | 
			
		||||
				this.mapContext.getScale({
 | 
			
		||||
					success: (res) => {
 | 
			
		||||
						this.covers = [];
 | 
			
		||||
						if (res.scale <= 14) {
 | 
			
		||||
							this.addMarkersWithoutLabels();
 | 
			
		||||
						} else {
 | 
			
		||||
							this.addMarkersWithLabels();
 | 
			
		||||
						}
 | 
			
		||||
					},
 | 
			
		||||
					fail: (error) => {
 | 
			
		||||
						// console.error('获取地图缩放级别失败:', error);
 | 
			
		||||
					},
 | 
			
		||||
				});
 | 
			
		||||
			},
 | 
			
		||||
			addMarkersWithoutLabels() {
 | 
			
		||||
				this.listmap.forEach((item) => {
 | 
			
		||||
					if (item.deviceCount !== null && item.deviceCount > 0){
 | 
			
		||||
						const shopCover = {
 | 
			
		||||
						id: parseFloat(item.storeId),
 | 
			
		||||
						latitude: item.lat,
 | 
			
		||||
						longitude: item.lng,
 | 
			
		||||
						width: 25,
 | 
			
		||||
						height: 30,
 | 
			
		||||
						iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uZXgsJE6hXbRSwbKILB4',
 | 
			
		||||
					};
 | 
			
		||||
					this.covers.push(shopCover)
 | 
			
		||||
					}
 | 
			
		||||
			
 | 
			
		||||
				});
 | 
			
		||||
			},
 | 
			
		||||
			addMarkersWithLabels() {
 | 
			
		||||
				this.listmap.forEach((item) => {
 | 
			
		||||
					if (item.deviceCount !== null && item.deviceCount > 0){
 | 
			
		||||
						const shopCover = {
 | 
			
		||||
						id: parseFloat(item.storeId),
 | 
			
		||||
						latitude: item.lat,
 | 
			
		||||
						longitude: item.lng,
 | 
			
		||||
						width: 25,
 | 
			
		||||
						height: 30,
 | 
			
		||||
						iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uZXgsJE6hXbRSwbKILB4',
 | 
			
		||||
						label: {
 | 
			
		||||
							content: item.name,
 | 
			
		||||
							anchorX: this.calculateAnchorX(item.name),
 | 
			
		||||
							fontWeight: 700,
 | 
			
		||||
							color: '#8883F0',
 | 
			
		||||
							textShadow: '2px 2px 0px #000, -2px -2px 0px #000, 2px -2px 0px #000, -2px 2px 0px #000',
 | 
			
		||||
							rotate: 20
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
					this.covers.push(shopCover)
 | 
			
		||||
					}
 | 
			
		||||
					
 | 
			
		||||
				});
 | 
			
		||||
			},
 | 
			
		||||
			calculateAnchorX(name) {
 | 
			
		||||
				let chineseLength = 0
 | 
			
		||||
				let englishLength = 0
 | 
			
		||||
| 
						 | 
				
			
			@ -297,8 +243,6 @@
 | 
			
		|||
			},
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
			btnindex(num) {
 | 
			
		||||
				if (num == 2) {
 | 
			
		||||
					uni.navigateTo({
 | 
			
		||||
| 
						 | 
				
			
			@ -404,10 +348,9 @@
 | 
			
		|||
													})(),
 | 
			
		||||
													fontWeight: 700,
 | 
			
		||||
													color: '#8883F0',
 | 
			
		||||
													textShadow: '2px 2px 0px white, -2px -2px 0px white, 2px -2px 0px white, -2px 2px 0px white',
 | 
			
		||||
													style: {
 | 
			
		||||
											
 | 
			
		||||
													},
 | 
			
		||||
													borderColor:'#fff',
 | 
			
		||||
													borderRadius:5,
 | 
			
		||||
													bgColor: 'rgba(255, 255, 255, 0.7)'
 | 
			
		||||
												}
 | 
			
		||||
											}
 | 
			
		||||
											this.covers.push(shopCover)
 | 
			
		||||
| 
						 | 
				
			
			@ -421,6 +364,65 @@
 | 
			
		|||
					}
 | 
			
		||||
				});
 | 
			
		||||
			},
 | 
			
		||||
			updateMarkers() {
 | 
			
		||||
				this.mapContext.getScale({
 | 
			
		||||
					success: (res) => {
 | 
			
		||||
						this.covers = []; // 清空之前的覆盖物  
 | 
			
		||||
						if (res.scale <= 14) {
 | 
			
		||||
							this.addMarkersWithoutLabels();
 | 
			
		||||
						} else {
 | 
			
		||||
							this.addMarkersWithLabels();
 | 
			
		||||
						}
 | 
			
		||||
					},
 | 
			
		||||
					fail: (error) => {
 | 
			
		||||
						console.error('获取地图缩放级别失败:', error);
 | 
			
		||||
					},
 | 
			
		||||
				})
 | 
			
		||||
			},
 | 
			
		||||
			addMarkersWithoutLabels() {
 | 
			
		||||
				this.listmap.forEach((item) => {
 | 
			
		||||
					if (item.deviceCount !== null && item.deviceCount > 0){
 | 
			
		||||
						const shopCover = {
 | 
			
		||||
						id: parseFloat(item.storeId),
 | 
			
		||||
						latitude: item.lat,
 | 
			
		||||
						longitude: item.lng,
 | 
			
		||||
						width: 25,
 | 
			
		||||
						height: 30,
 | 
			
		||||
						iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uZXgsJE6hXbRSwbKILB4',
 | 
			
		||||
						borderColor:'#fff',
 | 
			
		||||
						borderRadius:5,
 | 
			
		||||
						bgColor: 'rgba(255, 255, 255, 0.7)'
 | 
			
		||||
					};
 | 
			
		||||
					this.covers.push(shopCover);
 | 
			
		||||
					}
 | 
			
		||||
				});
 | 
			
		||||
			},
 | 
			
		||||
			addMarkersWithLabels() {
 | 
			
		||||
				this.listmap.forEach((item) => {
 | 
			
		||||
					if (item.deviceCount !== null && item.deviceCount > 0){
 | 
			
		||||
						const shopCover = {
 | 
			
		||||
						id: parseFloat(item.storeId),
 | 
			
		||||
						latitude: item.lat,
 | 
			
		||||
						longitude: item.lng,
 | 
			
		||||
						width: 25,
 | 
			
		||||
						height: 30,
 | 
			
		||||
						iconPath: 'https://api.ccttiot.com/smartmeter/img/static/uZXgsJE6hXbRSwbKILB4',
 | 
			
		||||
						label: {
 | 
			
		||||
							content: item.name,
 | 
			
		||||
							anchorX: this.calculateAnchorX(item.name),
 | 
			
		||||
							fontWeight: 700,
 | 
			
		||||
							color: '#8883F0',
 | 
			
		||||
							textShadow: '2px 2px 0px white, -2px -2px 0px white, 2px -2px 0px white, -2px 2px 0px white',
 | 
			
		||||
							borderColor:'#fff',
 | 
			
		||||
							borderRadius:5,
 | 
			
		||||
							bgColor: 'rgba(255, 255, 255, 0.7)'
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
					this.covers.push(shopCover);
 | 
			
		||||
					}
 | 
			
		||||
					
 | 
			
		||||
				});
 | 
			
		||||
			},
 | 
			
		||||
 | 
			
		||||
			handleMarkerClick(event) {
 | 
			
		||||
				let markerId = event.markerId;
 | 
			
		||||
| 
						 | 
				
			
			@ -457,8 +459,9 @@
 | 
			
		|||
					} else {
 | 
			
		||||
						this.jmlogin()
 | 
			
		||||
					}
 | 
			
		||||
				});
 | 
			
		||||
				})
 | 
			
		||||
			},
 | 
			
		||||
			
 | 
			
		||||
			jmlogin() {
 | 
			
		||||
				let taht = this
 | 
			
		||||
				wx.login({
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user