<template>
	<view class="content">
		<block v-if="logs.length > 0">
			<view class="log-blcok" v-for="(item, index) in logs" :key="index" @click="onInfo(item.business_order_id)">
				<view class="flex">
					<label>订单编号：</label>
					<view class="val">{{item.order_no}}</view>
				</view>
				<view class="flex">
					<label>业务类型：</label>
					<view class="val">
						<text v-for="(titem, tindex) in item.item_type" :key="tindex">{{titem.title}}</text>
					</view>
				</view>
				<view class="flex">
					<label>签约时间：</label>
					<view class="val">{{item.created_at}}</view>
				</view>
			</view>
			
			<view class="pagesLoding" v-if="lodingStats">
			    <block v-if="page.has_more">
			        <image class="pagesLodingIcon" src="/static/icons/refresh_loding.gif" mode="widthFix"></image>加载中...
			    </block>
			    <block v-else>
			        没有更多了~
			    </block>
			</view>
		</block>
		<view class="reveal-no pages-hint" v-else>
		    <image src="https://douhuo-storage.oss-cn-beijing.aliyuncs.com/images/2023/06/06/7ad417d0c215db601b8e1bead05c3a5e.png"></image>
		    <view>暂无数据</view>
		</view>
	</view>
</template>

<script>
	import { getSignLogs, getFlows } from '@/apis/interfaces/user.js'
	export default {
		data() {
			return {
				logs		 : [],
				page         : {},     // 分页信息
				lodingStats  : false,  // 加载状态
			};
		},
		created() {
			this.getLog()
		},
		methods: {
			getLog(page){
				uni.showLoading({
					title: '加载中...',
					mask : true
				})
				getSignLogs({
					page  : page || 1
				}).then(res => {
					let esArr = res.data
					let list = this.logs,
					    newData = []
					    if(page == 1 || page == undefined) list = []
					    newData = list.concat(esArr)
					this.logs        = newData
					this.page        = res.page
					this.lodingStats = false
					uni.stopPullDownRefresh()
				}).catch( err => {
					uni.showToast({
						title: err.message,
						icon: "none"
					})
				})
			},
			onInfo(id){
				this.$Router.push({
					name	: 'Contract',
					params	: { id }
				})
			}
		},
		
		// 页面相关事件处理函数--监听用户下拉动作
		onPullDownRefresh() {
		    // 获取信息
		   this.getLog();
		},
		        
		// 上拉加载
		onReachBottom(){
		    this.lodingStats = true
		    let pageNumber = this.page.current
		    if(this.page.has_more){
		        pageNumber++
		        // 获取信息
		        this.getLog(pageNumber);
		    }
		}
	}
</script>

<style lang="scss">
	.content {
		background-color: #f7f9fa;
		overflow-y: scroll;
		height: 100%;
		position: absolute;
		width: 100%;
		padding: 30rpx;
		box-sizing: border-box;
	}
	
	// 订单列表
	.log-blcok{ 
		background: white;
		border-radius: $radius;
		padding: $padding;
		position: relative;
		margin-bottom: 20rpx;
		// .log-icon{ position: absolute; right: $margin; top: 50%; margin-top: -14rpx; }
		.flex{
			display: flex;
			justify-content: space-between;
			font-size: 30rpx;
			line-height: 60rpx;
			label{ color: gray; }
		}
	}
	
	// 分页加载
	.pages-loding{ padding: 10rpx; }
	
	// 暂无内容
	.reveal-no {
		align-items: center;  justify-content: space-around;
		padding: 40% 0;
	}
	
</style>