1
1
<template >
2
2
<div class =" shoplist_container" >
3
- <ul v-load-more =" loadmore " v-if =" shopListArr.length" type =" 1" >
3
+ <ul v-load-more =" loadmoreMethod " v-if =" shopListArr.length" type =" 1" >
4
4
<router-link v-for =" item in shopListArr" tag =" li" :key =" item.id" class =" shop_li" :to =" {path: 'shop', query: {geohash: geohash, id: item.id}}" >
5
5
<section >
6
- <img :src =" imageBaseUrl + item.image_path" class =" shop_img" >
6
+ <img :src =" imgBaseUrl + item.image_path" class =" shop_img" >
7
7
</section >
8
8
<hgroup class =" shop_right" >
9
- <headedr class =" shop_detail_header" ><!-- preminum额外费用-->
10
- <h4 :class =" item.is_premium ? 'preminum ' : ''" class =" shop_title ellipsis" >{{item.name}}</h4 >
11
- <ul class =" shop_detal_ul " >
9
+ <header class =" shop_detail_header" ><!-- preminum额外费用-->
10
+ <h4 :class =" item.is_premium ? 'premium ' : ''" class =" shop_title ellipsis" >{{item.name}}</h4 >
11
+ <ul class =" shop_detail_ul " >
12
12
<li v-for =" item in item.supports" :key =" item.id" class =" supports" >{{item.icon_name}}</li >
13
13
</ul >
14
- </headedr >
14
+ </header >
15
15
<h5 class =" rating_order_num" >
16
16
<section class =" rating_order_num_left" >
17
17
<section class =" rating_section" >
29
29
</h5 >
30
30
<h5 class =" fee_distance" >
31
31
<p class =" fee" >
32
- ¥{{item.minimum_order_amount}}起送<span class =" segmentation" >/</span >{{item.piecewise_agent_fee.tips}}
32
+ <!-- ¥{{item.minimum_order_amount}}起送<span class="segmentation">/</span>{{item.piecewise_agent_fee.tips}} -->
33
+ ¥{{item.float_minimum_order_amount}}起送<span class =" segmentation" >/</span >{{item.piecewise_agent_fee.tips}}
33
34
</p >
34
35
<p class =" distance_time" >
35
36
<span v-if =" Number(item.distance)" >{{item.distance > 1000 ? (item.distance/1000).toFixed(2) + 'km': item.distance + 'm'}}
36
37
<span class =" segemtation" >/</span >
37
38
</span >
38
39
<span v-else >{{item.distance}}</span >
39
40
<span class =" segemtation" >/</span >
40
- <span class =" order_time" >{{item.order_load_time }}</span >
41
+ <span class =" order_time" >{{item.order_lead_time }}</span >
41
42
</p >
42
43
</h5 >
43
44
</hgroup >
44
45
</router-link >
45
46
</ul >
46
47
<ul v-else class =" animation_opacity" >
47
48
<li class =" list_back_li" v-for =" item in 10" :key =" item" >
48
- <img : src =" imageUrl " class =" list_back_svg" >
49
+ <img src =" ../../images/shopback.svg " class =" list_back_svg" >
49
50
</li >
50
51
</ul >
51
52
<p class =" empty_data" v-if =" touched" >没有更多了</p >
@@ -71,15 +72,15 @@ import urls from '../../config/urls'
71
72
export default {
72
73
data () {
73
74
return {
74
- imageUrl : ' ../images/shopback.svg' ,
75
+ imagePath : ' ../images/shopback.svg' ,
75
76
offset: 0 , // 批次加载店铺列表,每次加载20个 limit = 20
76
77
shopListArr: [], // 店铺列表数据
77
78
preventRepeatReuqest: false , // 到达底部加载数据,防止重复加载
78
79
showBackStatus: false , // 显示返回顶部按钮
79
80
showLoading: true , // 显示加载动画
80
81
touchend: false , // 没有更多数据
81
- imgBaseUrl : imgBaseUrl ,
82
- touched : false
82
+ touched : false ,
83
+ imgBaseUrl
83
84
}
84
85
},
85
86
mounted () {
@@ -97,19 +98,10 @@ export default {
97
98
])
98
99
},
99
100
methods: {
100
- async initData () {
101
- let res = await this .getShopList (this .latitude , this .longitude , this .offset , this .restaurantCategoryId )
102
- this .shopListArr = [... res]
103
- if (res .length < 20 ) {
104
- this .touchend = true
105
- }
106
- this .hideLoading ()
107
- // 开始监听scrollTop的值,达到一定程度后显示返回顶部按钮
108
- showBack (callbackStatus => {
109
- this .showBackStatus = callbackStatus
110
- })
101
+ initData () {
102
+ this .getShopList (' init' , this .latitude , this .longitude , this .offset , this .restaurantCategoryId )
111
103
},
112
- getShopList (latitude , longitude , offset = 0 , restaurantCategoryId = ' ' , restaurantCategoryIds = ' ' , orderBy = ' ' , deliveryMode = ' ' , supportIds = []) {
104
+ getShopList (flag , latitude , longitude , offset = 0 , restaurantCategoryId = ' ' , restaurantCategoryIds = ' ' , orderBy = ' ' , deliveryMode = ' ' , supportIds = []) {
113
105
let supportStr = ' '
114
106
supportIds .forEach (item => {
115
107
if (item .status ) {
@@ -119,10 +111,38 @@ export default {
119
111
let query = ' ?latitude=' + latitude + ' &longitude=' + longitude + ' &offset=' + offset + ' &limit=20' + ' &restaurant_category_id=' + restaurantCategoryId + ' &restaurant_category_ids[]' + restaurantCategoryIds
120
112
query += ' &order_by=' + orderBy + ' &delivery_mode[]=' + deliveryMode + supportStr
121
113
this .$axios .get (urls .shopList + query).then ((res ) => {
122
- return res
114
+ let length = res .data .length
115
+ if (length > 0 ) {
116
+ this .hideLoading ()
117
+ switch (flag) {
118
+ case ' init' :
119
+ this .shopListArr = [... res .data ]
120
+ if (length < 20 ) {
121
+ this .touchend = true
122
+ }
123
+ // 开始监听scrollTop的值,达到一定程度后显示返回顶部按钮
124
+ showBack (callbackStatus => {
125
+ this .showBackStatus = callbackStatus
126
+ })
127
+ break
128
+ case ' load' :
129
+ this .shopListArr = [... this .shopListArr , ... res .data ]
130
+ // 当获取数据小于20,说明没有更多数据,不需要再次请求数据
131
+ if (length < 20 ) {
132
+ this .touchend = true
133
+ return
134
+ }
135
+ this .preventRepeatReuqest = false
136
+ break
137
+ case ' listenPropChange' :
138
+ // 考虑到本地模拟数据是引用类型,所以返回一个新的数组
139
+ this .shopListArr = [... res .data ]
140
+ break
141
+ }
142
+ }
123
143
})
124
144
},
125
- async loadMore () {
145
+ loadmoreMethod () {
126
146
if (this .touchend ) {
127
147
return
128
148
}
@@ -134,28 +154,17 @@ export default {
134
154
this .preventRepeatReuqest = true
135
155
// 数据的定位加20位
136
156
this .offset += 20
137
- let res = await this .getShopList (this .latitude , this .longitude , this .offset , this .restaurantCategoryId )
138
- this .hideLoading ()
139
- this .shopListArr = [... this .shopListArr , ... res]
140
- // 当获取数据小于20,说明没有更多数据,不需要再次请求数据
141
- if (res .length < 20 ) {
142
- this .touchend = true
143
- return
144
- }
145
- this .preventRepeatReuqest = false
157
+ this .getShopList (' load' , this .latitude , this .longitude , this .offset , this .restaurantCategoryId )
146
158
},
147
159
// 返回顶部
148
160
backTop () {
149
161
animate (document .body , {scrollTop: ' 0' }, 400 , ' ease-out' )
150
162
},
151
163
// 监听父级传来的数据发生变化时,触发此函数重新根据属性值获取数据
152
- async listenPropChange () {
164
+ listenPropChange () {
153
165
this .showLoading = true
154
166
this .offset = 0
155
- let res = await this .getShopList (this .latitude , this .longitude , this .offset , ' ' , this .restaurantCategoryIds , this .sortByType , this .deliveryMode , this .supportIds )
156
- this .hideLoading ()
157
- // 考虑到本地模拟数据是引用类型,所以返回一个新的数组
158
- this .shopListArr = [... res]
167
+ this .getShopList (' listenPropChange' , this .latitude , this .longitude , this .offset , ' ' , this .restaurantCategoryIds , this .sortByType , this .deliveryMode , this .supportIds )
159
168
},
160
169
// 开发环境与编译环境loading隐藏方式不同
161
170
hideLoading () {
0 commit comments