<template>
	<view class="body-background" :style="{backgroundImage:'url('+staticImage.bodyBackground+')'}"></view>
	<view class="app-wallpaper">

		<view class="chat-list-container row">
			<view v-for="item in chatList" class="chat-list-item-container col-12" :style="{
				backgroundImage:'url('+staticImage.chatBgImage+')'
			}">
				<view class="chat-item-background" @click="chatDetail(item)" :style="{
				backgroundImage:'url('+staticImage.chatLTBgImage+')'
			}">
					<view class="chat-item-content row">
						<view class="chat-item-left">
							<image class="img" :src="item.avatar" mode="aspectFill"/>
						</view>
						<view class="chat-item-right">
							<view class="chat-item-title-group row">
								<view class="chat-item-title">{{item.name}}</view>
								<view class="chat-item-time">{{item.create_time}}</view>
							</view>
							<view class="chat-item-desc">
								{{item.info}}
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="chat-item-end row">
				— 没有更多内容了 —
			</view>
		</view>
	</view>

</template>

<script>
	import {
		imghost
	} from '@/config/host.js'
	import HeaderNav from '@/components/HeaderNav/Index.vue';
	import FooterNav from '@/components/FooterNav/Index.vue';
	import RightNav from '@/components/RightNav/Index.vue';
	import MzButton from '@/components/MzButton/Index.vue';
	import api from '@/utils/functions.js';
	import {chatList} from "@/api/chat";
	export default {
		components: {
			HeaderNav,
			FooterNav,
			RightNav,
			MzButton
		},
		data() {
			return {
				title: 'Hello',
				loading: true,
				staticImage: {
					screenActiveImg: imghost + '/static/image/banner.png',
					orderCardBackground: imghost + '/static/image/order-card-background.png',
					wallpaperBgImage:imghost +'/static/image/background.png',
					chatBgImage:imghost +'/static/image/chat-list-background.png',
					chatLTBgImage:imghost +'/static/image/chat-list-lt-background.png',
					bodyBackground:imghost+'/static/image/background.png'
				},
				user: {
					avatar: imghost + '/static/image/banner.png',
					nickname: '清晨的风',
					coupons: 221,
					id: 88685,
				},
				isTop: false,
				chatList:[]
			}
		},
		mounted() {
			this.getChatList();
		},
		methods: {
			chatDetail(item){
				wx.navigateTo({
					url:'/pages/ChatDetail/index?id='+item.id
				});
			},
			getChatList(page = 1){
				chatList(page, this.$store.state.userInfo.store_id !== null).then(data => {
						this.chatList = data.data;
				})
			}
		},
		onPageScroll(res) {
			if(res.scrollTop <= 20){
				uni.$emit('isTop', true);
			}else{
				uni.$emit('isTop', false);
			}
		},
		created() {
			// this.pagePadding = (api.navHeight().navPaddingTop +
			// 	api.navHeight().navHeight + (api.navHeight().headerPadding * 2))
		}
	}
</script>

<style lang="scss">
	@import '@/pages/Index/components/ChatPage/components/index.scss';
</style>