<template>
	<view class="content">
		<navseat :opacity='false' :title='"开票记录"' :titleshow='true' :namecolor='"#fff"' iconcolor='#fff'></navseat>
		<view class="content_item" v-for="(item,index) in list" :key="index" @click="clickoange(item)">
			<view class="content_item_top flex-between">
				<view class="content_item_topone flex-start">
					<image src="https://czg-invoicing.oss-cn-beijing.aliyuncs.com/static/sz.png" mode="aspectFill"></image>
					<text>{{item.createtime}}</text>
				</view>
				<view class="content_item_toptow flex-start">
					<text class="content_item_toptowtext">¥{{item.price}}</text>
					<u-icon name="arrow-right" color="#9d9d9d" size="10"></u-icon>
				</view>
			</view>
			<view class="content_item_bottom" style="background: #318AFE;" v-if="item.status == 0">
				客户未提交信息
			</view>
			<view class="content_item_bottom" style="background:#8B8B8B ;" v-if="item.status == 1">
				开票中
			</view>
			<view class="content_item_bottom" v-if="item.status == 2">
				已开票
			</view>
			<view class="content_item_bottom" style="background:#FD482C;" v-if="item.status == 3">
				开票失败
			</view>
			<view class="content_item_bottom" style="background: #ffbb76;" v-if="item.status == 4">
				已作废
			</view>
		</view>
		<view class="empty-wrap">
			<u-loadmore :status="form.status" fontSize="16" color="#999" iconSize="16" />
		</view>
	</view>
</template>

<script>
	import navseat from '@/components/navseat.vue'
	export default {
		components: {
			navseat
		},
		data() {
			return {
				list: [],
				form: {
					page: 1,
					status: 'loadmore',
				},
			};
		},
		onShow() {
			this.initial()
		},
		onReachBottom() {
			if (this.form.status != 'nomore') {
				this.form.page = ++this.form.page;
				this.storeinvoicelist()
			}

		},
		methods: {
			initial() {
				this.form = {
						page: 1,
						status: 'loadmore',
					},
					this.storeinvoicelist()
			},
			clickoange(e) {
				if (e.status == 2 || e.status == 4 || e.status == 3) {
					uni.pro.navigateTo('index/orderinfo', {
						id: e.id,
						status: e.status
					});
				}
				if (e.status == 0) {
					uni.pro.navigateTo('index/orderinfos', {
						id: e.id,
						status: e.status
					});
				}
			},
			async storeinvoicelist() {
				this.form.status = 'loading';
				let res = await this.api.storeinvoicelist({
					store_id: uni.getStorageSync('userId'),
					page: this.form.page

				})
				if (this.form.page == 1 && res.data.list.length == 0) {
					this.form.status = 'nomore'
					return false;
				} else {

					setTimeout(() => {
						if (this.form.page == 1) {
							this.list = res.data.list
						} else {
							this.list = [...this.list, ...res.data.list];
						}
						if (res.data.list.length < 10) {
							this.form.status = 'nomore';
						} else {
							this.form.status = 'loadmore';
						}
					}, 500)
				}
				console.log(this.list)
			},
		}
	}
</script>

<style lang="scss">
	page {
		background: #F9F9F9;
	}

	.content {
		padding: 6px 28rpx;

		.content_item {
			margin-top: 32rpx;
			width: 100%;
			background: #FFFFFF;
			border-radius: 30rpx 30rpx 30rpx 30rpx;

			.content_item_top {
				padding: 34rpx 16rpx 30rpx 42rpx;

				.content_item_topone {
					image {
						width: 37.11rpx;
						height: 37.11rpx;
					}

					text {
						margin-left: 28rpx;
						font-family: Source Han Sans CN, Source Han Sans CN;
						font-weight: 400;
						font-size: 28rpx;
						color: #666666;
						text-align: center;
						font-style: normal;
						text-transform: none;
					}
				}

				.content_item_toptow {
					.content_item_toptowtext {
						font-family: Source Han Sans CN, Source Han Sans CN;
						font-weight: 500;
						font-size: 32rpx;
						color: #666666;
						text-align: center;
						font-style: normal;
						text-transform: none;
					}
				}
			}

			.content_item_bottom {
				padding: 16rpx 0 16rpx 108rpx;
				background: rgba(85, 159, 255, 0.74);
				box-shadow: 0px 3rpx 6rpx 1px rgba(0, 0, 0, 0.16);
				border-radius: 0rpx 0rpx 30rpx 30rpx;
				font-family: Source Han Sans CN, Source Han Sans CN;
				font-weight: 500;
				font-size: 32rpx;
				color: #FFFFFF;
				font-style: normal;
				text-transform: none;
			}
		}
	}
</style>