<template>
|
<view>
|
<!-- <view style="display: none;"> -->
|
<view class="acea-row row-around nav">
|
<template v-for="item in navList">
|
<view :key="item.type" :class="['acea-row', 'row-middle', type === item.type ? 'on' : '']" @click="setType(item.type)">{{ item.name }}</view>
|
</template>
|
</view>
|
<view style="height: 106rpx;"></view>
|
<!-- </view> -->
|
<view class='coupon-list' v-if="couponsList.length">
|
<view v-for="(item,index) in couponsList" :key="index" :class="{fadeout:item.isUse==true}" >
|
<view class='item acea-row row-center-wrapper' :class="{zone:!item.isUse&&Number(item.moneyType)==4&&[4,-1].includes(item.userLvType)}">
|
<view class='money' :class='item.isUse ? "moneyGray" : (Number(item.moneyType)==4&&[4,-1].includes(item.userLvType)?"zoneMoney":"") '>
|
<!-- <view class="give">送</view> -->
|
<view v-if="Number(item.moneyType)==2">
|
<text class="price">{{item.money?Number(item.money*10):''}}</text>
|
<text class="zhe">折</text>
|
</view>
|
<view v-else-if="Number(item.moneyType)==4">
|
<view class="vipName">
|
<text v-if="Number(item.userLvType)==4">臻享专区</text>
|
<text v-else-if="Number(item.userLvType)==-1">臻享会员</text>
|
<text v-else-if="Number(item.userLvType)<4">{{['普通会员','畅享会员','悦享会员','臻享会员'][item.userLvType]}}</text>
|
<text v-else>userLvType下标超出:{{item.userLvType}}</text>
|
</view>
|
<view class="type">
|
<text v-if="Number(item.userLvType)==4">惠购权</text>
|
<text v-else-if="Number(item.userLvType)==-1">体验券</text>
|
<text v-else>权益券</text>
|
</view>
|
</view>
|
<view v-else>
|
<text class='num price'>{{item.money?Number(item.money):''}}</text>
|
</view>
|
<view class="pic-num" v-if="item.moneyType==4"></view>
|
<view class="pic-num" v-else>满{{ item.minPrice?Number(item.minPrice):'' }}元可用</view>
|
<span class='corner tp rt'></span>
|
<span class='corner bm rt'></span>
|
</view>
|
<view class='text' :class='item.isUse ? "textGray" : (Number(item.moneyType)==4&&[4,-1].includes(item.userLvType)?"zoneText":"") '>
|
<view class='condition line2'>
|
<span class='line-title quanyi' :class='(item.isUse==true || item.isUse==2)?"gray":""' v-if='item.moneyType===4&&[4,-1].includes(item.userLvType)'>权益</span>
|
<span class='line-title' :class='(item.isUse==true || item.isUse==2)?"gray":""' v-else-if='item.moneyType===4'>权益</span>
|
<span class='line-title' :class='(item.isUse==true || item.isUse==2)?"gray":""' v-else-if='item.useType===1'>通用</span>
|
<span class='line-title' :class='(item.isUse==true || item.isUse==2)?"gray":""' v-else-if='item.useType===3'>品类</span>
|
<span class='line-title' :class='(item.isUse==true || item.isUse==2)?"gray":""' v-else>商品</span>
|
<span v-if="item.moneyType === 4 &&Number(item.userLvType)==4" class="name">仅限臻享专区使用</span>
|
<span v-else-if="item.moneyType === 4" class="name">仅限分类商品使用</span>
|
<span v-else class="name">{{item.name}}</span>
|
</view>
|
<view class='data acea-row row-between-wrapper'>
|
<view v-if="Number(item.moneyType)==4&&Number(item.userLvType)==-1">
|
自动优先使用本券结算
|
</view>
|
<!-- <view v-else-if="Number(item.moneyType)==4">当月有效</view> -->
|
<view v-else-if="item.day>0">领取后{{item.day}}天内可用</view>
|
<view v-else-if="item.useStartTimeStr&& item.useEndTimeStr">
|
<view>{{item.useStartTimeStr}}</view>
|
<view>至{{item.useEndTimeStr}}</view>
|
</view>
|
<view class='bnt gray' :class="Number(item.moneyType)==4&&[4,-1].includes(item.userLvType)?'bg-zone':''" v-if="item.isUse==true">已领取</view>
|
<view class='bnt bg-blue' :class="Number(item.moneyType)==4&&[4,-1].includes(item.userLvType)?'bg-zone':''" v-else
|
@click='getCoupon(item.id,index)'>立即领取</view>
|
</view>
|
<span class='corner tp lt'></span>
|
<span class='corner bm lt'></span>
|
</view>
|
</view>
|
</view>
|
</view>
|
<view class='loadingicon acea-row row-center-wrapper'>
|
<text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{hasCoupons()?loadTitle:'暂无优惠券可领'}}
|
</view>
|
<view class='noCommodity' v-if="!couponsList.length && isShow && !loading">
|
<view class='pictrue'>
|
<!-- 暂无优惠券可领 -->
|
<!-- <image src='https://ossacmall.bluedeer.com.cn/app/static/images/noCoupon.png'></image> -->
|
</view>
|
</view>
|
<home :hideCoupon="true"></home>
|
</view>
|
</template>
|
|
<script>
|
import home from '@/components/home';
|
import {
|
getCoupons,
|
setCouponReceive
|
} from '@/api/api.js';
|
import {
|
toLogin
|
} from '@/libs/login.js';
|
import {
|
mapGetters
|
} from "vuex";
|
export default {
|
components: {home},
|
data() {
|
return {
|
couponsList: [],
|
loading: false,
|
loadend: false,
|
loadTitle: '加载更多', //提示语
|
page: 1,
|
limit: 20,
|
isAuto: false, //没有授权的不会自动授权
|
isShowAuth: false, //是否隐藏授权
|
type: 1,
|
isShow: false,
|
navList: [{
|
type: 1,
|
name: '通用券',
|
count: 0
|
},
|
{
|
type: 2,
|
name: '商品券',
|
count: 0
|
},
|
{
|
type: 3,
|
name: '品类券',
|
count: 0
|
},
|
],
|
count: 0,
|
isPageShow: false,
|
loginBackFn: null,
|
};
|
},
|
computed: mapGetters(['isLogin']),
|
watch: {
|
isLogin: {
|
handler: function(newV, oldV) {
|
if (newV) {
|
this.getUseCoupons();
|
}
|
},
|
deep: true
|
}
|
},
|
onShow() {
|
let that = this;
|
that.isPageShow = true;
|
let pages = getCurrentPages(),
|
currPage = pages[pages.length - 1];
|
console.log('------------------page onShow start-----------------');
|
console.log('route', currPage.route);
|
console.log('options', currPage.options);
|
console.log('------------------page onShow end-----------------');
|
|
|
//会有第三方进入场景
|
if (that.$store.getters.isBelong) {
|
that.belongInfoReadyFn({
|
isRegister: false
|
})
|
} else {
|
uni.$once('BELONG_READY', that.belongInfoReadyFn);
|
}
|
},
|
onHide() {
|
let that = this;
|
that.isPageShow = false;
|
uni.$off('loginFlSuccess', that.registerFn);
|
uni.$off('BELONG_READY', that.belongInfoReadyFn);
|
},
|
onReachBottom: function() {
|
this.getUseCoupons();
|
},
|
methods: {
|
belongInfoReadyFn(data) {
|
let that = this;
|
if (!data.isRegister) {
|
that.checkLoginFn()
|
}
|
},
|
checkLoginFn() {
|
let that = this;
|
let pages = getCurrentPages(),
|
currPage = pages[pages.length - 1];
|
that.addTrack('yy_pageView', {
|
pageTitle_var: '领券中心',
|
pagePath_var: currPage.$page.fullPath,
|
pageType_var: '领券中心'
|
});
|
if (that.$store.getters.isLogin) {
|
that.onLoadFn();
|
} else {
|
toLogin(that);
|
}
|
that.loginBackFn = function() {
|
that.onLoadFn();
|
}
|
uni.$once('loginFlSuccess', that.registerFn);
|
},
|
registerFn() {
|
console.log('registerFn');
|
let that = this;
|
if (that.loginBackFn) {
|
that.loginBackFn();
|
}
|
that.loginBackFn = null;
|
},
|
onLoadFn() {
|
let that = this;
|
that.getUseCoupons();
|
},
|
// 授权关闭
|
authColse: function(e) {
|
this.isShowAuth = e
|
},
|
hasCoupons() {
|
const item = this.couponsList.filter(cou => {
|
return !cou.isUse
|
})
|
if (item && item.length > 0) {
|
return true
|
}
|
return false
|
},
|
getCoupon: function(id, index) {
|
let that = this;
|
let list = that.couponsList;
|
let ids = [];
|
ids.push(id);
|
//领取优惠券
|
setCouponReceive(id).then(function(res) {
|
that.addTrack('yy_getCoupon', {
|
'couponName_var': list[index].name,
|
'couponId_var': id
|
});
|
list[index].isUse = true;
|
that.$set(that, 'couponsList', list);
|
that.$util.Tips({
|
title: '领取成功,请在我的优惠券中查看'
|
});
|
}, function(res) {
|
return that.$util.Tips({
|
title: res
|
});
|
})
|
},
|
/**
|
* 获取领取优惠券列表
|
*/
|
getUseCoupons: function() {
|
let that = this
|
if (that.loadend) return false;
|
if (that.loading) return false;
|
that.loading = true;
|
getCoupons({
|
page: that.page,
|
limit: that.limit,
|
type: that.type
|
}).then(res => {
|
let list = res.data,
|
loadend = list.length < that.limit;
|
let couponsList=list.filter(function(item){
|
return item.isUse?false:true;
|
});
|
let newList = that.$util.SplitArray(couponsList, that.couponsList);
|
that.$set(that, 'couponsList', newList);
|
that.loadend = loadend;
|
that.loadTitle = loadend ? '我也是有底线的' : '加载更多';
|
that.page = that.page + 1;
|
that.loading = false;
|
that.isShow = true;
|
}).catch(err => {
|
that.loading = false;
|
that.loadTitle = '加载更多';
|
});
|
},
|
setType: function(type) {
|
if (this.type !== type) {
|
this.type = type;
|
this.couponsList = [];
|
this.page = 1;
|
this.loadend = false;
|
this.getUseCoupons();
|
}
|
}
|
}
|
}
|
</script>
|
|
<style scoped lang="scss">
|
@keyframes fadeOut {
|
0% {
|
opacity: 1;
|
transform: none;
|
height: 170rpx;
|
}
|
|
99% {
|
opacity: 0;
|
transform: scale(0,0);
|
height: 0;
|
}
|
100%{
|
opacity: 0;
|
transform: scale(0,0);
|
height: 0;
|
overflow: hidden;
|
}
|
}
|
|
.nav {
|
position: fixed;
|
top: 0;
|
left: 0;
|
width: 100%;
|
height: 106rpx;
|
background-color: #F5F5F5;
|
font-size: 30rpx;
|
color: #999999;
|
z-index: 9;
|
font-weight: bold;
|
}
|
|
.nav .acea-row {
|
border-top: 5rpx solid transparent;
|
border-bottom: 5rpx solid transparent;
|
cursor: pointer;
|
}
|
|
.nav .acea-row.on {
|
/* border-bottom-color: #E93323; */
|
color: #000;
|
|
&::after {
|
content: '';
|
position: absolute;
|
width: 60rpx;
|
height: 44rpx;
|
bottom: 12rpx;
|
clip-path: circle(50% at 50% 100%);
|
border: 6rpx solid #FFE20E;
|
border-radius: 50%;
|
}
|
}
|
|
.condition .line-title {
|
width: 90rpx;
|
height: 40rpx !important;
|
line-height: 40rpx !important;
|
padding: 4rpx 12rpx;
|
-webkit-box-sizing: border-box;
|
box-sizing: border-box;
|
background: rgba(4, 199, 99, 1);
|
// border: 1px solid rgba(232, 51, 35, 1);
|
opacity: 1;
|
border-radius: 20rpx;
|
font-size: 24rpx !important;
|
color: #FFFFFF;
|
margin-right: 12rpx;
|
|
&.quanyi {
|
background: #016DCC !important;
|
color: #FFF2A7 !important;
|
}
|
}
|
|
.condition .line-title.gray {
|
border-color: #BBB;
|
color: #bbb;
|
background-color: #F5F5F5;
|
}
|
|
.coupon-list .pic-num {
|
/* color: #FFFFFF; */
|
font-size: 24rpx;
|
}
|
|
.condition .name {
|
font-weight: bold;
|
}
|
|
.money {
|
display: flex;
|
flex-direction: column;
|
justify-content: center;
|
background: #FFE20E !important;
|
border-radius: 14rpx;
|
color: #000000 !important;
|
border-right: 4rpx dashed #F5F5F5;
|
position: relative;
|
width: 260rpx !important;
|
height: 100%;
|
|
&.zoneMoney {
|
background: none !important;
|
|
.vipName {
|
color: #002561;
|
}
|
|
.type {
|
color: #002561;
|
}
|
}
|
|
.give{
|
font-weight: bold;
|
font-size: 19rpx;
|
color: #FFFFFF;
|
text-align: center;
|
font-style: normal;
|
text-transform: none;
|
background-color: #016DCC;
|
border-radius: 14rpx 14rpx 14rpx 0;
|
width: 49rpx;
|
height: 28rpx;
|
line-height: 28rpx;
|
position: absolute;
|
left: 0;
|
top: 0;
|
z-index: 2;
|
}
|
|
.price {
|
font-size: 76rpx !important;
|
}
|
|
.zhe {
|
font-size: 30rpx;
|
}
|
|
.vipName {
|
font-size: 38rpx !important;
|
font-weight: 600;
|
}
|
|
.type {
|
font-size: 27rpx !important;
|
font-weight: 600;
|
}
|
|
&.moneyGray {
|
background: #DDDDDD !important;
|
color: #6f6f6f !important;
|
}
|
|
.num {
|
position: relative;
|
|
&::before {
|
content: '¥';
|
position: absolute;
|
left: -22rpx;
|
top: 8rpx;
|
font-size: 26rpx;
|
// height: 30rpx;
|
// width: 30rpx;
|
}
|
}
|
}
|
|
.coupon-list {
|
margin-top: 20rpx;
|
|
.corner {
|
position: absolute;
|
width: 30rpx;
|
height: 30rpx;
|
background-color: #F5F5F5;
|
border-radius: 30rpx;
|
|
&.rt {
|
right: -15rpx;
|
}
|
|
&.tp {
|
top: -15rpx;
|
}
|
|
&.bm {
|
bottom: -15rpx;
|
}
|
|
&.lt {
|
left: -15rpx;
|
}
|
}
|
|
.fadeout {
|
transform-origin: center top;
|
animation: fadeOut .5s linear both;
|
}
|
|
.item {
|
margin-bottom: 20rpx;
|
// opacity: 1;
|
|
&.zone {
|
background: linear-gradient(to left, #F6C488, #FADDBB, #FEEED6, #FFF4D6);
|
border-radius: 14rpx;
|
// background: linear-gradient(to left, red, blue);
|
}
|
|
&.fadeout {
|
animation: fadeOut 1s linear both;
|
}
|
|
.text {
|
height: 100%;
|
background: #FFE20E;
|
border-radius: 14rpx;
|
position: relative;
|
width: 426rpx !important;
|
|
&.zoneText {
|
background: none !important;
|
color: #002561;
|
|
.data,
|
.name {
|
color: #002561 !important;
|
}
|
}
|
|
&.textGray {
|
background-color: #DDDDDD !important;
|
|
.data,
|
.condition {
|
color: #6f6f6f !important;
|
}
|
|
.gray {
|
background-color: #F5F5F5 !important;
|
color: #979797 !important;
|
}
|
}
|
|
.data {
|
padding-bottom: 16rpx;
|
color: #000000;
|
font-size: 22rpx;
|
}
|
|
.bnt {
|
// width: 158rpx;
|
height: 60rpx;
|
border-radius: 8rpx;
|
line-height: 60rpx;
|
text-align: center;
|
|
&.bg-blue {
|
background-color: #016DCC;
|
}
|
|
&.bg-zone {
|
background-color: #002561;
|
color: #FFF2A7 !important;
|
}
|
}
|
}
|
}
|
}
|
</style>
|