duanshipinlist.vue
6.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
<template>
<div class="container">
<div class="tiezitop tiezilisttopk">
<div class="hometopbark hometopbackk flextwo">
<div class="homesearch flexone">
<img src="../../../assets/sousuo.png" alt="" class="souimg" />
<div class="souenter">
<input
type="text"
placeholder="请输入关键词搜索"
v-model="keyword"
@blur="finish"
/>
</div>
</div>
<div class="searchpro flexone" @click="showprovince">
<div class="proname">{{ proname }}</div>
<img src="../../../assets/xiasanjiao.png" alt="" class="xiasanjiao" />
</div>
</div>
</div>
<!-- 帮工招聘 -->
<div class="tiezikind flextwo" v-if="kindtype == 2">
<div
class="tiezikinditem"
:class="search_type == 1 ? 'tiezikindactive' : ''"
@click="seltiekind(1)"
>
招聘
</div>
<div
class="tiezikinditem"
:class="search_type == 2 ? 'tiezikindactive' : ''"
@click="seltiekind(2)"
>
求职
</div>
</div>
<!-- 面坊转让 -->
<div class="tiezikind flextwo" v-if="kindtype == 3">
<div
class="tiezikinditem"
:class="search_type == 3 ? 'tiezikindactive' : ''"
@click="seltiekind(3)"
>
求购
</div>
<div
class="tiezikinditem"
:class="search_type == 4 ? 'tiezikindactive' : ''"
@click="seltiekind(4)"
>
转让
</div>
</div>
<!-- 征婚交友 -->
<div class="tiezikind flextwo" v-if="kindtype == 4">
<div
class="tiezikinditem"
:class="search_type == 5 ? 'tiezikindactive' : ''"
@click="seltiekind(5)"
>
找男友
</div>
<div
class="tiezikinditem"
:class="search_type == 6 ? 'tiezikindactive' : ''"
@click="seltiekind(6)"
>
找女友
</div>
</div>
<!-- 帖子列表 -->
<div class="tiezhlist">
<van-list
v-model="loading"
:finished="finished"
finished-text="没有更多了"
@load="onLoad"
>
<tiezicontent :tiezilist="tiezilist" :showpull="showpull" />
</van-list>
</div>
<!-- 选择器 -->
<van-picker
title="标题"
show-toolbar
:columns="citylist"
@confirm="onConfirm"
@cancel="onCancel"
v-if="showcity"
/>
</div>
</template>
<script>
import tiezicontent from "@/components/tiezicontent.vue";
import area from "../../../utils/area.js";
import { changename } from "../../../utils/base.js"; //城市去掉市
export default {
components: {
tiezicontent
},
data() {
return {
tiezisel: 1,
showcity: false,
citylist: area.province_list,
tiezilist: [],
showpull: true,
loading: false,
finished: false,
proname: "",
province_id: "",
kindtype: "",
search_type: "",
keyword: "",
page: 1
};
},
created() {
document.title = "短视频专区";
// 分类id
this.kindtype = this.$route.query.id;
if (this.kindtype == 2) {
// 帮工招聘
this.search_type = 1;
} else if (this.kindtype == 3) {
//面坊转让
this.search_type = 3;
} else if (this.kindtype == 4) {
//征婚交友
this.search_type = 5;
}
// localStorage.setItem("proname", "天津");
this.proname = localStorage.getItem("proname");
this.getprovinceid();
},
methods: {
// 显示省份
showprovince() {
this.showcity = true;
},
// 1 帮工2 招聘 3求购 4 转让 5 找男友 6 找女友
seltiekind(id) {
this.search_type = id;
this.page = 1;
this.tiezilist = [];
this.getteizilist();
},
onLoad() {
// 异步更新数据
// setTimeout 仅做示例,真实场景中一般为 ajax 请求
setTimeout(() => {
let newpage = this.page;
newpage++;
this.page = newpage;
this.getteizilist();
// 加载状态结束
this.loading = false;
// 数据全部加载完成
if (this.showpull == false) {
this.finished = true;
}
}, 1000);
},
// 关键词搜索
finish() {
this.page = 1;
this.tiezilist = [];
this.getteizilist();
},
// 确定选择城市
onConfirm(value, index) {
let tat = this;
console.log(value, index);
let that = this;
this.showcity = false;
if (changename(value) != "") {
that.proname = changename(value);
} else {
that.proname = value;
}
that.page = 1;
that.tiezilist = [];
that.getprovinceid();
},
// 根据城市名字获取id
getprovinceid() {
let that = this;
var url = "/api/question/get_area";
var params = {
province_name: that.proname
};
console.log("7766554", params);
that.$axios
.post(url, params)
.then(res => {
that.province_id = res.data.id;
that.tiezilist = [];
that.page = 1;
// 获取论坛列表
this.getteizilist();
})
.catch(err => {
console.log(err);
});
},
// 获取论坛列表
getteizilist() {
let that = this;
var url = "/api/forum/get_forum";
var params = {
search_type: that.search_type,
keyword: that.keyword,
province_id: that.province_id,
type: that.kindtype,
page: that.page,
pageNum: 10
};
console.log("参数", params);
that.$axios
.post(url, params)
.then(res => {
console.log(res);
that.tiezilist = that.tiezilist.concat(res.data);
if (that.page > 1) {
if (res.data.length == 0) {
that.showpull = false;
}
}
that.tiezilist.forEach(function(value,index,array){
value.content=richTextFormat(value.content)
})
that.tiezilist=that.tiezilist;
that.$forceUpdate()
})
.catch(err => {
console.log(err);
});
},
onCancel() {
this.showcity = false;
},
tiezidetail() {
this.$router.push({
path: "/tiezidetail",
query: {
type: 3
}
});
}
}
};
</script>
<style scoped>
@import "../../style/homepage.css";
.van-picker {
position: fixed;
bottom: 0;
left: 0;
z-index: 999;
width: 100%;
}
</style>