<template>
<view class="view-page" :style="{backgroundImage : `url('${ThemeData?.app_bg ?? 'https://vespa.qxmier.com/image/bg.png'}')`}">
		<headerHeight />
		<navBar :navTitle="`公会补贴`">
			<template #rightView>
				<view class="icon-right flex-line" @click="exit"
					v-if="detailData && leaderStatus" >
					<view @click="historyRecord" class="font-24" style="color:#FF8ACC;white-space: nowrap">
						历史记录
					</view>
				</view>
			</template>
		</navBar>
		<view class="content-view" v-if="detailData">
			<view class="bottom" v-for="(data,index) in detailData" :key="index">
				<view class="flex-line flex-spaceB w-fill">
					<view class="color-3 font-w500 font-32">
						{{data.name}}
					</view>
					<view class="font-28" :style="{'color' : data.status_str === '已发放' ? '#999' : '#45D08C'}">
						{{data.status_str}}
					</view>
				</view>
				<view class="line">

				</view>
				<view class="flex-line flex-spaceB w-fill">
					<view class="cumulative font-28 font-w400">
						累计流水：{{data.total_transaction}}
					</view>
					<view class="subsidy font-28">
						获得补贴：{{data.subsidy_amount}}
					</view>
				</view>
			</view>
		</view>
	</view>
</template>


<script>
	import headerHeight from '@/component/headerHeight.vue';
	import navBar from '@/component/nav.vue';
	import http from '@/until/http.js';
	import logo from '@/static/image/logo.png'
	export default {
		components: {
			headerHeight,
			navBar
		},
		data() {
			return {
				logo,
				detailData: null,
				searchParams: {
					guild_id: 0,
					token: uni.getStorageSync('token') ?? '',
				},
				ThemeData:null
			}
		},
		onLoad(options) {
			const {
				id,
				leader
			} = options
			this.leaderStatus = +leader
			this.searchParams.guild_id = id
			if (id) this.getSubsidy()
			if(uni.getStorageSync('Theme_Data')) {
				this.ThemeData = JSON.parse(uni.getStorageSync('Theme_Data'))
			}
		},
		methods: {
			// 
			async getSubsidy() {
				const {
					code,
					data
				} = await http.get('/api/Guild/guild_subsidy', this.searchParams)
				this.detailData = code ? data.list : null
			},
			historyRecord(){
				uni.navigateTo({
					url: `/pages/union/historyRecord?id=${this.searchParams.guild_id}`
				});
			},
		}
	}
</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-view{
			padding: 0 24rpx;
		}
		.bottom{
			margin-top: 40rpx;
		}
		.cumulative {
			color: #FF8ACC;
		}

		.line {
			background-color: #ECECEC;
			height: 1rpx;
			margin: 24rpx 0;
		}

		.subsidy {
			color: #0DFFB9;

		}
	}
</style>