<template>
	<HeaderNav title="付款权益卡" :is-back="true"></HeaderNav>
	<view class="body-background" :style="{
		backgroundImage:'url('+staticImage.wallpaperBgImage+')'
		}"></view>
	<view class="app-wallpaper">

		<view class="screen-container row">

			<view class="list-container">
				<view class="list-item" v-for="item in orderCardList">
					<view class="card-container row">
						<view class="card-container-background col-12"></view>
						<view class="card-container-background-main row">
							<view class="card-col row" :style="{backgroundImage:'url('+staticImage.cardBackground+')'}">

								<view class="card-right">
									<view class="card-title">{{item.title}}</view>
									<view class="card-desc-container">
										<view class="card-desc">
											<view class="card-desc-text">{{item.profile}}</view>
											<view class="card-desc-background"></view>
										</view>
									</view>
									<view class="card-content-container row">
										<view class="card-avatar">
											<image class="img" mode="aspectFit" :src="staticImage.dogImage"/>
										</view>
										<view class="card-content">
											<view class="card-content-top">
												{{item.illustrate}}
											</view>
											<view class="card-content-bottom">
                        {{item.que_illustrate}}
											</view>
										</view>
										<view class="card-btn" @click="navTo('/pages/CardDetail/index?id='+item.id)">
											<MzButton
													title="开始预约"
													font-color="#FFFFFF"
													button-color="#4DC3B8"
													button-width="255rpx"
													padding-tb="10rpx"
													font-size="28rpx"
													class="card-button"
                      ></MzButton>
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
<!--				<view class="item-end row">-->

<!--				</view>-->

			</view>
		</view>
    <u-loadmore :status="status" fontSize="28"
                color="#ACB4B6"
                line
                line-color="#ACB4B6"
                marginBottom="30" marginTop="30" @loadmore="getCardList()"/>
	</view>

	<!-- <RightNav></RightNav> -->
</template>

<script>
	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 image from "@/config/image";
  import {cardList} from "@/api/card";
	export default {
		components: {
			HeaderNav,
			FooterNav,
			RightNav,
			MzButton
		},
		data() {
			return {
				title: 'Hello',
				loading: true,
				staticImage: image.CardList,
				isTop: false,
				pagePadding: 100,
				orderCardList:[],
        status:'loadmore',
        data:{
          page:1,
          limit:10,
        }
			}
		},
		onLoad() {



		},
		methods: {
      navTo(url){
        uni.navigateTo({
          url:url
        })
      },
      getCardList(){
        if(this.status === 'nomore'){
          return false;
        }
        this.status = 'loading';
        cardList(this.data).then((res) => {
          this.orderCardList.push.apply(this.orderCardList,res.data);
          if(res.data.length === 0){
            this.status = 'nomore';
          }else{
            this.status = 'loadmore';
          }
          this.data.page++;
        })
      }
		},
		onPageScroll(res) {
			if(res.scrollTop <= 20){
				uni.$emit('isTop', true);
			}else{
				uni.$emit('isTop', false);
			}
		},
    onReachBottom() {
      this.getCardList();
    },
		created() {
			this.pagePadding = (api.navHeight().navPaddingTop +
				api.navHeight().navHeight + (api.navHeight().headerPadding * 2))
		},
    mounted() {
      this.getCardList();
    }
  }
</script>

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