wangchao 3 gadi atpakaļ
vecāks
revīzija
dabeb61da4

+ 10 - 5
components/linzq-citySelect/linzq-citySelect.vue

@@ -96,11 +96,12 @@
 				showMask: false,
 				disdingwei: true,
 				Visit: [], //最近访问
-				position: '营口',
+				position: '营口',
 				longitude: '', //经度
 				latitude: '', //纬度
 				seconds: 3,
 				po_tips: '重新定位',
+				positionObj:{}
 			}
 		},
 
@@ -191,9 +192,10 @@
 				}
 			},
 
-			back_city(item) {
+			back_city(item) {debugger
 				if (item) {
-					this.$emit('back_city', item);
+					this.positionObj.positionName = item
+					this.$emit('back_city', this.positionObj);
 					//unshift 把数据插入到首位,与push相反
 					this.Visit.unshift(item)
 					this.searchValue = "";
@@ -227,9 +229,12 @@
 					that.seconds--;
 					uni.getLocation({
 						type: 'gcj02',
+						geocode: true,
 						success: function(res) {
-							console.log('当前位置的经度:' + res.longitude);
-							console.log('当前位置的纬度:' + res.latitude);
+							// console.log('当前位置的经度:' + res.longitude);
+							// console.log('当前位置的纬度:' + res.latitude);
+							// console.log(res)
+							that.positionObj = res;
 							that.longitude = res.longitude
 							that.latitude = res.latitude
 							that.position = res.address.city

+ 300 - 100
pages/grain_pulse/distribution/distribution.nvue

@@ -6,10 +6,12 @@
 				<text class="text Medium title">{{address}}</text>
 			</view>
 			<view class="selectType">
-				<text @click="selectType" class="header-type Regular">{{typeStr}}</text>
-				<!-- 				<u-icon :style="{transform:(showType?'rotate(180deg)':'')}" name="arrow-down-fill" size="8"
-					color="#AFB3BF" class="icon"></u-icon> -->
+				<picker @change="bindPickerChange" :value="index" :range="typeList">
+					<text class="uni-input header-type">{{typeList[index]}}</text>
+				</picker>
 			</view>
+
+
 		</view>
 		<view class="uni-common-mt">
 			<view class="content">
@@ -18,57 +20,142 @@
 				</map>
 			</view>
 		</view>
-		<view class="alert">
-			<view class="select-alert" v-if="showType">
-				<view class="select-top">
-					<text class="cancel" @click="cancel">取消</text>
-					<text class="confirm" @click="confirm">确定</text>
-				</view>
-				<view class="select">
-					<text class="select-item" v-for="(item,index) in typeList" :key="index">
-						{{item.name}}
-					</text>
-				</view>
-			</view>
-		</view>
-
 		<view class="content2">
 			<view class="no-enterprise Regular" v-if="enterpriseList.length!=0">
 				附近暂无相关企业
 			</view>
 			<view class="warp">
-				<view class="top-line"></view>
-				<view class="bottom-list-item">
-					<view class="left"><img src="../../../static/img/location.png" alt=""></view>
-					<view class="middle">
-						<view class="title Medium">中天昊元粮库中天昊元粮库</view>
-						<view class="location Regular">辽宁省营口市鲅鱼圈区xx路108号</view>
+				<view class="line-style"  @click="lineClick">
+					<text class="top-line"></text>
+				</view>
+				<scroll-view :scroll-top="scrollTop" :scroll-y="isscroll" @scrolltoupper="upper" @scrolltolower="lower"
+					@scroll="scroll" :class="{'active':isActive}" class="scroll-style">
+					<view class="bottom-list-item">
+						<img class="left-img" src="/static/location.png" alt="">
+						<view class="middle">
+							<text class="title Medium">中天昊元粮库中天昊元粮库</text>
+							<text class="localtion Regular">辽宁省营口市鲅鱼圈区xx路108号</text>
+						</view>
+						<text class="line"></text>
+						<view class="right">
+							<img class="right-img" src="/static/location.png" alt="">
+							<text class="right-bottom Regular">500m</text>
+						</view>
 					</view>
-					<view class="line"></view>
-					<view class="right">
-						<view class="top">
-							<img src="../../../static/img/location.png" alt="">
+					<view class="bottom-list-item">
+						<img class="left-img" src="/static/location.png" alt="">
+						<view class="middle">
+							<text class="title Medium">中天昊元粮库中天昊元粮库</text>
+							<text class="localtion Regular">辽宁省营口市鲅鱼圈区xx路108号</text>
+						</view>
+						<text class="line"></text>
+						<view class="right">
+							<img class="right-img" src="/static/location.png" alt="">
+							<text class="right-bottom Regular">500m</text>
 						</view>
-						<view class="bottom Regular">500m</view>
 					</view>
-				</view>
-				<view class="bottom-list-item">
-					<view class="left"><img src="../../../static/img/location.png" alt=""></view>
-					<view class="middle">
-						<view class="title Medium">中天昊元粮库中天昊元粮库</view>
-						<view class="location Regular">辽宁省营口市鲅鱼圈区xx路108号</view>
+					<view class="bottom-list-item">
+						<img class="left-img" src="/static/location.png" alt="">
+						<view class="middle">
+							<text class="title Medium">中天昊元粮库中天昊元粮库</text>
+							<text class="localtion Regular">辽宁省营口市鲅鱼圈区xx路108号</text>
+						</view>
+						<text class="line"></text>
+						<view class="right">
+							<img class="right-img" src="/static/location.png" alt="">
+							<text class="right-bottom Regular">500m</text>
+						</view>
 					</view>
-					<view class="line"></view>
-					<view class="right">
-						<view class="top">
-							<img src="../../../static/img/location.png" alt="">
+					<view class="bottom-list-item">
+						<img class="left-img" src="/static/location.png" alt="">
+						<view class="middle">
+							<text class="title Medium">中天昊元粮库中天昊元粮库</text>
+							<text class="localtion Regular">辽宁省营口市鲅鱼圈区xx路108号</text>
+						</view>
+						<text class="line"></text>
+						<view class="right">
+							<img class="right-img" src="/static/location.png" alt="">
+							<text class="right-bottom Regular">500m</text>
 						</view>
-						<view class="bottom Regular">500m</view>
 					</view>
-				</view>
+					<view class="bottom-list-item">
+						<img class="left-img" src="/static/location.png" alt="">
+						<view class="middle">
+							<text class="title Medium">中天昊元粮库中天昊元粮库</text>
+							<text class="localtion Regular">辽宁省营口市鲅鱼圈区xx路108号</text>
+						</view>
+						<text class="line"></text>
+						<view class="right">
+							<img class="right-img" src="/static/location.png" alt="">
+							<text class="right-bottom Regular">500m</text>
+						</view>
+					</view>
+					<view class="bottom-list-item">
+						<img class="left-img" src="/static/location.png" alt="">
+						<view class="middle">
+							<text class="title Medium">中天昊元粮库中天昊元粮库</text>
+							<text class="localtion Regular">辽宁省营口市鲅鱼圈区xx路108号</text>
+						</view>
+						<text class="line"></text>
+						<view class="right">
+							<img class="right-img" src="/static/location.png" alt="">
+							<text class="right-bottom Regular">500m</text>
+						</view>
+					</view>
+					<view class="bottom-list-item">
+						<img class="left-img" src="/static/location.png" alt="">
+						<view class="middle">
+							<text class="title Medium">中天昊元粮库中天昊元粮库</text>
+							<text class="localtion Regular">辽宁省营口市鲅鱼圈区xx路108号</text>
+						</view>
+						<text class="line"></text>
+						<view class="right">
+							<img class="right-img" src="/static/location.png" alt="">
+							<text class="right-bottom Regular">500m</text>
+						</view>
+					</view>
+					<view class="bottom-list-item">
+						<img class="left-img" src="/static/location.png" alt="">
+						<view class="middle">
+							<text class="title Medium">中天昊元粮库中天昊元粮库</text>
+							<text class="localtion Regular">辽宁省营口市鲅鱼圈区xx路108号</text>
+						</view>
+						<text class="line"></text>
+						<view class="right">
+							<img class="right-img" src="/static/location.png" alt="">
+							<text class="right-bottom Regular">500m</text>
+						</view>
+					</view>
+					<view class="bottom-list-item">
+						<img class="left-img" src="/static/location.png" alt="">
+						<view class="middle">
+							<text class="title Medium">中天昊元粮库中天昊元粮库</text>
+							<text class="localtion Regular">辽宁省营口市鲅鱼圈区xx路108号</text>
+						</view>
+						<text class="line"></text>
+						<view class="right">
+							<img class="right-img" src="/static/location.png" alt="">
+							<text class="right-bottom Regular">500m</text>
+						</view>
+					</view>
+					<view class="bottom-list-item">
+						<img class="left-img" src="/static/location.png" alt="">
+						<view class="middle">
+							<text class="title Medium">中天昊元粮库中天昊元粮库</text>
+							<text class="localtion Regular">辽宁省营口市鲅鱼圈区xx路108号</text>
+						</view>
+						<text class="line"></text>
+						<view class="right">
+							<img class="right-img" src="/static/location.png" alt="">
+							<text class="right-bottom Regular">500m</text>
+						</view>
+					</view>
+				</scroll-view>
+
 			</view>
 
 		</view>
+
 	</view>
 </template>
 <script>
@@ -76,6 +163,12 @@
 	export default {
 		data() {
 			return {
+				isscroll: true,
+				scrollTop: 0,
+				old: {
+					scrollTop: 0
+				},
+				"isActive": false,
 				address: {},
 				nowLocation: {
 					longitude: '',
@@ -83,17 +176,9 @@
 				},
 				showType: false,
 				enterpriseList: [],
-				typeStr: '全部类型',
-				typeList: [{
-						name: "全部"
-					},
-					{
-						name: "粮库"
-					},
-					{
-						name: "加工厂"
-					}
-				],
+				// typeStr: '全部类型',
+				index: 0,
+				typeList: ['全部类型', '粮仓', '加工厂'],
 				title: 'map',
 				latitude: 39.909,
 				longitude: 116.39742,
@@ -118,6 +203,24 @@
 			// })  
 		},
 		methods: {
+			lineClick(){
+				this.isActive= !this.isActive
+				// this.isscroll = !this.isscroll
+			},
+			upper: function(e) {
+				console.log(e)
+			},
+			lower: function(e) {
+				console.log(e)
+			},
+			scroll: function(e) {
+				console.log(e)
+				this.old.scrollTop = e.detail.scrollTop
+			},
+			bindPickerChange: function(e) {
+				console.log('picker发送选择改变,携带值为', e.target)
+				this.index = e.detail.value
+			},
 			confirm() {
 				console.log('确定')
 				this.showType = false
@@ -130,53 +233,55 @@
 				this.showType = true
 				console.log(1)
 			},
-			typeConfirm(e) {
-				console.log(e)
-				this.typeStr = this.typeList[e[0]].name
+			// typeConfirm(e) {
+			// 	console.log(e)
+			// 	this.typeStr = this.typeList[e[0]].name
 
-			},
+			// },
 			getLocation() {
 				let that = this;
-				uni.getLocation({
-					type: 'gcj02',
-					geocode: true,
-					success: function(res) {
-						that.nowLocation.longitude = res.longitude
-						that.nowLocation.latitude = res.latitude
-						that.covers[0].longitude = res.longitude
-						that.covers[0].latitude = res.latitude
-						let _coverrsData = []
-						for (let i = 0; i < 50; i++) {
-							let _obj = {
-								id: i,
-								latitude: res.latitude += 0.00150,
-								longitude: res.longitude + 0.00150,
-								iconPath: '../../../static/img/location.png',
-								width:30,
-								height:30,
-								callout: {
-									content: '中天昊元粮库',
-									color: '#333333',
-									fontSize: 24,
-									borderRadius: 20,
-									padding:10,
-									bgColor: 'white',
-									display: 'ALWAYS',
-								},
-							}
-							_coverrsData.push(_obj)
-						}
-						that.covers = _coverrsData
-						console.log('获取位置数据:', res);
-						console.log('当前位置的经度:' + res.longitude);
-						console.log('当前位置的纬度:' + res.latitude);
-						//拼接当前定位回显地址
-						let _address = res.address
-
-						that.address = _address.province + _address.city + _address.district + _address.poiName
-						console.log(that.address)
-					}
-				});
+				// uni.getLocation({
+				// 	type: 'gcj02',
+				// 	geocode: true,
+				// 	success: function(res) {
+				// 		that.nowLocation.longitude = res.longitude
+				// 		that.nowLocation.latitude = res.latitude
+				// 		that.covers[0].longitude = res.longitude
+				// 		that.covers[0].latitude = res.latitude
+				// 		let _coverrsData = []
+				// 		for (let i = 0; i < 50; i++) {
+				// 			let _obj = {
+				// 				id: i,
+				// 				latitude: res.latitude += 0.00150,
+				// 				longitude: res.longitude + 0.00150,
+				// 				iconPath: '../../../static/img/location.png',
+				// 				width: 30,
+				// 				height: 30,
+				// 				callout: {
+				// 					content: '中天昊元粮库',
+				// 					color: '#333333',
+				// 					fontSize: 12,
+				// 					borderRadius: 20,
+				// 					padding: 4,
+				// 					bgColor: 'white',
+				// 					display: 'ALWAYS',
+				// 				},
+				// 			}
+				// 			_coverrsData.push(_obj)
+				// 		}
+				// 		that.covers = _coverrsData
+				// 		console.log('获取位置数据:', res);
+				// 		console.log('当前位置的经度:' + res.longitude);
+				// 		console.log('当前位置的纬度:' + res.latitude);
+				// 		//拼接当前定位回显地址
+
+				// 		// #ifdef APP-PLUS
+				// 		let _address = res.address
+				// 		that.address = _address.province + _address.city + _address.district + _address.poiName
+				// 		console.log(that.address)
+				// 		// #endif
+				// 	}
+				// });
 			},
 			markertap(e) {
 				console.log(e)
@@ -185,12 +290,19 @@
 					icon: 'none',
 					duration: 2000
 				})
+			},
+			getLst() {
+				console.log("加载数据")
 			}
 
 		}
 	}
 </script>
 <style scoped>
+	.active {
+		height: 583rpx!important;
+	}
+
 	.header {
 		flex-direction: row;
 		justify-content: space-between;
@@ -200,6 +312,8 @@
 
 	.title {
 		font-size: 32rpx;
+		font-weight: 500;
+		color: #333333;
 	}
 
 	.content {
@@ -216,12 +330,21 @@
 		bottom: 0;
 		width: 750rpx;
 		flex: 1;
-		font-size: 34px;
-		background: pink;
+		font-size: 34rpx;
+		background: white;
+		border-top-left-radius: 20rpx;
+		border-top-right-radius: 20rpx;
+	}
+
+	.warp {
+		/* 		flex-direction: row;
+		justify-content: center; */
 	}
 
 	.header-type {
 		font-size: 26rpx;
+		font-weight: 400;
+		color: #333333;
 	}
 
 	.alert {
@@ -253,17 +376,94 @@
 		align-items: center;
 		background: white;
 	}
-	.cancel{
+
+	.cancel {
 		font-size: 24rpx;
 		color: white;
 		font-weight: bold;
 	}
-	.confirm{
+
+	.confirm {
 		font-size: 24rpx;
 		color: green;
 		font-weight: bold;
 	}
-	.select-item{
+
+	.select-item {
 		font-size: 24rpx;
 	}
+
+	.warp {}
+
+	.bottom-list-item {
+		flex-direction: row;
+		justify-content: space-between;
+		margin-bottom: 20rpx;
+		padding-bottom: 20rpx;
+		margin-top: 20rpx;
+		border-bottom: 1px solid #EEEEEE;
+	}
+
+	.left {}
+
+	.left-img {
+		width: 102rpx;
+		height: 106rpx;
+	}
+
+	.localtion {
+		font-size: 24rpx;
+		font-weight: 400;
+		color: #AFB3BF;
+	}
+
+	.localtion {
+
+		flex-direction: column;
+	}
+
+	.right-img {
+		width: 21rpx;
+		height: 26rpx;
+		background: #AFB3BF;
+	}
+
+	.right {
+		flex-direction: column;
+		justify-content: center;
+		align-items: center;
+	}
+
+	.middle {
+		flex-direction: column;
+		justify-content: center;
+	}
+
+	.warp {
+		padding: 20rpx;
+	}
+
+	.right-bottom {
+		font-size: 24rpx;
+		font-weight: 400;
+		color: #AFB3BF;
+	}
+
+	.top-line {
+		width: 68px;
+		height: 8px;
+		background: #B4B7C3;
+		border-radius: 4px;
+		flex-direction: row;
+		margin-bottom: 30rpx;
+	}
+
+	.line-style {
+		flex-direction: row;
+		justify-content: center;
+	}
+
+	.scroll-style {
+		height: 130rpx;
+	}
 </style>

+ 52 - 247
pages/grain_pulse/distribution/distribution.vue

@@ -1,269 +1,74 @@
 <template>
 	<view class="container">
-		<view class="header">
-			<view class="now-location">
-				<u-icon name="map" size="36" class="icon"></u-icon>
-				<text class="text Medium title">{{address}}</text>
-			</view>
-			<view class="selectType">
-				<text @click="selectType" class="header-type Regular">{{typeStr}}</text>
-				<!-- 				<u-icon :style="{transform:(showType?'rotate(180deg)':'')}" name="arrow-down-fill" size="8"
-					color="#AFB3BF" class="icon"></u-icon> -->
-			</view>
-		</view>
-		<view class="uni-common-mt">
-			<view class="content">
-				<map class="map" @markertap="markertap" :latitude="nowLocation.latitude"
-					:longitude="nowLocation.longitude" :markers="covers" :enable-poi="true">
-				</map>
-			</view>
-		</view>
-		<view class="alert">
-			<view class="select-alert" v-if="showType">
-				<view class="select-top">
-					<text class="cancel" @click="cancel">取消</text>
-					<text class="confirm" @click="confirm">确定</text>
-				</view>
-				<view class="select">
-					<text class="select-item" v-for="(item,index) in typeList" :key="index">
-						{{item.name}}
-					</text>
-				</view>
-			</view>
-		</view>
-
-		<view class="content2">
-			<view class="no-enterprise Regular" v-if="enterpriseList.length!=0">
-				附近暂无相关企业
-			</view>
-			<view class="warp">
-				<view class="top-line"></view>
-				<view class="bottom-list-item">
-					<view class="left"><img src="../../../static/img/location.png" alt=""></view>
-					<view class="middle">
-						<view class="title Medium">中天昊元粮库中天昊元粮库</view>
-						<view class="location Regular">辽宁省营口市鲅鱼圈区xx路108号</view>
-					</view>
-					<view class="line"></view>
-					<view class="right">
-						<view class="top">
-							<img src="../../../static/img/location.png" alt="">
-						</view>
-						<view class="bottom Regular">500m</view>
-					</view>
-				</view>
-				<view class="bottom-list-item">
-					<view class="left"><img src="../../../static/img/location.png" alt=""></view>
-					<view class="middle">
-						<view class="title Medium">中天昊元粮库中天昊元粮库</view>
-						<view class="location Regular">辽宁省营口市鲅鱼圈区xx路108号</view>
-					</view>
-					<view class="line"></view>
-					<view class="right">
-						<view class="top">
-							<img src="../../../static/img/location.png" alt="">
-						</view>
-						<view class="bottom Regular">500m</view>
-					</view>
-				</view>
-			</view>
-
-		</view>
+	<map 
+	
+	:latitude="latitude"
+	
+	:longitude="longitude"
+	
+	scale="11" 
+	
+	:markers="markers"
+	
+	:show-location="true"
+	
+	@markertap="markertap"
+	
+	@updated='mapUpdated'
+	
+	@tap='closeMapMarker'></map>
 	</view>
 </template>
 <script>
-	// import amap from '@/js_sdk/js-amap/amap-wx.130.js'
+	import amap from '@/js_sdk/js-amap/amap-wx.130.js'
 	export default {
 		data() {
 			return {
-				address: {},
-				nowLocation: {
-					longitude: '',
-					latitude: ''
-				},
-				showType: false,
-				enterpriseList: [],
-				typeStr: '全部类型',
-				typeList: [{
-						name: "全部"
-					},
-					{
-						name: "粮库"
-					},
-					{
-						name: "加工厂"
-					}
-				],
-				title: 'map',
-				latitude: 39.909,
-				longitude: 116.39742,
-				covers: [{
-					id: 0,
-					latitude: 39.9085,
-					longitude: 116.39747,
-					iconPath: '../../../static/img/location.png',
-				}]
+				
 			}
 		},
 		onShow() {
 
 		},
 		onLoad() {
-			//获取当前位置
-			this.getLocation()
-			// var subnvue = uni.getSubNVueById('popup') // 获取nvue
-			// 	subnvue.show()  // 显示nvue
-			// uni.$on('popup', (data) => {
-			// 	console.log(data)
-			// })  
-		},
-		methods: {
-			confirm() {
-				console.log('确定')
-				this.showType = false
-			},
-			cancel() {
-				console.log('取消')
-				this.showType = false
-			},
-			selectType() {
-				this.showType = true
-				console.log(1)
-			},
-			typeConfirm(e) {
-				console.log(e)
-				this.typeStr = this.typeList[e[0]].name
-
-			},
-			getLocation() {
-				let that = this;
-				uni.getLocation({
-					type: 'gcj02',
-					geocode: true,
-					success: function(res) {
-						that.nowLocation.longitude = res.longitude
-						that.nowLocation.latitude = res.latitude
-						that.covers[0].longitude = res.longitude
-						that.covers[0].latitude = res.latitude
-						let _coverrsData = []
-						for (let i = 0; i < 50; i++) {
-							let _obj = {
-								id: i,
-								latitude: res.latitude += 0.00150,
-								longitude: res.longitude + 0.00150,
-								iconPath: '../../../static/img/location.png',
-								width:30,
-								height:30,
-								callout: {
-									content: '中天昊元粮库',
-									color: '#333333',
-									fontSize: 24,
-									borderRadius: 20,
-									padding:10,
-									bgColor: 'white',
-									display: 'ALWAYS',
-								},
-							}
-							_coverrsData.push(_obj)
-						}
-						that.covers = _coverrsData
-						console.log('获取位置数据:', res);
-						console.log('当前位置的经度:' + res.longitude);
-						console.log('当前位置的纬度:' + res.latitude);
-						//拼接当前定位回显地址
-						let _address = res.address
-
-						that.address = _address.province + _address.city + _address.district + _address.poiName
-						console.log(that.address)
-					}
-				});
+			this.amapPlugin = new amap.AMapWX({
+			
+			key: this.mapKey  //该key 是在高德中申请的微信小程序key
+			
+			});
+			
+			this.amapPlugin.getRegeo({
+			
+			type: 'gcj02', //map 组件使用的经纬度是国测局坐标, type 为 gcj02
+			
+			success: function(res) {
+			
+			const latitude = res[0].latitude;
+			
+			const longitude = res[0].longitude;
+			
+			that.longitude = longitude;
+			
+			that.latitude = latitude;
+			
+			that.mapInfo=res[0];
+			
 			},
-			markertap(e) {
-				console.log(e)
-				uni.showToast({
-					title: "点击id为" + e.detail.markerId + "的坐标",
-					icon: 'none',
-					duration: 2000
-				})
+			
+			fail: (res) => {
+			
+			console.log(JSON.stringify(res));
+			
 			}
+			
+			});
+		},
+		methods: {
+	
 
 		}
 	}
 </script>
 <style scoped>
-	.header {
-		flex-direction: row;
-		justify-content: space-between;
-		margin-bottom: 20rpx;
-		padding: 20rpx;
-	}
-
-	.title {
-		font-size: 32rpx;
-	}
-
-	.content {
-		width: 750px;
-		flex: 1;
-	}
-
-	.map {
-		height: 1350rpx;
-	}
-
-	.content2 {
-		position: fixed;
-		bottom: 0;
-		width: 750rpx;
-		flex: 1;
-		font-size: 34px;
-		background: pink;
-	}
-
-	.header-type {
-		font-size: 26rpx;
-	}
-
-	.alert {
-		flex: 1;
-	}
-
-	.select-alert {
-		background-color: green;
-		position: fixed;
-		bottom: 0;
-		width: 750rpx;
-		flex: 1;
-	}
-
-	.select-top {
-		flex-direction: row;
-		align-items: center;
-		justify-content: space-around;
-		background: yellow;
-		height: 80rpx;
-	}
-
-
-	.select {
-		width: 750rpx;
-		flex: 1;
-		flex-direction: column;
-		justify-content: center;
-		align-items: center;
-		background: white;
-	}
-	.cancel{
-		font-size: 24rpx;
-		color: white;
-		font-weight: bold;
-	}
-	.confirm{
-		font-size: 24rpx;
-		color: green;
-		font-weight: bold;
-	}
-	.select-item{
-		font-size: 24rpx;
-	}
+	
 </style>

+ 1 - 1
pages/grain_pulse/localtion/coordinate.nvue

@@ -123,7 +123,7 @@ width: 750rpx;
 		bottom: 54rpx;
 		left: 0;
 		right: 0;
-		margin: auto;
+		/* margin: auto; */
 		padding: 27rpx 37rpx;
 	}
 

+ 0 - 2
pages/grain_pulse/localtion/localtion.nvue

@@ -119,11 +119,9 @@
 			margin-top: 15rpx;
 
 			.left {
-				display: flex;
 				flex-wrap: nowrap;
 			}
 			.metre{
-				display: flex;
 				justify-content: space-between;
 				align-items: center;
 				.line{

+ 107 - 40
pages/grain_pulse/position/position.vue

@@ -2,11 +2,13 @@
 	<view class="">
 		<view class="header">
 			<view class="city Medium">
-				<text class="select-city" @click="loadCity">{{city}}</text>
+				<view class="select-city" @click="loadCity">{{city}}</view>
 				<u-icon name="arrow-down"></u-icon>
 			</view>
-			<u-search input-align="left" :disabled="true" @click="searchAddress" :show-action="false" height="70"
-				placeholder="请输入位置信息" v-model="addressName"></u-search>
+			<u-search input-align="left" @change="searchAddress" :show-action="false" height="70" placeholder="请输入位置信息"
+				v-model="addressName"></u-search>
+			<!-- 	<u-search input-align="left" :disabled="true" @click="searchAddress" :show-action="false" height="70"
+				placeholder="请输入位置信息" v-model="addressName"></u-search> -->
 		</view>
 		<view class="header2">
 			<view class="header2-tip Regular">
@@ -30,17 +32,24 @@
 			</view>
 			<view class="search-list">
 				<view v-for="(item,index) in list" class="search-list-item" @click="toHome(item)">
-					{{item}}
+					{{item.name}}
 				</view>
 			</view>
 
 		</view>
+		<view>
+			<view v-html="item.name" v-for="(item,index) in searchList" :key="index">
+				<!-- {{item.name}} -->
+			</view>
+
+		</view>
 
 	</view>
 </template>
 
 <script>
 	import permision from "@/js_sdk/wa-permission/permission.js"
+		import amap from '@/js_sdk/js-amap/amap-wx.130.js'
 	import uniSegmentedControl from "@/components/uni-segmented-control/uni-segmented-control.vue"
 	export default {
 		components: {
@@ -48,22 +57,47 @@
 		},
 		data() {
 			return {
+				searchList: [],
+				nowRegion: {},
 				addressName: "",
 				isposition: false,
 				isIos: true,
 				address: "定位失败,请点击重新定位",
-				city: '营口市',
+				city: '北京',
 				list: [],
 				position: '',
 				addressObj: {},
 				seconds: 3,
 				po_tips: '重新定位',
+				seach: {
+					latitude: 39.92,
+					longitude: 116.46,
+				}
 			}
 		},
-		onLoad(e) {
-			if (e.city) {
-				this.city = e.city
-			}
+		onShow() {
+			let that = this
+			uni.getStorage({
+				key: 'nowRegion',
+				success: (res) => {
+					console.log("nowRegion", res.data)
+					that.nowRegion = res.data
+					this.seach.longitude = res.data.longitude
+					this.seach.latitude = res.data.latitude
+					that.city = res.data.positionName.cityName
+					// console.log("city", that.city)
+					uni.removeStorage({
+						key: 'nowRegion'
+					})
+				},
+			})
+		},
+		onLoad(e) {debugger
+			var p1 = [116.434027, 39.941037];
+			var p2 = [116.461665, 39.941564];
+			// 返回 p1 到 p2 间的地面距离,单位:米
+			var dis = amap.GeometryUtil.distance(p1, p2);
+			console.log("dis",dis)
 			let that = this
 			uni.getStorage({
 				key: 'SearchList_key',
@@ -110,13 +144,13 @@
 					type: 'gcj02',
 					geocode: true,
 					success: function(res) {
-						console.log('获取位置数据:', res);
-						console.log('当前位置的经度:' + res.longitude);
-						console.log('当前位置的纬度:' + res.latitude);
+						// console.log('获取位置数据:', res);
+						// console.log('当前位置的经度:' + res.longitude);
+						// console.log('当前位置的纬度:' + res.latitude);
 						//拼接当前定位回显地址
 						// #ifdef APP-PLUS
 						let _address = res.address
-						that.city = _address.city
+						// that.city = _address.city
 						that.address = _address.province + _address.city + _address.district + _address.poiName
 						console.log(that.address)
 						// #endif
@@ -131,6 +165,7 @@
 					that.seconds--;
 					uni.getLocation({
 						type: 'gcj02',
+						geocode: true,
 						success: function(res) {
 							console.log('当前位置的经度:' + res.longitude);
 							console.log('当前位置的纬度:' + res.latitude);
@@ -171,7 +206,7 @@
 			// 跳转ios权限界面
 			judgeIosPermission: function(permisionID) {
 				var result = permision.judgeIosPermission(permisionID)
-				console.log(result);
+				// console.log(result);
 				var strStatus = (result) ? "已" : "未"
 				uni.showModal({
 					content: permisionID + '权限' + strStatus + "获得授权",
@@ -194,37 +229,69 @@
 					showCancel: false
 				});
 			},
-			// 搜索
+			//设置搜索关键字颜色
+			getStringColorReplace(val, val1) {
+				for (let j = 0; j < val.length; j++) {
+					var replaceString = '<view style="color:red' + ';">' + val1 + "</view>";
+					val[j].name = val[j].name.replace(RegExp(val1, 'g'), replaceString);
+				}
+
+			},
+			// 关键字搜索
 			searchAddress(val) {
-				// console.log(val)
-				let that = this;
-				uni.chooseLocation({
-					success: function(res) {
-						console.log(res)
-						// console.log('位置名称:' + res.name);
-						// console.log('详细地址:' + res.address);
-						// console.log('纬度:' + res.latitude);
-						// console.log('经度:' + res.longitude);
-						that.list.push(res.name)
-						this.position = res.name
-						uni.setStorage({
-							key: 'SearchList_key',
-							data: that.list
-						});
-						uni.setStorage({
-							key: 'setLocaltion',
-							data: res.name,
-							success() {
-								uni.switchTab({
-									url: "../home"
-								});
-							}
+				console.log(1222)
+				let parameters = {
+					key: 'dd701d394d116b50268dc16470ddd615',
+					keywords: val,
+					region: this.city,
+					page_size: 25
+				}
+				uni.request({
+					url: 'https://restapi.amap.com/v5/place/text',
+					data: parameters,
+					success: (res) => {
+						console.log(res.data);
+						this.searchList = res.data.pois
+						this.getStringColorReplace(res.data.pois, val)
+
 
-						})
 					}
 				});
-
 			},
+			// 搜索
+			// searchAddress(val) {
+			// 	// console.log(val)
+			// 	let that = this;
+			// 	console.log("search", that.seach)
+			// 	uni.chooseLocation({
+			// 		latitude: that.seach.latitude,
+			// 		longitude: that.seach.longitude,
+			// 		success: function(res) {
+			// 			console.log(res)
+			// 			// console.log('位置名称:' + res.name);
+			// 			// console.log('详细地址:' + res.address);
+			// 			// console.log('纬度:' + res.latitude);
+			// 			// console.log('经度:' + res.longitude);
+			// 			that.list.push(res)
+			// 			this.position = res.name
+			// 			uni.setStorage({
+			// 				key: 'SearchList_key',
+			// 				data: that.list
+			// 			});
+			// 			uni.setStorage({
+			// 				key: 'setLocaltion',
+			// 				data: res,
+			// 				success() {
+			// 					uni.switchTab({
+			// 						url: "../home"
+			// 					});
+			// 				}
+
+			// 			})
+			// 		}
+			// 	});
+
+			// },
 			// 切换城市
 			loadCity() {
 				uni.navigateTo({

+ 14 - 6
pages/grain_pulse/selectCity/selectCity.vue

@@ -16,6 +16,7 @@
 			}
 		},
 		onLoad() {
+			let that = this
 			uni.getSystemInfo({
 				success: function(res) {
 					console.log("statusBarHeight", res.statusBarHeight)
@@ -24,13 +25,20 @@
 			});
 		},
 		methods: {
-			back_city(e) {
-				if (e !== 'no') {
-					this.region = e.cityName 
+			back_city(e) {debugger
+				if (e.positionName !== 'no') {
+					this.region = e.positionName.cityName 
 					// this.$refs.popupRef.close();
-					uni.navigateTo({
-						url:"../position/position?city="+this.region
-					})
+					uni.setStorage({
+						key: 'nowRegion',
+						data: e,
+						success() {
+							uni.navigateTo({
+								url:"../position/position"
+							})
+						}
+					});
+				
 					
 				} else {
 					// this.$refs.popupRef.close();