myYouHuiJuan.vue 11.1 KB
<template>
	<view class="youHui_content"> <!-- swiperCurrent -->
		<view class="you-Youhui">
			<view class="u-tabs-swiper">
				<u-tabs-swiper ref="tabs" :list="list" :is-scroll="false" inactive-color="#969799" active-color="#3E554E"
					bar-width="90" bar-height="3" gutter="163" :current="Tabcurrent" @change="change"></u-tabs-swiper>
			</view>
			
			<swiper class="swiper-box" :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish">
				<swiper-item class="swiper-item">
					<!-- 第一部分 -->
					<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom">
						<view v-if="isMyYouHui">
						<view class="page-content" v-if="orderList[0].length > 0">
							<view class="youHuiBox" v-for="(item,index) in orderList[0]">
								<!-- 待使用样式 -->
								<view class="youHuiItem relative">
									<view class="youHuiBg relative">
										<image src="/static/myImage/youhuiBg.png" mode="widthFix"></image>
										<view class="youHuiContentF absolute">
											<view class="youHuiMoney moneyCom">
												¥{{item.price}}
											</view>
											<view class="youHuiContentF">
												<view class="content_left">
													<view class="content_left-title" v-if="item.bottom_price != 0 ">
														满{{item.bottom_price}}可用
													</view>
													<view class="content_left-title" v-else>
														无门槛使用
													</view>
													<view class="content_left_text">
														{{item.end_time}}
													</view>
												</view>
												<view class="content_right">
													<view class="content_right-title">
			
													</view>
													<view class="content_right-btn" @click="navTo_shouye">
														待使用
													</view>
												</view>
											</view>
										</view>
									</view>
								</view>
							</view>
						</view>
						<!-- 没有优惠卷的页面 -->
						<view class="no-Youhui" v-else>
							<view class="no-youhuiBox">
								<view class="no-youhuiImg">
									<image src="/static/myImage/ic_money.png" mode="widthFix"></image>
								</view>
								<view class="no-youhui-text">
									暂无优惠券可用
								</view>
							</view>
						</view>
						</view>
						<!-- 没有优惠卷的页面end -->
					</scroll-view>
				</swiper-item>
				<!-- 第二部分 -->
				<swiper-item class="swiper-item">
					<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom">
						<view v-if="isMyYouHui">
						<view class="page-box" v-if="orderList[1].length > 0">
							<view class="youHuiBox" v-for="(item,index) in orderList[1]">
								<!-- 已使用 样式-->
								<view class="youHuiItem relative">
									<view class="youHuiBg relative">
										<image src="/static/myImage/youhuiBg.png" mode="widthFix"></image>
										<view class="youHuiContents absolute">
											<view class="youHuiMoney moneyCom">
												¥{{item.price}}
											</view>
											<view class="youHuiContents">
												<view class="content_left">
													<view class="content_left-title" v-if="item.bottom_price != 0 ">
														满{{item.bottom_price}}可用
													</view>
													<view class="content_left-title" v-else>
														无门槛使用
													</view>
													<view class="content_left_text">
														{{item.end_time}}
													</view>
												</view>
												<view class="content_right">
													<view class="content_right-title">
			
													</view>
													<view class="content_right-btn">
														已使用
													</view>
												</view>
											</view>
										</view>
									</view>
								</view>
							</view>
						</view>
						<!-- 没有优惠卷的页面 -->
						<view class="no-Youhui" v-else>
							<view class="no-youhuiBox">
								<view class="no-youhuiImg">
									<image src="/static/myImage/ic_money.png" mode="widthFix"></image>
								</view>
								<view class="no-youhui-text">
									显示暂无优惠券可用
								</view>
							</view>
						</view>
						</view>
						<!-- 没有优惠卷的页面end -->
					</scroll-view>
				</swiper-item>
				<!-- 第三部分 -->
				<swiper-item class="swiper-item">
					<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom">
						<view v-if="isMyYouHui">
						<view class="page-box" v-if="orderList[2].length > 0">
							<view class="youHuiBox" v-for="(item,index) in orderList[2]">
								<view class="youHuiItem relative">
									<view class="youHuiBg relative">
										<image src="/static/myImage/youhuiBg.png" mode="widthFix"></image>
										<view class="youHuiContent  absolute">
											<view class="youHuiMoney moneyCom">
												¥{{item.price}}
											</view>
											<view class="youHuiContent">
												<view class="content_left">
													<view class="content_left-title" v-if="item.bottom_price != 0 ">
														满{{item.bottom_price}}可用
													</view>
													<view class="content_left-title" v-else>
														无门槛使用
													</view>
													<view class="content_left_text">
														{{item.end_time}}
													</view>
												</view>
												<view class="content_right1">
													<image src="/static/myImage/shixiao.png" mode="widthFix"></image>
												</view>
											</view>
										</view>
									</view>
								</view>
							</view>
						</view>
						<!-- 没有优惠卷的页面 -->
						<view class="no-Youhui" v-else>
							<view class="no-youhuiBox">
								<view class="no-youhuiImg">
									<image src="/static/myImage/ic_money.png" mode="widthFix"></image>
								</view>
								<view class="no-youhui-text">
									显示暂无优惠券可用
								</view>
							</view>
						</view>
						</view>
						<!-- 没有优惠卷的页面end -->
					</scroll-view>
				</swiper-item>
			</swiper>
		</view>
		<!-- 领卷中心 -->
		<view class="lingJuang-Container fixed" @click="navTo()">
			<view class="lingJuang-Container-bgimg">
				<image src="/static/myImage/lingJuan.png" mode="widthFix"></image>
				<!-- 领卷中心内容 -->
				<view class="lingJuang-Container-content absolute">
					更多好券请到领券中心领取
				</view>
			</view>
			<!-- <view class="lingJuangBg"></view> -->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isMyYouHui:false,
				pageNote: true,
				pgaeOne: 1,
				pgaeTwo: 1,
				pgaeThree: 1,
				//优惠选项tab页
				list: [{
						name: '待使用',

					},
					{
						name: '已使用'
					},
					{
						name: '已过期',

					}
				],
				Tabcurrent: 0, //当前默认显示索引
				swiperCurrent: 0, //优惠卷轮播索引
				tabsHeight: 0,
				dx: 0,
				orderstateText: '',
				orderList: [
					[],
					[],
					[]
				]
			}
		},
		onShow() {
			//后台接口调用
			this.youHujuanDataOne((this.swiperCurrent + 1), (this.pgaeOne));
			this.youHujuanDataTwo((this.swiperCurrent + 2), (this.pageTwo));
			this.youHujuanDataThree((this.swiperCurrent + 3), (this.pageThree));
		},
		onLoad() {
			
		},
		methods: {
			//跳转到首页
			navTo_shouye() {
				uni.switchTab({
					url: "../../home/home"
				})
			},
			//后台接口调用
			youHujuanDataOne(s, p) {
				console.log(p);
				let that = this;
				let dataOne = {
					status: s,
					page: p,
				}
				that.$rqs('/api/coupon/getUserCoupon', dataOne).then(res => {
					if ((res.data.code == 1) && (res.data.data.usercoupon.data.length)) {
						res.data.data.usercoupon.data.forEach(item => {
							let d = new Date(item.end_time * 1000);
							item.end_time = (d.getFullYear()) + "." + (d.getMonth() + 1) + "." + (d
								.getDate()) + '到期'
							item.bottom_price = parseInt(item.bottom_price)
							item.price = parseInt(item.price)
							that.orderList[0].push(item)
							that.isMyYouHui = true;
						})
						console.log(res.data.data.userInfo);
						this.pgaeOne++;
					} else {
						this.pageNote = false;
						this.isMyYouHui = true
					}
				})
			},
			youHujuanDataTwo(s, p) {
				console.log(p);
				let that = this;
				let dataTwo = {
					status: s,
					page: p,
				}
				that.$rqs('/api/coupon/getUserCoupon', dataTwo).then(res => {
					if ((res.data.code == 1) && (res.data.data.usercoupon.data.length)) {
						res.data.data.usercoupon.data.forEach(item => {
							let d = new Date(item.end_time * 1000);
							item.end_time = (d.getFullYear()) + "." + (d.getMonth() + 1) + "." + (d
								.getDate()) + '到期'
							item.bottom_price = parseInt(item.bottom_price)
							item.price = parseInt(item.price)
							that.orderList[1].push(item)
						})
						this.pgaeTwo++;
					} else {
						this.pageNote = false;
					}
				})
			},
			youHujuanDataThree(s, p) {
				console.log(p);
				let that = this;
				let dataThree = {
					status: s,
					page: p,
				}
				that.$rqs('/api/coupon/getUserCoupon', dataThree).then(res => {
					console.log(res.data.data.usercoupon.data.length);
					if ((res.data.code == 1) && (res.data.data.usercoupon.data.length)) {
						res.data.data.usercoupon.data.forEach(item => {
							let d = new Date(item.end_time * 1000);
							item.end_time = (d.getFullYear()) + "." + (d.getMonth() + 1) + "." + (d
								.getDate()) + '到期'
							item.bottom_price = parseInt(item.bottom_price)
							item.price = parseInt(item.price)
							that.orderList[2].push(item)
						})
						this.pgaeThree++;
					} else {
						this.pageNote = false;
					}
				})
			},
			navTo() {
				uni.navigateTo({
					url: './yuhuijuanCenter'
				})
			},
			// 遍历读取orderlist 
			readorderlist() {

			},
			// 触底事件
			reachBottom() {
				let that = this;
				let r = that.swiperCurrent + 1;
				if (r == 1 && that.pageNote) {
					that.youHujuanDataOne((that.swiperCurrent + 1), that.pgaeOne);
				} else if (r == 2 && that.pageNote) {
					that.youHujuanDataTwo((that.swiperCurrent + 2), that.pgaeTwo);
				} else if (r == 3 && that.pageNote) {
					that.youHujuanDataThree((that.swiperCurrent + 3), that.pgaeThree);
				}
			},
			change(index) {
				// tab栏切换
				this.page = 1;
				this.pageNote = true;
				console.log(index);
				this.swiperCurrent = index;
			},
			transition({
				detail: {
					dx
				}
			}) {
				this.$refs.tabs.setDx(dx);
			},
			animationfinish({
				detail: {
					current
				}
			}) {
				this.page = 1;
				this.pageNote = true;
				this.$refs.tabs.setFinishCurrent(current);
				this.swiperCurrent = current;
				this.current = current;
			},

		},

	}
</script>

<style>
	@import url("./my_Youhui.css");
	.youHuiContents {
		width: 100%;
		height: 100%;
	}
	.no-Youhui {
		position: fixed;
		height: 100vh;
		width: 100vw;
		background-color: #FFFFFF;
		box-sizing: border-box;
		padding-top: 348rpx;
	}
	
	.no-youhuiBox {
		width: 320rpx;
		height: 388rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		margin: 0 auto;
	}
	
	.no-youhuiImg {
		width: 320rpx;
		height: 320rpx;
	}
	
	.no-youhui-text {
		color: rgba(50, 50, 51, 1);
		font-size: 28rpx;
		font-weight: 500;
		text-align: center;
	}
	
	.no-youhuiBox-wraper {
		margin: 348rpx auto 0;
	}
</style>