<template>
	<view class="page">
		<navBar title="产品指南" :back="true" color="black" background="white" />

		<view class="con" v-if="list.length!=0">
			<view class="item" v-for="(item,index) in list" @click="goDetail(item)">
				<image :src="picBase+item.image" mode=""></image>
				<view class="bottom">
					<view class="txt">
						{{item.title}}
					</view>
				</view>
			</view>
		</view>
		<view class="con" v-else style="justify-content: center;">
			<u-empty mode="data" text="暂无数据" width="160" height="160" :icon="picUrl+'/static/other/empty.png'">
			</u-empty>
		</view>
		<!-- 	<u-loadmore v-if="list.length!=0" :status="status" style="" loadmoreText="已经到底啦" color="#CCCCCC"
			lineColor="#CCCCCC" line /> -->
		<u-loadmore :status="status" style="" nomoreText="已经到底啦" color="#CCCCCC" lineColor="#CCCCCC" line />

		<u-loading-page :loading="loading" image="/static/index/logo.png" loading-text="页面加载中..."></u-loading-page>
	</view>
</template>

<script>
	import {
		getGuideDataReq,
	} from '@/api/index/index.js'
	export default {
		components: {

		},
		data() {
			return {
				picUrl: this.$picUrl,
				picBase: this.$picBase,
				list: [],

				// 分页
				page: 1,
				pagesize: 15,
				totalElements: 0,
				loadstatus: "noMore",


				loading: true
				// status: 'loadmore',
			}
		},
		async onReachBottom() {
			console.log('onReachBottom---------------------------------');
			// this.status = "loading"
			return
			let allTotal = this.page * this.pagesize
			if (allTotal < this.totalElements) {
				this.page++;
				this.status = "loading"
				let parms = {
					page: this.page,
					per_page: this.pagesize,
				}

				console.log('每次传递的分页参数', parms);
				this.changePageMthd(parms)
			} else {
				this.status = "nomore"
			}
		},
		async onLoad(o) {
			let res = await getGuideDataReq()
			if (res.code == 0) {
				this.list = res.data
				this.loading = false
				console.log('首页指南列表返回值', res);

				// this.totalElements = res.data.total
			} else {
				this.loading = false
				uni.showToast({
					title: res.message,
					icon: 'none'
				})
			}
		},


		methods: {
			goDetail(item) {
				getApp().Litem = item
				uni.navigateTo({
					url: '/pages/index/productLeadDetail/index'
				})
			},

			async changePageMthd(parms) {
				let res = await getGuideDataReq(parms)
				if (res.code == 0) {
					console.log('首页指南列表返回值--分页', res);
					this.list = [...this.list, ...res.data.data]
					this.status = "nomore"
				} else {
					this.$toast(res.message)
					this.status = "nomore"
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import "./index.scss";
</style>