storeList.vue
9.66 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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
<template>
<view class="container">
<!-- <u-navbar title="门店列表" autoBack :safeAreaInsetTop="true" placeholder fixed></u-navbar> -->
<Navbar title="门店列表" canBack></Navbar>
<customNavBar mode="store" @search="handSearch"></customNavBar>
<!-- 推荐tag区域 -->
<view class="recommendCss padding-sm">
<view class="text-lg text-gray margin-sm">
为您推荐当前定位地址附近的服务店
</view>
<view class="flex justify-around">
<view class="" v-for="(item,index) in recommendList" :key="index">
<u-tag class="recommendTagCss" :borderColor="item.checked?'#EB1815':'#B1B4C2'"
:color="item.checked?'#EB1815':'#B1B4C2'" bgColor="#fff" shape="circle" :text="item.name"
:name="index" @click="checkboxClick"></u-tag>
</view>
</view>
</view>
<view class="storeCardCss" v-for="(item,index) in storeList" :key="index" @click="goToDetails(item)">
<view class="flex align-center margin-top">
<u-tag :text="item.fCzlx||''" :bgColor="item.fCzlx==='储配站'?'#00AEAA':'#5875EB'" borderColor="#fff"
color="#fff"></u-tag>
<text class="storeNameCss margin-left-sm text-lg text-bold">{{item.fCzjc || ""}}</text>
</view>
<view class="flex justify-between align-center">
<view class="flex flex-direction">
<!-- <view class="flex typeTagCss margin-top-xs">
<u-tag class="margin-right-sm margin-top-xs" text="充装" bgColor="#FFF6E6" color="#FFB700"
borderColor="#fff"></u-tag>
<u-tag class="margin-right-sm margin-top-xs" text="配送" bgColor="#FFF6E6" color="#FFB700"
borderColor="#fff"></u-tag>
<u-tag class="margin-right-sm margin-top-xs" text="自提" bgColor="#FFF6E6" color="#FFB700"
borderColor="#fff"></u-tag>
</view> -->
<view class="flex align-center margin-top-sm">
<view class="">
<u-image src="/static/images/home/localtion.png" mode="aspectFit" width="15px"
height="15px"></u-image>
</view>
<view class="text-gray margin-left-xs">
{{item.fSssf || ""}}{{item.fSss || ""}}{{item.fSsq || ""}}{{item.fSsjd || ""}}{{item.fXxdz || ""}}
<!-- 孝感市汉川市S1006炼厂石化(农利加油站) 西南侧约150米 -->
</view>
</view>
<view class="flex align-center margin-top-xs">
<view class="">
<u-image src="/static/images/home/yysj.png" mode="aspectFit" width="15px"
height="15px"></u-image>
</view>
<view class="text-gray margin-left-xs">
{{item.fYykssj || ""}} ~ {{item.fYyjssj || ""}}
</view>
</view>
<view class="flex align-center margin-top-sm">
<view class="">
<u-image src="/static/images/home/phone.png" mode="aspectFit" width="15px"
height="15px"></u-image>
</view>
<view class="text-gray margin-left-xs">
<!-- 0712-8468188/1367712675 -->
{{item.fCzlxfs || ""}}
</view>
</view>
</view>
<view class="rightIconBodyCss flex flex-direction margin-right-xs margin-top-sm">
<!-- <view class="rightTagCss" v-if="item.distance <= 1">
最近订气场站
</view> -->
<view class="text-center">
<view class="iconRoundCss" @click.stop="handleMap(item)">
<u-icon name="map-fill" color="#EA5504" size="20"></u-icon>
</view>
<text class="text-gray text-sm" style="width: 30px;">{{$formatDistance(item.distance)}}</text>
</view>
<view class="margin-top-lg">
<view class="iconRoundCss" @click.stop="handleCallPhone(item)">
<u-icon name="phone-fill" color="#EA5504" size="20"></u-icon>
</view>
<!-- <u-image width="30px" height="30px" shape="circle"></u-image> -->
</view>
</view>
</view>
</view>
<u-empty mode="list" icon="http://cdn.uviewui.com/uview/empty/list.png" v-if="!storeList.length"></u-empty>
<u-loadmore :status="status" marginTop="20" height="10" marginBottom="10" v-else />
</view>
</template>
<script>
import {
mapState
} from 'vuex';
import customNavBar from '@/components/customNavBar/customNavBar.vue'
export default {
components: {
customNavBar
},
data() {
return {
recommendList: [{
index: 0,
name: '全部',
checked: true
}, {
index: 1,
name: '推荐',
checked: false
}, {
index: 2,
name: '充装站',
checked: false
}, {
index: 3,
name: '供应站',
checked: false
}],
storeList: [],
formData: {
current: 1,
size: 10,
// jd: "114.347455", //PC无法定位调试使用
// wd: "30.504396", //PC无法定位调试使用
jd: "",
wd: "",
czlxList: '',
search: ""
},
status: "loadmore",
total: null,
}
},
computed: {
// 使用 mapState 辅助函数将 Vuex state 中的 adsJd 和 adsWd 映射到当前组件的计算属性中
...mapState({
adsJd: state => state.user.adsJd,
adsWd: state => state.user.adsWd
})
},
onPullDownRefresh() {
this.storeList = []
//调用获取数据方法
this.getStoreList()
setTimeout(() => {
//结束下拉刷新
uni.stopPullDownRefresh();
}, 500);
},
onReachBottom() {
let allTotal = this.formData.current * this.formData.size
if (allTotal < this.total) {
//当前条数小于总条数 则增加请求页数
this.formData.current++;
this.status = 'loading';
setTimeout(() => {
this.getStoreList()
}, 500)
} else {
this.status = 'nomore'
// console.log('已加载全部数据')
}
},
async onLoad() {
},
async onShow() {
console.log(this.$store);
// 如果未选择地址则获取当前定位
if (!this.adsJd && !this.adsWd) {
await this.getLocation();
}
await this.getStoreList();
},
methods: {
//获取当前的定位
getLocation() {
let that = this;
return new Promise((resolve, reject) => {
uni.getLocation({
type: 'gcj02',
success: (res) => {
console.log('无地址,定位获取', JSON.parse(JSON.stringify(res)));
that.formData.jd = res.longitude;
that.formData.wd = res.latitude;
resolve(); // 成功获取经纬度后 resolve
},
fail: (error) => {
uni.$u.toast("定位失败");
console.log("定位失败",error);
reject(error); // 获取经纬度失败时 reject
}
});
});
},
async getStoreList() {
// 如果有选择的地址经纬度
if(this.adsJd && this.adsWd){
this.formData.jd = this.adsJd;
this.formData.wd = this.adsWd;
}
console.log('门店列表查询条件', JSON.parse(JSON.stringify(this.formData)));
const result = await this.$api.memberApi.getwCzxxList(this.formData);
let {
code,
value
} = result;
if (code === 200) {
let allTotal = this.formData.current * this.formData.size
this.total = value.total
const newlist = value.records;
if (this.formData.current === 1) {
this.storeList = newlist;
} else {
this.storeList.push(...newlist)
}
if (this.storeList.length < allTotal) {
this.status = 'nomore'
}
}
console.log('门店列表', JSON.parse(JSON.stringify(this.storeList)));
},
checkboxClick(name) {
console.log(name);
let tempIsOpen = this.recommendList[name].checked;
this.recommendList[name].checked = !tempIsOpen;
console.log("tempIsOpen", tempIsOpen);
this.recommendList.map((item, index) => {
item.checked = index === name ? true : false
})
if (name === 0 || name === 1) {
this.formData.czlxList = '';
}
if (name === 2) {
this.formData.czlxList = '充装站';
// if (this.recommendList[name].checked) {
// this.formData.czlxList.push('储配站')
// } else {
// let index = this.formData.czlxList.indexOf('储配站');
// if (index !== -1) {
// this.formData.czlxList.splice(index, 1);
// }
// }
}
if (name === 3) {
this.formData.czlxList = '供应站'
// if (this.recommendList[name].checked) {
// this.formData.czlxList.push('供应站')
// } else {
// let index = this.formData.czlxList.indexOf('供应站');
// if (index !== -1) {
// this.formData.czlxList.splice(index, 1);
// }
// }
}
this.getStoreList();
},
handleMap(item){
console.log('item',JSON.parse(JSON.stringify(item)));
this.$viewMapLocation(item.fJd,item.fWd,item.fCzmc);
},
handleCallPhone(item){
console.log('item',JSON.parse(JSON.stringify(item)));
if(item.fCzlxfs){
uni.makePhoneCall({
phoneNumber:item.fCzlxfs,
})
}
},
handSearch(e) {
console.log("搜索关键词", e);
this.formData.search = e;
this.getStoreList();
},
goToDetails(item) {
console.log(item);
uni.navigateTo({
url: "/pages/home/storeDetails?czid=" + item.id
})
}
}
}
</script>
<style scoped lang="scss">
.container {
padding-bottom: 10px;
}
.recommendCss {
background: #fff;
}
/deep/.recommendTagCss .u-tag {
width: 80px !important;
display: flex !important;
justify-content: center;
}
/deep/.typeTagCss .u-tag {
width: 60px !important;
height: 30px;
display: flex !important;
justify-content: center;
}
.storeCardCss {
position: relative;
.storeNameCss {
width: 100%;
}
.rightIconBodyCss {
width: 20vw;
display: flex;
align-items: flex-end;
.iconRoundCss {
width: 40px;
height: 40px;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
background: #FDEEE6;
}
}
.rightTagCss {
position: absolute;
top: 0;
right: 0;
border-radius: 0px 10px 0px 10px;
padding: 5px;
background: #EA5504;
color: #fff;
}
}
.storeCardCss {
margin: 10px;
padding: 10px;
background: #fff;
border-radius: 15px;
}
</style>