<template>
	<view>
		<view class="list" v-if="pageList&&pageList.length>0">
			<view class="li" v-for="(item,index) in pageList" :key="index">
				<view class="user ddflex" @click="toUserHomePage(item.userDTO)">
					<image :src="item.userDTO.avatar ? item.userDTO.avatar : '../../static/images/userImg.png'" mode="aspectFill" class="userimg"></image>
					<view class="fflex">
						<view class="username">{{item.userDTO.realName}}</view>
						<view class="time">{{item.createDate}}</view>
					</view>
				</view>
				<view class="reply" v-if="item.superiorFabulousDTO" @click="jumpUrlDetail(item)">
					<view class="reply-c"><text>回复：</text>{{item.content}}</view>
					<view class="reply-s">{{item.superiorFabulousDTO.content}}</view>
				</view>
				<view class="des" @click="jumpUrlDetail(item)" v-else>{{item.content}}</view>
				<view class="info ddflex" @click="jumpUrlDetail(item)">
					<image :src="item.momentsDto.url" mode="aspectFill" v-if="item.momentsDto.url"></image>
					<view class="infos fflex">
						<!-- <view class="tit">此处为评论的团妈说标题</view> -->
						<view class="bri tovers"><rich-text :nodes="item.momentsDto.content"></rich-text></view>
					</view>
				</view>
			</view>
		</view>
		<view class="nodata" v-if="isshow">
		  <image :src="picUrlss+'empty_sc.png'"></image>
		  <text>暂无消息</text>
		</view>
	</view>
</template>

<script>
	const req = require("../../utils/request.js");
	const app = getApp();

	export default {
		data() {
			return {
				picUrlss: req.public.picUrls,
				form: {
					page: 1,
					limit: 10
				},
				pageList: [],
				isLoad: true,
				isshow: false
			};
		},
		onLoad: function(options) {
			this.getList();
		},
		onReachBottom() {
			this.form.page++;
			this.getList();
		},
		methods: {
			getList() {
				if (!this.isLoad) return false;
				this.isLoad = false;
				let form = this.form;
				let that = this;
				req.getRequest('/api/v3/fabulous/seeFabulousList', form, data => {
					if (data && data.length == 10) that.isLoad = true;
					if (data && data.length == 0 && that.form.page == 1) that.isshow = true;
					if (that.form.page > 1) data = that.pageList.concat(data);
					that.pageList = data
				});
			},
			jumpUrl(url){
				uni.navigateTo({
					url: url
				})
			},
			toUserHomePage(userObj) {
				if (userObj.isApiUser != 1) {
					//不是后台用户，则可跳转
					this.jumpUrl('/topics/home/home?userId=' + userObj.id);
				}
			},
			jumpUrlDetail(item) {
				if(item.superiorFabulousDTO){
					uni.navigateTo({
						url: '/office/comments/comments?commentId=' + item.pid + '&commentIds=' + item.id + '&isSecond=' +true
					});
				}else{
					// uni.navigateTo({
					// 	url: '/office/detail/detail?contentId=' + item.momentsDto.id + '&isNews=' + true + '&commentId=' + item.id
					// });
					uni.navigateTo({
						url: '/office/comments/comments?commentId=' + item.id
					});
				}
			}

		}
	};
</script>

<style>
	@import "./news.css";
</style>
