Skip to content

Commit ba6af7a

Browse files
committed
updata
1 parent faaa083 commit ba6af7a

11 files changed

Lines changed: 19977 additions & 52 deletions

File tree

‎build/webpack.base.conf.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ var cssSourceMapDev = (env === 'development' && config.dev.cssSourceMap)
1010
var cssSourceMapProd = (env === 'production' && config.build.productionSourceMap)
1111
var useCssSourceMap = cssSourceMapDev || cssSourceMapProd
1212

13+
1314
module.exports = {
1415
entry: {
1516
app: './src/main.js'

‎src/components/header/head.vue‎

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<template>
22
<header id='head_top'>
33
<slot name='logo'></slot>
4+
<div class="head_goback" v-if="goBack" @click="$router.go(-1)"></div>
45
<router-link to='/login' v-if='signinUp' class="head_login">登陆|注册</router-link>
6+
<div class="title_head" v-if="headTitle">{{headTitle}}</div>
7+
<slot name="changecity"></slot>
58
</header>
69
</template>
710

@@ -19,12 +22,12 @@
1922
mounted(){
2023
2124
},
22-
props: ['signinUp'],
25+
props: ['signinUp', 'headTitle', 'goBack'],
2326
computed: {
2427
2528
},
2629
methods: {
27-
30+
2831
},
2932
3033
}
@@ -35,19 +38,25 @@
3538
@import '../../style/mixin.scss';
3639
3740
#head_top{
38-
height: 1.95rem;
39-
width: 100%;
4041
background-color: $blue;
4142
position: fixed;
4243
left: 0;
4344
top: 0;
45+
@include wh(100%, 1.95rem);
46+
}
47+
.head_goback{
48+
left: 0.4rem;
49+
@include wh(0.375rem, 0.7rem);
50+
@include center-top;
51+
@include backimg('../../images/icon_back.png');
4452
}
4553
.head_login{
46-
position: absolute;
47-
font-size: 0.6rem;
48-
color: #fff;
4954
right: 0.55rem;
50-
top: 50%;
51-
transform: translateY(-50%);
55+
@include sizecolor(0.6rem, #fff);
56+
@include center-top;
57+
}
58+
.title_head{
59+
@include sizecolor(0.7rem, #fff);
60+
@include center;
5261
}
5362
</style>

‎src/images/icon_back.png‎

1.48 KB
Loading

‎src/page/city/index.vue‎

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,46 @@
11
<template>
2-
<ul>
3-
<router-link tag='li' to='home'>首页</router-link>
4-
<router-link tag='li' to='city'>城市页面</router-link>
5-
<router-link tag='li' to='msite'>商店列表</router-link>
6-
<router-link tag='li' to='shop'>商铺详情</router-link>
7-
<router-link tag='li' to='search'>搜索</router-link>
8-
<router-link tag='li' to='login'>登陆</router-link>
9-
<router-link tag='li' to='checkout'>确认订单</router-link>
10-
<router-link tag='li' to='forget'>忘记密码</router-link>
11-
<router-link tag='li' to='profile'>个人信息</router-link>
12-
<router-link tag='li' to='order'>订单列表</router-link>
13-
<router-link tag='li' to='vipcard'>会员卡</router-link>
14-
</ul>
2+
<div>
3+
<head-top head-title="上海" go-back='true'>
4+
<router-link to="/home" slot="changecity" class="change_city">切换城市</router-link>
5+
</head-top>
6+
</div>
157
</template>
168

179
<script>
10+
import headTop from '../../components/header/head'
1811
19-
export default {
20-
21-
}
12+
export default {
13+
data(){
14+
return{
15+
16+
}
17+
},
18+
19+
created(){
20+
21+
},
22+
23+
components:{
24+
headTop
25+
},
26+
27+
computed:{
28+
29+
},
30+
31+
methods:{
32+
33+
}
34+
}
2235
2336
</script>
2437

2538
<style lang="scss" scoped>
39+
@import '../../style/mixin';
2640
41+
.change_city{
42+
right: 0.4rem;
43+
@include sizecolor(0.6rem, #fff);
44+
@include center-top;
45+
}
2746
</style>

‎src/page/home/index.vue‎

Lines changed: 128 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,81 @@
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>
1643
import headTop from '../../components/header/head'
44+
import {cityGuess, hotcity, groupcity} from '../../service/getData'
45+
1746
export 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: 2px solid $bordercolor;
105+
border-top: 1px 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(4n){
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>

‎src/router/router.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default [{
2020
children: [ //二级路由。对应App.vue
2121
{ path: '', redirect: '/home' }, //地址为空时跳转home页面
2222
{ path: '/home', component: home }, //首页城市列表页
23-
{ path: '/city', component: city }, //当前选择城市页
23+
{ path: '/city/:ciytid', component: city }, //当前选择城市页
2424
{ path: '/msite', component: msite, //所有商铺列表页
2525
children:[
2626
{ path: 'food', component: food }, //特色商铺列表页

‎src/service/getData.js‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
import fetch from '../config/fetch'
2-
2+
import * as home from './tempdata/home'
33
/**
44
* 获取首页默认地址
55
*/
6-
const cityGuess = () => fetch('GET', '/v1/cities', {type: 'guess'})
6+
// const cityGuess = () => fetch('GET', '/v1/cities', {type: 'guess'})
7+
// const hotcity = () => fetch('GET', '/v1/cities', {type: 'hot'})
8+
// const groupcity = () => fetch('GET', '/v1/cities', {type: 'group'})
9+
10+
11+
12+
13+
14+
15+
//临时数据
16+
const setpromise = data => {
17+
return new Promise((resolve, reject) => {
18+
resolve(data)
19+
})
20+
}
21+
22+
const cityGuess = () => setpromise(home.guesscity)
23+
const hotcity = () => setpromise(home.hotcity)
24+
const groupcity = () => setpromise(home.groupcity)
725

826

9-
export {cityGuess}
27+
export {cityGuess, hotcity, groupcity}

‎src/service/setPromise.js‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
import fetch from '../config/fetch'
21

3-
export default (type = 'GET', url = '', data = {}) => {
2+
export default (data) => {
43
return new Promise((resolve, reject) => {
5-
fetch(type, url, data).then(res => {
6-
resolve(res)
7-
}).catch(err => {
8-
reject(err)
9-
})
4+
resolve(data)
105
})
116
}
127

0 commit comments

Comments
 (0)