<template>
	<view class="content">
		<kevyloading v-if="loading" type="bsm-loader" color="#618af8" transparent></kevyloading>
		
		<view class=" bg-white sticky top-0 z-50 flex items-center" style="height: 9vh;display: flex;justify-content: flex-end;">
			<view style="text-align: center;width: 100%;color: red;font-weight: bold;">
				余额：￥{{ shop_info ? shop_info.money : '0.00' }}
			</view>
		</view>
		
		<view class="grid p-2">

			<yList height="91vh" ref="yListRef" :apiObj="fullDiscountApi.caiwu.List" :params="{ ...params }">
				<template #default="{ list }">
					<view>
						<view v-for="item of list" class="goods">
							<wd-card type="rectangle">
								<template #title>
									<view class="title">
										<view>
											<span class="mr-2">ID：{{ item?.id }}</span>
										</view>
										<view>
											{{ item.create_time }}
										</view>
									</view>
								</template>
								<view class="bg-gray-50 p-2 mb-2 flex justify-between" style="font-size: 22rpx;">
									<view>
										{{ item.desc_info }}
									</view>
									<view style="font-weight: bold;font-size: 32rpx;" :style="{
										color: item.type == 1 ? '#19be6b' : '#fa3534'
									}">
										{{ item.type == 1 ? '+' : '-' }} {{ item.money }}
									</view>
								</view>
							</wd-card>
						</view>
					</view>
				</template>
			</yList>

		</view>

		<wd-toast />
		<wd-message-box></wd-message-box>
	</view>
</template>

<script setup>
	import {
		ref,
		nextTick
	} from 'vue';
	import utils from '@/utils/utils.js';
	import fullDiscountApi from '@/api/mall/discount.js';
	import kevyloading from "@/components/kevy-loading/kevy-loading";
	import yList from "/components/yList/index.vue";

	import {
		onShow,
	} from "@dcloudio/uni-app";

	const yListRef = ref(null);

	const popover = ref(false);

	const params = ref({
		name: null,
		price: null,
		send_type: null
	});
	
	const shop_info = ref(null);

	/** 
	 * @type {Ref<boolean>} 
	 * 控制页面加载状态的 Ref
	 */
	const loading = ref(false);

	
	
	const getData = async () => {
		const res = await fullDiscountApi.caiwu.shopData()
		console.log(res, 'res')
		shop_info.value = res.data.shop_info ? res.data.shop_info : null
	}
	
	// 初始化调用获取一行数据
	onShow(() => {
		getData()
	})
</script>

<style lang="scss" scoped>
	.search-type {
		position: relative;
		height: 30px;
		line-height: 30px;
		padding: 0 8px 0 16px;
		font-size: 24rpx;
		color: rgba(0, 0, 0, .45);
	}

	.search-type::after {
		position: absolute;
		content: '';
		width: 1px;
		right: 0;
		top: 5px;
		bottom: 5px;
		background: rgba(0, 0, 0, 0.25);
	}

	.search-type {
		:deep(.icon-arrow) {
			display: inline-block;
			font-size: 20px;
			vertical-align: middle;
		}
	}


	.couponBox,
	.title {
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
		align-items: center;
	}

	.couponBox {
		justify-content: flex-start;
	}

	.title {
		justify-content: space-between;
	}

	.title-tip {
		color: rgba(0, 0, 0, 0.25);
		font-size: 12px;
	}
</style>