2022-04-25 06:38:26 +00:00
|
|
|
|
<template>
|
|
|
|
|
<view>
|
|
|
|
|
<!-- 状态栏 -->
|
|
|
|
|
<status-nav :titleVal="'优惠券'" :statusTitle="true"></status-nav>
|
|
|
|
|
<view id="daoh" class="bacf pad-zy40 pad-sx20 isTopf fon28 col3 disjbac" :style="{top:statusHeight+'px'}">
|
2022-04-27 02:10:31 +00:00
|
|
|
|
<view @tap="chooseNav(indexn)" :class="isStatus==indexn?' bold':''" class="posir" :style="{color: isStatus==indexn ? publicColor : ''}" v-for="(itemn,indexn) in navList" :key="indexn">
|
|
|
|
|
{{itemn}}
|
|
|
|
|
<view v-if="isStatus==indexn" class="isWen" :style="{background: publicColor}"></view>
|
|
|
|
|
</view>
|
2022-04-25 06:38:26 +00:00
|
|
|
|
</view>
|
|
|
|
|
<!-- 列表 -->
|
|
|
|
|
<view :style="{paddingTop: (statusHeight+chuTop+15)+'px'}" class="pad-zy32">
|
|
|
|
|
<view class="pad-x30">
|
|
|
|
|
<view v-if="dataList.length!=0" class="mar-x20 animated fadeInLeft" v-for="(item,index) in dataList" :key="index">
|
|
|
|
|
<view style="height: 200rpx;" class="disjbac posir">
|
|
|
|
|
<view class="disjcac fc recerve-left" style="width: 218rpx;height: 200rpx;flex-shrink: 0;text-align: center;color: #FFFFFF;">
|
|
|
|
|
<image v-if="item.statusNum!=0 && item.statusNum!=2" class="posia quan-img" src="/static/public/quan-left-two.png" mode=""></image>
|
|
|
|
|
<image v-else class="posia quan-img" src="/static/public/quan-left.png" mode=""></image>
|
|
|
|
|
<view class="posir disjcac fc" style="z-index: 1;">
|
|
|
|
|
<view class="fon28 mar-s20 mar-x36"><span v-if="!item.isTiyan && !item.isZhek">¥</span><span class="bold" style="font-size: 56rpx;">{{item.num}}</span></view>
|
|
|
|
|
<view v-if="item.statusNum==0 || item.statusNum==2" @tap="useEv(index)" class="fon24 quan-btn">{{item.statusNum==2?'立即领取':'立即使用'}}</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="quan-right-box">
|
|
|
|
|
<view class="fon28 col3 mar-s20">{{item.title}}</view>
|
|
|
|
|
<view class="fon24 col80">满{{item.manPrice}}元可使用</view>
|
|
|
|
|
<view class="fon20 col80 mar-x20">有效期:{{item.startTime}}至{{item.endTime}}</view>
|
|
|
|
|
</view>
|
|
|
|
|
<image v-if="item.statusNum==1" class="posia quan-use" src="/static/public/quan-use.png" mode=""></image>
|
|
|
|
|
<image v-if="item.statusNum==3" class="posia quan-use" src="/static/public/quan-over.png" mode=""></image>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<block v-if="loading">
|
|
|
|
|
<nothing-page v-if="dataList.length==0" :content="['暂无可使用优惠券','暂无已使用优惠券','暂无可领取优惠券','暂无已过期优惠券'][isStatus]"></nothing-page>
|
|
|
|
|
</block>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<!-- 体验券使用弹框 -->
|
|
|
|
|
<view v-if="isTY" @tap="isTY=false" class="disjcac tc quan-tk-box" catchtouchmove="return">
|
|
|
|
|
<view class="bacf width100 radius20 pad30 posir" style="margin: 0 128rpx;" @tap.stop="isTY=true">
|
|
|
|
|
<view class="fon28 col3">体验券使用</view>
|
|
|
|
|
<view class="mar-sx30">
|
|
|
|
|
<!-- <image :src="tyImg" class="quan-tk-em" style="width: 325rpx;height: 325rpx;" mode="aspectFill"></image> -->
|
|
|
|
|
<yz-qr ref="qrPath" :text="text" :size="sizeq" :colorDark="colorDark" :colorLight="colorLight"></yz-qr>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="fon24 col3 mar-s40 mar-x20">工作人员扫码使用体验券</view>
|
|
|
|
|
<image @tap.stop="closeQuanEv" src="/static/public/closequan.png" class="posia quan-tk-btn" mode=""></image>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<!-- 用户信息授权,手机号授权 -->
|
|
|
|
|
<auth-userInfo-mobileInfo></auth-userInfo-mobileInfo>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import yzQr from '@/components/yz-qr/yz-qr.vue';
|
|
|
|
|
export default {
|
|
|
|
|
components:{
|
|
|
|
|
yzQr
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
chuTop:'',
|
|
|
|
|
navList:['未使用','已使用','可领取','已过期'],
|
|
|
|
|
isStatus:0,
|
|
|
|
|
dataList:[],
|
|
|
|
|
zcList:[],
|
|
|
|
|
isTY:false,
|
|
|
|
|
page:1,
|
|
|
|
|
size:10,
|
|
|
|
|
quanStatus:'normal',//优惠券状态
|
|
|
|
|
loading:false,
|
|
|
|
|
tyImg:'',//立即使用体验券时,弹框中的img
|
|
|
|
|
canvasQrPath: '',
|
|
|
|
|
text: 'hello',
|
|
|
|
|
sizeq: 162,
|
|
|
|
|
colorDark: '#000000',
|
|
|
|
|
colorLight: '#ffffff',
|
|
|
|
|
timer:null,
|
|
|
|
|
secret:''
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
computed:{
|
|
|
|
|
statusHeight() {
|
|
|
|
|
return this.$store.state.statusHeight
|
2022-04-27 02:10:31 +00:00
|
|
|
|
},
|
|
|
|
|
// 主题颜色
|
|
|
|
|
publicColor() {
|
|
|
|
|
return this.$store.state.publicColor
|
|
|
|
|
},
|
2022-04-25 06:38:26 +00:00
|
|
|
|
},
|
|
|
|
|
onLoad() {
|
|
|
|
|
const query = wx.createSelectorQuery()
|
|
|
|
|
query.select('#daoh').boundingClientRect((rect) => {
|
|
|
|
|
// console.log('状态栏+标题栏:',rect);
|
|
|
|
|
this.chuTop = rect.height;
|
|
|
|
|
}).exec()
|
|
|
|
|
if(uni.getStorageSync('phone_active')!=0 && uni.getStorageSync('is_active')!=0){
|
|
|
|
|
this.checkAllList(0);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onUnload() {
|
|
|
|
|
this.closeQuanEv();
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
checkAllList(index){//查询所有优惠券列表
|
|
|
|
|
let params = {
|
|
|
|
|
status: this.quanStatus,//留空默获取全部 normal=正常(未使用) used=已使用 invalid=已失效 waiting=待领取
|
|
|
|
|
page:this.page,
|
|
|
|
|
size:this.size
|
|
|
|
|
}
|
|
|
|
|
this.$requst.post('user/get-coupon-list',params).then(res=>{
|
|
|
|
|
if(res.code==0){
|
|
|
|
|
this.dataList = [];
|
|
|
|
|
this.zcList = [];
|
|
|
|
|
if(res.data.length!=0){
|
|
|
|
|
res.data.forEach(item=>{
|
|
|
|
|
let leix = false;
|
|
|
|
|
if(item.type=='taste') leix = true;
|
|
|
|
|
let obj = {
|
|
|
|
|
id:item.id,
|
|
|
|
|
num:item.amount/100,
|
|
|
|
|
title:item.name,
|
|
|
|
|
cover:this.$http + item.cover,
|
|
|
|
|
manPrice:item.condition/100,
|
|
|
|
|
startTime:item.begin_at.slice(0,10),
|
|
|
|
|
endTime:item.end_at.slice(0,10),
|
|
|
|
|
isTiyan:leix,
|
|
|
|
|
isZhek:false,
|
|
|
|
|
statusNum:index
|
|
|
|
|
}
|
|
|
|
|
this.dataList.push(obj);//渲染的列表
|
|
|
|
|
this.zcList.push(obj);//暂存的列表
|
|
|
|
|
})
|
|
|
|
|
this.checkList(index);
|
|
|
|
|
}
|
|
|
|
|
this.loading = true;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
chooseNav(index){
|
|
|
|
|
this.isStatus = index;
|
|
|
|
|
if(index==0) this.quanStatus = 'normal';//未使用
|
|
|
|
|
if(index==1) this.quanStatus = 'used';//已使用
|
|
|
|
|
if(index==2) this.quanStatus = 'waiting';//待领取
|
|
|
|
|
if(index==3) this.quanStatus = 'invalid';//已过期
|
|
|
|
|
this.loading = false;
|
|
|
|
|
this.checkAllList(index);
|
|
|
|
|
},
|
|
|
|
|
checkList(index){
|
|
|
|
|
this.dataList = this.zcList.filter(item=>item.statusNum==index);
|
|
|
|
|
},
|
|
|
|
|
useEv(index){
|
|
|
|
|
if(this.dataList[index].statusNum==2) {
|
|
|
|
|
this.$requst.post('user/get-coupon',{coupon_id:this.dataList[index].id}).then(res=>{
|
|
|
|
|
if(res.code==0){
|
|
|
|
|
this.$toolAll.tools.showToast('领取成功');
|
|
|
|
|
this.checkAllList(this.isStatus);
|
|
|
|
|
} else {
|
|
|
|
|
this.$toolAll.tools.showToast(res.msg);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
if(this.dataList[index].isTiyan==false && this.dataList[index].statusNum==0) {
|
|
|
|
|
uni.navigateTo({url:'/pages/tabbar/shop/shop'})
|
|
|
|
|
}
|
|
|
|
|
if(this.dataList[index].isTiyan==true && this.dataList[index].statusNum==0){
|
|
|
|
|
this.tyImg = this.dataList[index].cover;
|
|
|
|
|
this.$requst.post('user/exhibition-experience-coupon',{coupon_id:this.dataList[index].id}).then(res=>{
|
|
|
|
|
if(res.code==0){
|
|
|
|
|
this.isTY = true;
|
|
|
|
|
this.text = `${this.dataList[index].id}HtrueH${res.data.secret}H${uni.getStorageSync('userId')}`;
|
|
|
|
|
this.secret = res.data.secret;
|
|
|
|
|
} else this.$toolAll.tools.showToast(res.msg);
|
|
|
|
|
},error=>{})
|
|
|
|
|
this.timer = setInterval(()=>{
|
|
|
|
|
this.$requst.post('staff/coupon/write-off-experience-couponQuery',{coupon_id:this.dataList[index].id,secret:this.secret}).then(res=>{
|
|
|
|
|
if(res.code==0){
|
|
|
|
|
// if(res.data.result==0){
|
|
|
|
|
this.$toolAll.tools.showToast('使用成功');
|
|
|
|
|
this.isTY = false;
|
|
|
|
|
clearInterval(this.timer);
|
|
|
|
|
this.checkAllList(0);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},3000)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
closeQuanEv(){
|
|
|
|
|
this.isTY = false;
|
|
|
|
|
clearInterval(this.timer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
.isWen{color: #3875F6;}
|
2022-04-27 02:10:31 +00:00
|
|
|
|
.isWen{
|
2022-04-25 06:38:26 +00:00
|
|
|
|
content: '';
|
|
|
|
|
display: block;
|
|
|
|
|
height: 8rpx;
|
|
|
|
|
width: 100%;
|
|
|
|
|
position: absolute;
|
|
|
|
|
bottom: -20rpx;
|
|
|
|
|
background: #3875F6;
|
|
|
|
|
}
|
|
|
|
|
</style>
|