<template>
	<view class="client">
		<mescroll-body top="30" bottom="40" @init="mescrollInit" @down="downCallback" @up="upCallback" :option="{}">
			<view class="common-list">
				<view class="common-item" v-for="(item,index) in list" :key="item.id"
					@click="$navigateTo('/pages/clientDetail/clientDetail?clientId='+item.id)">
					<view class="title">{{item.name}}</view>
					<view class="date">{{item.visitingTime}}</view>
					<view>
						<view class="space" v-for="(node,index) in item.roomMap" :key="index">{{node}}</view>
					</view>
					<view class="other">
						<view class="item">
							<view class="label">客户行业</view>
							<view class="value">{{item.customerIndustry}}</view>
						</view>
						<view class="item">
							<view class="label">客户需求</view>
							<view class="value">{{item.demand}}</view>
						</view>
					</view>
					<view class="state">
						<view class="create">
							<uni-icons class="inherit-icons" type="person-filled" color="#08979c" size="18"></uni-icons>
							<text class="name">{{user.userName}}</text>
						</view>
						<view class="tag">
							<view class="status-tag info" v-if="!item.status">待邀请</view>
							<view class="status-tag warning" v-if="item.status == 1">邀请中</view>
							<view class="status-tag success" v-if="item.status == 2">通过邀请</view>
							<view class="status-tag error" v-if="item.status == 3">拒绝邀请</view>
						</view>
					</view>
					<view class="icon">
						<uni-icons type="staff-filled" color="#08979c" size="30"></uni-icons>
					</view>
				</view>
			</view>
		</mescroll-body>
	</view>
</template>

<script>
	import {
		getCustomerListByPage
	} from '@/request/api/my.js'
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin], // 使用mixin
		data() {
			return {
				list: [],
				user: {}
			}
		},
		onShow() {
			this.user = this.$store.getters.user;
		},
		onLoad() {},
		methods: {
			/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
			upCallback(page) {
				getCustomerListByPage({
					currPage: page.num,
					pageSize: 10,
					userId: this.$store.getters.user.userId
				}).then(res => {
					if (res.code === 200) {
						this.mescroll.endBySize(res.data.dataList.length, res.data.totalCount);
						if (page.num == 1) this.list = []; //如果是第一页需手动制空列表
						let data = res.data.dataList;
						this.list = this.list.concat(data); //追加新数据
					} else {
						this.mescroll.endErr();
					}
				}).catch(() => {
					//联网失败, 结束加载
					this.mescroll.endErr();
				})

			}
		}
	}
</script>

<style lang="scss">

</style>