<template>
	<view>
		<view class="alijusstart fotct font14 height40p backcor9 fcor333">
			<view class="width40">卡券名称</view>
			<view class="width20">分发数量</view>
			<view class="width40">分发时间</view>
		</view>
		<view v-if="couponcardlistdes == '' " class="mart60 fotct font14 fcor666">
			<image mode="widthFix" style="width: 70vw;" :src="imagewxUrl+imgadres"></image>
		</view>
		<view class="width96 alijusstart fotct font14 height45 fcor666 mart5  bor-botm1 marb5" :key="index"
			v-for="(item,index) in couponcardlistdes">
			<view class="width40">{{item.couponName}}</view>
			<view class="width20">{{item.stockCount}}</view>
			<view class="width40">{{item.createTime | timeFormat('yyyy-mm-dd')}}
				{{item.createTime | timeFormat('hh:mm')}} </view>
		</view>
	</view>
</template>

<script>
	import {
		getRecordByCouponAgentId
	} from '../../Utils/Api.js';
	let app = getApp();
	export default {
		data() {
			return {
				couponcardlistdes: [],
				couponAgentId: '',
				imgadres: 'noorder.png',
				imagewxUrl: app.globalData.imageWxImg,
				pageNum: 1,
				pageSize: 10,
				isNoMoreData: false
			}
		},
		onLoad(options) {
			this.couponAgentId = options.couponAgentId;
			this.getRecordByCouponAgentId();
		},
		onReachBottom() {
			this.getRecordByCouponAgentId();
		},
		methods: {
			//查询卡列表
			getRecordByCouponAgentId() {
				uni.showLoading({
					title: '加载中...'
				})
				if (this.isNoMoreData) {
					uni.hideLoading()
					return false;
				}
				let pagenum = this.pageNum;
				let datas = {
					couponAgentId: this.couponAgentId,
					pageNum: pagenum,
					pageSize: this.pageSize
				}
				getRecordByCouponAgentId(datas).then(res => {
					if (res.return_code == '000000' && res.return_data.list != '') {
						uni.hideLoading();
						this.isNoMoreData = res.return_data.list.length == this.pageSize ? false : true;
						this.couponcardlistdes = this.couponcardlistdes.concat(res.return_data.list);
						if (res.return_data.total == (this.pageNum * this.pageSize)) {
							this.isNoMoreData = true;
						}
						this.pageNum = res.return_data.list.length == this.pageSize ? ++pagenum : pagenum;
					} else {
						this.couponcardlistdes = [];
						uni.hideLoading()
					}
				})
			},
		}
	}
</script>

<style lang="scss">

</style>