<template>
	<view class="page">
		<view class="body after-navber">
			<view class="info">
				<view class="info-list" style="width:100%;">
					<block v-for="(item, index) in coupon_list" :key="index">
						<block>
							<view class="info-one">
								<image class="bga" src="../../static/icon-coupon-enabled.png">
								</image>
								<view class="info-content flex-row flex-x-center flex-y-center fs-b">
									<navigator hover-class="none"
										class="info-content flex-row flex-x-center flex-y-center">
										<view class="flex-grow-0">
											<view class="flex-row flex-y-bottom">
												<block>
													<view class="flex-grow-0">￥</view>
													<view class="flex-grow-1" style="font-size:23pt;">
														{{ Number(item.price) }}
													</view>
												</block>

											</view>
										</view>
										<view class="flex-grow-1">
											<view style="margin-left:16rpx;">
												<view style="margin-bottom:4rpx;">{{item.goods_name}}</view>
												<view style="font-size: 26rpx;">
													{{ item.discount_type==1?'满减券':item.discount_type==2 ?'折扣券':item.discount_type==3?'特价券':''}}
												</view>
											</view>
										</view>
									</navigator>

									<view class="flex-grow-0">
										<block>
											<view @tap="receive(index)" :data-index="index"
												class="flex-x-center flex-y-center info-btn fs-sm" :data-id="item.id"
												style="color:#ff4544;">立即查看</view>
										</block>
										<!-- 					<block v-if="coupon.state == 2">
											<view class="flex-x-center flex-y-center info-btn fs-sm"
												style="color:#999;">已领取</view>
										</block> -->
									</view>

								</view>

								<view class="info-footer fs-sm box-pack-between flex-y-center">
									<view class="">
										<!-- <view v-if="item.type==2" style="font-size: 24rpx;">指定商品可用</view> -->
										<view class="info-day">描述：{{item.body}}</view>
									</view>
									<!-- <image v-if="item.type==2" @click.stop="bindChecked(index)" class="more-down"
										:class="item.checked?'more-down-deg':''" src="../../static/more-down.png">
									</image> -->
								</view>
								<!-- 
								<view class="coupon-foot flex-grow-1" v-if="coupon.checked">
									<view class="box-pack-between">
										<view class="mrt16 flex flex-grow-1">
											<text style="min-width: 190rpx;">指定商品：</text>
											<view class="flex-grow-1">
												<view class="box-pack-between" v-for="(item,index) of coupon.goods">
													{{item.name}} <text style="color: red;">￥{{item.price}}</text>
												</view>
											</view>
										</view>
									</view>
								</view> -->
							</view>
						</block>
					</block>
				</view>
				<block v-if="coupon_list.length <= 0">
					<view class="flex-x-center"><text style="margin-top:50rpx;color: #999;">暂无优惠券</text></view>
				</block>
			</view>
		</view>
	</view>
</template>
<script>
	var share_count = 0;
	let hideLoading = true;
	export default {
		data() {
			return {
				coupon_list: [
					// {goods_name:'发发发发发',body:'2这',discount_type:1,price:'110'},{},
				],
				get_coupon_list: "",
				wxapp_img: {},

				staff_id: "",
				is_load: false,
				is_load_more: false,
				setColor: "",
				systemInfo: {},
				limit: 10,
				page: 1,
			};
		},
		props: {},
		onLoad: function(t) {
			uni.setNavigationBarColor({
				frontColor: '#ffffff',
				backgroundColor: this.$store.state.color,
			})
			this.setColor = this.$store.state.color;
			this.http();
			this.systemInfo = uni.getStorageSync('systemInfo');
		},
		onShareAppMessage(e) {
			return {}
		},
		onShow: function() {},
		onReachBottom() {
			// if (!this.is_load) {
			// this.page = this.page + 1;
			this.http();
			// }
		},
		methods: {

			bindChecked(index) {
				this.coupon_list[index].checked = !this.coupon_list[index].checked;
			},

			http() {
				this.$http.request('xcx/wofu_coupon_list', {
					// user_id: uni.getStorageSync('user_id'),
					store_id: uni.getStorageSync('store_id'),
					limit: this.limit,
					page: this.page,
				}, "", "", hideLoading).then(res => {
					console.log(res, "LqCoupons_lists")
					this.coupon_list = this.coupon_list.concat(res.data);
					this.page = this.page + 1;
				})
			},
			receive(index) {
				// #ifdef MP-WEIXIN
				uni.showToast({
					title: '请到支付宝端领取',
					icon: 'none'
				})
				// #endif
				// #ifdef MP-ALIPAY
				let url = this.coupon_list[index].link_url;
				my.ap.navigateToAlipayPage({
					// 例如跳转到共享单车页面，其 scheme 格式为：
					// alipays://platformapi/startapp?appId=60000155&chInfo=ch_${appid}，${appid} 替换为自己的16位 appid，例如：
					path: url,
					success: (res) => {
						// my.alert({content:'系统信息' + JSON.stringify(res)});
					},
					fail: (error) => {
						// my.alert({content:'系统信息' + JSON.stringify(error)});        
					}
				})
				// #endif
			},
		}
	};
</script>
<style>
	@import "./coupon-list.css";
</style>
