<template>
	<view class="comment">
		<view class="comment_tabs">
			<view class="box" v-for="(item,index) in list" :key="index" @click="change(index)" :class="{btna:count == index}">{{item}}</view>
		</view>
		<view class="tab_box" :class="{dis:btnnum == 0}">
			<view class="content">
				<view class="content_box" v-for="(item,index) in head" :key="item.id">
					<view class="comment_head">
						<view class="head_left">
							<view class="img">
								<image :src="item.avatar?item.avatar:'../../../static/logo.png'"></image>
							</view>
							<view class="comment_name">{{item.nickName?item.nickName:'匿名'}}</view>
						</view>
						<view class="head_right" v-if="item.satisfactionFlag=='0'">
							<view class="image">
								<image src="../../../static/rider/zan.png"></image>
							</view>
							<view class="comment_tit">满意</view>
						</view>
					</view>
					<view class="comment_title">{{item.evaluateMessage}}</view>
				</view>
			</view>
			<empty v-if="head.length == 0" ></empty>
		</view>
		<view class="tab_box" :class="{dis:btnnum == 1}">
			<view class="content">
				<view class="content_box" v-for="(item,index) in head" :key="item.id">
					<view class="comment_head">
						<view class="head_left">
							<view class="img">
								<image :src="item.avatar?item.avatar:'../../../static/logo.png'"></image>
							</view>
							<view class="comment_name">{{item.nickName?item.nickName:'匿名'}}</view>
						</view>
						<view class="head_right" v-if="item.satisfactionFlag=='1'">
							<view class="image">
								<image src="../../../static/rider/zz.png"></image>
							</view>
							<view class="comment_tit comment_tit1">不满意</view>
						</view>
					</view>
					<view class="comment_title">{{item.evaluateMessage}}</view>
				</view>
			</view>
			<empty v-if="head.length == 0" ></empty>
		</view>
	</view>
</template>

<script>
	import empty from '@/components/empty'
	export default {
		components: {
			empty
		},
		data() {
			return {
				list: ["满意", "不满意"],
				btnnum: 0,
				count: "",
				head: [],
				page:1,
				limit:10,
				totalCount:0,
				satisfactionFlag:0
			}
		},
		mounted() {
			this.bindorder()
		},
		methods: {
			change(e) {
				// console.log(e)
				this.head = []
				this.page = 1
				this.count = e
				this.btnnum = e
				this.satisfactionFlag = e
				this.bindorder()
			},
			// 获取数据
			bindorder() {
				this.$Request.getT('/app/userinfo/findEvaluate',
				{
					page:this.page,
					limit:this.limit,
					satisfactionFlag:this.satisfactionFlag
				}).then(res => {
					if(res.code==0){
						// this.head = res.data
						if (this.page == 1) {
							this.head = res.data.list
						} else {
							this.head = this.head.concat(res.data.list)
						}
						this.totalCount = res.data.totalCount
					}else{
						console.log('失败：',res.data)
					}
					uni.stopPullDownRefresh();
				});
			},
		},
		// 上拉加载
		onReachBottom: function() {
			if(this.page<this.totalCount){
				this.page = this.page + 1;
				this.bindorder();
			}else{
				uni.showToast({
					title:'已经最后一页啦',
					icon:'none'
				})
			}
			
		},
		// 下拉刷新
		onPullDownRefresh: function() {
			this.page = 1;
			this.bindorder();
		},
	}
</script>

<style>
	body {
		background: #F5F5F5;
	}

	.comment {
		width: 100%;
	}

	.comment_tabs {
		width: 100%;
		display: flex;
		background: #FFFFFF;
		height: 90rpx;
	}

	.box {
		flex: 1;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.btna {
		background-color: #E6E6E6;
	}

	.tab_box {
		display: none;
	}

	.dis {
		display: block;
	}

	/* 满意 */
	.content {
		width: 90%;
		margin: 0 auto;
		background: #ffffff;
		border-radius: 16rpx;
		margin-top: 30rpx;
	}

	.content_box {
		height: 145rpx;
	}

	.img image {
		width: 50rpx;
		height: 50rpx;
		border-radius: 50%;
	}

	.comment_head {
		width: 90%;
		margin: 0 auto;
		display: flex;
	}

	.comment_name {
		color: #333333;
		font-size: 22rpx;
		margin-left: 10rpx;
	}

	.head_left {
		flex: 1;
		display: flex;
		justify-content: left;
		align-items: center;
		height: 65rpx;
		margin-top: 20rpx;
	}

	.head_right {
		flex: 1;
		display: flex;
		justify-content: flex-end;
		align-items: center;
		color: #3390FF;
		font-size: 20rpx;
	}

	.image {
		margin-right: 11rpx;
		margin-top: 8rpx;
	}

	.image image {
		width: 22rpx;
		height: 22rpx;
	}

	.comment_title {
		width: 90%;
		margin: 0 auto;
		color: #333333;
		font-size: 25rpx;
	}

	/* 不满意 */
	.comment_tit1 {
		color: #cccccc;
	}
</style>
