<template> 
	<view>
		<view class="consult">
			<dHeader :title="$lang.lang.consult.consult"></dHeader>
		</view>
		<view class="start-bar"></view>
		<view class="consult-list">
			<view class="consult-list-it" v-for="(item, index) in data" v-if="item.content" @click="toInfo(item.id)" :key="index">
				<view class="consult-list-top">
					<image :src="item.status == 1 ? '../../static/img/consult-1.png' : '../../static/img/consult-2.png'" mode=""></image>
					<view class="">{{item.content}}</view>
				</view>
				<view class="times">
					<image src="../../static/img/time.png" mode=""></image>
					<text>{{$request.getLocalTime(item.createTime)}}</text>
				</view>
				<view :class="item.status == 1 ? 'tags' : 'tags2'">{{item.status == 1 ? $lang.lang.consult.reply : $lang.lang.consult.replyed}}</view>
			</view>
		</view>
		
		<view class="bom">
			<view class="" @click="$request.goPage('../complaint/complaint')">
				<image src="../../static/img/feed.png" mode=""></image>
				<text>{{$lang.lang.consult.change}}</text>
			</view>
			<view class="" @click="$request.goPage('../consult_add/consult_add')">
				<image src="../../static/img/zixun.png" mode=""></image>
				<text>{{$lang.lang.consult.consulting}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	import dHeader from '../../components/dHeader/index.vue'
	export default {
		components: {
			dHeader
		},
		data() {
			return {
				data: [],
				page: 1,
				totalPage: 1,
			}
		},
		onShow () {
			this.page = 1
			this.getData()
		},
		onPullDownRefresh() {
			this.page = 1
			this.data = []
			this.getData()
			uni.stopPullDownRefresh()
		},
		onReachBottom() {
			if(this.totalPage > this.page){
				this.page ++
				this.getData()
			}
		},
		methods: {
			getData () {
				this.$request.get('/app-api/ecw/message-leave/page', {pageNo: this.page, pageSize: 20}).then(res => {
					console.log(res)
					if(res.code == 0&&res.data){
						if(this.page == 1){
							this.data = res.data.list
						} else {
							this.data = this.data.concat(res.data.list)
						}
						this.totalPage = res.data.pages
					}
				})
			},
			toInfo(id){
				uni.navigateTo({
					url:'../consult_info/consult_info?id='+id
				})
			}
		}
	}
</script>

<style>
	@import url("../../static/css/consult.css");
</style>
