You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

245 lines
7.2 KiB

<template>
<view class="container">
<block v-if="isload">
<dd-tab style="position: fixed;left:0;right:0;z-index:11;top:-1rpx" :itemdata="['未使用','已使用','已过期']" :itemst="['0','1','2']" :st="st" :isfixed="false" @changetab="changetab"></dd-tab>
<view class="coupon-list">
<view class="coupon-item flex al-item-center" :style="st ==2 || st == 1?'color: #AAAAAA':'color:#0a5d3b'" v-for="(item, index) in datalist" :key="index" @tap.stop="goto" :data-url="'coupondetail?rid=' + item.id">
<image class="coupon-item__bg" :src="event_rul + '/static/img/static/icon/coupon-bg.svg'" mode=""></image>
<image v-if="st ==2 || st == 1" class="coupon-item__bg" :src="event_rul + '/static/img/static/icon/couponed-bg.svg'" mode=""></image>
<view class="coupon-item__hd flex al-item-center j-center">
<view class="coupon-item__hd-price" v-if="item.type==1"><text class="symbol">¥</text><text class="txt">{{item.money}}</text></view>
<view class="coupon-item__hd-txt" v-if="item.type==2">礼品券</view>
<view class="coupon-item__hd-price" v-if="item.type==3"><text class="txt">{{item.limit_count}}</text><text class="unit">次</text></view>
<view class="coupon-item__hd-txt" v-if="item.type==4">抵运费</view>
<view class="coupon-item__hd-price" v-if="item.type==5"><text class="symbol">¥</text><text class="txt">{{item.money}}</text></view>
<view class="coupon-item__hd-tips" v-if="item.type==1 || item.type==4 || item.type==5">
<text v-if="item.minprice>0">满{{item.minprice}}元可用</text>
<text v-else>无门槛</text>
</view>
</view>
<view class="coupon-item__bd flex j-between">
<view class="coupon-item__bd-title flex al-item-center" :style="st ==2 || st == 1?'color: #AAAAAA':'color:#333333'">
<view class="coupon-item__bd-tag" :style="st ==2 || st == 1?'color: #AAAAAA;border-color: #AAAAAA':'color:' + t('color1')">{{item.type==1?'代金券':(item.type==2?'礼品券':(item.type==3?'计次券':(item.type==4?'运费抵扣券':(item.type==5?'餐饮券':''))))}}</view>
<view class="coupon-item__bd-tag" v-if="item.isgive == 1" :style="st ==2 || st == 1?'color: #AAAAAA;border-color: #AAAAAA':'color:' + t('color2')">可赠送</view>
{{item.couponname}}
</view>
<view class="coupon-item__bd-txt" :style="st ==2 || st == 1?'color: #AAAAAA':'color:#999999'" v-if="item.bid>0">适用商家:{{item.bname}}</view>
<view class="coupon-item__bd-time">有效期至 {{item.endtime}}</view>
</view>
<view class="coupon-item__ft" v-if="st==0 && item.type==1" @tap.stop="goto" :data-url="'/pages/shop/prolist?cpid=' + item.couponid">
<view class="coupon-item__ft-txt">立即使用</view>
</view>
<view class="coupon-item__ft" v-else-if="st==0" @tap.stop="goto" :data-url="'coupondetail?rid=' + item.id">
<view class="coupon-item__ft-txt">立即使用</view>
</view>
<view class="coupon-item__ft" v-if="st==1||st==2">
<view class="coupon-item__ft-txt">{{st==1?'已使用':(st==2?'已过期':'')}}</view>
</view>
</view>
</view>
<nomore v-if="nomore"></nomore>
<nodata v-if="nodata"></nodata>
</block>
<loading v-if="loading"></loading>
<dp-tabbar :opt="opt"></dp-tabbar>
<popmsg ref="popmsg"></popmsg>
<!-- 悬浮按钮 -->
<drag-button></drag-button>
</view>
</template>
<script>
var app = getApp();
export default {
data() {
return {
opt:{},
loading:false,
isload: false,
menuindex:-1,
pre_url:app.globalData.pre_url,
st: 0,
datalist: [],
pagenum: 1,
nomore: false,
nodata:false,
event_rul: app.globalData.event_url,
};
},
onLoad: function (opt) {
this.opt = app.getopts(opt);
this.st = this.opt.st || 0;
this.getdata();
},
onPullDownRefresh: function () {
this.getdata();
},
onReachBottom: function () {
if (!this.nodata && !this.nomore) {
this.pagenum = this.pagenum + 1;
this.getdata(true);
}
},
methods: {
getdata: function (loadmore) {
if(!loadmore){
this.pagenum = 1;
this.datalist = [];
}
var that = this;
var pagenum = that.pagenum;
var st = that.st;
var bid = that.opt && (that.opt.bid || that.opt.bid === '0') ? that.opt.bid : '';
that.loading = true;
that.nomore = false;
that.nodata = false;
app.post('ApiCoupon/mycoupon', {st: st,pagenum: pagenum,bid: bid}, function (res) {
that.loading = false;
uni.setNavigationBarTitle({
title: '我的' + that.t('优惠券')
});
var data = res.data;
if (pagenum == 1) {
that.pics = res.pics;
that.clist = res.clist;
that.datalist = data;
if (data.length == 0) {
that.nodata = true;
}
that.loaded();
}else{
if (data.length == 0) {
that.nomore = true;
} else {
var datalist = that.datalist;
var newdata = datalist.concat(data);
that.datalist = newdata;
}
}
});
},
changetab: function (st) {
this.st = st;
uni.pageScrollTo({
scrollTop: 0,
duration: 0
});
this.getdata();
}
}
};
</script>
<style lang="scss">
.container {
background: #f5f5f5;
height: 100vh;
padding-top: 90rpx;
box-sizing: border-box;
padding-bottom: calc(20rpx + constant(safe-area-inset-bottom));
padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
}
.coupon-list {
width: 100%;
padding: 6rpx;
}
.coupon-item {
display: flex;
position: relative;
z-index: 1;
height: 234rpx;
color: #0a5d3b;
&:not(:first-child) {
margin-top: -12rpx;
}
&__bg {
position: absolute;
z-index: -1;
width: 100%;
height: 100%;
top: 0;
left: 0;
}
&__hd {
flex-shrink: 0;
flex-direction: column;
color: #ffffff;
width: 210rpx;
padding-left: 15rpx;
&-price {
font-size: 36rpx;
line-height: 50rpx;
font-weight: bold;
.txt {
font-size: 72rpx;
line-height: 100rpx;
}
.unit {
padding-left: 10rpx;
}
}
&-tips {
font-size: 24rpx;
line-height: 34rpx;
}
&-txt {
font-size: 46rpx;
font-weight: bold;
line-height: 58rpx;
}
}
&__bd {
flex: 1;
padding: 0 24rpx;
min-height: 125rpx;
flex-direction: column;
&-title {
font-size: 28rpx;
line-height: 40rpx;
color: #333333;
}
&-tag {
border-radius: 4rpx;
margin-right: 6rpx;
border: 1rpx solid #0a5d3b;
font-size: 22rpx;
font-weight: bold;
height: 32rpx;
line-height: 30rpx;
padding: 0 6rpx;
}
&-txt {
font-size: 22rpx;
color: #999999;
line-height: 32rpx;
margin-top: 16rpx;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
/* autoprefixer: ignore next */
-webkit-box-orient: vertical;
text-align: justify;
white-space: pre-wrap;
word-break: break-all;
}
&-time {
margin-top: 10rpx;
font-size: 20rpx;
line-height: 28rpx;
}
}
&__ft {
padding: 0 50rpx 0 30rpx;
&-txt {
width: 20rpx;
font-size: 24rpx;
font-weight: bold;
line-height: 30rpx;
}
}
}
</style>