luntanlist.vue 7.5 KB
<template>
	<view class="content">
		<view class="searchGoods-wrap">
			<view class="search-nav">
				<!-- search -->
				<view class="search">
					<view class="searchimg">
						<image src="../../static/search.png" mode=""></image>
					</view>
					<input type="text" confirm-type="search" placeholder-class="placeholder" placeholder="请输入关键词搜索" @confirm="finish"
					 @input="enterword" />
					<!-- <view class="search-btn">
						北京
						<image src="../../static/huixia.png" />
					</view> -->

					<picker @change="bindproChange" :value="index" :range="provincelist" range-key="name">
						<!-- <view class="uni-input">{{array[index]}}</view> -->
						<view class="proselect flexthree">
							<text class="proname">{{provincename}}</text>
							<image class="down-ico" src="../../static/huixia.png" />
						</view>
					</picker>
				</view>
				<!-- nav -->
				<view class="nav-menus">
					<scroll-view class="nav-menu" scroll-x="true">
						<view :class="kindtype=='4'?'active':''" @click="kindchange" :data-id="4">
							视频专区
						</view>
						<view :class="kindtype=='1'?'active':''" @click="kindchange" :data-id="1">
							帮工招聘求职
						</view>
						<view :class="kindtype=='2'?'active':''" @click="kindchange" :data-id="2">
							面坊转让求购
						</view>
						<view :class="kindtype=='3'?'active':''" @click="kindchange" :data-id="3">
							征婚交友
						</view>
						
					</scroll-view>
				</view>
			</view>
			<!-- 列表 -->
			<view class="list">
				<!-- content -->
				<view class="new-release-content" v-for="(item,index) in luntanlist" :key="index" @click="luntandetail(item)">
					<!-- 头像,名称,等级 -->
					<view class="userinfo-wrap">
						<image :src="item.user.avatar"></image>
						<text class="title">{{item.user.nickname}}</text>
						<view class="VIP">
							<image src="../../icons/vip.png"></image>
							{{item.user.level.name1}}
						</view>
					</view>
					<!-- type -->
					<view class="type-wrap">
						帮工招聘求职
						<text v-for="(item,index) in item.user.label" :key="index">{{item.name_label}}</text>
						<!-- <text>配送员</text>
						<text>销售员</text> -->
					</view>
					<!-- content -->
					<view class="release-text">
						<view class="release-text-title">
							{{item.title}}
						</view>
						<view class="release-text-content">
							<rich-text :nodes="item.content"></rich-text>
						</view>
					</view>
					<!-- 点赞, 人数 -->
					<view class="thumbs-number" @click.stop="praisedian(item,index)">
						<view class="thumbs">
						<image src="../../static/tienozan.png" v-if="item.is_praise==2"></image>
						<image src="../../static/tiezan.png" v-else></image>
							{{item.praise}}
						</view>
						<view class="number">
							<image src="../../icons/number.png"></image>
							{{item.view}}
						</view>
					</view>
				</view>


			</view>
		</view>



	</view>
</template>

<script>
	import app from "../../App.vue";
	export default {
		data() {
			return {
				showbanben: false,
				kindtype: '',
				provincelist: [],
				province_id:'',
				provincename: '',
				index: 0,
				keyword: '',
				luntanlist: []
			}
		},
		onLoad(options) {
			this.kindtype = options.id;
			this.getprovincelist()
		},
		methods: {
			kindchange(e) {
				this.kindtype = e.currentTarget.dataset.id;
				this.page = 1;
				this.luntanlist = [];
				this.getluntanlist()
			},

			// 输入完成
			finish() {
				this.page = 1;
				this.luntanlist = [];
				// this.getluntanlist()
			},

			// 输入关键字
			enterword(e) {
				this.keyword = e.detail.value
			},
			// 获取省份列表
			getprovincelist() {
				let that = this;
				var url = 'forum/get_province';
				var params = {
					is_forum_hot: ''
				}
				console.log('7766554', params)
				app.post(url, params).then((res) => {
					console.log(res);
					that.provincelist = res.data.data;
					this.provincename = res.data.data[0].name;
					that.province_id = res.data.data[0].id;
					// 获取论坛列表
					this.getluntanlist()
				}).catch((err) => {

				})
			},
			bindproChange(e) {
				this.index = e.target.value;
				this.provincename = this.provincelist[e.target.value].name;
				this.province_id = this.provincelist[e.target.value].id;
				this.page = 1;
				this.luntanlist = [];
				// 获取论坛列表
				 this.getluntanlist();
			},

			// 获取论坛列表
			getluntanlist() {
				let that = this;
				var url = 'forum/get_forum';
				var params = {
					keyword: that.keyword,
					province_id: that.province_id,
					type: that.kindtype,
					page: that.page,
					pageNum: 10
				}
				console.log('参数', params)
				app.post(url, params).then((res) => {
					console.log(res);
					that.luntanlist = that.luntanlist.concat(res.data.data);
					console.log('9999', this.luntanlist)


				}).catch((err) => {
					console.log(err)

				})
			},
			praisedian(item,index){
				let that = this;
				if(that.luntanlist[index].is_praise==2){
					uni.showToast({
						title:'点赞成功',
						icon:'none'
					})
					that.luntanlist[index].is_praise=1;
					that.luntanlist[index].praise=that.luntanlist[index].praise+1
				}else{
					uni.showToast({
						title:'取消点赞成功',
						icon:'none'
					})
					that.luntanlist[index].is_praise=2;
					that.luntanlist[index].praise=that.luntanlist[index].praise-1
				}
				
				that.luntanlist=that.luntanlist;
				
				var url = 'forum/praise';
				var params = {
					forum_id:item.id
				}
				console.log('参数',params)
				app.post(url, params).then((res) => {
					console.log(res);
					
				
				
				}).catch((err) => {
					console.log(err)
				
				})
			},
			luntandetail(item) {
				uni.navigateTo({
					url:'/pages/luntan/luntandetail?id='+item.id
				})
			}
		}

	}
</script>

<style>
	page {
		background: #f9f9f9;
	}

	.search {
		position: relative;
	}

	.proname {
		color: #BDC4CE;
		font-size: 24rpx;
	}

	.down-ico {
		width: 16rpx;
		height: 16rpx;
	}

	.searchimg {
		width: 28rpx;
		height: 28rpx;
		font-size: 0;
		position: absolute;
		left: 54rpx;
		top: 19rpx;

	}

	.search-nav {
		width: 750rpx;
		padding: 14rpx 14rpx 0;
		box-sizing: border-box;
		position: fixed;
		top: 0;
		left: 0;
		z-index: 1000;
		background: #fff;
	}

	.search-nav .search {
		padding: 0 32rpx;
		display: flex;
		justify-content: flex-start;
		align-items: center;
	}

	.search-nav .search .placeholder {
		font-size: 24rpx;
		color: #BDC4CE;
	}

	.search-nav .search icon {
		position: absolute;
		top: 14rpx;
		left: 45rpx;
	}

	.search-nav .search input {
		height: 60rpx;
		width: 72vw;
		border: 1px solid #eee;
		background: #F9F9F9;
		border-radius: 50px;
		padding-left: 60rpx;
	}

	.search-nav .search .search-btn {
		color: #BDC4CE;
		font-size: 24rpx;
		margin-left: 24rpx;
		border: 1px solid #EEEEEE;
		width: 120rpx;
		height: 60rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		border-radius: 50px;
	}

	.search-nav .search .search-btn image {
		width: 16rpx;
		height: 16rpx;
		margin-left: 10rpx;
	}

	.search-nav .nav-menus {
		padding-left: 36rpx;
		padding-right: 8rpx;
	}

	.search-nav .nav-menu {
		white-space: nowrap;
	}

	.search-nav .nav-menu view {
		display: inline-block;
		color: #232323;
		font-size: 30rpx;
		height: 88rpx;
		line-height: 88rpx;
		margin-right: 28rpx;
	}

	.search-nav .nav-menu .active {
		color: #FF9417;
		position: relative;
	}

	.search-nav .nav-menu .active::after {
		content: "";
		position: absolute;
		bottom: 0rpx;
		left: 0;
		height: 2px;
		width: 100%;
		background: #FF9417;
	}

	.list {
		padding-top: 152rpx;
	}
</style>