<template>
	<ciy-header title="收入明细" ref="header"></ciy-header>
	<view v-if="init.code != 1">
		<view class="px4 py4">
			<view style="height:2em;width:100%;" class="ciy-skeleton"></view>
			<view style="height:6em;width:100%;" class="ciy-skeleton"></view>
			<view style="height:6em;width:100%;" class="ciy-skeleton"></view>
		</view>
	</view>
	<view v-else>
		<view class="sti" :style="{top:(header_statusbar_height+header_title_height)+'px'}">
			<ciy-segment :lis="g.cashintype" all="全部" v-model="liid" @change="segment_change"></ciy-segment>
		</view>
		<view class="ciy-list" v-for="(item,index) in init.list" :key="item.id">
			<view class="l2" style="margin-right: 4em;">{{item.name}}</view>
			<view class="rt"><text class="code">{{ccode(g.cashintype, item.cashintype)}}</text></view>
			<view class="lb">{{todatetime(item.addtimes)}}</view>
			<view class="rb txt-lgg txt-wb">{{item.cashmoney/100}}</view>
		</view>
		<ciy-listend :pageno="pageno" :listlen="init.list.length" :nodataimg="file_stor('/img/mbnone.png')"></ciy-listend>
	</view>
</template>

<style>
</style>

<script>
	export default {
		data() {
			return {
				liid: 0,
				pageno: 0,
			}
		},
		onLoad() {
			this.liid = this.opn.liid;
			this.getlist();
		},
		onReachBottom(b) {
			if (this.init.code != 1)
				return;
			this.getlist();
		},
		onPullDownRefresh(b) {
			this.pageno = 0;
			this._stopPullDown = true;
			this.getlist();
		},
		watch: {},
		computed: {},
		methods: {
			async getlist() {
				if (this.pageno < 0)
					return;
				this.pagepost.pageno = this.pageno + 1;
				this.pagepost.query.liid = this.liid;
				if (this._loading)
					return;
				this._loading = true;
				var retjson = await this.callajax({
					func: 'me.cashin_get',
					data: this.pagepost
				});
				this._loading = false;
				if (retjson.code != 1)
					return this.alert(retjson.errmsg);
				this.pageno++;
				if (this.pageno == 1)
					this.init.list = [];
				this.init = this.objdeepmerge(this.init, retjson);
				if (retjson.list.length < retjson.pagecount)
					this.pageno = -1;
			},
			segment_change() {
				this.pageno = 0;
				this.getlist();
				uni.pageScrollTo({
					scrollTop: 0,
					duration: 800
				});
			},
			search_change(e) {
				this.pagepost.query.key = e.value;
				this.pageno = 0;
				this.getlist();
				uni.pageScrollTo({
					scrollTop: 0,
					duration: 800
				});
			},
		}
	}
</script>