<wxs module="filter" src="filter.wxs"></wxs>
<wxs module="time" src="../../../../utils/filter.wxs"></wxs>

<com_top_nav title="我的优惠券"></com_top_nav>

<view>
	
	<view class="tab-head" bindtap="clickTab">
		<view wx:for="{{grades}}" wx:key="unique" class="tab-head-item {{currentIndex == index ? 'active':''}}" data-name="{{item}}" data-index="{{index}}">{{item}}</view>
	</view>
	
	<view class="tab-body">
		<block wx:if="{{currentIndex != 3}}">
			<view class="tab-list-item" wx:for="{{details}}" wx:for-index="idx" wx:for-item="detail">
				<block wx:if="{{detail.isby}}">
					<view class="coupon">
						<view class="flex">
							<view class="c-l"><text class="fs40">包邮券</text></view>
							<view class="c-r dash">
								<view class="flex jc_sb ai_c">
									<view class="pdr20">
										<view class="fs28 ellipsis-1x">包邮券</view>
										<view class="fs24 c-7b pdt4 ellipsis-1x">微券来源: 微信商城</view>
									</view>
									<view class="shrink0"><text class="btn {{currentIndex != 0 ? 'gray':''}}" bindtap="{{currentIndex == 0 ? 'nvShop':''}}" data-index="{{idx}}" data-cashrepno="{{detail.no}}">{{filter.showBtnText(currentIndex)}}</text></view>
								</view>
								<view class="flex jc_sb ai_c c-time">
									<text class="ellipsis-1x" wx:if="{{detail.use_end_time!=null}}">有效期:{{detail.use_start_time==null?" " : time.format_time(detail.use_start_time)}} 至 {{time.format_time(detail.use_end_time)}}</text>
									<text wx:else>有效期:不限</text>
                  <!-- <image  bindtap="clickUse" data-index="{{idx}}" data-cashrepno="{{detail.no}}" style="height: 42rpx ;width: 42rpx;border: 2px solid #fe9db5;background: #fe9db5;" src="{{iurl}}/miniapp/images/qrcode1.png"></image> -->
                  <image  bindtap="clickUse" data-index="{{idx}}" data-cashrepno="{{detail.no}}" style="height: 52rpx ;width: 52rpx;" src="{{iurl}}/miniapp/images/qrcode_img.png"></image>
                  <!-- <text class="iconfont icon-erweima" bindtap="clickUse" style="color: black;" data-index="{{idx}}" data-cashrepno="{{detail.no}}"  ></text> -->

								</view>
							</view>
						</view>
					</view>
					<view class="c-info arrow-down {{detail.isShowDetails ? 'active':''}}" bindtap="clickDetails" data-index="{{idx}}">
						<!--<text class="{{detail.isShowDetails ? '':'ellipsis-1x'}}">使用说明: 包邮券,全场通用,满 {{detail.condition}}元使用{{detail.title?',不包邮地区:'+detail.title:''}}</text>-->
						<text class="{{detail.isShowDetails ? '':'ellipsis-1x'}}"><text style="margin-right: 15rpx">使用说明:</text>{{filter.showtypeName(detail.type)}}【消费满{{time.toFix(detail.condition,2)}}元可用】 </text>
					</view>
				</block>
				
				<block wx:else>
					<view class="coupon">
						<view class="flex">
							<view class="c-l"><text class="rmb fs40">{{filter.getNum(detail.Sum)}}</text></view>
							<view class="c-r dash">
								<view class="flex jc_sb ai_c">
									<view class="pdr20">
                  	<view class="fs28 ellipsis-1x" wx:if="{{detail.ActName}}">{{detail.ActName}}</view>
										<view class="fs28 ellipsis-1x" wx:else>{{filter.getNum(detail.Sum)}}元微券</view>
										<view class="fs24 c-7b pdt4 ellipsis-1x">微券来源: {{detail.SendMan==null?'线下发放':detail.SendMan==''?"线下发放":detail.SendMan}}</view>
									</view>
									<view class="shrink0">
										<text class="btn {{currentIndex != 0 ? 'gray':''}}" bindtap="{{currentIndex == 0 ? ( detail.UseObjectID==null || detail.UseObjectID== '' ? 'nvShop' : (detail.UseObjectType==20 ? 'nvShopInfo' :'clickUse') ):''}}" data-index="{{idx}}" data-cashrepno="{{detail.CashRepNo}}" data-useobjectid="{{detail.UseObjectID}}">{{filter.showBtnText(currentIndex)}}</text>
									</view>
								</view>
								<view class="c-time flex jc_sb ai_c">
									<text  wx:if="{{detail.ValidDate}}" class="ellipsis-1x">有效期:{{detail.BeginDate==null ? " " : time.replace_time2(detail.BeginDate)}} 至 {{time.replace_time2(detail.ValidDate)}}</text>
									<text wx:else>有效期:不限</text>
                  <!-- <image wx:if="{{detail.UseObjectID==null || detail.UseObjectID=='' || detail.UseObjectType==20}}"  bindtap="{{currentIndex == 0 ? 'clickUse':''}}" data-index="{{idx}}" data-cashrepno="{{detail.CashRepNo}}" style="height: 42rpx ;width: 42rpx;border: 2px solid #fe9db5;background: #fe9db5;" src="{{iurl}}/miniapp/images/qrcode1.png"></image> -->
                  <image wx:if="{{detail.UseObjectID==null || detail.UseObjectID=='' || detail.UseObjectType==20}}"  bindtap="{{currentIndex == 0 ? 'clickUse':''}}" data-index="{{idx}}" data-cashrepno="{{detail.CashRepNo}}" style="height: 52rpx ;width: 52rpx;" src="{{iurl}}/miniapp/images/qrcode_img.png"></image>
								</view>
							</view>
						</view> 
					</view>
					<view class="c-info arrow-down {{detail.isShowDetails ? 'active':''}}" bindtap="clickDetails" data-index="{{idx}}">
						<view class="{{detail.isShowDetails ? '':'ellipsis-1x'}}" wx:if="{{detail.Remark1!=''}}">
							<text style="margin-right: 15rpx">使用说明:</text>{{filter.getNum(detail.Sum)}}元优惠券，{{(detail.UseObjectID==null || detail.UseObjectID=='')?"全场通用":"仅限"+(detail.UseObjectName)+"使用"}}，满 {{detail.BuySum==null || detail.BuySum==''?filter.getNum(0):filter.getNum(detail.BuySum)}}元使用 {{detail.region_list_name==null || detail.region_list_name==''?"":"，不包邮地区:"+region_list_name}};{{detail.Remark1}};活动名称：{{detail.ActName}}、活动编号：{{detail.ActNo}}、使用场景：{{ (detail.UseRange && detail.UseRange !=0) ? (detail.UseRange==1 ? '仅线下可用' : '仅线上可用') :'通用'}} 取价规则：<block wx:if="{{detail.FactPriceType>0}}">零售价</block> <block wx:else >实收价</block></view>
						<view class="{{detail.isShowDetails ? '':'ellipsis-1x'}}" wx:else>
							<text style="margin-right: 15rpx">使用说明:</text> {{filter.getNum(detail.Sum)}}元优惠券，{{(detail.UseObjectID==null || detail.UseObjectID=='')?"全场通用":"仅限"+(detail.UseObjectName)+"使用"}}，满 {{detail.BuySum==null || detail.BuySum==''?filter.getNum(0):filter.getNum(detail.BuySum)}}元使用 {{detail.region_list_name==null || detail.region_list_name==''?"":"，不包邮地区:"+region_list_name}};活动名称：{{detail.ActName}}、活动编号：{{detail.ActNo}}、使用场景：{{(detail.UseRange && detail.UseRange !=0) ? (detail.UseRange==1 ? '仅线下可用' : '仅线上可用') :'通用'}} 取价规则：<block wx:if="{{detail.FactPriceType>0}}">零售价</block> <block wx:else>实收价</block></view>
					</view>
				</block>
			</view>
		</block>
		
	
		<block wx:else>
			<view class="tab-list-item" wx:for="{{result}}" wx:for-item="result">
				<view class="coupon2">
					<view class="flex">
						<view class="c-l"><text class="rmb fs40">{{filter.getNum(result.ToSum)}}</text></view>
						<view class="c-r dash">
							<view class="flex jc_sb ai_c">
								<view class="pdr20">
									<view class="fs26 ellipsis-1x breakall">{{result.Integral}}积分兑换{{filter.getNum(result.ToSum)}}元微券</view>
									<!-- <view class="fs24 c-7b pdt4 ellipsis-1x">微券来源: 微信商城</view> -->
								</view>
								<view class="shrink0"><text class="btn2" bindtap="clickExchange" data-index="{{index}}">立即兑换</text></view>
							</view>
							<!-- <view class="c-time">
								<text class="ellipsis-1x" wx:if="{{detail.use_end_time!=null}}">有效期:{{detail.use_start_time==null?" " : time.format_time(detail.use_start_time)}}至{{  time.format_time(detail.use_end_time)}}</text>
								<text wx:else>有效期:不限</text>
							</view> -->
						</view>
					</view>
				</view>
			</view>
		</block>
		
		<!-- 暂无数据 -->
		<nodata nodataContainer="t-c" wx:if="{{(is_no_more == 1 && current_page == 1) || (result.length == 0)}}"></nodata>
		
		<block wx:if="{{is_get}}">
			<!-- 没有更多数据 -->
			<view class="noMore 1" wx:if="{{(is_no_more == 1)||((details.length !== 0) && (pageSize >= (byTotal+wjTotal)))}}">—— 已经到底了 ——</view>
		</block>
		<view class="noMore 2" wx:if="{{noMore}}">—— 已经到底了 ——</view>
	</view>
	
</view>




<!-- 遮罩层 -->
<view class="mask" hidden="{{!showQr}}" catchtouchmove="touchMove"></view>
<!-- 码 -->
<view class="popup-container" hidden="{{!showQr}}" catchtouchmove="touchMove">
	<view class="t-r pdb20"><text class="iconfont icon-close fs40" bindtap="closeQr"></text></view>
	<view class="popup">
		<view class="popup-title">
			<block wx:if="{{details[useIndex].isby == 1}}">包邮券</block>
      <block wx:else>
      <block wx:if="{{details[useIndex].ActName}}">{{details[useIndex].ActName}}</block>
			<block wx:else>
				{{filter.getNum(details[useIndex].Sum)}}元微券 
			</block>
      </block>
		</view>
		<!-- <view class="pdt20 c-fe0000"><text class="rmb fs80" wx:if="{{details[useIndex].isby != 1}}">{{filter.getNum(details[useIndex].Sum)}}</text></view> -->
		<!-- 条形码 -->
		<view class="bar-container">
			<canvas class="barcode" canvas-id="barcode"/>
			<view class="pdt20 fs26" wx:if="{{details[useIndex].CashRepNo}}">{{details[useIndex].CashRepNo}}</view>
			<view class="pdt20 fs26" wx:else>{{details[useIndex].no}}</view>
		</view>
		<!-- 二维码 -->
		<view class="qr-container">
		  <canvas class="qrcode" canvas-id="qrcode"/>
		</view>
		<view class="pdv20 c-7b fs26 bdt">
			<text  wx:if="{{details[useIndex].ValidDate}}" class="ellipsis-1x">有效期:{{details[useIndex].BeginDate==null ? " " : time.replace_time2(details[useIndex].BeginDate)}} 至 {{time.replace_time2(details[useIndex].ValidDate)}}</text>
			<text  wx:elif="{{details[useIndex].use_end_time}}" class="ellipsis-1x">有效期:{{details[useIndex].use_start_time==null ? " " : time.format_time(details[useIndex].use_start_time)}} 至 {{time.format_time(details[useIndex].use_end_time)}}</text>
			<text wx:else>有效期:不限</text>
		</view>
	</view>
</view>




