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

	<block wx:if="{{ad_data}}">
		<view class="top_img rel">
			<image mode="widthFix" src="{{ad_data.ad_code}}" lazy-load="true"
				   binderror="bind_bnerr2" data-errorimg="wareCard[{{index}}].lbUrl"></image>
			<lb_sear id="lb_sear" bindinput_sear="input_sear" bindsearch_lb="search_lb"></lb_sear>
		</view>
	</block>
	<block wx:else>
		<view class="top_img rel">
			<image mode="widthFix" src="{{iurl+'/miniapp/images/giftbag/gift00.jpg?v=202403'}}" lazy-load="true"></image>
			<lb_sear id="lb_sear" bindinput_sear="input_sear" bindsearch_lb="search_lb"></lb_sear>
		</view>
	</block>


	<view class="tab-title" bindtap="clickTab">
		<view class="tab-title-item {{currentIndex == index ? 'active':''}}" wx:for="{{tabArr}}" data-index="{{index}}">{{item}}</view>
	</view>
	<view class="tab-content">
		<block wx:if="{{currentIndex == 0}}">
			<view class="tab-item" wx:for="{{list.pageData}}" wx:if="{{now > item.startime  || (item.is_show && now > item.show_time)}}">
				<view bindtap="goto" data-url="{{'/packageA/pages/myGiftDetails/myGiftDetails?index=0&id=' + item.id}}">
					<!-- 图片 -->
					<view class="img-container rel">
						<image src="{{imghost + (item.lburl ? item.lburl:'miniapp/images/default_g_img.gif')}}" class="img" mode="widthFix" />
						<view catchtap="show_remark" data-index="{{index}}" class="lb_remark ellipsis-1" wx:if="{{item.lbintro}}">活动说明:{{item.lbintro}}</view>
					</view>
					<view class="desc-container">
						<!-- 标题 -->
						<view class="mgb10 ellipsis-2 lh taj">{{item.lbtitle}}</view>
						<!-- 价格 -->
						<view class="flex jc_sb ai-center pdb10">
							<view class="flex ai-center">
								<view class="c-red fs28">
									<block wx:if="{{item.lbprice>0 && item.lbintegral}}">
										<text class="rmb">{{filter.toFix(item.lbprice,2)}}</text>/{{item.lbintegral}}积分
									</block>
									<block wx:elif="{{item.lbprice>0 || item.lbintegral}}">
										<block wx:if="{{item.lbprice>0}}">
											<text class="rmb">{{filter.toFix(item.lbprice,2) }}</text>
										</block>
										<block wx:if="{{item.lbintegral>0}}">
											{{item.lbintegral}}积分
										</block>
									</block>
								</view>
								<view class="fs22 c-a4 line-through mgl10">{{filter.toFix(item.oldprice,2)}}</view>
							</view>
							<view class="fs24 c-a4">已售{{item.salenum+item.virtualsales}}件</view>
						</view>
						<!-- 时间 -->
						<view class="date" wx:if="{{item.is_show && now < item.startime}}">活动开始日期 {{filter.format_time(item.startime)}}</view>
						<view class="date" wx:else>活动结束日期 {{filter.format_time(item.endtime)}}</view>
						<!-- 按钮 -->
					</view>
				</view>
				<block wx:if="{{now < item.startime}}">
					<view class="btn1 gray">活动还未开始</view>
				</block>
				<block wx:else>
					<view class="btn-container pd20">
						<view wx:if="{{item.lbintegral>0}}" bindtap="GetBuyIntegral" data-index="{{index}}" class="btn red">立即兑换</view>
						<view wx:if="{{item.lbprice>0}}" bindtap="GetBuyPrice" data-index="{{index}}" class="btn pink">立即购买</view>
					</view>
				</block>
			</view>
		</block>

		<block wx:else>
			<view class="tab-item flex pd20" wx:for="{{list.pageData}}" bindtap="goto" data-url="{{'/packageA/pages/myGiftDetails/myGiftDetails?index=1&id=' + item.lbvipid}}">
				<view class="img-container2">
					<image src="{{imghost + (item.lburl ? item.lburl:'miniapp/images/default_g_img.gif')}}" class="img" mode="widthFix" data-index="{{index}}" />
				</view>
				<view class="flex fdc jc_sb">
					<view>
						<!-- 标题 -->
						<view class="mgb10 ellipsis-2 lh taj">{{item.lbtitle}}</view>
						<!-- 时间 -->
						<view class="date pdb20" wx:if="{{item.lbtype==1}}">兑换截止日期 {{filter.format_time(item.expdate,1)}}</view>
						<view catchtap="show_remark" data-index="{{index}}" wx:if="{{item.lbintro}}" class="date pdb20">活动说明</view>
					</view>
					<!-- 说明 -->
					<view wx:if="{{item.lbtype==1}}" class="c-red fs24">注:请到线下门店兑换</view>
				</view>
			</view>
		</block>

		<nodata nodataContainer="t-c" wx:if="{{list.pageData.length == 0}}"></nodata>
		<view class="noMore" hidden="{{!noMore}}" wx:if="{{list.pageData.length !== 0}}">—— 已经到底了 ——</view>
	</view>
</view>

<!-- 引入提示组件 -->
<warn id="warn"></warn>
<my_confirm id="my_confirm"></my_confirm>
<view wx:if="{{show_rem_pop}}">
	<view class="cover-layer" bindtap="close_remark"></view>
	<view class="rem_pop;">
		<view style="text-align: right;" bindtap="close_remark"><text class="iconfont icon-close" style="font-size: 40rpx;"></text></view>
		<view style="padding: 0 16rpx;">
			<view class="fs32">活动说明：</view>
			<view class="fs30">{{pop_remark_text}}</view>
		</view>
	</view>
</view>