<template>
	<view>
		<view class="" style="padding: 10px;">
			<view class="dis-flex" style="padding: 10px 0px;border-bottom: 1px solid #efefef;">
				<!-- <image src="https://qingyuan.xingtongworld.com/attachment/images/weliam_smartcity/1/167720398280232.png" mode="" style="width: 70px;height: 70px;background-color: #000;"></image> -->
				<view style="margin-left: 10px;line-height: 24px;">
					<view class="">#{{keyword}}#</view>
					<view style="color: #999999;font-size: 12px;">{{communityList.length}}条内容</view>
					<view style="color: #999999;font-size: 12px;">今日阅读量：{{communityList.length}}，今日讨论{{communityList.length}}</view>
				</view>
			</view>
			<view class="conc">
				<block v-for="(item, index) in communityList" :key="index">
					<view @click="toDetails(item.id)" style="border-bottom: 1px solid #efefef;">
						<pic-text :info="item"></pic-text>
					</view>
				</block>
			</view>
		</view>
	</view>
</template>

<script>
// 参考pages/mainPages/econdaryClassification/econdaryClassification
import App from '@/common/js/app.js';
import picText from "@/components/template/pic_text/pic_text.vue"
export default {
	data() {
		return {
			communityList: [],
			page_index: 10,
			keyword: '',
			indexShow: -1,
		}
	},
	components:{
		picText
	},
	onLoad(e) {
		this.keyword = e.keyword;
		this.getList();
	},
	methods: {
		getList(page = 1, isPage = false){
			let _this = this;
			let data = {
				id: 0,//0对应掌上生活的全部类目
				two_id: undefined,
				page,
				page_index: _this.page_index,
				homeflag: 1,
				keyword:'',
			};
			
			App._post_form('&p=pocket&do=infoList', data, res => {
				console.log(res, '--------------')
				let list = [];
				if (!isPage) {
					if (res.data.list.length > 0) {
						list = res.data.list.map(item=>{
							let itemN = {...item}
							itemN.comment_list.total = item.comment_list.list.length;//暂时传给组件需要(后端给的total值不对)
							return itemN
						})
						list = list.sort(function(){// 乱序一下
							return Math.random() - 0.5;
						});
						_this.setData({
							communityList: list
						})
					} else {
						// _this.isMore = true;
					}
				} else {
					
				};
			});
		},
		lookimg(){
			// this.isOnshow = false;
		},
		operationShow(e) {
			// let _this = this;
			// _this.indexShow = e;
		},
		getover(id,bor){
			
		},
		// 跳转正文详情
		toDetails(id){
			uni.navigateTo({
				url:"/pagesA/pictureTextDetails/pictureTextDetails?id=" + id
			})
		},
	},
	onShareAppMessage(res){
		let _this = this;
		if (res.from === 'button') {// 来自页面内分享按钮
			let listId = res.target.id;
			let title = res.target.dataset.title;
			App._post_form('&p=pocket&do=shareNum', { id: listId }, res => {
				for(let index=0;index<_this.communityList.length;index++){
					if(_this.communityList[index].id == listId){
						_this.communityList[index].share++;
					}
				}
				setTimeout(()=>{
					uni.showToast({
						icon: 'none',
						title: '分享成功',
						duration: 2000
					});
				}, 2000)
			});
			return {
				title: '粤职才',
				path: '/pagesA/pictureTextDetails/pictureTextDetails?id='+listId
			}
		}else{
			return {
				title: '粤职才',
				path: '/pages/mainPages/index/index'
			}
		}
	}
}
</script>

<style lang="scss" scoped>
.dis-flex{
	display: flex;
	align-items: center;
}
.conc{
	image{
		width: calc(100vw - 20px);
	}
}
</style>
