twt лет назад: 2
Родитель
Сommit
fd7738bfc2
5 измененных файлов с 105 добавлено и 64 удалено
  1. 4 1
      manifest.json
  2. 37 23
      pages/chooseCity/chooseCity.vue
  3. 33 22
      pages/homePage/homePage.vue
  4. 6 0
      pages/index/carModel.vue
  5. 25 18
      pages/index/index.vue

+ 4 - 1
manifest.json

@@ -61,7 +61,10 @@
             "scope.userLocation" : {
                 "desc" : "获取定位"
             }
-        }
+        },
+		"requiredPrivateInfos": [
+				"getLocation"
+		]
     },
     "mp-alipay" : {
         "usingComponents" : true

+ 37 - 23
pages/chooseCity/chooseCity.vue

@@ -41,7 +41,7 @@
 				</view>
 
 				<!-- 字母列表 -->
-				<view>
+				<view class="zhimubox">
 					<view v-for="(item, index) in alphabet">
 						<view class="alphabet" :class="{select:toIndex == item}" @click="tap(item)">
 							{{item}}
@@ -128,7 +128,7 @@
 
 				const that = this
 				uni.getLocation({
-					type: 'gcj02',
+					type: 'wgs84',
 					success: function(res) {
 						console.log('定位', res)
 						that.locationCity.lng = res.longitude
@@ -148,31 +148,39 @@
 				// 根据经纬度 逆城市地理编码 获取城市信息
 				var location = this.locationCity.lng + ',' + this.locationCity.lat
 				uni.request({
-					url: 'https://restapi.amap.com/v3/place/around',
+					url: 'https://restapi.amap.com/v3/geocode/regeo',
 					data: {
-						key: '064b6a4a8ade55656edcde2f528876de',
+						key: '389a059efa3f499d9145eb84b1c3248d',
 						location: location,
-						types: "190000",
-						extensions: "all",
-						radius: 100
+						//location: '117.06533,36.68013',
+						//types: "190000",
+						//extensions: "all",
+						//radius: 100
 					},
 					dataType: "json",
 					success: (res) => {
 						console.log('定位城市', res);
-						let cityname = res.data.pois[0].cityname;
-						var cityCode = res.data.pois[0].adcode
-						cityCode = cityCode.slice(0, -2)
-						cityCode = cityCode + '00'
-						this.locationCity.cityName = cityname
-						this.locationCity.cityCode = cityCode
-
-						uni.setStorage({
-							key: 'locationCity',
-							data: this.locationCity,
-							success: function() {
-								console.log('定位城市,保存成功');
-							}
-						})
+						if(res.data.regeocode){
+							console.log("城市名称")
+							 console.log(res.data.regeocode.addressComponent.city)
+							// console.log(res.data.pois[0].cityname)
+							let cityname = res.data.regeocode.addressComponent.city;
+							var cityCode = res.data.regeocode.addressComponent.adcode
+							cityCode = cityCode.slice(0, -2)
+							cityCode = cityCode + '00'
+							this.locationCity.cityName = cityname
+							this.locationCity.cityCode = cityCode
+							uni.setStorage({
+								key: 'locationCity',
+								data: this.locationCity,
+								success: function() {
+									console.log('定位城市,保存成功');
+								}
+							})
+						}else{
+							console.log("接口获取失败")
+						}
+						
 					}
 				});
 			},
@@ -256,8 +264,14 @@
 	}
 </script>
 
-<style>
-	
+<style scoped>
+	.zhimubox{
+		position: fixed;
+		right: 30rpx;
+		top: 200rpx;
+		height: 80vh;
+		    overflow-y: scroll;
+	}
 	.content {
 		
 		background: #FFFFFF;

+ 33 - 22
pages/homePage/homePage.vue

@@ -84,9 +84,9 @@
 		<!-- <view>shareID:{{shareID}}</view> -->
 		<!-- 优惠券中心 -->
 
-		<view class="quanImg">
+		<view class="quanImg" v-if="bannerArr.length>0">
 			<swiper class="swiper" :circular="true" :indicator-dots="true" indicator-active-color="#FF4F00"
-				v-if="bannerArr.length>0">
+				>
 				<swiper-item v-for="(item,index) in bannerArr">
 				
 					<image :src="item" mode="" class="swpImg" @click="goImg(index)"></image>
@@ -281,7 +281,7 @@
 
 				const that = this
 				uni.getLocation({
-					type: 'gcj02',
+					type: 'wgs84',
 					success: function(res) {
 						console.log('定位', res)
 						that.locationCity.lng = res.longitude
@@ -301,9 +301,9 @@
 				// 根据经纬度 逆城市地理编码 获取城市信息
 				var location = this.locationCity.lng + ',' + this.locationCity.lat
 				uni.request({
-					url: 'https://restapi.amap.com/v3/place/around',
+					url: 'https://restapi.amap.com/v3/geocode/regeo',
 					data: {
-						key: '064b6a4a8ade55656edcde2f528876de',
+						key: '389a059efa3f499d9145eb84b1c3248d',
 						location: location,
 						types: "190000",
 						extensions: "all",
@@ -312,23 +312,30 @@
 					dataType: "json",
 					success: (res) => {
 						console.log('定位城市', res);
-						let cityname = res.data.pois[0].cityname;
-						var cityCode = res.data.pois[0].adcode
-						cityCode = cityCode.slice(0, -2)
-						cityCode = cityCode + '00'
-						this.locationCity.cityName = cityname
-						this.locationCity.cityCode = cityCode
-
-						uni.setStorage({
-							key: 'locationCity',
-							data: this.locationCity,
-							success: function() {
-								console.log('定位城市,保存成功');
-							}
-						})
-
-						this.cityName = this.locationCity.cityName
-						this.cityCode = this.locationCity.cityCode
+						if(res.data.regeocode){
+							//console.log("城市名称"+res.data.pois[0].cityname)
+							let cityname = res.data.regeocode.addressComponent.city;
+							var cityCode = res.data.regeocode.addressComponent.adcode
+							cityCode = cityCode.slice(0, -2)
+							cityCode = cityCode + '00'
+							this.locationCity.cityName = cityname
+							this.locationCity.cityCode = cityCode
+							
+							uni.setStorage({
+								key: 'locationCity',
+								data: this.locationCity,
+								success: function() {
+									console.log('定位城市,保存成功');
+								}
+							})
+							
+							this.cityName = this.locationCity.cityName
+							this.cityCode = this.locationCity.cityCode
+						}else{
+							this.cityName=''
+							this.cityCode=''
+						}
+						
 
 
 					}
@@ -386,9 +393,13 @@
 				})
 			},
 			showCity() {
+				if (!this.uid) {
+					this.goLonIn();
+				}
 				uni.navigateTo({
 					url: '../chooseCity/chooseCity'
 				})
+				
 			},
 			getItemData() {
 				uni.showLoading({

+ 6 - 0
pages/index/carModel.vue

@@ -72,6 +72,8 @@
 					  <h3 class="cell-item-title">{{ item.manufactor }}</h3>
 					  <span v-for="item2 in item.carSeries" :key="item2" :title="item2" class="span-cell" @click="selectCarFactory(item.manufactor,item2)" >{{item2}}</span>
 					</view>
+					<view class="status_bar" :style="{height: iStatusBarHeight + 'px'}"></view>
+					<view class="status_bar" style="height: 50px;"></view>
 				</scroll-view>
 				
 			</view>
@@ -89,6 +91,8 @@
 			  <view @click="selectDisplacement(item)" v-for="item in displacementList" class="displacementListLine" >
 			    {{item}}
 			  </view>
+			  <view class="status_bar" :style="{height: iStatusBarHeight + 'px'}"></view>
+			  <view class="status_bar" style="height: 50px;"></view>
 			</scroll-view>
 		</view>
 		
@@ -104,6 +108,8 @@
 			  <view @click="goAddCar(item)" v-for="item in carGroupList" class="displacementListLine" >
 			    {{item.title}}
 			  </view>
+			  <view class="status_bar" :style="{height: iStatusBarHeight + 'px'}"></view>
+			  <view class="status_bar" style="height: 50px;"></view>
 			</scroll-view>
 		</view>
 		<!-- 离合器 -->

+ 25 - 18
pages/index/index.vue

@@ -200,9 +200,9 @@
 				// 根据经纬度 逆城市地理编码 获取城市信息
 				var location = this.locationCity.lng + ',' + this.locationCity.lat
 				uni.request({
-					url: 'https://restapi.amap.com/v3/place/around',
+					url: 'https://restapi.amap.com/v3/geocode/regeo',
 					data: {
-						key: '064b6a4a8ade55656edcde2f528876de',
+						key: '389a059efa3f499d9145eb84b1c3248d',
 						location: location,
 						types: "190000",
 						extensions: "all",
@@ -211,23 +211,30 @@
 					dataType: "json",
 					success: (res) => {
 						console.log('定位城市', res);
-						let cityname = res.data.pois[0].cityname;
-						var cityCode = res.data.pois[0].adcode
-						cityCode = cityCode.slice(0, -2)
-						cityCode = cityCode + '00'
-						this.locationCity.cityName = cityname
-						this.locationCity.cityCode = cityCode
-			
-						uni.setStorage({
-							key: 'locationCity',
-							data: this.locationCity,
-							success: function() {
-								console.log('定位城市,保存成功');
-							}
-						})
+						if(res.data.regeocode){
+							
+							let cityname = res.data.regeocode.addressComponent.city;
+							var cityCode = res.data.regeocode.addressComponent.adcode
+							cityCode = cityCode.slice(0, -2)
+							cityCode = cityCode + '00'
+							this.locationCity.cityName = cityname
+							this.locationCity.cityCode = cityCode
+										
+							uni.setStorage({
+								key: 'locationCity',
+								data: this.locationCity,
+								success: function() {
+									console.log('定位城市,保存成功');
+								}
+							})
+							
+							this.cityName = this.locationCity.cityName
+							this.cityCode = this.locationCity.cityCode
+						}else{
+							this.cityName=''
+							this.cityCode=''
+						}
 						
-						this.cityName = this.locationCity.cityName
-						this.cityCode = this.locationCity.cityCode
 						
 						
 					}