<template>
|
<view>
|
<view class="top-tabbar">
|
<view :class="state_active == 0 ? 'tab-item active' : 'tab-item'" @click="stateFunc(0)">未使用</view>
|
<view :class="state_active == 1 ? 'tab-item active' : 'tab-item'" @click="stateFunc(1)">已使用</view>
|
<view :class="state_active == 2 ? 'tab-item active' : 'tab-item'" @click="stateFunc(2)">已过期</view>
|
</view>
|
|
<!--列表-->
|
<scroll-view scroll-y="true" class="scroll-Y" :style="'height:' + scrollviewHigh + 'px;'" lower-threshold="50"
|
@scrolltoupper="scrolltoupperFunc" @scrolltolower="scrolltolowerFunc">
|
<view class="p30">
|
<view class="item-wrap mb20" v-for="(item, index) in supList" :key="index" v-if="item.list.length > 0">
|
<view class="d-c-c">
|
<view class="d-f flex-1">
|
<span class="icon iconfont icon-dianpu1"></span>
|
<view class="con_tit">{{item.name}}</view>
|
</view>
|
<view>
|
<button v-if="item.shop_supplier_id>0" class="btn-red-border btn-to-shop" @click="gotoShopPage(item.shop_supplier_id)">进店</button>
|
</view>
|
</view>
|
<view v-for="(sup_item,sup_index) in item.list" :key="sup_index" class="coupon_item"
|
v-if="item.list.length > 0">
|
<view class="coupon-box coupon-item" :class="sup_item.is_expire==0&&sup_item.is_use==0?'coupon-item-'+sup_item.color.text:'coupon-item-normal'">
|
<!--装饰用的小圆-->
|
<!-- <view class="circles circles-right">
|
<text v-for="(circle,num) in 5" :key="num"></text>
|
</view> -->
|
<!-- <view class="info">
|
<view >{{item.coupon_type.text}}</view>
|
</view> -->
|
|
<view class="operation d-b-c w-b">
|
<view class="flex-1 coupon-content">
|
<template v-if="sup_item.coupon_type.value==30">
|
<view class="f26 fb">
|
<text v-if="sup_item.shop_supplier_id>0">[{{sup_item.supplier.name}}]</text>
|
<text>{{sup_item.name}}</text>
|
</view>
|
</template>
|
<template v-else>
|
<view class="f26 fb" v-if="sup_item.apply_range==10">
|
<text v-if="sup_item.shop_supplier_id>0">[{{sup_item.supplier.name}}]{{sup_item.apply_range==10?'店铺通用券':sup_item.name}}</text>
|
<text v-else>平台通用券</text>
|
</view>
|
<view class="f26 fb" v-else>
|
<text>限购</text>
|
<text v-if="sup_item.shop_supplier_id>0">[{{sup_item.supplier.name}}]店铺</text>
|
<text>部分商品</text>
|
</view>
|
</template>
|
<view class="f24">{{sup_item.start_time.text}}至{{sup_item.end_time.text}}</view>
|
</view>
|
<view class="btns d-c-c d-c">
|
<view>
|
<template v-if=" sup_item.coupon_type.value == 10 ">
|
<view class="price" >
|
<text>¥</text>
|
<text class="f40 fb">{{ sup_item.reduce_price }}</text>
|
</view>
|
</template>
|
<template v-if="sup_item.coupon_type.value == 20 ">
|
<text class="f40 fb">{{ sup_item.discount }}</text><text>折</text>
|
</template>
|
</view>
|
<view class="f24" v-if=" sup_item.coupon_type.value == 30 ">
|
限到店使用
|
</view>
|
<view class="f24" v-else>
|
<template v-if="sup_item.min_price ==0">
|
无低消门槛
|
</template>
|
<template v-if="sup_item.min_price >0">
|
满{{sup_item.min_price}}元可用
|
</template>
|
</view>
|
<button type="default" v-if="sup_item.coupon_type.value == 10 && sup_item.use_permission !=1" class="btn-gray coupon-text mt10" v-on:click.stop="gotoPages(sup_item)">
|
查看券码
|
</button>
|
<button type="default" v-if="sup_item.state.value>0 && sup_item.use_permission !=2" class="btn-gray coupon-text mt10" v-on:click.stop="gotoPages(sup_item,(sup_item.coupon_type.value == 30?0:1))">
|
{{sup_item.coupon_type.value == 30?'查看券码':'立即使用'}}
|
</button>
|
<button type="default" v-else class="btn-gray mt30" v-on:click.stop>
|
{{ sup_item.state.text }}
|
</button>
|
</view>
|
</view>
|
</view>
|
</view>
|
|
|
|
|
|
<view class="">
|
<view class="bottom-refresh">
|
<view class="d-c-c p30" v-if="loading">
|
<text class="gray3">加载中...</text>
|
</view>
|
<view class="d-c-c p30" v-if="no_more ">
|
<text class="gray3">~~加载完成~~</text>
|
</view>
|
</view>
|
</view>
|
<view class="d-c-c p30" v-if="DataList.length==0 && !loading">
|
<text class="iconfont icon-wushuju"></text>
|
<text class="cont">亲,暂无相关记录哦</text>
|
</view>
|
</view>
|
</view>
|
</scroll-view>
|
|
<!--核销二维码-->
|
<Popup :show="isCodeImg" type="middle" @hidePopup="hideCodePopupFunc">
|
<view class="ww100 p20 box-s-b">
|
<image class="ww100" :src="codeImg" mode="widthFix"></image>
|
</view>
|
</Popup>
|
|
</view>
|
</template>
|
|
<script>
|
import Popup from '@/components/uni-popup.vue';
|
export default {
|
components: {
|
Popup
|
},
|
data() {
|
return {
|
/*手机高度*/
|
phoneHeight: 0,
|
/*可滚动视图区域高度*/
|
scrollviewHigh: 0,
|
/*状态选中*/
|
state_active: 0,
|
/*列表*/
|
DataList: {},
|
no_more: false,
|
loading: false,
|
data_type: 'not_use',
|
supList: [],
|
isCodeImg:false,
|
codeImg: ''
|
};
|
},
|
mounted() {
|
/*初始化*/
|
this.init();
|
/*获取数据*/
|
this.getData();
|
},
|
methods: {
|
/*初始化*/
|
init() {
|
let self = this;
|
uni.getSystemInfo({
|
success(res) {
|
self.phoneHeight = res.windowHeight;
|
// 计算组件的高度
|
let view = uni.createSelectorQuery().select('.top-tabbar');
|
view.boundingClientRect(data => {
|
let h = self.phoneHeight - data.height;
|
self.scrollviewHigh = h;
|
}).exec();
|
}
|
});
|
},
|
|
/*获取数据*/
|
getData() {
|
|
let self = this;
|
uni.showLoading({
|
title: '加载中'
|
});
|
let data_type = self.data_type;
|
self._get('user.coupon/lists', {
|
data_type: data_type,
|
}, function(res) {
|
uni.hideLoading();
|
self.DataList = res.data.list;
|
self.getSup();
|
});
|
},
|
gotoShopPage(shop_supplier_id) {
|
uni.setStorageSync('shop_supplier_id', shop_supplier_id)
|
this.gotoPage('/pages/shop/shop?shop_supplier_id=' + shop_supplier_id)
|
},
|
/* 优惠券分类 */
|
getSup() {
|
let self = this;
|
let supList = [];
|
let platformCoupon = {
|
name: "平台优惠券",
|
list: []
|
};
|
self.DataList.forEach((item, index) => {
|
item.min_price = parseFloat(item.min_price);
|
item.reduce_price = parseFloat(item.reduce_price);
|
console.log(index)
|
if (item.supplier == null) {
|
platformCoupon.list.push(item)
|
} else {
|
if (supList == '') {
|
supList.push({
|
name: item.supplier.name,
|
shop_supplier_id: item.shop_supplier_id,
|
list: [item]
|
})
|
} else {
|
let flag = true;
|
supList.forEach((sup_item, sup_index) => {
|
if (sup_item.name === item.supplier.name) {
|
flag = false;
|
sup_item.list.push(item)
|
}
|
})
|
if (flag) {
|
supList.push({
|
name: item.supplier.name,
|
list: [item]
|
})
|
}
|
}
|
}
|
})
|
console.log(supList)
|
supList.push(platformCoupon);
|
self.supList = supList;
|
},
|
/*状态切换*/
|
stateFunc(e) {
|
let self = this;
|
if (self.state_active != e) {
|
if (e == 0) {
|
self.data_type = 'not_use';
|
}
|
if (e == 1) {
|
self.data_type = 'is_use';
|
}
|
if (e == 2) {
|
self.data_type = 'is_expire';
|
}
|
self.state_active = e;
|
self.getData();
|
}
|
},
|
|
/*可滚动视图区域到顶触发*/
|
scrolltoupperFunc() {
|
console.log('滚动视图区域到顶');
|
},
|
|
/*可滚动视图区域到底触发*/
|
scrolltolowerFunc() {
|
console.log('滚动视图区域到底');
|
},
|
|
/*查看规则*/
|
lookRule(item) {
|
item.rule = true;
|
},
|
|
/*关闭规则*/
|
closeRule(item) {
|
item.rule = false;
|
},
|
gotoPages(sup_item,type=0) {
|
if(type){
|
this.gotoPage('/pages/product/category');
|
}else if (sup_item.apply_range != 10 || sup_item.coupon_type.value == 30) {
|
this.gotoPage('/pages/user/my-coupon/my-detail?user_coupon_id='+ sup_item.user_coupon_id+'&apply_range='+sup_item.apply_range);
|
}else if (sup_item.use_permission != 1 || sup_item.coupon_type.value == 10) {
|
//满减券 具有线下核销权限 byyj 2024.1.16
|
this.getQRCode(sup_item.user_coupon_id);
|
} else {
|
this.gotoPage('/pages/product/category');
|
}
|
},
|
/*满减券核销码*/
|
getQRCode(user_coupon_id) {
|
let self = this;
|
self._get(
|
'user.coupon/qrcode', {
|
user_coupon_id: user_coupon_id,
|
source: self.getPlatform()
|
},
|
function(res) {
|
self.isCodeImg = true;
|
self.codeImg = res.data.qrcode;
|
}
|
);
|
},
|
/*关闭核销二维码*/
|
hideCodePopupFunc() {
|
this.isCodeImg = false;
|
},
|
}
|
};
|
</script>
|
|
<style>
|
.d-f {
|
display: flex;
|
align-items: center;
|
}
|
|
.icon-dianpu1 {
|
margin-right: 15rpx;
|
}
|
|
.coupon_type {
|
padding: 10rpx 20rpx;
|
position: absolute;
|
z-index: 100;
|
color: #ffffff;
|
right: 0;
|
top: 0;
|
background: #cacaca80;
|
height: 36rpx;
|
border-bottom-left-radius: 18rpx;
|
}
|
|
.con_tit {
|
font-weight: 800;
|
font-size: 31rpx
|
}
|
|
.coupon_item {
|
margin: 20rpx 0;
|
}
|
|
.range_item {
|
border: 1rpx solid #D9D9D9;
|
border-top: none;
|
padding: 8rpx;
|
border-bottom-left-radius: 10rpx;
|
border-bottom-right-radius: 10rpx;
|
color: #666666;
|
box-shadow: 0 0 8rpx rgba(0, 0, 0, 0.1);
|
}
|
/* 新样式 by lyzflash */
|
/* 新样式 by lyzflash */
|
.coupon-box {
|
border-radius: 12rpx;
|
height: 200rpx;
|
}
|
.coupon-box .circles {
|
left: auto;
|
right: 0;
|
top: 70rpx;
|
bottom: 70rpx;
|
}
|
.coupon-box .circles-right text {
|
border-radius: 10rpx 0 0 10rpx;
|
width: 8rpx;
|
height: 15rpx;
|
background: #f6f6f6;
|
}
|
.coupon-box .operation .coupon-content {
|
position: relative;
|
background-color: #FFFFFF;
|
color: #333333;
|
padding: 20rpx 30rpx;
|
}
|
.coupon-box .coupon-content::before,
|
.coupon-box .coupon-content::after {
|
position: absolute;
|
display: block;
|
content: '';
|
width: 22rpx;
|
height: 11rpx;
|
background: #EEEEEE;
|
z-index: 10;
|
}
|
.coupon-box .coupon-content::before {
|
top: 0;
|
right: -10rpx;
|
border-radius: 0 0 15rpx 15rpx;
|
}
|
.coupon-box .coupon-content::after {
|
bottom: 0;
|
right: -10rpx;
|
border-radius: 15rpx 15rpx 0 0;
|
}
|
.coupon-box .btns {
|
width: 150rpx;
|
padding: 0 20rpx;
|
background: transparent;
|
}
|
.coupon-box.coupon-item- .btns {
|
/* background-color: #BEBEBE; */
|
}
|
.coupon-box .btns button {
|
width: auto;
|
background: #FFFFFF;
|
border-radius: 60rpx;
|
font-size: 22rpx;
|
padding: 4rpx 20rpx;
|
}
|
.coupon-box .operation {
|
padding-left: 0;
|
margin-left: 4rpx;
|
border-radius: 12rpx;
|
}
|
.coupon-product {
|
width: 100%;
|
}
|
.coupon-product-item image {
|
width: 124rpx;
|
height: 124rpx;
|
border-radius: 12rpx;
|
background-color: rgba(0, 0, 0, 0.1);
|
}
|
.coupon-box .coupon-sp .btns {
|
width: 446rpx;
|
background: #FFFFFF;
|
position: relative;
|
color: #333333;
|
box-sizing: border-box;
|
padding: 20rpx;
|
}
|
.coupon-box .coupon-sp .btns:after {
|
position: absolute;
|
content: " ";
|
border-left: 2rpx dashed #EEEEEE;
|
left: -2rpx;
|
height: 100%;
|
}
|
.coupon-sp .coupon-product-item image {
|
width: 180rpx;
|
height: 180rpx;
|
}
|
.btns-box {
|
width: 100%;
|
padding-top: 30rpx;
|
border-top: 1rpx solid #eee;
|
}
|
.btns-box .btns-sp {
|
width: 150rpx;
|
text-align: center;
|
}
|
.btns-box .btns-sp button {
|
color: #FFFFFF;
|
display: inline-block;
|
}
|
.coupon-item-red .btns-sp button {
|
background: #e62423;
|
}
|
|
.coupon-item-blue .btns-sp button {
|
background: #178ed9;
|
/* linear-gradient(-128deg, #1fd6ff, #3661ff); */
|
}
|
|
.coupon-item-violet .btns-sp button {
|
background: #ab0bf6;
|
/* linear-gradient(-128deg, #d63efc, #6600c3); */
|
}
|
|
.coupon-item-yellow .btns-sp button {
|
background: #f4a50b;
|
/* linear-gradient(-128deg, #ffe31f, #ffaf36); */
|
}
|
|
.coupon-item-gray .btns-sp button {
|
background: #999999;
|
/* linear-gradient(-128deg, #888888, #999999); */
|
}
|
.coupon-item .coupon-sp .coupon-content {
|
align-items: center;
|
}
|
.coupon-item-normal {
|
background: #BEBEBE;
|
}
|
.coupon-item-normal .btns button {
|
color: #BEBEBE;
|
}
|
.coupon-item-normal .btns-sp button {
|
background: #BEBEBE;
|
color: #FFFFFF;
|
}
|
button.btn-to-shop {
|
line-height: 45rpx;
|
border-radius: 60rpx;
|
font-size: 26rpx;
|
}
|
</style>
|