<template>
|
<view class="popCoupon" :class="isShow?'show':''">
|
<!-- <view class="guoqing_box">
|
<image class="guoqing_img" src="https://ossacmall.bluedeer.com.cn/app/static/images/pop_guoqing.png">
|
</image>
|
<view class="guoqing_btn" @click="getCoupon('all')"></view>
|
<view class="guoqing_close" @click="hide()"> </view>
|
</view> -->
|
<view class="box" v-if="true">
|
<view class="title" v-if="pageName == 'zone' && zoneType==3"></view>
|
<view class="title" v-else>恭喜获得商城优惠券</view>
|
<view class="zone-content" v-if="pageName == 'zone' && zoneType==3">
|
签到成功,赠您悦养商城优惠券
|
</view>
|
<view class="couponList" v-else-if="couponList.length">
|
<view class="couponList_item" v-for="(item,index) in couponList" :key="item.uniKey">
|
<view class="line"></view>
|
<block v-if="item.moneyType==2">
|
<view class="amount">{{item.money?Number(item.money)*10:''}}<text class="unit2">折</text></view>
|
</block>
|
<block v-else-if="item.moneyType==4">
|
<view class="amount amountSmall">
|
<block v-if="item.userLvType==4">
|
<text>臻享专区</text><br><text class="unit2">惠购权</text>
|
</block>
|
<block v-else-if="item.userLvType==3">
|
<text>臻享会员</text><br><text class="unit2">权益券</text>
|
</block>
|
<block v-else-if="item.userLvType==2">
|
<text>悦享会员</text><br><text class="unit2">权益券</text>
|
</block>
|
<block v-else-if="item.userLvType==1">
|
<text>畅享会员</text><br><text class="unit2">权益券</text>
|
</block>
|
<block v-else-if="item.userLvType==0">
|
<text>普通会员</text><br><text class="unit2">权益券</text>
|
</block>
|
<block v-else-if="item.userLvType==-1">
|
<text>臻享会员</text><br><text class="unit2">体验券</text>
|
</block>
|
<block v-else>
|
{{item.name}}
|
</block>
|
</view>
|
</block>
|
<block v-else>
|
<view class="amount"><text class="unit1">¥</text>{{item.money}}</view>
|
</block>
|
<view class="info" v-if="item.moneyType!==4">满{{item.minPrice}}元可用</view>
|
<view class="name">
|
<text class="type" v-if="item.type==3">品类</text>
|
<text class="type" v-else-if="item.type==2">商品</text>
|
<text class="type" v-else-if="item.moneyType==4">权益</text>
|
<text class="type" v-else>通用</text>
|
<text v-if="item.moneyType==4&&item.userLvType==4">仅限臻享专区使用</text>
|
<text v-else-if="item.moneyType==4&item.userLvType!==4">仅限分类商品使用</text>
|
<text v-else>{{item.name}}</text>
|
</view>
|
<view class="time">
|
{{item.useStartTimeStr?item.useStartTimeStr:''}}{{(item.useStartTimeStr&&item.useEndTimeStr)?'-':''}}{{item.useEndTimeStr?item.useEndTimeStr:''}}
|
</view>
|
<view class="get_btn" @click="getCoupon(false,item,index)" :class="item.isUse?'used':''">
|
{{item.isUse?'去使用':'立即领取'}}
|
</view>
|
</view>
|
</view>
|
<view class="btn_box" v-if="pageName == 'zone' && zoneType==3">
|
<view class="btn ok" @click="getZoneCoupon()">一键领取</view>
|
</view>
|
<view class="btn_box" v-else-if="!isGetAll">
|
<view class="btn ok" @click="getCoupon('all')">一键领取全部</view>
|
</view>
|
<view class="popCoupon_close" @click="hide()"></view>
|
</view>
|
</view>
|
|
</template>
|
|
<script>
|
import {
|
getStoreZoneAndCouponPopupList,
|
getZoneCouponList
|
} from '@/api/store.js';
|
import {
|
setWholeCouponReceive,
|
setCouponReceive
|
}
|
from '@/api/api.js';
|
export default {
|
name: "popCoupon",
|
props: {
|
pageName: String,
|
zoneId: Number,
|
zoneType:Number
|
},
|
data() {
|
return {
|
isShow: false,
|
couponList: [],
|
isGetAll: false,
|
isClicking:false
|
};
|
},
|
methods: {
|
getZoneCoupon(){
|
this.$util.Tips({
|
title: '领取成功'
|
});
|
this.hide()
|
},
|
getCoupon: function(isWhole, item, index) {
|
let that = this;
|
if (!that.$store.getters.isLogin) {
|
that.goToLogin();
|
return false;
|
}
|
if(that.isClicking){
|
return false;
|
}
|
//领取优惠券
|
if (isWhole) {
|
let nameArr = {
|
index: '首页',
|
addCart: '购物车',
|
user: '我的',
|
zone: '专区',
|
goodsCate: '商品分类',
|
goodsDetails: '商品详情'
|
};
|
this.addTrack('yy_marketPageClick', {
|
pageTitle_var: nameArr[that.pageName] ? nameArr[that.pageName] : '-',
|
firstTabName_var: '-',
|
moduleName_var: '优惠券弹窗',
|
buttonName_var: '一键领取'
|
});
|
let couponIds = [];
|
that.couponList.forEach((item1, index1) => {
|
if (!item1.isUse) {
|
couponIds.push(item1.id);
|
}
|
})
|
if (couponIds.length > 0) {
|
var useNum = 0;
|
that.isClicking=true;
|
uni.showLoading()
|
setWholeCouponReceive({
|
couponIds: couponIds,
|
}).then(function(res) {
|
uni.hideLoading();
|
that.isClicking=false;
|
let nameArr = [];
|
let idArr = [];
|
that.couponList.forEach((item1, index1) => {
|
if (!item1.isUse) {
|
that.couponList[index1].isUse = true;
|
nameArr.push(item1.name);
|
idArr.push(item1.id);
|
}
|
});
|
that.isGetAll = true;
|
that.hide();
|
if (that.pageName == 'index' || that.pageName == 'addcart' || that
|
.pageName == 'user') {
|
that.$parent.$refs.showConfirm.show({
|
title: '领取成功',
|
content: '优惠券已收入囊中!可在<span class="strong" style="color:#016DCC;">「我的优惠券」</span>中查看,快去挑选心仪好物吧~',
|
center: true,
|
hideCancel: true,
|
showClose: true,
|
confirmText: '去使用',
|
success: function(res) {
|
that.hide();
|
uni.switchTab({
|
url: '/pages/goods_cate/goods_cate'
|
})
|
}
|
});
|
} else {
|
that.$util.Tips({
|
title: '领取成功'
|
});
|
}
|
that.addTrack('yy_getCoupon', {
|
'couponName_var': nameArr.join(','),
|
'couponId_var': idArr.join(',')
|
});
|
if (that.pageName == 'index') {
|
that.$emit('resetCoupon', idArr)
|
}else if (that.pageName == 'goodsDetails') {
|
console.log(22222,that.pageName );
|
that.$emit('getInitData',false)
|
}
|
}).catch(err => {
|
uni.hideLoading();
|
that.isClicking=false;
|
return that.$util.Tips({
|
title: (err && err.message) ? err.message : err
|
});
|
});
|
} else {
|
that.isGetAll = true;
|
that.hide();
|
}
|
} else {
|
if (item.isUse) {
|
if (that.pageName == 'index' || that.pageName == 'addcart' || that.pageName == 'user') {
|
that.hide();
|
that.isClicking=true;
|
var timer=setTimeout(()=>{
|
clearTimeout(timer);
|
that.isClicking=false;
|
},500)
|
if (item.appId && item.toPath) {
|
that.goToThird(item.toPath, item.appId);
|
} else if (item.toPath) {
|
if (that.isTabLink(item.toPath)) {
|
uni.switchTab({
|
url: item.toPath
|
})
|
} else {
|
uni.navigateTo({
|
url: item.toPath
|
})
|
}
|
} else {
|
uni.switchTab({
|
url: '/pages/goods_cate/goods_cate'
|
})
|
}
|
} else {
|
that.hide();
|
}
|
} else {
|
that.isClicking=true;
|
uni.showLoading()
|
setCouponReceive(item.id).then(function(res) {
|
that.isClicking=false;
|
uni.hideLoading()
|
that.addTrack('yy_getCoupon', {
|
'couponName_var': item.name,
|
'couponId_var': item.id
|
});
|
that.$set(that.couponList[index], 'isUse', true);
|
that.$util.Tips({
|
title: '领取成功'
|
});
|
if (that.pageName == 'index') {
|
that.$emit('resetCoupon', [item.id])
|
}else if (that.pageName == 'goodsDetails') {
|
console.log('11111111',that.pageName );
|
that.$emit('getInitData',false)
|
}
|
}).catch(err => {
|
that.isClicking=false;
|
uni.hideLoading()
|
return that.$util.Tips({
|
title: (err && err.message) ? err.message : err
|
});
|
})
|
}
|
}
|
},
|
show(parentCouponList) {
|
let that = this;
|
this.hide()
|
return false;
|
function getCouponList(couponList) {
|
if (couponList.length > 0) {
|
couponList.map((item, index) => {
|
item.uniKey = 'popCouponList' + index;
|
})
|
that.isGetAll = false;
|
that.$set(that, 'couponList', couponList);
|
that.isShow = true;
|
} else {
|
that.hide()
|
}
|
}
|
if (that.pageName == 'zone') {
|
if(that.zoneType==3){
|
//签到专区
|
const hasShown=uni.getStorageSync(that.zoneId+'-hasCoupon');
|
if(!hasShown){
|
that.isShow = true;
|
uni.setStorageSync(that.zoneId+'-hasCoupon',true);
|
}
|
} else {
|
getZoneCouponList(that.zoneId).then(res => {
|
getCouponList((res.data && res.data.length) > 0 ? res.data : []);
|
});
|
}
|
} else {
|
getStoreZoneAndCouponPopupList({}).then(res => {
|
getCouponList((res.data && res.data.storeCouponList) ? res.data.storeCouponList : []);
|
});
|
}
|
|
},
|
hide() {
|
this.isShow = false;
|
this.$emit('hide')
|
},
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.popCoupon {
|
position: fixed;
|
left: 0;
|
top: 0;
|
width: 100%;
|
height: 100%;
|
z-index: 11111;
|
background-color: rgba(0, 0, 0, .7);
|
display: none;
|
|
&.show {
|
display: block;
|
}
|
|
.box {
|
width: 600rpx;
|
padding: 90rpx 0 70rpx 0;
|
background: url("https://ossacmall.bluedeer.com.cn/app/static/images/confirm_bg.png") center -120rpx / 100% auto no-repeat;
|
background-color: #f5f5f5;
|
position: absolute;
|
left: 50%;
|
top: 50%;
|
transform: translate(-50%, -50%);
|
border-radius: 14rpx;
|
}
|
|
.popCoupon_close {
|
position: absolute;
|
right: 10rpx;
|
top: 10rpx;
|
width: 90rpx;
|
height: 90rpx;
|
background: url("https://ossacmall.bluedeer.com.cn/app/static/images/pop_close.png") center center/30rpx auto no-repeat;
|
}
|
|
.title {
|
lineh-height: 40rpx;
|
font-size: 30rpx;
|
font-weight: bold;
|
color: #000000;
|
text-align: center;
|
}
|
|
.couponList {
|
width: 100%;
|
max-height: 100vw;
|
overflow-y: scroll;
|
margin-top: 50rpx;
|
margin-bottom: 50rpx;
|
}
|
.zone-content{
|
font-size: 30rpx;
|
font-weight: bold;
|
color: #000000;
|
text-align: center;
|
margin-top: 50rpx;
|
margin-bottom: 50rpx;
|
}
|
|
.couponList_item {
|
position: relative;
|
width: 520rpx;
|
height: 146rpx;
|
color: #000000;
|
background: #FFE20E;
|
border-radius: 11rpx;
|
overflow: hidden;
|
margin: 0 auto 20rpx auto;
|
|
&:last-child {
|
margin-bottom: 0;
|
}
|
|
&:before,
|
&:after {
|
content: '';
|
display: block;
|
width: 18rpx;
|
height: 18rpx;
|
position: absolute;
|
left: 205rpx;
|
margin-left: -9rpx;
|
background: #f5f5f5;
|
border-radius: 50%;
|
z-index: 2;
|
}
|
|
&:before {
|
top: -9rpx;
|
}
|
|
&:after {
|
bottom: -9rpx;
|
}
|
|
.line {
|
height: 100%;
|
border-left: 1px dashed #f5f5f5;
|
position: absolute;
|
left: 205rpx;
|
top: 0;
|
}
|
|
.amount {
|
font-size: 57rpx;
|
line-height: 1em;
|
position: absolute;
|
left: 102rpx;
|
top: 30rpx;
|
width: max-content;
|
transform: translateX(-50%);
|
font-weight: bold;
|
text-align: center;
|
|
&.amountSmall {
|
font-size: 30rpx;
|
padding-top: 15rpx;
|
}
|
|
.unit1 {
|
font-size: 22rpx;
|
position: absolute;
|
left: -15rpx;
|
top: -18rpx;
|
}
|
|
.unit2 {
|
font-size: 23rpx;
|
line-height: 30rpx;
|
}
|
}
|
|
.info {
|
font-size: 19rpx;
|
line-height: 29rpx;
|
position: absolute;
|
left: 102rpx;
|
top: 93rpx;
|
width: max-content;
|
transform: translateX(-50%);
|
}
|
|
.get_btn {
|
width: 111rpx;
|
font-size: 19rpx;
|
line-height: 40rpx;
|
text-align: center;
|
background: #016DCC;
|
color: #ffffff;
|
border-radius: 6rpx;
|
position: absolute;
|
right: 19rpx;
|
bottom: 19rpx;
|
}
|
|
.name {
|
font-weight: bold;
|
font-size: 23rpx;
|
line-height: 30rpx;
|
position: absolute;
|
left: 218rpx;
|
top: 30rpx;
|
display: flex;
|
|
.type {
|
border-radius: 15rpx;
|
background-color: #04C763;
|
padding: 0 12rpx;
|
font-size: 17rpx;
|
color: #ffffff;
|
margin-right: 10rpx;
|
}
|
}
|
|
.time {}
|
}
|
|
.btn_box {
|
display: flex;
|
display: flex;
|
justify-content: space-around;
|
margin: 0 auto;
|
text-align: center;
|
}
|
|
.btn {
|
width: 237rpx;
|
font-size: 27rpx;
|
line-height: 80rpx;
|
background: #002561;
|
color: #ffffff;
|
border-radius: 11rpx;
|
}
|
|
.ok {
|
background: #016DCC;
|
}
|
}
|
|
.guoqing_box {
|
width: 643rpx;
|
height: 1024rpx;
|
position: absolute;
|
left: 50%;
|
top: 50%;
|
transform: translate(-50%, -50%);
|
|
.guoqing_img {
|
width: 643rpx;
|
height: 894rpx;
|
}
|
|
.guoqing_btn {
|
width: 360rpx;
|
height: 82rpx;
|
position: absolute;
|
left: 50%;
|
margin-left: -180rpx;
|
bottom: 130rpx;
|
}
|
|
.guoqing_close {
|
position: absolute;
|
left: 50%;
|
margin-left: -45rpx;
|
bottom: 0;
|
width: 90rpx;
|
height: 90rpx;
|
background: url("https://ossacmall.bluedeer.com.cn/app/static/images/pop_close2.png") center center/78rpx auto no-repeat;
|
|
}
|
}
|
</style>
|