allprovince.vue
3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<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>