<template>
	<view class="container">

		<view class="intro">本项目已包含uni ui组件，无需import和注册，可直接使用。在代码区键入字母u，即可通过代码助手列出所有可用组件。光标置于组件名称处按F1，即可查看组件文档。</view>
		<text class="intro">详见：</text>
		<uni-link :href="href" :text="href"></uni-link>
		<!-- <mescroll-body ref="mescrollRef" @init="mescrollInit" @up="upCallback" @down="downCallback">
			<view class="content3" v-for="(item,index) in infoList">

			</view>
		</mescroll-body> -->
	</view>
</template>

<script>
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	import {
		mapState,
		mapMutations
	} from 'vuex';
	export default {
		mixins: [MescrollMixin], // 使用mixin
		computed: {
			...mapState(['hasLogin'])
		},
		data() {
			return {
				href: 'https://uniapp.dcloud.io/component/README?id=uniui',
				canReset: false,
				userInfo: {},
				infoList: []
			}
		},
		onShow() {
			// this.$nextTick(function() {
			// 	this.canReset && this.mescroll.resetUpScroll() // 重置列表数据为第一页  
			// 	this.canReset && this.mescroll.scrollTo(0, 0) // 重置列表数据为第一页时,建议把滚动条也重置到顶部,避免无法再次翻页的问题  
			// 	this.canReset = true // 过滤第一次的onShow事件,避免初始化界面时重复触发upCallback, 无需配置auto:false
			// });
			// if (this.hasLogin || uni.getStorageSync("userInfo").username) {
			// 	this.userInfo = uni.getStorageSync("userInfo")
			// 	this.isLogin = true
			// } else {
			// 	uni.navigateTo({
			// 		url: "/pages/login/login"
			// 	})
			// }
		},
		methods: {
			upCallback(page) {
				uni.showLoading({
					title: '数据加载中'
				})
				this.$request.baseRequest('pincheCarSharingApp', 'list', {
					remark2: this.route,
					carpoolingType: this.type,
					companyId: 1,
					pageNum: page.num,
					pageSize: page.size,
				}, failres => {
					console.log('res+++++', failres.errmsg)
					this.$refs.uToast.show({
						type: 'error',
						message: failres.errmsg,
					})
					uni.hideLoading()
				}).then(res => {
					// if (res.errno == 200) {
					uni.hideLoading()
					console.log(11)
					let curPageData = res.data.items;
					let totalPage = res.data.total;
					let curPageLen = curPageData.length;
					this.mescroll.endByPage(curPageLen, totalPage);
					console.log(res.data)
					// this.makeData(res.data)
					if (page.num == 1) this.infoList = []; //如果是第一页需手动置空列表
					this.infoList = this.infoList.concat(curPageData); //追加新数据
					// }
				})
			},
		}
	}
</script>

<style>
	.container {
		padding: 20px;
		font-size: 14px;
		line-height: 24px;
	}
</style>