selectSchool.vue
7.0 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<template>
<!-- 选择高中页 -->
<view class="content">
<view class="selectCity">
<view class="title">所在地区</view>
<view class="selectBtn" @click="diquShow">
<view class="uni-input">{{isRegionShow ? region : '请选择所在地区'}}</view>
<image class="icon" src="../../static/zhuandao_icon@2x.png"></image>
</view>
</view>
<view class="diquPopup" v-if="isDiquShow">
<view class="cont">
<view class="colum" style="overflow: auto;height: 600rpx;">
<!-- <view class="title" @click="selectprovince" :data-id="''">全部省</view> -->
<view class="item" @click="selectprovince" v-for="(item,index) in provinceList" :key="index" :data-id="item.code">{{item.name}}</view>
</view>
<view class="colum" style="overflow: auto;height: 600rpx;">
<view class="title" @click="selectcity" :data-id="''">全部市</view>
<view class="item" @click="selectcity" v-for="(item,index) in cityList" :key="index" :data-id="item.code">{{item.name}}</view>
</view>
<!-- <view class="colum" style="overflow: auto;height: 224rpx;">
<view class="title" @click="selectschool" :data-id="null">全部学校</view>
<view class="item" @click="selectschool" v-for="(item,index) in schoolList" :key="index" :data-id="item.id">{{item.name}}</view>
</view> -->
</view>
</view>
<view class="list">
<view class="item" @click="selectschool" v-for="(item,index) in schoolList" :key="index" :data-id="item">{{item.name}}</view>
</view>
<view class="bottomItem">
没有找到你的高中?
<navigator class="btn" hover-class="none" url="./addSchool">点击此处立即添加</navigator>
</view>
</view>
</template>
<script>
import app from "../../App.vue";
export default {
data(){
return{
isDiquShow:false,
region:[] ,
isRegionShow:false,
provinceList:[],
cityList:[],
schoolList:[],
province_id:"",
city_id:'',
school_id:''
}
},
onLoad(){
this.getAllProvince()
this. getAllSchool()
},
methods:{
diquShow(){
this.isDiquShow=true
},
//点击选中的省
selectprovince(e){
this.province_id=e.currentTarget.dataset.id
console.log(e.currentTarget.dataset.id)
this.getAllCity()
},
//点击选中的市
selectcity(e){
this.city_id=e.currentTarget.dataset.id
this.getAllSchool()
},
selRegion(){
this.isRegionShow=true
},
bindRegionChange(e){
var arr=e.target.value
var str=e.target.value.toString()
this.region = arr.join("-")
},
//获取全部地区(省)
getAllProvince(){
var url ="city/getAllProvince"
var params ={}
app.post(url,params,"get").then((res)=>{
var nullData = {
code:'',
name:"全部省"
}
res.unshift(nullData)
console.log(res)
this.provinceList=res
}).catch((err)=>{
console.log(err)
})
},
//市
getAllCity(){
var url = "city/getCity"
var params = {
province_id:this.province_id
}
app.post(url,params,"get").then((res)=>{
console.log(res)
this.cityList=res
}).catch((err)=>{
console.log(err)
})
},
//学校
getAllSchool(){
var url="school/getSchoolList"
var params ={
// name:,
city_id:this.city_id
}
app.post(url,params,"get").then((res)=>{
console.log(res)
this.schoolList=res
}).catch((err)=>{
console.log(err)
})
},
//点击选中的省
selectprovince(e){
this.province_id=e.currentTarget.dataset.id
this.getAllCity()
},
//点击选中的市
selectcity(e){
this.city_id=e.currentTarget.dataset.id
this.getAllSchool()
this.isDiquShow=false
},
selectschool(e){
console.log(e.currentTarget.dataset)
this.school_id=e.currentTarget.dataset.id.id
var name = e.currentTarget.dataset.id.name
//this.$emit('school_id',this.school_id)
// var id = this.school_id
let pages = getCurrentPages();
let prevPage = pages[ pages.length - 2 ]
prevPage.$vm.school_id=this.school_id
prevPage.$vm.name = name
uni.navigateBack()
}
}
}
</script>
<style lang="less">
.content{
font-size: 28rpx;
background:rgba(249,249,249,1);
color:rgba(6,18,30,1);
height: 100vh;
display: flex;
flex-direction: column;
// padding: 0 32rpx;
.selectCity{
display: flex;
justify-content: space-between;
padding: 30rpx 32rpx;
background-color: #fff;
font-size: 28rpx;
.selectBtn{
color:rgba(189,196,206,1);
display: flex;
align-items: center;
.icon{
width: 13rpx;
height: 24rpx;
margin-left: 8rpx;
}
}
}
.list{
font-size: 28rpx;
padding: 12rpx 32rpx;
box-sizing: border-box;
overflow-y: scroll;
margin-bottom: 100rpx;
.item{
padding: 28rpx 0;
border-bottom: 1rpx solid rgba(238,238,238,1);
}
}
.bottomItem{
font-size: 28rpx;
display: flex;
padding: 20rpx 32rpx;
// margin-top: 122rpx;
position: absolute;
bottom: 0;
.btn{
color:rgba(129,195,191,1);
text-decoration: underline;
}
}
.diquPopup{
font-size: 28rpx;
width: 750rpx;
// height: 314rpx;
position: absolute;
top: 84rpx;
left: 0;
background-color: #fff;
padding: 22rpx 32rpx;
box-sizing: border-box;
z-index: 999;
box-shadow:0px 4px 4px rgba(0,0,0,0.06);
border-top: 1rpx solid rgba(249,249,249,1);
.item{
margin-bottom: 22rpx;
// height: 74rpx;
width: 170rpx;
font-size: 28rpx;
}
.title{
margin-bottom: 20rpx;
font-size: 28rpx;
}
.cont{
.colum{
width: 30%;
font-size: 28rpx;
}
display: flex;
// height: 314rpx;
// flex-direction: column;
flex-wrap: wrap;
justify-content: start;
}
}
}
</style>