<style lang="scss" scoped>

</style>

<template>
	<view class="MyGroupLeader">
		<u-empty v-if="data.list.length == 0" text="暂无数据" mode="list"></u-empty>
		<view v-if="data.list.length > 0" style="
		    height: calc(100vh);
		    width: calc(100vw);
		    overflow: hidden;
		  ">
			<scroll-view :scroll-y="true" :enable-back-to-top="true" :enable-flex="true" @scrolltolower="lower"
				:style="{ height: '100%' }">
				<matchmaking :navs="data"></matchmaking>
				<u-loadmore :status="status" :load-text="loadText" :font-size="24" :margin-top="20" :margin-bottom="20"
					bg-color="#FFF" />
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import matchmaking from "@/components/matchmaking/index";
	export default {
		components: {
			matchmaking
		},
		data() {
			return {
				pageTitle: "我的群组",
				msg: {
					pageIndex: 1,
					pageSize: 10,
					lookGroupIds: "1"
				},
				page_count: 1,
				loading: false,
				status: "loadmore",
				loadText: {
					loadmore: "轻轻上拉，加载更多",
					loading: "努力加载中",
					nomore: "没有更多了",
				},
				data: {
					listStyle: -1,
					list: []
				}
			}
		},
		created() {
			uni.setNavigationBarTitle({
				title: this.pageTitle,
			});
		},
		onLoad(options) {
			if (options && options.groupId) {
				this.msg.lookGroupIds = options.groupId
			}
			this.init()
		},
		methods: {
			init() {
				this.loading = true;
				this.request2({
						url: '/api/AppletMiai/GetUserGroupList',
						data: this.msg
					},
					res => {
						if (res.resultCode == 1) {
							this.loading = false;
							this.data.list = this.data.list.concat(res.data.pageData.list);
							this.data.listStyle = res.data.pageData.listStyle;
							this.page_count = res.data.pageCount;
							if (this.page_count == 1) {
								this.status = "nomore";
							}
						}
					}
				);
			},
			lower(e) {
				if (this.msg.pageIndex < this.page_count) {
					this.msg.pageIndex++;
					this.status = "loading";
					this.init();
				} else {
					this.status = "nomore";
				}
			},
		}
	}
</script>
