moreSearch.vue
12.5 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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
<template>
<view class="main">
<view class="flexB" style="padding: 24rpx;justify-content: space-between;">
<view class="flexB" style="width: 100%;height: 64rpx;">
<u-input placeholder="请输入" prefixIcon="search" confirm-type="search" @confirm="confirm" border="surround" v-model="keyword" shape="circle"
style="height: 22px;" >
<view slot="prefix" style="display: flex; align-items: center; justify-content: center;"
@click="goRot('/pages/subPages/moreChoose')">
<text style="font-size: 24rpx; margin-right: 6rpx;"
@click.stop="goRot('/pages/subPages/moreChoose')">{{city_name ? city_name : '城市'}}</text>
<u-icon name="arrow-down-fill" size="20rpx"></u-icon>
</view>
</u-input>
<view class="" v-if="flag" style="margin-left: 20rpx;">
<u-button text="帮我找" type="primary" shape="circle" @click="goRot('/pages/sellAndBuy/hub')"></u-button>
</view>
</view>
</view>
<view class="" v-if="!flag">
<view style="margin-top: 32rpx; padding: 24rpx;" v-if="historyList && historyList.length>0">
<view class="flexB" style="margin-bottom: 24rpx; justify-content: space-between;">
<view class="flexB">
<view class="tip" style="margin-right: 8rpx;">
<u-icon name="search" style="width: 32rpx; height: 32rpx;"></u-icon>
</view>
<p>搜索历史</p>
</view>
<view class="">
<view class="tip" style="margin-right: 8rpx;" @click.stop="del">
<u-icon name="close-circle" style="width: 32rpx; height: 32rpx;"></u-icon>
</view>
</view>
</view>
<view class="flexB" style="flex-wrap: wrap; ">
<view class="boxb oneh" style="margin-bottom: 10rpx; padding: 0 10rpx;" v-for="item in historyList.slice(historyList.length-10,historyList.length)" @click.stop="(e) => choose(e,item)">
{{item}}
</view>
</view>
</view>
<view style="margin-top: 32rpx; padding: 24rpx;">
<view class="flexB" style="margin-bottom: 24rpx;">
<view class="tip" style="margin-right: 8rpx;">
<image src="../../static/huo.png" style="width: 32rpx; height: 32rpx;" mode=""></image>
</view>
<p>热门搜索</p>
</view>
<view class="flexB" style="flex-wrap: wrap; ">
<view class="boxb oneh" v-for="item in hotCity" @click.stop="(e) => choose(e,item)">
{{item.name}}
</view>
</view>
</view>
</view>
<view class="" v-else>
<view class=" ">
<view class="" style="background: white; margin-bottom: 32rpx;">
<view class="">
<u-tabs :scrollable="false" lineWidth="45" lineHeight="7" :list="list1" @click.stop="clickTab"></u-tabs>
</view>
<view class="flexB"
style="margin: 20rpx 20rpx; padding-bottom: 10px;justify-content: space-between;">
<view class="flexB">
<view class="box1 flexB " style="margin: 0 8px; justify-content: center;" @click.stop="goQy">
<text style="font-size: 24rpx;margin-right: 6rpx;">{{region ? region : '区域'}}
</text>
<u-icon name="arrow-down-fill" size="20rpx"></u-icon>
</view>
<view class="box1 flexB " style="margin: 0 8px; justify-content: center;" @click.stop="goXh">
<text
style="font-size: 24rpx;margin-right: 6rpx;">{{xinghao_name ? xinghao_name : '型号'}}
</text>
<u-icon name="arrow-down-fill" size="20rpx"></u-icon>
</view>
<view class="box1 flexB " style="margin: 0 8px; justify-content: center;" @click.stop="goPP">
<text style="font-size: 24rpx;margin-right: 6rpx;">{{brand_name ? brand_name : '品牌'}}
</text>
<u-icon name="arrow-down-fill" size="20rpx"></u-icon>
</view>
</view>
<view class="" @click.stop="show = true">
筛选
</view>
</view>
</view>
<view style="padding: 0 16rpx 12rpx 16rpx;" v-for="item in list">
<item v-if="type == 3 || type == 4" :isBtn="false" :info="item"></item>
<item-sell v-else :info="item"></item-sell>
</view>
</view>
<view class="" style="margin-top: 20%;" v-if="list.length==0">
<u-empty>
</u-empty>
</view>
<!-- <view class="" v-else>
<view style="margin-bottom: 32rpx;">
<view class="flexB" style="margin-bottom: 32rpx">
<view class="tip" style="margin-right: 12rpx">
<image src="../../static/local.png" style="width: 32rpx; height: 32rpx;" mode=""></image>
</view>
<p>定位/最近访问</p>
</view>
<view class="flexB">
<view class="box" v-for="item in 4">
</view>
</view>
</view>
<view style="margin-bottom: 32rpx;">
<view class="flexB" style="margin-bottom: 32rpx">
<view class="tip" style="margin-right: 12rpx">
<image src="../../static/huo.png" style="width: 32rpx; height: 32rpx;" mode=""></image>
</view>
<p>热门城市</p>
</view>
<view class="flexB">
<view class="box" v-for="item in 4">
</view>
</view>
</view>
</view> -->
</view>
<u-popup :show="show" mode="right" @close="close" @open="open" style="position: relative;">
<view class="rightBox">
<!-- <view >
<view class="">
设备标签
</view>
<view class="">
<u-checkbox-group
v-model="checkboxValue2"
placement="column"
@change="checkboxChange"
>
<u-checkbox
:customStyle="{marginBottom: '8px'}"
v-for="(item, index) in checkboxList2"
:key="index"
:label="item.name"
:name="item.name"
>
</u-checkbox>
</u-checkbox-group>
</view>
</view> -->
<view>
<view class="" style="color: #000000e6;font-size: 28rpx;font-weight: 500; margin: 20rpx -40rpx;">
排序方式
</view>
<view class="">
<u-checkbox-group v-model="checkboxValue3" placement="column" @change="checkboxChange">
<u-checkbox :customStyle="{marginBottom: '8px'}" v-for="(item, index) in checkboxList3"
:key="index" :label="item.name" :name="item.value">
</u-checkbox>
</u-checkbox-group>
</view>
</view>
<view class="flexB" style="position: absolute; bottom:60rpx">
<u-button text="取消" @click="close"></u-button>
<u-button text="确定" type="primary" @click="getList(); show = false"></u-button>
</view>
</view>
</u-popup>
</view>
</template>
<script>
import item from '@/component/listItem/listItem.vue'
import ItemSell from '@/component/sellItem/sellItem.vue'
export default {
components: {
item,
ItemSell
},
data() {
return {
show: false,
flag: false,
list: [],
historyList: [],
checkboxValue1: [],
// 基本案列数据
checkboxValue2: [],
// 基本案列数据
checkboxList2: [{
name: '设备出租',
disabled: false
},
{
name: '设备出租',
disabled: false
},
{
name: '设备求租',
disabled: false
},
{
name: '设备求购',
disabled: false
}
],
checkboxValue3: [],
// 基本案列数据
checkboxList3: [{
name: '综合排序',
value: 1,
disabled: false
},
{
name: '时间排序',
value: 2,
disabled: false
},
{
name: '距离排序',
value: 3,
disabled: false
},
],
keyword: '',
city_name: '',
city_id: '',
xinghao_id: '',
xinghao_name: '',
lat: '',
lng: '',
region: '',
keywordId:'',
lat: '',
lng: '',
brand_name: '',
brand_id: '',
hotCity: [],
list1: [{
name: '出租',
}, {
name: '出售',
}, {
name: '求租'
}, {
name: '求售'
}],
type: 3
}
},
methods: {
open() {
// console.log('open');
},
close() {
this.show = false
// console.log('close');
},
checkboxChange(n) {
console.log('change', n);
},
goPP() {
uni.navigateTo({
url: '/pages/sellAndBuy/logo?category_id=' + this.keywordId
})
},
goQy() {
let that = this
uni.chooseLocation({
success: function(res) {
console.log('位置名称:' + res.name);
console.log('详细地址:' + res.address);
console.log('纬度:' + res.latitude);
console.log('经度:' + res.longitude);
console.log(that.model1);
that.region = res.address.slice(0, 3)
that.lat = res.latitude
that.lng = res.longitude
}
});
},
goXh() {
uni.navigateTo({
url: `/pages/sellAndBuy/chooseNum?category_id=${this.keywordId || ''}&brand_id=${this.brand_id || ''}`
})
},
del() {
uni.removeStorageSync('content')
uni.showToast({
title: '清空成功'
})
this.historyList = []
},
goHub() {
uni.navigateTo({
url: `/pages/sellAndBuy/hub?val=3`
})
},
goRot(url) {
uni.navigateTo({
url: url + '?val=' + '3'
})
},
clickTab(e) {
console.log(e.name);
if (e.name == '出租') {
this.type = 3
} else if (e.name == '出售') {
this.type = 4
} else if (e.name == '求租') {
this.type = 1
} else if (e.name == '求售') {
this.type = 2
}
this.getList()
},
confirm(e) {
this.getList()
console.log(e);
this.historyList.push(e)
uni.setStorageSync('content', JSON.stringify(this.historyList))
this.flag = true
},
choose(e,item){
console.log(item);
this.keyword = (item.name || item)
this.keywordId = (item.id || item)
this.flag = true
this.getList()
},
getList() {
uni.$u.http.post('/api/equip/equip_list', {
type: this.type,
keyword: this.keyword,
brand_ids: this.brand_id,
lat: this.lat,
lng: this.lng,
region: this.region,
category_ids: this.xinghao_id,
orderby: this.checkboxValue3.toString()
}).then(res => {
console.log(res);
if(res.code == 1){
this.list = res.data.data
}
}).catch(err => {
console.log(err);
})
},
getHot() {
uni.$u.http.get('/api/index/hot_search').then(res => {
this.hotCity = res.data
}).catch(err => {
console.log(err);
})
}
},
onLoad(option) {
console.log(option);
if(option && option.val !== '' && option.val !== "undefined" && option.valId !== '' && option.valId !== "undefined"){
this.keyword = option && option.val || ''
this.keywordId = option && option.valId || ''
this.flag = true
}
this.getList()
this.getHot()
this.historyList = JSON.parse(uni.getStorageSync('content') || '[]')
this.historyList = this.historyList.filter(item => item !== '')
},
onShow() {
let pagearr = getCurrentPages(); //获取应用页面栈
let currentPage = pagearr[pagearr.length - 1]; //获取当前页面信息
console.log('option:', currentPage) //获取页面传递的信息
this.city_id = currentPage.$vm.city_id
this.city_name = currentPage.$vm.city_name
this.xinghao_id = currentPage.$vm.xh_id
this.xinghao_name = currentPage.$vm.xh_name
this.brand_id = currentPage.$vm.brand_id
this.brand_name = currentPage.$vm.brand_name
this.lat = currentPage.$vm.lat
this.lng = currentPage.$vm.lng
this.getList()
this.historyList = JSON.parse(uni.getStorageSync('content') || '[]')
this.historyList = this.historyList.filter(item => item !== '')
this.historyList = Array.from(new Set(this.historyList))
console.log(result) // [ 1, 2, 'abc', true, false, undefined, NaN ]
},
}
</script>
<style scoped lang="scss">
.main {
background: #f7f8faff;
}
.flexB {
display: flex;
align-items: center;
}
.oneh{
display: inline-block;
white-space: nowrap;
width: 20%;
overflow: hidden;
text-overflow:ellipsis;
}
.box {
width: 154rpx;
height: 60rpx;
border-radius: 8rpx;
border: 0 solid #979797ff;
background: #ecf2feff;
margin-right: 24rpx;
}
.rightBox {
padding: 220rpx 120rpx
}
.boxb {
width: 124rpx;
height: 60rpx;
line-height: 60rpx;
border-radius: 8rpx;
opacity: 1;
border: 0 solid #979797ff;
background: #ecf2feff;
margin-right: 24rpx;
font-size: 24rpx;
text-align: center;
}
.box1 {
min-width: 102rpx;
height: 48rpx;
border-radius: 8rpx;
background: #f0f2f5ff;
font-size: 24rpx;
padding: 0 4rpx;
}
/deep/ .u-input--circle {
height: 30rpx;
}
/deep/ .u-button {
height: 58rpx !important;
}
/deep/ .u-input__content__field-wrapper__field{
white-space: nowrap;
overflow: hidden;
text-overflow:ellipsis;
}
</style>