| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405 | 
							- <template>
 
- 	<view class="content">
 
- 		
 
- 		<!-- 城市列表 -->
 
- 		<scroll-view class="scroll-view" scroll-y scroll-with-animation="true" enable-back-to-top="true"
 
- 			:scroll-into-view="toIndex" >
 
- 			<view class="listContent">
 
- 				<view class="city-list">
 
- 					<!-- 城市列表  -->
 
- 					<view v-for="(item, index) in cityData">
 
- 						<view class="c-title"  :id="item['首字母']">{{item['首字母']}}</view>
 
- 						<view class="item" v-for="(city,index2) in item['城市列表']" @click="selectCity(city)">
 
- 							{{city.city}}
 
- 						</view>
 
- 					</view>
 
- 				</view>
 
- 				
 
- 			</view>
 
- 		</scroll-view>
 
- 		<!-- 字母列表 -->
 
- 		<view class="zhimubox">
 
- 			<view v-for="(item, index) in alphabet">
 
- 				<view class="alphabet" :class="{select:toIndex == item}" @click="tap(item)">
 
- 					{{item}}
 
- 				</view>
 
- 			</view>
 
- 		</view>
 
- 		
 
- 	</view>
 
- </template>
 
- <script>
 
- 	export default {
 
- 		data() {
 
- 			return {
 
- 				searchValue: '',
 
- 				cityData: [],
 
- 				alphabet: [],
 
- 				toIndex: '', //跳转的索引的字母
 
- 				searchData:[],
 
- 				locationCity: {
 
- 					cityName: '',
 
- 					cityCode: '',
 
- 					lng: '',
 
- 					lat: '',
 
- 				},
 
- 				type:'',
 
-                 id:'',
 
- 			}
 
- 		},
 
- 		onLoad(opt) {
 
- 			this.type=opt.type
 
- 			this.id=opt.id
 
- 			this.getData();
 
- 		},
 
- 		onShow() {
 
- 			/* var nowCity = uni.getStorageSync("locationCity");
 
- 			if (nowCity) {
 
- 				this.locationCity = nowCity
 
- 			} else {
 
- 				this.getLocation()
 
- 			} */
 
- 			this.getData();
 
- 		},
 
- 		methods: {
 
- 			tap(item) {
 
- 				console.log('字母点击', item);
 
- 				this.toIndex = item
 
- 			},
 
- 			againDingWei() {
 
- 				console.log('重新定位');
 
- 				this.getLocation();
 
- 			},
 
- 			getLocation() {
 
- 				const that = this
 
- 				uni.getLocation({
 
- 					type: 'wgs84',
 
- 					success: function(res) {
 
- 						console.log('定位', res)
 
- 						that.locationCity.lng = res.longitude
 
- 						that.locationCity.lat = res.latitude
 
- 						
 
- 						that.getAdress();
 
- 					},
 
- 					fail(err) {
 
- 						console.log(err)
 
- 					}
 
- 				});
 
- 			},
 
- 			getAdress() {
 
- 				// 根据经纬度 逆城市地理编码 获取城市信息
 
- 				var location = this.locationCity.lng + ',' + this.locationCity.lat
 
- 				uni.request({
 
- 					url: 'https://restapi.amap.com/v3/geocode/regeo',
 
- 					data: {
 
- 						key: '389a059efa3f499d9145eb84b1c3248d',
 
- 						location: location,
 
- 						//location: '117.06533,36.68013',
 
- 						//types: "190000",
 
- 						//extensions: "all",
 
- 						//radius: 100
 
- 					},
 
- 					dataType: "json",
 
- 					success: (res) => {
 
- 						console.log('定位城市', res);
 
- 						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("接口获取失败")
 
- 						}
 
- 						
 
- 					}
 
- 				});
 
- 			},
 
- 			search(val) {
 
- 				// console.log(val);
 
- 				this.searchValue = val
 
- 				this.getData()
 
- 			},
 
- 			getData() {
 
- 				uni.showLoading({
 
- 					title: '加载中'
 
- 				})
 
- 				var	params = {
 
- 						
 
- 					}
 
-                 if(this.type==2){
 
- 					//项目商品下单
 
- 					var url = 'openMall/shop-city-list'
 
- 					params.id=this.id
 
- 				}else if(this.type==3){
 
- 					//板金喷漆
 
- 					var url = 'openSheetMetalSprayPaint/shop-city-list'
 
- 				}else if(this.type==1){
 
- 					//门店列表
 
- 					var url = 'opencarOwnerHome/shop-city-list'
 
- 				}else if(this.type==4){
 
- 					//积分商城
 
- 					var url = 'openIntegralMall/shop-city-list'
 
- 					params.id=this.id
 
- 				}else if(this.type==5){
 
- 					//集客
 
- 					var url = 'openHome/shop-city-list'
 
- 					params.collectingID=this.id
 
- 				}
 
- 				
 
- 				
 
- 				this.$http(url, params, 'GET').then(res => {
 
- 					uni.hideLoading()
 
- 					if (res.code == 0) {
 
- 						this.cityData = res.data
 
- 						var arr = []
 
- 						this.cityData.forEach((item, index) => {
 
- 							arr.push(item.首字母)
 
- 						});
 
- 					}
 
- 					this.alphabet = arr
 
- 					
 
- 				})
 
- 			},
 
- 			selectDingCity(locationCity){
 
- 				console.log('选择了定位城市:', locationCity);
 
- 				var city={}
 
- 				city.city = locationCity.cityName
 
- 				city.code = locationCity.cityCode
 
- 				uni.setStorage({
 
- 					key: 'selectCity',
 
- 					data: city,
 
- 					success: function() {
 
- 						console.log('选择了定位城市,保存成功');
 
- 					}
 
- 				})
 
- 				
 
- 				uni.navigateBack({
 
- 				
 
- 				})
 
- 			},
 
- 			selectCity(city) {
 
- 				console.log('选择的城市:', city);
 
- 				uni.setStorage({
 
- 					key: 'selectCity',
 
- 					data: city,
 
- 					success: function() {
 
- 						console.log('选择的城市,保存成功');
 
- 					}
 
- 				})
 
- 				uni.navigateBack({
 
- 				})
 
- 			},
 
- 		},
 
- 		onPullDownRefresh() {
 
- 			this.getData()
 
- 			setTimeout(function() {
 
- 				uni.stopPullDownRefresh();
 
- 			}, 1000);
 
- 		},
 
- 	}
 
- </script>
 
- <style scoped>
 
- 	.zhimubox{
 
- 		position: fixed;
 
- 		right: 25rpx;
 
- 		top: 200rpx;
 
- 		height: 80vh;
 
- 		overflow-y: scroll;
 
- 	}
 
- 	.content {
 
- 		
 
- 		background: #FFFFFF;
 
- 		min-height: 100vh;
 
- 	}
 
- 	.topView {
 
- 		background: #FFFFFF;
 
- 		position: fixed;
 
- 		width: 100%;
 
- 		height: 120rpx;
 
- 		z-index: 99;
 
- 	}
 
- 	.searchBoxBg {
 
- 		width: 100%;
 
- 		background-color: #FFFFFF;
 
- 		border-top: 1rpx solid #EEEEEE;
 
- 	}
 
- 	.searchBox {
 
- 		display: flex;
 
- 		height: 72rpx;
 
- 		margin: 24rpx;
 
- 		background-color: #F4F5F7;
 
- 		border-radius: 36rpx;
 
- 	}
 
- 	.scroll-view {
 
- 		width: 100%;
 
- 		/* height: calc(100vh - 80rpx); */
 
- 		height: 100vh;
 
- 		box-sizing: border-box;
 
- 	
 
- 	}
 
- 	.nowArea {
 
- 		width: 100%;
 
- 		height: 147rpx;
 
- 	}
 
- 	.area {
 
- 		color: #999999;
 
- 		font-size: 24rpx;
 
- 		margin-bottom: 20rpx;
 
- 	}
 
- 	.dingwBox {
 
- 		display: flex;
 
- 		justify-content: space-between;
 
- 	}
 
- 	.dingweiCity {
 
- 		background-color: #F4F5F7;
 
- 		border-radius: 49rpx;
 
- 		width: 140rpx;
 
- 		height: 64rpx;
 
- 		text-align: center;
 
- 		line-height: 64rpx;
 
- 		font-size: 26rpx;
 
- 	}
 
- 	.dingBg {
 
- 		display: flex;
 
- 		align-items: center;
 
- 		color: #3F90F7;
 
- 		font-size: 26rpx;
 
- 	}
 
- 	.icon {
 
- 		width: 33rpx;
 
- 		height: 33rpx;
 
- 		margin-right: 5rpx;
 
- 	}
 
- 	.listContent {
 
- 		display: flex;
 
- 		justify-content: space-between;
 
- 			padding: 20rpx 24rpx 20rpx;
 
- 	}
 
- 	.city-list {
 
- 		display: flex;
 
- 		flex-direction: column;
 
- 		width: 95%;
 
- 	}
 
- 	.c-title {
 
- 		color: #999999;
 
- 		font-size: 24rpx;
 
- 		height: 33rpx;
 
- 		line-height: 33rpx;
 
- 		padding-top: 30rpx;
 
- 	}
 
- 	.item {
 
- 		width: 100%;
 
- 		height: 46rpx;
 
- 		padding: 30rpx 13rpx;
 
- 		color: #3C3C3C;
 
- 		font-size: 28rpx;
 
- 		border-bottom: 1rpx solid #EEEEEE;
 
- 	}
 
- 	.alphabet {
 
- 		font-size: 22rpx;
 
- 		font-weight: bold;
 
- 		color: #999999;
 
- 		width: 4%;
 
- 		margin: 2rpx 0;
 
- 		text-align: center;
 
- 		padding: 10rpx 20rpx 10rpx 20rpx;
 
- 	}
 
- 	.select {
 
- 		color: #FF4F00;
 
- 	}
 
- 	
 
- 	.reach-content{
 
- 		width: 100%;
 
- 		height: calc(100vh - 120rpx);
 
- 		box-sizing: border-box;
 
- 		padding: 120rpx 24rpx 20rpx;
 
- 	}
 
- 	/* 空白页css */
 
- 	.nodataBox {
 
- 		text-align: center;
 
- 	}
 
- 	.nodataImg {
 
- 		width: 400rpx;
 
- 		padding-top: 300rpx;
 
- 	}
 
- 	.noTxt {
 
- 		font-size: 30rpx;
 
- 		color: #999999;
 
- 		padding-top: 50rpx;
 
- 	}
 
- </style>
 
 
  |