<template>
	<view class="centenr">
		<view class="Candywrapper">

			<view class="f-box" v-for="(item,index) in list" :key="index" @click="goDetails(item.id)">
				<view class="f-top">{{item.storeName}}可用</view>
				<view class="f-bs">
					<image :src="item.backgroundImage" v-if="item.backgroundImage" style="width: 60px; height: 60px; ">
					</image>
					<image src="../../static/logo.png" v-else style="width: 60px; height: 60px; "></image>
					<view class="r-box">
						<view class="">
							<view class="m_">{{item.name}}</view>
							<view class="p_">{{item.useCondition}}</view>
							<view class="q_">{{item.typeName}}</view>
						</view>
						<view class="">
							<view class="an_">领取</view>
							<u-line-progress :percentage="50" :showText="false" height="6"
								activeColor="#FA6400"></u-line-progress>
							<view class="hui_">券已领{{item.scale}}</view>
						</view>

					</view>
				</view>
			</view>

			<view v-if="list.length==0" style="margin-top: 20vh;">
				<u-empty mode="car" icon="http://47.94.122.58:83/queshengye.png" text="您当前没有优惠券~">
				</u-empty>
			</view>
		</view>
	</view>
</template>

<script>
	import request from '../../utils/request';
	export default {
		data() {
			return {
				list: [],
				total: 0,
				queryParams: {
					storeId: '',
					pageNo: 1,
					pageSize: 30
				}
			}
		},
		onPullDownRefresh() {
			//下拉刷新
			uni.stopPullDownRefresh()
		},
		onReachBottom() {
			// 触底加载
			if (this.list.length >= this.totalPage) {} else {
				this.queryParams.pageNo++
				this.getList()
			}
		},
		onShow() {
			this.queryParams.storeId = uni.getStorageSync("storeId")
			this.getList()
		},
		methods: {
			getList() {
				request({
					url: '/cardCoupon/queryByPageAndStoreId',
					method: 'get',
					params: this.queryParams
				}).then(res => {
					console.log(res, 66);
					if (res.code == 200) {
						this.list = res.data.records
						this.total = res.data.total
					}
				})
			},
			goIntegral() {
				uni.navigateTo({
					url: '/pagesMy/integral/integral'
				})
			},
			goDetails(id) {
				uni.navigateTo({
					url: '/pagesHome/certificate/details?certificateId=' + id
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.centenr {
		width: 100%;
		height: 100vh;
		background: #F9F9F9;
	}

	.Candywrapper {
		background: #F9F9F9;
		box-sizing: border-box;
		padding: 10px;
	}

	.top-box {
		width: 100%;
		box-sizing: border-box;
		padding: 10px;
		display: flex;
		align-items: center;
		justify-content: space-between;
		background: #fff;

	}

	.d-s {
		display: flex;
		align-items: center;

	}

	.f-box {
		width: 100%;
		box-sizing: border-box;
		padding: 10px;
		background: #fff;
		margin: 10px auto;
		border-radius: 4px;
	}

	.f-top {
		box-sizing: border-box;
		padding: 5px 0px;
		border-bottom: 1px dashed #eee;
		margin-bottom: 15px;
	}

	.f-bs {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.r-box {
		width: 80%;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.m_ {
		font-size: 16px;
		color: #333333;
		font-weight: bold;
		margin-bottom: 5px;
	}

	.p_ {
		font-size: 12px;
		color: #666666;
	}

	.q_ {
		font-size: 12px;
		color: #E02020;
	}

	.an_ {
		width: 80px;
		height: 25px;
		background: #FA6400;
		border-radius: 4px;
		display: flex;
		align-items: center;
		justify-content: center;
		color: #fff;
		margin-bottom: 5px;
	}

	.hui_ {
		font-size: 10px;
		color: #666666;
	}
</style>