<template>
	<view class="my-comment">
		<navbar ref="navbar" :config="config"></navbar>
		<view class="top">
			<view class="green">				
			</view>
			<view class="comment">
				评论({{number}})
				<text>只显示已通过审核的评论</text>
			</view>
		</view>
		<view class="middle">
			<view v-if="myComment.length>=0">
				
			
			<view class="item" v-for="(item,index) in myComment" :key="index" @click="goItem(item)">
				<view class="time">
					{{item.create_time}}
				</view>
				<view class="title">
					{{item.title}}
				</view>
				<view class="comment">
					评论：<text>{{item.content}}</text>
				</view>
			</view>
					<loadMore v-if="myComment.length>0" :status="status" ></loadMore>
			</view>
			<nodata v-else :config="{top:20,content:'暂无评论~'}"></nodata>
		</view>
	</view>
</template>

<script>
	import {userList,myStatistics} from "@/api/userInfo.js"
	export default{
		data(){
			return{
				config: {
					back: true, //false是tolbar页面 是则不写
					title: '我的评论',
					color: '#1A1A1A',
					//背景颜色;参数一：透明度（0-1）;参数二：背景颜色（array则为线性渐变，string为单色背景）
					backgroundColor: [1, "#FFFFFF"],
					statusBarFontColor: '#1A1A1A',
				},
				myComment:[] ,//我的评论
				status:"more",
				number:null,
				params:{
					page:1,
					limit:10,
				},
			}
		},
		onLoad(options) {
			this.params.userId = options.user_id
			this.getList()
			
		},
		//下拉刷新
		onPullDownRefresh() {
			
			this.params.page=1
			this.myComment = []
			this.getList()
		},
		//上拉加载
		onReachBottom() {
			if(this.status=="more"){
				this.params.page++
				this.getList()
			}
		
		},
		
		methods:{
			//跳转评论
			goItem(item){
				console.log(item,item.model_type)
				//作品
				if(item.model_type==0){
					let id  = item.model_id
					console.log(id)
					uni.navigateTo({
						url:"../recommend/details?id="+id
					})
					//文章
				}else if(item.model_type==1){
					let id = item.model_id
					uni.navigateTo({
						url:"../business/article?id="+id
					})
					//服务
				}else if(item.model_type==2){
					let id = item.model_id
					uni.navigateTo({
						url:"../../product/goods/goods?id="+id
					})
				}else if(item.model_type==3){
					let id = item.model_id
					uni.navigateTo({
						url:"../../product/goods/serviceGood?id="+id
					})
				}
			},
			//获取数据
			getList(){
				this.$http.get(userList,this.params).then(res=>{
					if(res&&res.code==200){
						uni.stopPullDownRefresh()
						this.number = res.page.totalCount
						this.myComment= this.myComment.concat(res.page.list)
						if(res.page.totalPage <= res.page.currPage){
							this.status = "noMore";
						}else{
							this.status = "more"
						}
						
					}
				})
			},
			
		}
	}
</script>

<style lang="scss" scoped>

	.top{
		padding: 30rpx 30rpx 20rpx 30rpx;
		display: flex;
		align-items: center;
		.green{
			width: 6rpx;
			height: 30rpx;
			background-color: #0B844A;
			border-radius: 2rpx;
		}
		.comment{
			margin-left: 10rpx;
			font-size: 30rpx;
			font-weight: Bold;
			color: #060606;
			line-height: 36rpx;
			text{
				margin-left: 10rpx;
				font-size: 24rpx;
				font-weight: Medium;
				color: #999999;
			}					
		}

	}
	.my-comment{
		background-color: #F5F5F5;
		padding-top: 10rpx;
	}
	.middle{
		background-color: #ffffff;
		
		border-radius: 40rpx 40rpx 0 0;
		.item{
			padding: 40rpx 0rpx 44rpx 0rpx;
			margin: 0 50rpx;
			border-bottom: 1rpx solid #E6E6E6;
			.time{
				font-size: 30rpx;
				font-weight: Medium;
				color: #999999;
			}
			.title{
				margin-top: 10rpx;
				font-size: 32rpx;
				font-weight: Bold;
				color: #1A1A1A;
				line-height: 44rpx;
			}
			.comment{
				margin-top: 16rpx;
				font-size: 24rpx;
				font-weight: Bold;
				line-height: 38rpx;
				color: #1A1A1A;
				text{
					font-weight: Medium;
					color: #999999;
				}
			}
		}
	}
</style>
