<template>
	<view class="con">
		<view class="search ddflex">
			<image src="../../static/images/ssico.png" class="ssico"></image>
			<input v-model="cTitle" placeholder="搜索感兴趣的投票话题" @input="inputTopicText" placeholder-class="placeholder" class="ipt fflex" />
			<!-- <view class="clear">取消</view> -->
		</view>
		<view class="list" v-if="hotPollList && hotPollList.length > 0">
			<view class="li ddflex" v-for="(item, index) in hotPollList" :key="index" @click="jumpUrl('/office/detail/detail?contentId=' + item.momentsId)">
				<text class="num">{{ index + 1 }}</text>
				<view class="fflex tover">{{ item.title }}</view>
				<text>{{ item.participantsNO }}参与</text>
			</view>
		</view>
		<view class="nodata" v-else>
			<image :src="picUrlss + 'empty_jl.png'"></image>
			<text>没有相关投票</text>
		</view>
	</view>
</template>

<script>
const app = getApp();
const req = require('../../utils/request.js');
export default {
	data() {
		return {
			picUrlss: req.public.picUrls,
			isLoad: true,
			form: {
				page: 1,
				limit: 10
			},
			hotPollList: [],
			cTitle: '' //输入的关键词
		};
	},
	onLoad() {
		this.getHotPoll();
	},
	onReachBottom() {
		this.form.page++;
		this.getHotPoll();
	},
	methods: {
		// 监听获取话题输入˚
		inputTopicText(e) {
			this.isLoad = true;
			this.form.page = 1;
			this.getHotPoll();
		},

		jumpUrl(url) {
			uni.navigateTo({
				url: url
			});
		},

		getHotPoll() {
			if (!this.isLoad) return false;
			this.isLoad = false;
			var dataPram = {};
			dataPram.page = this.form.page;
			dataPram.limit = this.form.limit;
			if (this.cTitle) {
				dataPram.search = this.cTitle;
			}
			dataPram.orderType = 1;
			req.getRequest('/api/v3/poll/pollListV2', dataPram, data => {
				if (data && data.length >= this.form.limit) {
					this.isLoad = true;
				}
				if (this.form.page > 1) {
					data = this.hotPollList.concat(data);
				}
				this.hotPollList = data;
			});
		}
	}
};
</script>

<style>
@import './voteList.css';
</style>
