<template>
<view class="view-page" :style="{backgroundImage: `url('${ThemeData?.app_bg || baseBgUrl}')`}">
		<headerHeight />
		<navBar :navTitle="`历史记录`">
		</navBar>
		<view class="content">
			<tableView :tableData="dataList"></tableView>
		</view>
	</view>
</template>

<script>
import headerHeight from '@/component/headerHeight.vue';
import config from '@/until/config.js';
import http from '@/until/http.js';
import navBar from '@/component/nav.vue';
import tableView from '@/component/newTable.vue'
export default {
	components: {
		headerHeight,
		navBar,
		tableView
	},
	data() {
		return {
			guildId: null,
			aseBgUrl: config.PRIMARY_BGURL,
			dataList: [],
			pageConfig: {
				currentPage: 1,
				pageSize: 10
			},
			searchParams: {
				guild_id: 0,
				token: uni.getStorageSync('token') || ''
			},
			ThemeData: null
		}
	},
	onLoad(options) {
		const {
			id
		} = options
		this.searchParams.guild_id = id
		if (id) this.getList()
		if (uni.getStorageSync('Theme_Data')) {
			this.ThemeData = JSON.parse(uni.getStorageSync('Theme_Data'))
		}
	},
	methods: {
		async getList() {
			const {
				code,
				data
			} = await http.get('/api/Guild/guild_subsidy_list', {
				...this.searchParams,
				page: this.pageConfig.currentPage,
				page_limit: this.pageConfig.pageSize,
			})
			if (code) {
				this.pageConfig.total = data.count
				this.loading = false
				const newData = data.list || []
				if (newData.length === 0) {
					this.noMore = true
					return
				}
				if (this.dataList.length === this.pageConfig.total) {
					this.noMore = true
					return
				}
				this.dataList = [...this.dataList, ...newData]
				this.pageConfig.currentPage++

			}
		}
	}
}
</script>

<style scoped lang="scss">
.view-page {
	min-height: 100vh;
	font-family: Source Han Sans CN, Source Han Sans CN;
	// background-image: url('@/static/image/help/bg.png');
	background-repeat: no-repeat;
	background-size: 100% 100%;

	.content {
		padding: 0 24rpx;
		width: calc(100vw - 48rpx);
		height: calc(100vh - 67px);
		background: #FFFFFF;
		border-radius: 32rpx 32rpx 0rpx 0rpx;
	}
}
</style>