allprovince.vue 3.5 KB
<template>
	<view class="content">
		<!-- 当前城市 -->
		<view class="city">
			<view class="localcity flexone">
				<view class="localname">定位</view>
				<view class="localleft">
					<image src="../../static/loaclcity.png" mode=""></image>
				</view>
			</view>
			<view class="citybox flexone">
				<view class="cityboxitem " :class="selcurrent==1?'selcityactive':''" wx:key="">{{provincename}}</view>
			</view>
		</view>
		<!-- 热门城市 -->
		<view class="city">
			<view class="citytop">热门城市</view>
			<view class="citybox flexone">
				<view class="cityboxitem" :class="selhot==index?'selcityactive':''" v-for="(item,index) in cityarr" :key='' @click="selhotcity(item,index)"
				>{{item.name}}</view>
			</view>
		</view>
		<!-- 当前城市 -->
		<view class="city">
			<view class="citytop">全部城市</view>
			<view class="citybox flexone">
				<view class="cityboxitem" :class="selall==index?'selcityactive':''" v-for="(item,index) in cityarr" :key='' @click="selallcity(item,index)"
				>{{item.name}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import app from "../../App.vue";
	    export default {
	        data() {
	            return {
	                showbanben: false,
					cityarr:[],
					provincename:'',
					selhot:-1,
					selall:-1,
					selcurrent:1
	            }
	        },
	        onLoad() {
				this.provincename=uni.getStorageSync("provincename")
				this.getprovincelist()
	
	        },
	        methods: {
	           // 获取省份列表
	           getprovincelist() {
	           	let that = this;
	           	var url = 'forum/get_province';
	           	var params = {
	           		is_forum_hot: ''
	           	}
	           	console.log('7766554', params)
	           	app.post(url, params).then((res) => {
	           		console.log(res);
	           		that.cityarr = res.data.data;
					
	           	}).catch((err) => {
	           
	           	})
	           },
			   // 选择城市
			   selhotcity(item,index){
				   console.log(item);
				   this.selhot=index;
				   this.selall=-1;
				   this.selcurrent=0;
				   uni.setStorageSync("provincename",item.name);
				   uni.navigateBack({
				   	checked:true
				   })
				   
			   },
			   selallcity(item,index){
				   this.selall=index;
				   this.selhot=-1;
				   this.selcurrent=0;
				   uni.setStorageSync("provincename",item.name);
				   uni.navigateBack({
				   	checked:true
				   })
			   },
	           
	           
	      
	        }
	
	    }
</script>

<style>
	page{
		background: #fff;
	}
	.city{
		border-bottom:16rpx solid #F7F7F7
	}
	.localcity{
		margin-top:34rpx;
	}
	.localleft{
		width:32rpx;
		height: 32rpx;
		font-size: 0;
		margin-left:8rpx;
	}
	.localname{
		color:#3D444C;
		font-size: 28rpx;
		margin-left:20rpx;
	}
	.search {
	  color: #06121e;
	  font-size: 28rpx;
	}
	
	.headmiddle {
	  width: 596rpx;
	}
	
	.tou {
	  background: #fff;
	}
	
	page {
	  background: #f9f9fb;
	}
	
	/* 城市 */
	
	.citybox {
	  display: flex;
	  flex-wrap: wrap;
	  margin-top:26rpx;
	}
	
	
	.city {
	  padding: 0 12rpx 0 32rpx;
	  box-sizing: border-box;
	}
	.citytop{
	  color:#707070;
	  font-size: 32rpx;
	  margin-top:44rpx;
	  font-weight: bold;
	  
	}
	
	.cityboxitem {
	  width: 216rpx;
	  height: 68rpx;
	  background: rgba(255, 255, 255, 1);
	  border: 1rpx solid rgba(189, 196, 206, 1);
	  opacity: 1;
	  border-radius: 8rpx;
	  color: #06121e;
	  font-size: 28rpx;
	  text-align: center;
	  line-height: 68rpx;
	  margin-right:14rpx;
	  margin-bottom:24rpx;
	}
	.selcityactive{
		background:#C29445 ;
		color:#fff;
		font-size: 28rpx;
		
	}

</style>