<template>
	<view>
		<template name="coupons">
			<view class="mt20 bgfff copons-view">
				<navigator class="head" hover-class="none" url="/product/coupon/coupon">
					<view class="titleNav pdlr20 dflex">
						先领券更优惠
						<image src="/static/pages/images/more.png" class="more"></image>
					</view>
					<!-- <image lazy-load="true" :src="hotTemplate.titleCon + '?x-oss-process=style/w750-auto'" mode="widthFix" class="imgtit"></image> -->
				</navigator>
				<view class="coupons-list mlr20 ddflex">
					<view class="li" v-for="(item,index) in couponList" :key="index">
						<view class="coupons-top">
							<view class="coupons-type">{{item.couponType == 1 ? '满减券':'通用券'}}</view>
							<view class="coupons-money"><text>￥</text>{{item.couponAmount}}</view>
							<view class="coupons-man tover">{{item.couponTitle}}</view>
						</view>
						<view class="coupons-btn" @click="recieveCoupon(item,index)">{{item.userCount >= item.userReceive&&item.userCount!=0&&item.userReceive!=-1 ? '已领取' : '立即领取'}}</view>
					</view>
				</view>
			</view>
		</template>
	</view>
</template>

<script>
	const req = require("../../utils/request");
	const utils = require("../../utils/util");
	const app = getApp();
	export default {
		data() {
			return {
			};
		},

		components: {},
		props: {
			couponList: Array,
		},
		options: {
		},

		mounted() {
		},

		methods: {
			recieveCoupon(item,index){
				if (item.userReceive > -1 && item.userCount >= item.userReceive) {
					return req.msg('超出优惠券领取限制，无法领取');
				}
				req.postRequest('/api/coupon/receive', {
					id: item.id
				}, res => {
					req.msg('领取成功');
				});
			}
		}
	};
</script>
<style>
	@import "./index.css";
</style>
