77 <div class =" city_tip" >
88 <span >当前定位城市:</span >
99 <span >定位不准时,请在城市列表中选择</span >
10- </div >
10+ </div >
11+ <router-link :to =" '/city/' + guessCityid" class =" guess_city" >
12+ <span >{{guessCity}}</span >
13+ <span >></span >
14+ </router-link >
1115 </nav >
16+ <div id =" hot_city_container" >
17+ <h4 class =" ciyt_title" >热门城市</h4 >
18+ <ul class =" citylistul clear" >
19+ <router-link tag =" li" v-for =" item in hotcity" :to =" '/city/' + item.id" :key =" item.id" >
20+ {{item.name}}
21+ </router-link >
22+ </ul >
23+ </div >
24+ <div class =" group_city_container" >
25+ <ul class =" letter_classify" >
26+ <li v-for =" (value, key, index) in sortgroupciyt" :key =" key" class =" letter_classify_li" >
27+ <h4 class =" ciyt_title" >{{key}}
28+ <span v-if =" index == 0" >(按字母排序)</span >
29+ </h4 >
30+ <ul class =" groupcity_name_container citylistul clear" >
31+ <router-link tag =" li" v-for =" item in value" :to =" '/city/' + item.id" :key =" item.id" class =" ellipsis" >
32+ {{item.name}}
33+
34+ </router-link >
35+ </ul >
36+ </li >
37+ </ul >
38+ </div >
1239 </div >
1340</template >
1441
1542<script >
1643import headTop from ' ../../components/header/head'
44+ import {cityGuess , hotcity , groupcity } from ' ../../service/getData'
45+
1746export default {
1847 data (){
1948 return {
20-
49+ guessCity: ' ' ,
50+ guessCityid: ' ' ,
51+ hotcity: [],
52+ groupcity: {},
2153 }
2254 },
2355
2456 created (){
25-
57+ cityGuess ().then (res => {
58+ this .guessCity = res .name ;
59+ this .guessCityid = res .id ;
60+ })
61+
62+ hotcity ().then (res => {
63+ this .hotcity = res;
64+ })
65+
66+ groupcity ().then (res => {
67+ this .groupcity = res;
68+ })
2669 },
2770
2871 components: {
2972 headTop
3073 },
3174
3275 computed: {
33-
76+ sortgroupciyt (){
77+ let sortobj = {};
78+ for (let i = 65 ; i <= 90 ; i++ ) {
79+ if (this .groupcity [String .fromCharCode (i)]) {
80+ sortobj[String .fromCharCode (i)] = this .groupcity [String .fromCharCode (i)];
81+ }
82+ }
83+ return sortobj
84+ }
3485 },
3586
3687 methods: {
@@ -41,24 +92,87 @@ export default {
4192 </script >
4293
4394<style lang="scss" scoped>
44- @import ' ../../style/mixin.scss ' ;
95+ @import ' ../../style/mixin' ;
4596 .head_logo {
46- position : absolute ;
47- width : 2.3rem ;
48- height : 0.7rem ;
4997 left : 0.4rem ;
50- top : 50% ;
51- transform : translateY (-50% );
52- font-size : 0.7rem ;
53- color : #fff ;
5498 font-weight : 400 ;
99+ @include sizecolor (0.7rem , #fff );
100+ @include wh (2.3rem , 0.7rem );
101+ @include center-top ;
55102 }
56103 .city_nav {
57104 margin-top : 2.35rem ;
58- border-top : 2 px solid $bordercolor ;
105+ border-top : 1 px solid $bordercolor ;
59106 background-color : #fff ;
107+ margin-bottom : 0.4rem ;
60108 .city_tip {
61- color : #666 ;
109+ display : flex ;
110+ justify-content : space-between ;
111+ line-height : 1.45rem ;
112+ padding : 0 0.45rem ;
113+ span :nth-of-type (1 ){
114+ @include sizecolor (0.55rem , #666 );
115+ }
116+ span :nth-of-type (2 ){
117+ font-weight : 900 ;
118+ @include sizecolor (0.475rem , #9f9f9f );
119+ }
120+ }
121+ .guess_city {
122+ display : flex ;
123+ height : 1.8rem ;
124+ justify-content : space-between ;
125+ padding : 0 0.45rem ;
126+ border-top : 1px solid $bordercolor ;
127+ border-bottom : 2px solid $bordercolor ;
128+ @include font (0.75rem , 1.8rem );
129+ span :nth-of-type (1 ){
130+ color : $blue ;
131+ }
132+ span :nth-of-type (2 ){
133+ color : #9f9f9f ;
134+ }
135+ }
136+ }
137+ #hot_city_container {
138+ background-color : #fff ;
139+ margin-bottom : 0.4rem ;
140+ }
141+ .citylistul {
142+ li {
143+ float : left ;
144+ text-align : center ;
145+ color : $blue ;
146+ border-bottom : 0.025rem solid $bordercolor ;
147+ border-right : 0.025rem solid $bordercolor ;
148+ @include wh (25% , 1.75rem );
149+ @include font (0.6rem , 1.75rem );
150+ }
151+ li :nth-of-type (4 n ){
152+ border-right : none ;
62153 }
63154 }
155+ .ciyt_title {
156+ color : #666 ;
157+ font-weight : 400 ;
158+ text-indent : 0.45rem ;
159+ border-top : 2px solid $bordercolor ;
160+ border-bottom : 1px solid $bordercolor ;
161+ @include font (0.55rem , 1.45rem , " Helvetica Neue" );
162+ span {
163+ @include sizecolor (0.475rem , #999 );
164+ }
165+ }
166+
167+ .letter_classify_li {
168+ margin-bottom : 0.4rem ;
169+ background-color : #fff ;
170+ border-bottom : 1px solid $bordercolor ;
171+ .groupcity_name_container {
172+ li {
173+ color : #666 ;
174+ }
175+ }
176+ }
177+
64178 </style >
0 commit comments