<template>
	<view>
		<mescroll-body :height="height" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption"
			:up="upOption">
			<card :list="list" @timeup='timeup'></card>
		</mescroll-body>
		<toast ref="toast" ></toast>
	</view>
</template>
<script>
	import card from "./comps/card.vue"
	import MescrollMixin from "@/components/mescroll-body/mescroll-mixins.js";
	export default {
		components:{
			card
		},
		mixins: [MescrollMixin],
		data() {
			return {
				list: [],
				downOption:{
					auto:false
				},
			}
		},
		onShow() {
			if (this.canReset) {
				this.mescroll.resetUpScroll()
			}
			this.canReset=true
		},
		methods: {
			timeup(item){
				let order = this.$u.deepClone(item)
				order.payStatus = '取消付款'
				order.orderStatus = '取消付款'
				this.$api.goodsbills.submit(order).then(res => {
					if (res.success) {
						this.mescroll.resetUpScroll()
					}
				})
			},
			//上拉回调
			upCallback(mescroll) {
				let params={
					payId:this.vuex_userId,
					current:mescroll.num,
					size:mescroll.size
				}
				try{
					this.$api.goodsbills.list(params).then(res=>{
						let data=res.data.records
						let length=data.length
						let total=res.data.total
						mescroll.endBySize(length, total);
						if(mescroll.num == 1) this.list = []; //如果是第一页需手动制空列表
						this.list=this.list.concat(data); //追加新数据
					})
				}catch(e){
					mescroll.endErr();
				}
			},
			//下拉回调
			downCallback(mescroll) {
				setTimeout(()=>{
					this.$refs.toast.info('刷新成功')
					this.mescroll.resetUpScroll()
				},500)
			},
		}
	}
</script>

<style lang="scss">
	
</style>

