<template>
	<view class="curpage">
	<view class="list" v-for="(item,index) in bill" @click="moveDetail(item)">
		<view class="flex">
			<view class="">
				{{item.name}}
			</view>
			<view class="" style="color: #1E9F6A;" v-if="item.status==1">
				已申请
			</view>
			<view class="" style="color: #1E9F6A;" v-if="item.status==2">
				已开票
			</view>
			<view class="" style="color: #1E9F6A;" v-if="item.status==3">
				待发送
			</view>
			<view class="" style="color: #1E9F6A;" v-if="item.status==4">
				已发送
			</view>
			<view class="" style="color: #1E9F6A;" v-if="item.status==5">
				已拒绝
			</view>
			
		</view>
		<view class="content">
			<view class="">
				<text style="color: #666666 ;">电子发票 | 发票金额 :</text>
				 ￥{{item.amount}}
			</view>
			<view class="" style="margin: 20rpx 0;">
				<text style="color: #666666 ;">申请时间：</text>
				{{item.created_at.slice(0,10)}}
			</view>
		</view>
		<!-- <view class="btn" @click.stop="sendEmail(item.id)" v-if="item.status!==1&&item!==5">
			发送至邮箱
		</view> -->
	</view>
	
	</view>
</template>

<script>
	export default {
		data(){
			return{
				bill:[],
				keyword:'',
				 checkboxValue1:[],
			}
		},
		onLoad() {
			this.loadLsit()
		},
		methods:{
			moveDetail(item){
				console.log(item)
				uni.navigateTo({
					url:"/pages/invoice/invoicedetail?obj="+JSON.stringify(item)
				})
			},
			loadLsit(){
				this.$showLoadding("加载中")
				uni.$u.http.post('/api/bill/list',{
					custom: {
						auth: true
					}
				}).then((res) => {
					uni.hideLoading()
					console.log(res)
					this.bill=res
				}).catch((err) => {
					uni.hideLoading()
					this.$toast(err.message)
				})
			},
			sendEmail(id){
				uni.$u.http.post('/api/bill/send', {id:id}, {
					custom: {
						auth: true
					}
				}).then((res) => {
					console.log(res)
					uni.showToast({
						icon: "success",
						title: "发送成功",
					})
					setTimeout(() => {
						this.loadLsit()
					}, 500)
				
				}).catch((err) => {
					this.$toast(err.message)
				})
			},
			 checkboxChange(n) {
			            console.log('change', n);
			        },
					// 跳转抬头管理
			choose(){
				
				uni.navigateTo({
					url:"/pages/invoice/applyInvoice"
				})
			}
		}
	}
</script>

<style lang="less">
	page{
		background-color: #f4f4f4;
		font-size: 30rpx;
	}
	.list{
		margin: 30rpx;
		padding-bottom: 20rpx;
		background: #FFFFFF;
		box-shadow: 0px 2rpx 4rpx 0px rgba(0, 0, 0, 0.02);
		border-radius: 8rpx 32rpx 8rpx 32rpx;
	}
	.flex{
		display: flex;
		justify-content: space-between;
		padding: 30rpx;
		border-bottom: 1rpx solid #E3E3E3;
	}
	.content{
		margin: 30rpx;
		border-bottom: 1rpx solid #E3E3E3;
	}
	.btn{
		width: 198rpx;
		height: 64rpx;
		line-height: 64rpx;
		text-align: center;
		margin: 30rpx auto 20rpx;
		color: #1E9F6A;
		background: rgba(30, 159, 106, 0.1);
		border-radius: 32rpx;
		border: 1px solid #1E9F6A;
	}
</style>
