<template>
<div>

	    <common @asynCallBack="asynCallBack"></common>
    	<top-header :pageTitle="pageTitle" :rightLink="rightLink" :doRightLink="doRightLink"></top-header>

		<div class="mui-content vongi-zd">
			<ul class="mui-table-view">
				<li class="mui-table-view-cell" v-for="mod in recordList">
					<a @click="goto(mod.id)">
						<div class="mui-media-object mui-pull-left">
							<img :src="mod.iconPic">
						</div>
						<div class="mui-media-body">
							<div class='flew-sp flew-items'>
								<div class="mui-ellipsis mui-col-xs-8">{{mod.goodName}}</div><span style="color:#FF8800" >未支付</span></div>
							<div class='mui-ellipsis flew-sp mui-h2 flew-items'>{{mod.totalFee}}<span class="mui-h6">{{mod.createTime}}</span></div>
						</div>
					</a>
				</li>
			</ul>
			<NullList :remark="'暂无账单信息'" v-if="!recordList.length"></NullList>

		</div>
		 <loading :visible="isLoading"></loading>

</div>
</template>

<script>
	import * as API_Pay from '$project/apis/payment'
	import Common from '$project/components/Common.vue'
	import Loading from '$project/components/Loading.vue'
	import TopHeader from '$project/components/TopHeader.vue'
	import isReachBottom from '$project/utils/isReachBottom'
	import NullList from '$project/components/NullList.vue'
	import {

		currentTimeStamp,
		parseUnixTime
	} from '$project/utils'
	import {
		mapGetters,
		mapMutations
	} from 'vuex'
	export default {
		name: 'MasterMineBillList',
		components: {
			Common,
			Loading,
			TopHeader,NullList
		},
		data() {
			return {
				pageTitle: '我的账单',

				rightLink: {
					show: true,
					icon: 'icon-baobiao',
					style: 'font-size:14px',
					title: '账单记录'
				},
				isLoading: false,

				listForm: {
					pageIndex: 1,
					pageSize: 20,
 					totalPage: 1,
 					status:10
 				},
				recordList: [],
 				statusColor: ['colorf8b155', 'color55f868', 'colorfe616c','color999'],

			}
		},
		created() {
 		},
		methods: {
	        //右上角点击事件
			doRightLink() {
				this.$router.push({
					name: 'MasterMineBillRecord',
					query: {
 					}
				})
			},
			//info
			goto(id) {

				this.$router.push({
					name: 'MasterMineBillPay',
					query: {
						id: id
					}
				})
			},

			//获取列表
			getList() {
				this.isLoading = true;
				API_Pay.orderList(this.listForm).then(res => {
					var response=res;
					if (response) {
						if (this.listForm.pageIndex == 1) {
							this.recordList = response.data;
							this.listForm.pageIndex = response.pageNumber;
							this.listForm.totalPage = response.totalPage;
						} else {
							this.recordList = [
								...this.recordList,
								...response.data
							];
						}
					}
					this.listForm.pageIndex++;
					this.isLoading = false;
				}).catch(error => {
					this.isLoading = false;
					mui.toast(error);
				})
			},
			//下拉事件
			handleScrool() {
				if (isReachBottom()) {
					console.log('到达底部')
					if (this.listForm.pageIndex <= this.listForm.totalPage && this.isLoading == false) {
						this.getList();
					} else {
						return;
					}
				}
			},

			asynCallBack() {

			},
		},
		mounted() {
			this.getList();
			//监控下拉加载事件
			var _this = this;
			window.addEventListener('scroll', _this.handleScrool);
		},
		destroyed() {
			//销毁监听事件
			var _this = this;
			window.removeEventListener('scroll', _this.handleScrool);
		},
		computed: {
			...mapGetters({
				openId: 'wx_openid',
				token: 'token',
				person_data: 'person_data',
				person_popedom: 'person_popedom',
			})
		},

	}
</script>

<style scoped src="$project/assets/css/xpwyfyy.css"></style>
<style src="$project/assets/css/iconfont.css"></style>
<style>
</style>
